/* Phone menu drawer: a modal <dialog> whose sheet is swiped in and out with scroll snap, and whose
   backdrop fades with a scroll-driven animation (modern-web-guidance: navigation-drawer). Global, not
   component-scoped, so @property and the keyframes keep their names. Behaviour lives in js/site.js. */
.drawer {
  --drawer-width: min(20em, 80dvw, 100dvw - 24px);
  --drawer-backdrop: 0;
  inset: 0;
  width: auto; height: auto;
  max-width: none; max-height: none;
  margin: 0; padding: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}

.drawer::backdrop { background: #000; opacity: calc(var(--drawer-backdrop) / 2); }

.drawer-scroller {
  position: relative;
  display: grid;
  grid-template-columns: var(--drawer-width) 100%;
  overflow-x: scroll;
  overscroll-behavior: none;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}

@media (prefers-reduced-motion: no-preference) {
  .drawer-scroller { scroll-behavior: smooth; }
}

.drawer-scroller::after {
  content: '';
  scroll-snap-align: end;
  scroll-initial-target: nearest;
}

.drawer-sheet {
  display: flex;
  flex-direction: column;
  height: 100svh;
  padding: var(--s-4);
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
  scroll-snap-align: start;
  scrollbar-width: none;
}

.drawer-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-2); }

.drawer-sheet ul { list-style: none; margin: 0; padding: 0; }

.drawer-sheet li a {
  min-height: 48px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
}

.drawer-sheet li a[aria-current="page"] { color: var(--accent); font-weight: 500; }
.drawer-sheet .drawer-lang { color: var(--accent); border-bottom: 0; }

@supports (animation-timeline: scroll()) {
  .drawer {
      timeline-scope: --drawer-fade;
      animation: fade-drawer-backdrop linear both;
      animation-timeline: --drawer-fade;
  }

  .drawer-scroller { scroll-timeline: --drawer-fade x; }

  @property --drawer-backdrop {
      syntax: '<number>';
      inherits: true;
      initial-value: 0;
  }

  @keyframes fade-drawer-backdrop {
      0% { --drawer-backdrop: 1; }
      100% { --drawer-backdrop: 0; }
  }
}
