/* ==========================================================================
   sitemenu.css — the bar's height, and the menu under the hamburger.

   After osmo's fixed-underlay nav (her reference): the menu is a card fixed
   on the left, under the bar; opening it slides the page to the right by the
   card's width and dims what is left of it. The bar stays put, so the
   burger turns into the cross where it was. Mobile first: on a phone the card
   takes the screen bar a strip of the page, which closes it when tapped.

   The menu ships `hidden` and is opened only by sitemenu.js, so with no
   JavaScript it is never in the way (the footer and contact card still link).
   ========================================================================== */

/* the bar's height used to live in rail.css; it lives here, and the page
   pays for the bar with padding so nothing slides under it.
   --bar-y is how much of the bar is on screen: the bar's height, or 0 while
   it is tucked away on the way down (header.js sets [data-bar="hidden"]).
   Everything stuck under the bar — the chapter stages, the sticky card
   corners, the next case — is placed on --bar-y, so it rides up and down
   with the bar instead of leaving a gap. Registered, so it can animate. */
@property --bar-y { syntax: "<length>"; inherits: true; initial-value: 80px; }
:root {
  --topbar-h: 80px;
  --bar-y: var(--topbar-h);
  --bar-move: 360ms;
  --stick-gap: 8px;   /* ground between the bar and a card's stuck top corners */
  --nav-w: calc(100vw - 2 * var(--card-gap, 8px) - 56px);   /* the menu card */
  --nav-shift: calc(var(--nav-w) + var(--card-gap, 8px));    /* how far the page moves */
  --nav-move: 680ms;
  --nav-ease: var(--md-sys-motion-easing-emphasized, cubic-bezier(0.2, 0, 0, 1));
}
body { padding-block-start: var(--topbar-h); }
html { transition: --bar-y var(--bar-move) var(--md-sys-motion-easing-emphasized, cubic-bezier(0.2, 0, 0, 1)); }
html[data-bar="hidden"] { --bar-y: 0px; }
@media (prefers-reduced-motion: reduce) { html { transition: none; } }

/* ---------- the page moves aside --------------------------------------- */

main,
.colophon {
  position: relative;                     /* always over the menu, which sits at z 0 under the page: */
  z-index: 1;                             /* without it the footer slid back *under* the menu's text */
  background-color: var(--paper);         /* the ground travels with the page */
  transition: transform var(--nav-move) var(--nav-ease);
}
html[data-nav="open"] main,
html[data-nav="open"] .colophon { transform: translateX(var(--nav-shift)); }
html[data-nav="open"] { overflow: hidden; scrollbar-gutter: stable; }
html[data-nav="open"] body { overflow-x: clip; }   /* the moved page never scrolls the window sideways */

/* fixed pieces inside the page would ride along at the wrong height while it
   is transformed: they rest until it is back */
html[data-nav="open"] .card-corners,
html[data-nav="open"] .nextcase__track { visibility: hidden; }

/* what is left of the page dims, and a tap on it closes the menu */
.navshade {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  z-index: 75;
  background: color-mix(in oklab, var(--paper) 62%, transparent);   /* the page's own ground, see-through: no seam against the body */
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--nav-move) var(--nav-ease), transform var(--nav-move) var(--nav-ease);
}
/* it rides with the page, so it never sits over the menu */
html[data-nav="open"] .navshade { opacity: 1; pointer-events: auto; cursor: pointer; transform: translateX(var(--nav-shift)); }

/* ---------- the menu card ---------------------------------------------- */

.navmenu {
  position: fixed;
  inset-block: var(--topbar-h) var(--card-gap, 8px);
  inset-inline-start: var(--card-gap, 8px);
  z-index: 0;                              /* under the page: it is uncovered, not laid on top */
  width: var(--nav-w);
}
.navmenu[hidden] { display: none; }
.navmenu__card {
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 4vh, 48px);
  height: 100%;
  padding: clamp(20px, 3vw, 36px) clamp(16px, 2.4vw, 28px);
  border-radius: var(--card-radius, 20px);
  background: none;                        /* trying it bare, on the page ground (was var(--surface)) */
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.navmenu__list,
.navmenu__subs,
.navmenu__contact { list-style: none; margin: 0; padding: 0; }
.navmenu__list { display: grid; gap: 4px; }

/* the pages: large, one per line; the current one is filled with the theme */
.navmenu__link,
.navmenu__sub {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: color var(--beat, 160ms), background-color var(--beat, 160ms), padding var(--beat, 160ms) var(--tempo, ease);
}
.navmenu__link {
  padding: 10px 12px 4px;                  /* Nohemi sits high in its box: more above centres the word */
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.navmenu__subs { display: grid; gap: 2px; margin: 4px 0 10px 12px; padding-left: 12px; border-left: 1px solid var(--rule); }
.navmenu__sub {
  padding: 9px 12px 5px;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2.2vw, 1.375rem);
  font-weight: 480;
  letter-spacing: -0.02em;
}
.navmenu__kind {
  font-family: var(--font-small);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
/* hover: the words slide right, smoothly (a transform on the label, so the
   cascade's own transition on the row can't cancel it) */
.navmenu__link-label,
.navmenu__sub-label { display: inline-block; transition: transform 320ms var(--nav-ease); }
a.navmenu__link:hover .navmenu__link-label,
.navmenu__sub:hover .navmenu__sub-label { transform: translateX(8px); }
a.navmenu__link:hover,
.navmenu__sub:hover { color: var(--accent); }
.navmenu__link--head { color: var(--ink); cursor: default; }
.navmenu__link[aria-current="page"],
.navmenu__sub[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.navmenu__link[aria-current="page"]:hover,
.navmenu__sub[aria-current="page"]:hover { color: var(--on-accent); }
.navmenu__sub[aria-current="page"] .navmenu__kind { color: var(--on-accent); }
.navmenu a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* the contact details, at the foot */
.navmenu__foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--rule); }
.navmenu__label {
  margin-bottom: 12px;
  font-family: var(--font-small);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.navmenu__contact { display: grid; gap: 10px 24px; font-family: var(--font-small); font-size: 0.875rem; }
.navmenu__contact li { display: grid; gap: 2px; min-width: 0; }
.navmenu__k { font-size: 0.6875rem; font-weight: 600; color: var(--ink-faint); }
.navmenu__contact a { color: var(--ink); text-underline-offset: 0.25em; overflow-wrap: anywhere; }
.navmenu__contact a:hover { color: var(--accent); }

/* the cascade: each line slides in after the one above it (--i, sitemenu.js) */
.navmenu [data-i] {
  opacity: 0;
  transform: translateX(-28px);
  transition: opacity var(--phrase, 420ms) var(--tempo, ease), transform var(--phrase, 420ms) var(--nav-ease);
  transition-delay: calc(120ms + var(--i, 0) * 45ms);
}
html[data-nav="open"] .navmenu [data-i] { opacity: 1; transform: none; }
/* closing: gone at once, no cascade, so nothing lingers while the page returns */
html:not([data-nav="open"]) .navmenu [data-i] { transition-duration: 160ms; transition-delay: 0ms; }

@media (min-width: 561px) {
  .navmenu__contact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 761px) {
  :root { --nav-w: min(460px, 42vw); }
}

@media (prefers-reduced-motion: reduce) {
  main, .colophon, .navshade, .navmenu [data-i], .navmenu__link-label, .navmenu__sub-label { transition: none; }
}
html[data-type-motion="off"] .navmenu [data-i] { transition: none; }
