@import url('https://fonts.googleapis.com/css?family=Manrope:700|Manrope:400');

/* Drawer Component Styles - Properly Scoped */
.drawer {
  --duration: 0.5s;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --drag-bar: 44px;
  --border: color-mix(in hsl, #121212, #ffffff 10%);
  --highlight: color-mix(in hsl, #121212, #ffffff 10%);
  --drawer: #121212;
  --color: color-mix(in hsl, #ffffff, #121212 5%);
  
  inset: 0 0 0 0;
  margin: 0;
  width: unset;
  height: unset;
  border: 0;
  padding: 0;
  background: transparent;
  font-family: 'Manrope', sans-serif;
}

.drawer::backdrop {
  background: hsl(0 0% 0% / 0.5);
  transition-property: display, --opened, --closed, overlay;
  transition-behavior: allow-discrete;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
  opacity: var(--opened, 0);
}

.drawer:popover-open::backdrop {
  --opened: 1;
}

.drawer__scroller {
  height: 100%;
  width: 100%;
  flex-direction: column;
  align-items: center;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: none;
  scroll-snap-type: y mandatory;
}

.drawer__scroller::after {
  content: '';
  width: 100%;
  height: 100svh;
  order: -999999;
  flex: 1 0 100svh;
}

.drawer__slide {
  --size: 600px;
  width: 600px;
  max-height: 95%;
  max-width: 100%;
  height: var(--size);
  flex: 1 0 var(--size);
  position: relative;
}

.drawer__anchors {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 10;
}

.drawer__anchor {
  height: 50px;
  width: 100%;
  scroll-snap-align: end;
}

.drawer__anchor:first-of-type {
  translate: 0 -100%;
}

.drawer__curtain {
  position: absolute;
  left: 50%;
  opacity: 0;
  height: 100svh;
  width: 100%;
  bottom: 0;
  border: 0;
  translate: -50% 0;
}

.drawer__content {
  width: 100%;
  height: 100%;
  z-index: 2;
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  color: var(--color);
  background: var(--drawer);
  transition-property: translate;
  transition-duration: var(--duration);
  transition-timing-function: var(--ease);
  translate: 0 100%;
}

.drawer:popover-open .drawer__content {
  translate: 0 0;
}

.drawer__drag {
  position: absolute;
  top: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  height: var(--drag-bar);
  background: transparent;
  border: 0;
  font-size: 0.875rem;
  outline-color: transparent;
  border-bottom: 1px solid var(--border);
  color: var(--color);
}

.drawer__drag span:first-of-type {
  width: 8ch;
  height: 6px;
  border-radius: 10px;
  background: #FF5722;
}

.drawer .content {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  font-family: 'Manrope', sans-serif;
  font-weight: 400;
}

.drawer .content ul {
  list-style-position: inside;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.drawer .content a {
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  color: var(--color);
  opacity: var(--active, 0.75);
}

.drawer .content a:is(:hover, :focus-visible) {
  --active: 1;
  color: #FF5722;
}

.drawer .reaction-bar {
  position: sticky;
  bottom: 0;
  width: 100%;
  padding: 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--drawer);
  border-top: 1px solid var(--border);
}

.drawer .reactions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  overflow: auto;
}

.drawer .reactions button {
  display: grid;
  place-items: center;
  padding: 0;
  width: 44px;
  aspect-ratio: 1;
  background: transparent;
  border: 0;
  cursor: pointer;
  position: relative;
}

.drawer .reactions button::before {
  border-radius: 12px;
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: var(--highlight);
  opacity: var(--active, 0);
  z-index: -1;
  transition: opacity var(--duration) var(--ease);
}

.drawer .reactions button:is(:hover, :focus-visible) {
  --active: 1;
}

.drawer .comment {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
}

.drawer .comment button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  position: relative;
}

.drawer .comment button::before {
  border-radius: 12px;
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: var(--highlight);
  opacity: var(--active, 0);
  z-index: -1;
  transition: opacity var(--duration) var(--ease);
}

.drawer .comment button:is(:hover, :focus-visible) {
  --active: 1;
}

.drawer .comment button svg {
  fill: color-mix(in hsl, #ffffff, #121212 25%);
  width: 20px;
}

.drawer .comment img {
  width: 32px;
  height: 32px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.drawer .comment input {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 0;
  background: transparent;
  height: 100%;
  border-radius: 12px;
  transition: background var(--duration) var(--ease);
  color: var(--color);
}

.drawer .comment input:focus-visible {
  background: var(--highlight);
  outline: none;
}

#reaction-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999999;
}

/* FireVision Custom Styling */
.drawer__content {
  /* FireVision Theme */
  --drawer: #121212;
  --border: #2a2a2a;
  --highlight: rgba(255, 87, 34, 0.1);
  --color: #f5f5f5;
}

.drawer .reactions button:is(:hover, :focus-visible)::before,
.drawer .comment button:is(:hover, :focus-visible)::before {
  background: rgba(255, 87, 34, 0.25);
}

/* Utilities - Scoped */
.drawer .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Integration Button - Outside drawer */
.drawer-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background-color: #FF5722;
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.drawer-open:hover {
  background-color: #FF3D00;
}

/* Floating action button */
.drawer-button {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #FF5722;
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border: none;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.drawer-button:hover {
  transform: translateY(-2px);
  background-color: #FF3D00;
}

.drawer-button svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .drawer__slide {
    width: 100%;
  }
}