/* Tonitza — menu page (category rail, filters, items, allergens).
   Loaded from templates/menu/menu_index_page.html after main.css; tokens and
   shared components live there. Layout per docs/brand/web-identity.md §5:
   a printed-menu column rhythm — plain names as the headline, prices aligned
   right, the painterly "signature" name as a small italic clay label above. */

/* ---------- Page head ---------- */
/* Eyebrow · h1 · intro on the left; the palette gloss + lei note sits opposite,
   on the same baseline as the intro. Stacks under 650px. */
.menu-intro {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: clamp(1.5rem, 4vw, 3rem);
}
.menu-intro__copy { min-width: 0; }
.menu-note {
  flex: none; max-width: 260px; margin: 0;
  font-size: 0.78rem; line-height: 1.65; color: var(--ink-soft);
}
.menu-note__price { display: block; margin-top: 0.35rem; color: var(--ink); }

/* ---------- Layout ---------- */
/* Two columns from 951px: a 220px rail for the category links, then the
   content column (controls row + sections). The rail is positioned into the
   empty first column from inside .menu-nav, so the markup keeps one set of
   [data-jump] links whether they render as a rail or as the mobile tab row. */
.menu-layout { position: relative; padding-bottom: clamp(3rem, 6vw, 5rem); }
/* Air between the bar / controls row and the first category heading. */
.menu-body { min-width: 0; padding-top: clamp(1.6rem, 3vw, 2.4rem); }

/* ---------- Category navigation + filters (mobile-first: the sticky bar) ---------- */
/* ≤950px: one bar under the sticky header — the scrolling tab row and the
   single Filters disclosure on line one, the result line (JS, only while a
   filter is active) beneath. Full-bleed via negative gutters so nothing shows
   past its edges while content scrolls under it. */
