/* Hamburger menu overlay (405×701 design basis).
   Full-screen grey #C9CAC3; nav 36px Inter Medium, UPPERCASE, 4% tracking,
   line-height 184%, centered with the design's staggered line offsets
   (drawn with leading/trailing spaces). The bottom-pinned X is the only
   close control. Red = tap (:active) state. */

.menu__nav {
  display: none;
}

/* capped to mobile widths so a menu left open pre-resize can't force this
   overlay on top of the desktop inline nav */
@media (max-width: 71.9375rem) {
  body:has(.menu[open]) .menu__nav {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(201, 202, 195, 0.95); /* one-off overlay grey */
    flex-direction: column;
    align-items: center;
    overflow: hidden; /* must fit without scrolling */
    /* spacing scales with viewport height (701 design basis) so the
       whole menu incl. the X fits without scrolling on small phones */
    padding-top: min(6.5rem, 14.8dvh); /* 104px */
    font-size: var(--text-menu);
    font-weight: var(--weight-medium);
    text-transform: uppercase;
    letter-spacing: var(--tracking-caps);
    line-height: 1.84;
  }

  body:has(.menu[open]) .menu__nav a {
    /* dvh compresses the pitch on short screens; the rem floor keeps the
       line box from closing on the type under browser zoom (WCAG) */
    line-height: clamp(2.5rem, 9.4dvh, 4.14rem);
  }

  /* stagger per the design's space-drawn offsets */
  .menu__nav a:nth-child(2) { transform: translateX(0.675rem); }  /* Journal */
  .menu__nav a:nth-child(3) { transform: translateX(0.675rem); }  /* Gathering */
  .menu__nav a:nth-child(5) { transform: translateX(0.675rem); }  /* Contact */
}

/* X close button — 40px square, 1px ink border.
   Pinned to the viewport bottom so it's in thumb reach on any phone. */
.menu__close {
  margin-top: auto;
  margin-bottom: calc(2.9375rem + env(safe-area-inset-bottom, 0px)); /* 47px */
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid var(--color-ink);
  border-radius: 0;
  cursor: pointer;
}

.menu__close:active {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

/* the X is the only close control; the sticky header sits below the
   overlay's z-index, so the burger is covered while open */

/* background page must not scroll behind the open menu (set via menu.js).
   overflow only — clamping height here caused a scroll-position jump
   when the menu closed */
html.has-menu-open {
  overflow: hidden;
}

.menu__nav a {
  text-decoration: none;
}

/* Each item's highlight color mirrors that section's own --header-tint
   (header.css). Applied on hover/focus/tap and persistently on the
   current section's item via aria-current (set in header.php from the
   same tint-mapping logic, so it lights up on sub-pages too). */
.menu__nav a:nth-child(1) { --section-color: #e73c7f; } /* Shop — deepened from the header's #fcf3fa, unreadable as text */
.menu__nav a:nth-child(2) { --section-color: #9c6b00; } /* Journal — deepened from the header's #fffada, unreadable as text */
.menu__nav a:nth-child(3) { --section-color: #50bb9f; --current-color: #1a4c3f; } /* Gatherings */
.menu__nav a:nth-child(4) { --section-color: #ff0000; --current-color: #660000; } /* About */
.menu__nav a:nth-child(5) { --section-color: #3fa9f5; } /* Contact — brightened from the header's #a6d7ff, which read too close to the overlay grey */

.menu__nav a:hover,
.menu__nav a:focus-visible,
.menu__nav a:active {
  color: var(--section-color, var(--accent-red));
}

/* --current-color: a darker shade for the 3 sections whose --section-color
   is identical to their own --header-tint (header.css), which made the
   current-page link invisible against its own header background. */
.menu__nav a[aria-current='page'] {
  color: var(--current-color, var(--section-color, var(--accent-red)));
}

/* Desktop: inline-looking row, but .menu__nav stays a sibling of <header>
   (never nested, see header.php) and is independently fixed, layered over
   the header via z-index. Right-anchored at a fixed 40px from
   .site-header__actions (~6.6rem: 3 icons + gaps + margin) instead of
   centered, so that gap stays a real, adjustable number. */
@media (min-width: 72rem) {
  .menu__nav {
    display: flex;
    position: fixed;
    top: 0;
    right: calc(var(--gutter) + 6.6rem + 2.5rem);
    z-index: 11;
    height: 2.78125rem;
    align-items: center;
    gap: var(--space-4);
    font-size: var(--text-title);
    font-weight: var(--weight-semibold);
  }

  .menu__close {
    display: none;
  }

  /* while the on-screen keyboard is open the header drops to static
     (header.css) — the nav has to fall back with it, or it keeps
     pinning itself over content with no header background behind it */
  html.has-focused-input .menu__nav {
    position: absolute;
  }

  /* plain ink row, underline as the only hover signal — the section
     colors above are the mobile overlay's language */
  .menu__nav a:hover,
  .menu__nav a:focus-visible,
  .menu__nav a:active {
    color: var(--color-ink);
    text-decoration: underline;
  }

  /* the current section leaves the row — it reads at the left instead,
     as the header title beside the logo (header.css shows it again) */
  .menu__nav a[aria-current='page'] {
    display: none;
  }
}
