/* Drawer Component CSS Module */

.Backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--demo-popover-z-index);

  &[data-state='open'] {
    animation: fade-in 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  }

  &[data-state='closed'] {
    animation: fade-out 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

.Positioner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: var(--demo-popover-z-index);

  &[data-swipe-direction='up'] {
    align-items: flex-start;
  }

  &[data-swipe-direction='left'] {
    justify-content: flex-start;
    align-items: stretch;
  }

  &[data-swipe-direction='right'] {
    justify-content: flex-end;
    align-items: stretch;
  }
}

.Content {
  --bleed: 3rem;

  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 96svh;
  padding: 0 1.25rem;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  background: var(--demo-bg-popover);
  box-shadow: var(--demo-shadow-xl);
  outline: none;
  transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.32, 0.72, 0, 1);

  /* Bottom bleed (default) */
  &::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 100%;
    height: var(--bleed);
    background-color: inherit;
    pointer-events: none;
  }

  &[data-state='open'] {
    animation-name: slide-in-bottom;
  }

  &[data-state='closed'] {
    animation: slide-out-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  &[data-swipe-direction='up'] {
    border-radius: 0 0 16px 16px;

    &::after {
      top: auto;
      bottom: 100%;
    }

    &[data-state='open'] {
      animation-name: slide-in-top;
    }

    &[data-state='closed'] {
      animation: slide-out-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
  }

  &[data-swipe-direction='left'] {
    max-height: none;
    max-width: 400px;
    border-radius: 0 16px 16px 0;

    &::after {
      inset-inline: auto;
      inset-block: 0;
      top: 0;
      width: var(--bleed);
      height: auto;
      right: 100%;
    }

    &[data-state='open'] {
      animation-name: slide-in-left;
    }

    &[data-state='closed'] {
      animation: slide-out-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
  }

  &[data-swipe-direction='right'] {
    max-height: none;
    max-width: 400px;
    border-radius: 16px 0 0 16px;

    &::after {
      inset-inline: auto;
      inset-block: 0;
      top: 0;
      width: var(--bleed);
      height: auto;
      left: 100%;
    }

    &[data-state='open'] {
      animation-name: slide-in-right;
    }

    &[data-state='closed'] {
      animation: slide-out-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
  }
}

.Grabber {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
  padding: 20px 0;
  cursor: grab;
  touch-action: none;
  user-select: none;

  &:active {
    cursor: grabbing;
  }
}

.GrabberIndicator {
  width: 40px;
  height: 4px;
  background-color: var(--demo-neutral-muted);
  border-radius: 1000px;

  .Grabber:hover & {
    background-color: var(--demo-neutral-emphasized);
  }
}

.Title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--demo-neutral-fg);
}

.Description {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--demo-neutral-fg-muted);
}

.Body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 1rem;
  max-width: 28rem;
  width: 100%;
  margin: 0 auto;
}

.CloseTrigger {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 3rem;
  right: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--demo-neutral-emphasized);
  cursor: pointer;

  & svg {
    width: 1rem;
    height: 1rem;
  }

  &:hover {
    background: var(--demo-neutral-muted);
  }

  &:focus-visible {
    outline: 2px solid var(--demo-coral-focus-ring);
    outline-offset: -1px;
  }
}

.Trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--demo-border-emphasized);
  background: var(--demo-bg-popover);
  color: var(--demo-neutral-fg);
  cursor: pointer;

  &:hover {
    background: var(--demo-neutral-subtle);
    border-color: var(--demo-neutral-muted);
  }

  &:focus-visible {
    outline: 2px solid var(--demo-coral-focus-ring);
    outline-offset: 2px;
  }
}

/* Scrollable content area */
.Scrollable {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0.5rem 0;

  /* Custom scrollbar */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background-color: var(--demo-neutral-muted);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background-color: var(--demo-neutral-emphasized);
  }
}

.ScrollableItem {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 3rem;
  padding: 0 1rem;
  background: var(--demo-neutral-subtle);
  border: 1px solid var(--demo-border-emphasized);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--demo-neutral-fg);

  &:hover {
    background: var(--demo-neutral-muted);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes slide-in-bottom {
  from {
    transform: translate3d(0, 100%, 0);
  }
  to {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
}

@keyframes slide-out-bottom {
  from {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
  to {
    transform: translate3d(0, 100%, 0);
  }
}

@keyframes slide-in-top {
  from {
    transform: translate3d(0, -100%, 0);
  }
  to {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
}

@keyframes slide-out-top {
  from {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
  to {
    transform: translate3d(0, -100%, 0);
  }
}

@keyframes slide-in-left {
  from {
    transform: translate3d(-100%, 0, 0);
  }
  to {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
}

@keyframes slide-out-left {
  from {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
  to {
    transform: translate3d(-100%, 0, 0);
  }
}

@keyframes slide-in-right {
  from {
    transform: translate3d(100%, 0, 0);
  }
  to {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
}

@keyframes slide-out-right {
  from {
    transform: translate3d(var(--drawer-translate-x, 0), var(--drawer-translate-y, 0), 0);
  }
  to {
    transform: translate3d(100%, 0, 0);
  }
}