.menu-nav {
  position: sticky; top: var(--header-h); z-index: 40;
  background: var(--paper);
  border-block: 1px solid var(--line);
  margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter);
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; column-gap: 1rem;
  padding-block: 0.35rem;
}
.menu-rail { min-width: 0; }
.menu-jump {
  display: flex; gap: 1.5rem; align-items: stretch;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
  min-width: 0;
  /* Edge fades hint at off-screen tabs; JS drives the two vars from the
     scroll position, so an edge only fades while there is content past it. */
  --fade-l: 0rem; --fade-r: 0rem;
  -webkit-mask-image: linear-gradient(to right,
    transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(to right,
    transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
.menu-jump.can-l { --fade-l: 2rem; }
.menu-jump.can-r { --fade-r: 2rem; }
.menu-jump::-webkit-scrollbar { display: none; }
/* A link is "01" in clay + the category name. The number is aria-hidden; the
   name carries the active state as a 1px clay rule (the same mark the header
   nav uses for the current page). */
.menu-jump__link {
  flex: none; display: inline-flex; align-items: baseline; gap: 0.55rem;
  min-height: 44px; padding: 0.7rem 0;
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--ink-soft); white-space: nowrap;
  transition: color 0.2s var(--ease);
}
.menu-jump__num {
  font-size: 0.62rem; font-weight: 500; letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums; color: var(--clay-deep);
}
.menu-jump__name { padding-bottom: 2px; border-bottom: 1px solid transparent; }
.menu-jump__link:hover { color: var(--ink); }
.menu-jump__link.is-active { color: var(--ink); }
.menu-jump__link.is-active .menu-jump__name { border-bottom-color: var(--terracotta); }
/* A jump-link whose section was filtered away: quiet and non-interactive,
   rather than scrolling to a now-empty anchor. */
.menu-jump__link.is-disabled { opacity: 0.4; pointer-events: none; }

/* The filter disclosure: a <details> whose panel drops below the bar, so the
   bar itself never changes height mid-scroll. */
.menu-filter { position: relative; display: flex; align-items: center; }
.menu-filter__btn {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
  min-height: 44px; padding: 0.55rem 0.95rem;
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.02em; line-height: 1.2;
  color: var(--ink); background: transparent;
  border: 1px solid var(--ink); border-radius: 0;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.menu-filter__btn::-webkit-details-marker { display: none; }
.menu-filter__btn:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.menu-filter[open] .menu-filter__btn,
.menu-filter.has-active .menu-filter__btn { background: var(--ink); color: var(--paper); }
.menu-filter__badge {
  min-width: 1.15rem; height: 1.15rem; padding: 0 0.3rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--ink);
  font-size: 0.66rem; font-weight: 500; font-variant-numeric: tabular-nums;
}
/* display:inline-flex would otherwise defeat the [hidden] attribute. */
.menu-filter__badge[hidden] { display: none; }
.menu-filter__panel {
  position: absolute; top: calc(100% + 0.5rem); right: 0; z-index: 50;
  width: min(26rem, calc(100vw - 2 * var(--gutter)));
  background: var(--white); border: 1px solid var(--line);
  box-shadow: 0 16px 40px -20px color-mix(in srgb, var(--ink) 45%, transparent);
  padding: 1.1rem 1.2rem 1.2rem;
  /* Short viewports: cap the panel to the visible height and let it scroll (it sits under a sticky bar, so page scrolling can never reveal its foot). */
  max-height: calc(100dvh - var(--header-h) - 4.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu-filter__group { border: 0; margin: 0 0 1.1rem; padding: 0; }
.menu-filter__group:last-child { margin-bottom: 0; }
.menu-filter__legend {
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.2em;
  text-transform: uppercase; line-height: 1.6; color: var(--ink);
  padding: 0; margin-bottom: 0.6rem;
}
.menu-filter__chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.menu-filter__chip {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500;
  letter-spacing: 0.02em; color: var(--ink);
  background: transparent; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent); border-radius: 0;
  min-height: 2.5rem; padding: 0.4rem 0.85rem;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.menu-filter__chip:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.menu-filter__chip.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
/* Avoid-allergen chips read as the cautionary system: clay, not ink. */
.menu-filter__chip--avoid {
  color: var(--clay-deep);
  border-color: color-mix(in srgb, var(--clay) 55%, transparent);
}
.menu-filter__chip--avoid:hover { background: color-mix(in srgb, var(--clay) 10%, transparent); }
.menu-filter__chip--avoid.is-active { background: var(--clay-deep); color: var(--paper); border-color: var(--clay-deep); }
.menu-filter__hint { margin: 0.7rem 0 0; font-size: 0.78rem; color: var(--ink-soft); }

/* Result line while a filter is active: visible count + one clear action. */
.menu-nav__status {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.15rem 0 0.45rem;
  font-size: 0.78rem; color: var(--ink-soft);
}
.menu-nav__status[hidden] { display: none; }
.menu-nav__clear {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 500; color: var(--ink);
  border-bottom: 1px solid var(--ink); line-height: 1.3;
  transition: border-color 0.2s var(--ease);
}
.menu-nav__clear:hover { border-bottom-color: var(--terracotta); }

/* ---------- Desktop: rail + controls row ---------- */
@media (min-width: 951px) {
  .menu-layout {
    display: grid; grid-template-columns: 220px minmax(0, 1fr);
    column-gap: clamp(2.5rem, 4vw, 3.5rem);
  }
  /* The controls row: Filters at the start, the result line at the end,
     hairlines above and below. Static (not sticky) so it stays the ordinary
     box the scroll-spy measures, and so the rail can be positioned from here. */
  .menu-nav {
    grid-column: 2; position: static; z-index: auto;
    margin: 0; padding: 1rem 0; background: transparent;
    display: flex; align-items: center; gap: 1.25rem;
  }
  .menu-body { grid-column: 2; }
  /* The rail column: the full height of the layout, so the sticky list inside
     it travels with the sections and lets go at the foot of the menu. */
  .menu-rail {
    position: absolute; top: 0; bottom: 0; left: 0; width: 220px;
  }
  .menu-jump {
    position: sticky; top: calc(var(--header-h) + 1.5rem);
    flex-direction: column; align-items: stretch; gap: 0;
    padding-top: 1rem; overflow: visible;
    -webkit-mask-image: none; mask-image: none;
  }
  .menu-jump__link { min-height: 0; padding: 0.45rem 0; white-space: normal; gap: 0.8rem; }
  .menu-jump__num { flex: none; min-width: 1.4rem; }
  .menu-filter__panel { right: auto; left: 0; }
  .menu-nav__status { grid-column: auto; margin-left: auto; padding: 0; }
}

/* ---------- Categories ---------- */
.menu-cat { margin-bottom: clamp(2.8rem, 5vw, 4rem); scroll-margin-top: calc(var(--header-h) + 4.5rem); }
.menu-cat[hidden] { display: none; }
.menu-cat__head { margin-bottom: 1.4rem; }
.menu-cat__head h2 {
  font-size: clamp(1.9rem, 1.4rem + 1.6vw, 2.75rem);
  margin: 0;
}
.menu-cat__head p { color: var(--ink-soft); margin: 0.5rem 0 0; font-size: 0.88rem; max-width: 52ch; }
.menu-cat__empty { color: var(--ink-soft); font-style: italic; margin: 0; }
@media (min-width: 951px) {
  /* Land a jumped-to heading level with the sticky rail's first entry. */
  .menu-cat { scroll-margin-top: calc(var(--header-h) + 1.5rem); }
}

/* Filter "wash settle". Under .js, filtering animates instead of snapping: a
   leaving row/section dissolves before JS removes it (it stays in flow,
   fading, so the grid doesn't reflow mid-fade), and an arriving row settles
   in. Timer-driven in JS — no animationend dependency — and the global
   reduced-motion rule drops these keyframes, at which point JS swaps [hidden]
   instantly. Sections dissolve out but reappear instantly (no enter keyframe). */
.js .menu-item.is-leaving,
.js .menu-cat.is-leaving { animation: menu-dissolve 0.26s var(--ease) forwards; }
.js .menu-item.is-entering { animation: menu-settle 0.32s var(--ease) both; }
@keyframes menu-dissolve {
  to { opacity: 0; transform: translateY(4px); }
}
@keyframes menu-settle {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
/* Page-level "nothing matches" state shown by JS when a filter empties the menu. */
.menu-noresults { text-align: center; padding: clamp(2rem, 5vw, 3.5rem) 0; color: var(--ink-soft); }
.menu-noresults p { margin: 0 0 1.1rem; }

/* ---------- Items ---------- */
/* Two rule-topped columns from 651px (one beneath), printed-menu style: no
   photos, no dotted leader — the price sits flush right in tabular figures.
   Filtering toggles [hidden] for an instant, no-reflow-jank swap. */
.menu-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr;
  gap: 0 clamp(1.5rem, 3.5vw, 3rem);
}
@media (min-width: 651px) {
  .menu-list { grid-template-columns: 1fr 1fr; }
}
.menu-item {
  padding: 1.2rem 0; border-top: 1px solid var(--line);
  transition: opacity 0.25s var(--ease);
}
.menu-item[hidden] { display: none; }
/* The painterly name: Fraunces italic, clay, small — a label above the plain
   name, never the headline. */
.menu-item__signature {
  display: block; margin-bottom: 0.3rem;
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 1rem; line-height: 1.25; letter-spacing: -0.01em;
  font-optical-sizing: none; font-variation-settings: "opsz" 32;
  color: var(--clay);
}
.menu-item__row { display: flex; align-items: baseline; gap: 0.6rem; }
.menu-item__name {
  flex: 0 1 auto; min-width: 0;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 500;
  line-height: 1.4; letter-spacing: -0.01em; color: var(--ink);
}
.menu-item__price {
  flex: none; margin-left: auto; text-align: right;
  font-size: 0.95rem; font-weight: 500; white-space: nowrap;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
/* The serving size sits just before the price, quieter, both pushed right. */
.menu-item__portion {
  flex: none; margin-left: auto; white-space: nowrap;
  font-size: 0.78rem; font-variant-numeric: tabular-nums; color: var(--ink-soft);
}
.menu-item__portion + .menu-item__price { margin-left: 0.2rem; }
.menu-item__desc {
  display: block; margin: 0.35rem 0 0; max-width: 46ch;
  font-size: 0.82rem; line-height: 1.6; color: var(--ink-soft);
}
/* Dietary labels as one quiet ink line ("vegan · seasonal"), not stacked
   pills — the filter panel is where they're actionable. */
.menu-item__diet {
  display: block; margin-top: 0.45rem;
  font-size: 0.66rem; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink);
}
/* A dish containing an avoided allergen stays listed — you can still ask the
   staff about it — but recedes; its triggering letters turn clay.
   (The second selector out-specifies `.js .reveal.is-visible`'s opacity: 1,
   which would otherwise win over a two-class rule.)
   0.8, not lower: olive ink at 0.8 on --paper still measures ≈4.9:1 (AA); at
   the old 0.72 it drops to ≈4.0:1. */
.menu-item.is-avoided,
.js .reveal.is-visible.menu-item.is-avoided { opacity: 0.8; }
/* Screen-only compensation for the dim: the softer runs (ink-soft and the
   clay signature / flagged letters, once multiplied by 0.8) step up to
   darker mixes so every text run stays ≥ 4.5:1. Scoped to screen so the print
   sheet (which forces opacity back to 1) keeps the normal palette. */
@media screen {
  .menu-item.is-avoided .menu-item__desc,
  .menu-item.is-avoided .menu-item__diet,
  .menu-item.is-avoided .menu-item__marks { color: var(--ink); }
  .menu-item.is-avoided .menu-item__signature,
  .menu-item.is-avoided .menu-item__marks .mark.is-flagged {
    color: color-mix(in srgb, var(--clay-deep) 40%, var(--ink)); /* ≈4.8:1 once composited at 0.8 */
  }
}
/* ---------- Allergens ---------- */
/* Per-dish codes ride inline after the name as small raised letters ("G ML"),
   the printed-menu convention. The whole cluster is one button — one honest
   tap target — opening the shared popover that spells the codes out (hover
   titles don't exist on touch). */
.menu-item__marks {
  background: none; border: 0; cursor: pointer;
  display: inline-flex; gap: 0.32rem; align-items: baseline;
  font-family: var(--sans);
  /* Generous hit area without visual bulk: padding grows the button, the
     negative block margin keeps the text row's rhythm unchanged. */
  padding: 1.05rem 0.7rem; margin: -1.05rem -0.35rem; min-width: 2.75rem; justify-content: center;
  color: var(--ink-soft);
}
.menu-item__marks .mark {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; line-height: 1;
  position: relative; top: -0.35em;
  border-bottom: 1px dotted color-mix(in srgb, var(--ink) 45%, transparent);
  padding-bottom: 1px;
  transition: color 0.2s var(--ease);
}
.menu-item__marks:hover .mark { color: var(--ink); }
/* A letter matching an avoided allergen turns clay — and its dotted underline
   turns solid and thicker, so the flag never rides on hue alone. */
.menu-item__marks .mark.is-flagged {
  color: var(--clay-deep);
  border-bottom: 2px solid var(--clay-deep);
}

/* Shared tap-popover: name + description for one dish's allergens. */
.allergen-pop {
  position: fixed; z-index: 80;
  max-width: min(21rem, calc(100vw - 2rem));
  background: var(--white); border: 1px solid var(--line);
  box-shadow: 0 16px 40px -20px color-mix(in srgb, var(--ink) 50%, transparent);
  padding: 0.9rem 1rem 1rem;
}
.allergen-pop__title {
  margin: 0 0 0.6rem;
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.2em;
  text-transform: uppercase; line-height: 1.6; color: var(--ink);
}
.allergen-pop__list { margin: 0; display: grid; gap: 0.5rem; }
.allergen-pop__name { margin: 0; font-size: 0.85rem; font-weight: 500; color: var(--ink); }
.allergen-pop__desc { margin: 0; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.5; }

/* Legend code: a small square outline holding the letter(s). */
.allergen {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.5rem; height: 1.5rem; padding: 0 0.2rem; box-sizing: border-box;
  border: 1px solid color-mix(in srgb, var(--ink) 45%, transparent);
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink);
  text-decoration: none; cursor: help;
}

.allergen-legend {
  margin-top: clamp(2rem, 4vw, 3rem); padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.allergen-legend__list, .allergen-legend__note { max-width: 60ch; }
.allergen-legend__title {
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.2em; line-height: 1.6;
  text-transform: uppercase; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; gap: 0.6rem; min-height: 44px;
}
.allergen-legend__title::-webkit-details-marker { display: none; }
.allergen-legend__title::before {
  content: "+"; font-size: 0.9rem; line-height: 1; color: var(--clay-deep);
  width: 0.9rem; text-align: center;
}
.allergen-legend[open] .allergen-legend__title::before { content: "–"; }
.allergen-legend[open] .allergen-legend__title { margin-bottom: 0.8rem; }
/* One shared term column for every row (subgrid), so the descriptions line
   up whatever the longest allergen name is; browsers without subgrid fall
   back to a per-row grid. */
.allergen-legend__list {
  margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 0.9rem;
}
.allergen-legend__row {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: minmax(9rem, auto) 1fr; gap: 0.4rem 0.9rem;
  grid-template-columns: subgrid;
  align-items: baseline;
}
.allergen-legend__term { display: flex; align-items: center; gap: 0.55rem; margin: 0; }
.allergen-legend__name {
  font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 500; color: var(--ink);
}
.allergen-legend__desc { margin: 0; font-size: 0.85rem; color: var(--ink-soft); line-height: 1.5; }
.allergen-legend__note {
  margin: 1.2rem 0 0; font-size: 0.82rem; font-style: italic; color: var(--ink-soft);
}
@media (max-width: 36rem) {
  .allergen-legend__list { grid-template-columns: 1fr; }
  .allergen-legend__row { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 650px) {
  .menu-intro { display: block; }
  .menu-note { max-width: 300px; margin-top: 1.4rem; }
  /* 44px chips for thumbs. */
  .menu-filter__chip { min-height: 2.75rem; }
}
@media (max-width: 560px) {
  .menu-nav { column-gap: 0.75rem; }
  .menu-jump { gap: 1.1rem; }
  /* The dropdown anchors to the bar (not the button) so it can span the full
     narrow viewport instead of hanging off the right edge. */
  .menu-filter { position: static; }
  .menu-filter__panel {
    left: var(--gutter); right: var(--gutter); width: auto;
    top: calc(100% + 0.5rem);
  }
}

/* Menu rows reveal in the same cascade as the card grids, but a price list runs
   10–20+ items — far past the .stagger nth-child(9) ceiling — so the delay
   recycles every 6 rows (capped at 0.25s) instead of climbing forever. Tiny
   rise (--reveal-rise); the existing .reveal / reduced-motion gating is reused
   unchanged. */
.menu-list .menu-item { --reveal-rise: 8px; }
.menu-list .menu-item:nth-child(6n+2) { --delay: 0.05s; }
.menu-list .menu-item:nth-child(6n+3) { --delay: 0.10s; }
.menu-list .menu-item:nth-child(6n+4) { --delay: 0.15s; }
.menu-list .menu-item:nth-child(6n+5) { --delay: 0.20s; }
.menu-list .menu-item:nth-child(6n+6) { --delay: 0.25s; }

@media print {
  .menu-nav { display: none !important; }
  .menu-layout { display: block; }
  .menu-intro { display: block; }
  /* Keep each dish (and each category heading with its list) intact across
     page breaks, and print the *whole* menu — a printout should never inherit
     an on-screen filter's hidden/dimmed state. */
  .menu-item { break-inside: avoid; }
  .menu-cat__head { break-after: avoid; }
  .menu-item[hidden], .menu-cat[hidden] { display: block !important; }
  .menu-item.is-avoided { opacity: 1 !important; }
  .menu-cat__empty { display: none !important; }
  .allergen-pop, .menu-noresults { display: none !important; }
  .menu-item__signature, .menu-item__price { color: #000; }
}
