/* Full-viewport mobile navigation overlay.
   Covers everything (announce bar, header, page) until closed via the
   explicit X button at top-right, escape, or backdrop click. Dark
   opaque surface with a faint hash, an internal header row (brand +
   close), a scrollable list, and a footer with the primary actions. */

.mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  color: var(--on-dark-foreground);

  /* Inner palette overrides so descendants read against a dark context. */
  --color-foreground: var(--on-dark-foreground);
  --color-muted-foreground: var(--on-dark-muted-foreground);
  --color-border: var(--on-dark-border);
  --color-accent: var(--on-dark-accent);
  --color-accent-foreground: var(--on-dark-accent-foreground);
  --color-primary: var(--on-dark-foreground);
  --color-primary-foreground: var(--surface-dark-999);

  /* Opaque base color first, subtle hash overlay on top. Separate
     properties (not shorthand) to guarantee the solid fill renders. */
  background-color: var(--surface-dark-999);
  background-image:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 9px,
      color-mix(in oklch, var(--on-dark-foreground) 4%, transparent) 9px,
      color-mix(in oklch, var(--on-dark-foreground) 4%, transparent) 10px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 9px,
      color-mix(in oklch, var(--on-dark-foreground) 3%, transparent) 9px,
      color-mix(in oklch, var(--on-dark-foreground) 3%, transparent) 10px
    );
}

/* Only render on narrow viewports. Above 960px the desktop nav handles
   navigation and this panel stays hidden even if toggled. */
@media (min-width: 961px) {
  .mobile-nav { display: none !important; }
}

/* --- Head row (brand + close) ----------------------------------- */

.mobile-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  min-height: var(--site-header-height, 60px);
  box-sizing: border-box;
}

.mobile-nav__brand {
  display: inline-flex;
  align-items: center;
}
.mobile-nav__brand img {
  width: 1.75rem;
  height: auto;
  display: block;
}

.mobile-nav__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-foreground);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.mobile-nav__close:hover,
.mobile-nav__close:focus-visible {
  background: color-mix(in oklch, var(--on-dark-foreground) 6%, transparent);
  border-color: color-mix(in oklch, var(--on-dark-foreground) 22%, transparent);
  outline: none;
}

/* --- Body list --------------------------------------------------- */

.mobile-nav__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mobile-nav__item { margin: 0; }

/* Shared row chrome for both <a> and <button> triggers. */
.mobile-nav__trigger,
.mobile-nav__link {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--color-foreground);
  font: inherit;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: -0.01em;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.mobile-nav__trigger:hover,
.mobile-nav__link:hover,
.mobile-nav__trigger:focus-visible,
.mobile-nav__link:focus-visible {
  background: color-mix(in oklch, var(--on-dark-foreground) 6%, transparent);
  outline: none;
}

.mobile-nav__label { flex: 1; min-width: 0; }

.mobile-nav__caret {
  display: inline-flex;
  align-items: center;
  color: var(--color-muted-foreground);
  transition: transform var(--dur-fast) var(--ease);
}
.mobile-nav__trigger--open .mobile-nav__caret { transform: rotate(180deg); }

/* Small arrow used on leaf links and expanded sub-items. */
.mobile-nav__sub-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--color-muted-foreground);
  opacity: 0.6;
  transition:
    transform var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.mobile-nav__link:hover .mobile-nav__sub-chevron,
.mobile-nav__sublink:hover .mobile-nav__sub-chevron,
.mobile-nav__link:focus-visible .mobile-nav__sub-chevron,
.mobile-nav__sublink:focus-visible .mobile-nav__sub-chevron {
  opacity: 1;
  transform: translateX(2px);
  color: var(--brand-teal);
}

/* --- Expanded sub-panel ----------------------------------------- */

.mobile-nav__panel {
  margin: 0.25rem 0 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--color-border);
  /* Height animation is handled by x-collapse from the Alpine plugin. */
}

.mobile-nav__sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.mobile-nav__sublink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-md);
  color: var(--color-muted-foreground);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.mobile-nav__sublink:hover,
.mobile-nav__sublink:focus-visible {
  background: color-mix(in oklch, var(--on-dark-foreground) 5%, transparent);
  color: var(--color-foreground);
  outline: none;
}

.mobile-nav__sublabel { flex: 1; min-width: 0; }

/* --- Footer: actions + copy ------------------------------------- */

.mobile-nav__footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
  background-color: color-mix(in oklch, var(--surface-dark-999) 80%, #000);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.mobile-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.mobile-nav__actions .btn--ghost { flex: 0 0 auto; }
.mobile-nav__actions .btn--solid { flex: 1 1 auto; margin-left: auto; }

.mobile-nav__footer-copy {
  margin: 0 auto;
  padding-top: 0.875rem;
  border-top: 1px solid color-mix(in oklch, var(--on-dark-foreground) 8%, transparent);
  font-size: var(--fs-xs);
  color: var(--color-muted-foreground);
  line-height: var(--lh-snug);
  max-width: 40ch;
  text-align: center;
  align-self: stretch;
}
