/* Mobile menu: button, drawer and backdrop.
   Loaded by every page that loads js/mobile-nav.js, including the essay reader.
   Pages without the site tokens fall back to system colours, so it works there too. */

#mobileMenuBtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
  border-radius: 10px;
  background: transparent; color: inherit;
  cursor: pointer;
  transition: background-color .15s ease;
}
#mobileMenuBtn:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
#mobileMenuBtn .menu-icon { display: grid; gap: 4px; width: 18px; }
#mobileMenuBtn .menu-icon i {
  display: block; height: 1.5px; background: currentColor;
  transition: transform .18s cubic-bezier(.22, 1, .36, 1), opacity .18s ease;
}
#mobileMenuBtn[aria-expanded="true"] .menu-icon i:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
#mobileMenuBtn[aria-expanded="true"] .menu-icon i:nth-child(2) { opacity: 0; }
#mobileMenuBtn[aria-expanded="true"] .menu-icon i:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
#mobileMenuBtn .menu-label {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (min-width: 768px) {
  .site-nav #mobileMenuBtn { display: none; }
}

#mobileMenuBackdrop {
  position: fixed; inset: var(--header-h, 64px) 0 0 0; z-index: 60;
  width: 100%; margin: 0; padding: 0; border: 0;
  background: rgba(0, 0, 0, .45);
  cursor: default;
}
/* Drawer height hugs the links, as in the original: no empty panel below Contact.
   Only very short screens scroll, via max-height. */
#mobileMenu {
  position: fixed; top: var(--header-h, 64px); right: 0; bottom: auto; z-index: 61;
  display: none;
  width: min(82vw, 320px);
  height: auto;
  max-height: calc(100dvh - var(--header-h, 64px) - 16px);
  padding: 4px 20px;
  overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  border-top: 0; border-right: 0;
  border-radius: 0 0 0 16px;
  background: var(--surface, Canvas); color: var(--text, CanvasText);
}
#mobileMenu.is-open { display: block; }
.mobile-drawer-links { display: flex; flex-direction: column; }
.mobile-drawer-links a {
  display: flex; align-items: center;
  min-height: 56px;
  border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  color: inherit;
  font: 500 18px/1.3 var(--font-ui, inherit);
  text-decoration: none;
}
.mobile-drawer-links a:last-child { border-bottom: 0; }
.mobile-drawer-links a[aria-current="page"] { color: var(--accent, inherit); }