/* =========================
   Drawers
========================= */

@use "../kit-deps" as *;

.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;

  &.a-show .drawer-backdrop {
    opacity: 1;
  }
  &.a-show .drawer-panel {
    transform: translateX(0);
  }

  &.a-hide .drawer-backdrop {
    opacity: 0;
  }
  &.a-hide .drawer-panel {
    transform: translateX(100%);
  }

  &.drawer-left.a-show .drawer-panel {
    transform: translateX(0);
  }
  &.drawer-left.a-hide .drawer-panel {
    transform: translateX(-100%);
  }

  .drawer-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba($neutral-900, 0.48);
    opacity: 0;
    transition: opacity $motion-base $motion-ease;
  }

  .drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 420px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: $neutral-0;
    box-shadow: -16px 0 48px rgba($neutral-900, 0.16);
    transform: translateX(100%);
    transition: transform $motion-base $motion-ease;

    .drawer-left & {
      right: auto;
      left: 0;
      transform: translateX(-100%);
      box-shadow: 16px 0 48px rgba($neutral-900, 0.16);
    }
  }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: $space-3;
    padding: $space-4 $space-5;
    border-bottom: 1px solid $neutral-100;
  }

  .drawer-title {
    margin: 0;
    font-size: 18px;
    font-weight: $font-weight-bold;
    color: $neutral-900;
  }

  .drawer-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: $radius-full;
    background-color: transparent;
    color: $neutral-700;
    cursor: pointer;
    transition: background-color $motion-base $motion-ease, color $motion-base $motion-ease;

    &:hover {
      background-color: $neutral-100;
      color: $neutral-900;
    }

    &:focus-visible {
      @include focus_ring;
    }
  }

  .drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: $space-5;
    font-size: 15px;
    line-height: 1.5;
    color: $neutral-800;
  }

  .drawer-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: $space-3;
    padding: $space-3 $space-5;
    border-top: 1px solid $neutral-100;
    background-color: $neutral-50;
  }
}
