/*
  Site styles: base elements and shared components, built only from tokens.css.
  Loaded on every page after the page's own <style> and before mobile.css.
  The rules behind these choices are in DESIGN.md at the repo root (direction N4).
*/

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-ink);
  font-family: var(--font-body); font-size: var(--text-body); line-height: var(--leading-body);
  font-optical-sizing: auto; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
body.menu-open { overflow: hidden; }
p { margin: 0; }
a { color: var(--color-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--color-ink-2); text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--color-ink); outline-offset: 2px; border-radius: var(--radius-box);
}
strong, b { font-weight: 600; }
img { max-width: 100%; height: auto; border: 0; border-radius: var(--radius-box); display: block; }
ul, ol { margin: 0; padding-left: 1.2em; }
li + li { margin-top: 2px; }
q { quotes: "“" "”"; }

.wrap {
  max-width: var(--page-max); margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: 0 var(--space-12);
  display: grid; gap: var(--section-gap);
}

/* ---------- Type ---------- */
h1, h2, h3, .stage-name {
  font-family: var(--font-display); font-weight: 500; letter-spacing: var(--tracking-display);
  color: var(--color-ink); margin: 0; text-wrap: balance;
}
h1 { font-size: var(--text-display); line-height: var(--leading-tight); }
h2 { font-size: var(--text-h2); line-height: var(--leading-heading); }
h3 { font-size: var(--text-h3); line-height: 1.15; letter-spacing: -0.02em; }
h4 { font-family: var(--font-body); font-size: var(--text-body); font-weight: 600; margin: 0; }

header { display: grid; gap: var(--space-3); }
header > p { max-width: var(--measure); }

/* Kicker above a title: plain sans, sentence case. */
.brand, .eyebrow, .kicker {
  font-family: var(--font-body); font-size: var(--text-small); font-weight: 600;
  letter-spacing: 0; text-transform: none; color: var(--color-ink);
}
.brand a { color: var(--color-ink); }

/* Intros under a title and Sam's notes: plain DM Sans, a step up from body. */
.lede, header > p.muted, .summary, .voice {
  font-family: var(--font-body); font-style: normal; font-weight: 400;
  font-size: var(--text-intro); line-height: 1.5; letter-spacing: 0; color: var(--color-ink-2);
  max-width: var(--measure);
}
.muted { color: var(--color-muted); }
.hint { font-size: var(--text-small); color: var(--color-muted); max-width: var(--measure); }
/* Page width (DESIGN.md §7): the frame is up to 1200 px, but running text keeps the reading width. */
.wrap :is(p, li, dd, blockquote) { max-width: var(--measure); }

/* Evidence: sources, dates, test IDs. */
.src, .source, .checked {
  font-family: var(--font-mono); font-size: var(--text-source); letter-spacing: -0.01em; color: var(--color-muted);
}
.num, td, .stat .v, .meter .top { font-variant-numeric: tabular-nums; }

/* Byline: the only uppercase on the site. */
.byline { display: flex; align-items: center; gap: var(--space-3); }
.byline .avatar {
  width: 44px; height: 44px; flex: none; border-radius: 999px; background: var(--color-sunken);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 20px; font-weight: 600;
}
.byline .who { font-size: 13px; font-weight: 600; letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.byline > span:last-child { display: flex; flex-direction: column; }

/* ---------- Signature: the measuring line ---------- */
.ruler {
  height: 12px;
  background-image:
    linear-gradient(var(--ruler-ink, var(--color-ink)), var(--ruler-ink, var(--color-ink))),
    repeating-linear-gradient(90deg, var(--ruler-ink, var(--color-ink)) 0 1px, transparent 1px 30px),
    repeating-linear-gradient(90deg, var(--ruler-ink, var(--color-ink)) 0 1px, transparent 1px 6px);
  background-size: 100% 1px, 100% 12px, 100% 6px;
  background-repeat: no-repeat;
}

/* ---------- Masthead ---------- */
.masthead { margin-inline: calc(-1 * var(--gutter)); display: grid; }
.masthead-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 60px; padding: 0 var(--space-3);
}
.menu-btn {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap-large); padding: 0 10px;
  border: 0; border-radius: var(--radius-box); background: transparent; color: var(--color-ink);
  font: 500 16px/1 var(--font-body); cursor: pointer;
}
.menu-btn svg { width: 22px; height: 22px; }
.find-btn, .button-primary {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap-large); padding: 0 var(--space-4);
  border-radius: var(--radius-box); background: var(--color-ink); color: var(--color-bg);
  font-size: 15px; font-weight: 500; text-decoration: none;
}
.find-btn:hover, .button-primary:hover { color: var(--color-bg); opacity: 0.88; }
.find-btn[aria-current] { background: transparent; color: var(--color-ink); box-shadow: inset 0 0 0 1px var(--color-control); }
.masthead-name {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px;
  padding: 2px 0 10px;
}
.masthead-name::before, .masthead-name::after { content: ""; height: 1px; background: var(--color-rule); }
.wordmark {
  font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1; letter-spacing: var(--tracking-display);
  text-decoration: none; color: var(--color-ink);
}

/* ---------- Menu panel: slides in from the left over a dimmed page (after every.to) ---------- */
.menu-sheet {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  background: transparent; transition: background-color 0.3s cubic-bezier(0, 0, 0.2, 1);
}
.menu-sheet.is-open { background: var(--color-menu-scrim); }
.menu-sheet:focus { outline: none; }
.menu-sheet-inner {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(88vw, 360px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--color-menu-bg); color: var(--color-menu-ink); border-right: 1px solid var(--color-menu-line);
  padding: 0 var(--space-5) var(--space-10) max(var(--space-5), env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0, 0, 0.2, 1);
}
.menu-sheet.is-open .menu-sheet-inner { transform: none; }
.menu-sheet-inner a { color: var(--color-menu-ink); }
.menu-close {
  align-self: flex-start; width: var(--tap-large); justify-content: center; padding: 0; margin: 6px 0 4px -12px;
  background: transparent; color: var(--color-menu-ink);
}
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li { margin: 0; }
.menu-list a {
  display: flex; align-items: center; min-height: 52px; padding: 6px 0;
  border-bottom: 1px dashed var(--color-menu-line); text-decoration: none;
  font-family: var(--font-body); font-size: 19px; line-height: 1.3; font-weight: 400;
}
.menu-list li:first-child a { border-top: 1px dashed var(--color-menu-line); }
.menu-list a:hover { text-decoration: underline; text-underline-offset: 4px; }
.menu-list a[aria-current] { font-weight: 600; }
.menu-list-small { margin-top: auto; padding-top: var(--space-8); }
.menu-list-small a, .menu-list-small li:first-child a { border: 0; min-height: var(--tap); font-size: 16px; color: var(--color-menu-muted); }
.menu-sheet-inner a:focus-visible, .menu-sheet-inner button:focus-visible { outline-color: var(--color-menu-ink); }
@media (prefers-reduced-motion: reduce) {
  .menu-sheet, .menu-sheet-inner { transition: none; }
}

/* ---------- Sections: flat, ruled ---------- */
.panel {
  background: transparent; border: 0; border-top: 2px solid var(--color-rule); border-radius: 0;
  padding: var(--space-4) 0 0; display: grid; gap: var(--space-4); min-width: 0;
}
.panel > h2:first-child, .panel > .row:first-child h2 { font-size: 26px; }
.panel h3 { font-size: 22px; }
/* Finder blocks inside a section: grouped by space, no box (DESIGN.md: space before lines). */
.stage-detail, .regions-out { border: 0; padding: 0; background: transparent; display: grid; gap: var(--space-2); }
.box, .estimate, .sit-out, .alert, .best, .result, .answer {
  border: 1px solid var(--color-line); border-radius: var(--radius-box); padding: var(--space-3) var(--space-4);
  background: transparent; display: grid; gap: var(--space-2);
}
.sit-out.ok { background: var(--color-ok-bg); border-color: transparent; }
.sit-out.warn, .alert { background: var(--color-warn-bg); border: 1.5px solid var(--color-warn-line); font-style: normal; }
.best { font-size: var(--text-lead); border-color: var(--color-rule); }
.next { border: 0; padding-top: 0; display: grid; gap: var(--space-2); }
figure { margin: 0; border: 0; padding: 0; display: grid; gap: var(--space-2); background: transparent; }
figcaption { font-family: var(--font-mono); font-size: var(--text-source); color: var(--color-muted); }
.card, .fact { background: transparent; border: 1px solid var(--color-line); border-radius: var(--radius-box); padding: var(--space-4); }
.layers { border: 0; border-top: 1px solid var(--color-rule); border-radius: 0; }
.layer { border-bottom: 1px dashed var(--color-dash); padding: var(--space-3) 0; }
.layer:first-child { background: transparent; }
.fact .n { font-family: var(--font-display); font-weight: 400; font-size: 44px; line-height: 1; letter-spacing: var(--tracking-display); }
.fact .s, .card dt { font-family: var(--font-mono); font-size: var(--text-source); color: var(--color-muted); }

/* Inputs: the one filled area, so what you tell us looks different from our answer (DESIGN.md). */
.panel.inputs { background: var(--color-sunken); border-top: 0; border-radius: var(--radius-box); padding: var(--space-5) var(--space-4); }

/* The catch: a full outlined box, never a side stripe. */
.catch { border: 1.5px solid var(--color-warn-line); border-radius: var(--radius-box); background: var(--color-warn-bg); padding: 14px var(--space-4); display: grid; gap: 6px; }

/* ---------- Tags, badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-body);
  font-size: 14px; font-weight: 600; line-height: 1.4; padding: 0; margin: 0 10px 0 0;
  border: 0; border-radius: 0; background: none; color: var(--color-ink); white-space: nowrap;
}
.tag.ok { color: var(--color-ok); background: none; border: 0; }
.tag.warn { color: var(--color-warn); background: none; border: 0; }
.tag.no { color: var(--color-no); font-weight: 700; background: none; border: 0; }
.tag.ok::before { content: "✓"; }
.tag.no::before { content: "✕"; }
.tag.warn::before { content: "!"; }
.chip {
  display: inline-flex; font-size: 13px; font-weight: 600; color: var(--color-ink-2); background: transparent;
  border: 1px solid var(--color-line); border-radius: var(--radius-tag); padding: 1px 8px;
}
/* Neutral facts: one plain line, separated by dots. */
.badge { display: inline; font-size: 14px; color: var(--color-ink-2); background: none; border: 0; padding: 0; }
.badge + .badge::before { content: "·"; margin: 0 4px; color: var(--color-muted); }
.draft {
  display: inline-block; font-family: var(--font-body); font-size: 11px; font-weight: 600; letter-spacing: var(--tracking-caps); text-transform: uppercase;
  border: 1px dashed var(--color-warn); color: var(--color-warn); background: var(--color-warn-bg); border-radius: var(--radius-tag); padding: 0 6px; vertical-align: middle;
}
.fit { font-family: var(--font-body); font-size: 13px; font-weight: 600; }
.fit.ok { color: var(--color-ok); } .fit.warn { color: var(--color-warn); } .fit.no { color: var(--color-no); }

/* ---------- Recall: urgent but factual ---------- */
.recall {
  border: 2px solid var(--color-no); border-radius: var(--radius-box); background: var(--color-no-bg);
  padding: var(--space-5); display: grid; gap: var(--space-2); color: var(--color-ink);
}
.recall h2 { color: var(--color-no); font-size: 26px; }
.recall h2::before { content: "✕ "; }
.recall p { white-space: pre-line; }

/* ---------- Tables ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; border-top: 1px solid var(--color-rule); }
th, td { border: 0; border-bottom: 1px solid var(--color-line); padding: 10px 12px 10px 0; text-align: left; vertical-align: top; background: none; }
thead th { font-family: var(--font-body); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--color-muted); background: none; }
tbody th[scope="row"] { font-weight: 400; color: var(--color-muted); width: 45%; }
td.yes::before { content: "✓ "; color: var(--color-ok); }
td.no::before { content: "✕ "; color: var(--color-no); }

.kv, dl { margin: 0; display: grid; gap: 0; }
.kv dt, dl dt { font-weight: 600; margin-top: var(--space-3); }
.kv dt:first-child, dl dt:first-child { margin-top: 0; }
.kv dd, dl dd { margin: 0; color: var(--color-ink-2); padding-bottom: var(--space-3); border-bottom: 1px dashed var(--color-dash); }
.card dl, .minimums { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; }
.card dd, .minimums dd { border: 0; padding: 0; }
.card dt, .minimums dt { margin: 0; font-weight: 400; }

/* ---------- Forms ---------- */
input, select, textarea, button { font-family: var(--font-body); font-size: 16px; }
select, input[type="number"], input[type="text"] {
  color: var(--color-ink); background: var(--color-surface); border: 1px solid var(--color-control);
  border-radius: var(--radius-box); min-height: var(--tap); padding: 8px 12px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--color-ink); }
.field { display: grid; gap: var(--space-2); }
.field > label, .legend { font-weight: 600; }
.unit { color: var(--color-muted); font-family: var(--font-mono); font-size: var(--text-small); }
fieldset { border: 0; padding: 0; margin: 0; }
.button, button.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 var(--space-4);
  border: 1px solid var(--color-control); border-radius: var(--radius-box); background: transparent; color: var(--color-ink);
  font-weight: 500; text-decoration: none; cursor: pointer;
}
summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 600; }

/* ---------- Finder: stage track ---------- */
.track { border: 0; border-top: 1px solid var(--color-line); border-radius: 0; background: transparent; gap: 0; }
.track li { color: var(--color-ink-2); border-color: var(--color-line) !important; font-size: 14px; }
/* No fills or outlines on stages: colour is for fit only (DESIGN.md, usability basics). */
.track li, .track li.s-ok, .track li.s-warn, .track li.s-no { background: transparent; }
.track li.now { color: var(--color-ink); font-weight: 400; box-shadow: none; }
.track li.now .nm { font-weight: 600; }

/* Finder: result */
.result-head { display: grid; gap: var(--space-2); }
.stage-name { font-size: 38px; line-height: var(--leading-tight); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); border: 0; padding-top: 0; }
.stat { border: 0; padding: 0; min-width: 0; }
.stat .k { font-size: 13px; color: var(--color-muted); }
.stat .v { font-family: var(--font-display); font-size: 28px; line-height: 1.1; font-weight: 400; letter-spacing: var(--tracking-display); }
.stat .s { font-family: var(--font-mono); font-size: var(--text-source); font-style: normal; color: var(--color-muted); }

/* Meters: a child's size against a limit, over the measuring line */
.limits { display: grid; gap: var(--space-4); }
.meter { display: grid; gap: 6px; }
.meter .top { font-size: var(--text-small); }
.meter .rail {
  --ruler-ink: var(--color-dash);
  height: 14px; border: 0; border-radius: 0; overflow: hidden;
  background-image:
    repeating-linear-gradient(90deg, var(--color-dash) 0 1px, transparent 1px 30px),
    repeating-linear-gradient(90deg, var(--color-dash) 0 1px, transparent 1px 6px);
  background-size: 100% 14px, 100% 11px; background-repeat: no-repeat; background-color: transparent;
}
.meter .fill { height: 8px; background: var(--color-ink); border-radius: 0; }

/* Finder: seat list. Flat rows; the first seat is "our pick" in an ink outline. */
.seat-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.seat-list li {
  margin: 0; border: 0; border-bottom: 1px dashed var(--color-dash); border-radius: 0; background: transparent;
  padding: var(--space-4) 0; display: grid; gap: var(--space-2);
}
.seat-list li.pick { border: 1.5px solid var(--color-rule); border-radius: var(--radius-box); padding: var(--space-4); margin-bottom: var(--space-2); }
.seat-list .top { display: grid; gap: var(--space-2); justify-content: stretch; }
.seat-list .top > span:last-child { display: flex; flex-wrap: wrap; gap: 4px 0; }
.seat-list .name { font-family: var(--font-display); font-size: var(--text-h3); line-height: 1.1; letter-spacing: var(--tracking-display); font-weight: 500; text-decoration: none; }
.seat-list li.pick .name { font-size: 32px; }
.seat-list .name:hover { text-decoration: underline; }
.seat-list .why { font-size: 15px; color: var(--color-ink-2); }
.badges { display: block; }

/* ---------- Footer ---------- */
footer, .disclaimer {
  border-top: 1px solid var(--color-rule); padding-top: var(--space-4); color: var(--color-muted);
  font-size: var(--text-small); display: grid; gap: var(--space-2); max-width: var(--measure);
}
footer strong, .disclaimer strong { color: var(--color-ink); }

/* ---------- Charts (SVG) ---------- */
svg.chart { font-family: var(--font-mono); color: var(--color-ink); }
figure svg { color: var(--color-ink); }

/* ---------- Phones: data tables become labelled blocks (layout in mobile.css) ---------- */
@media (max-width: 640px) {
  table:has(thead) tbody tr {
    border: 0; border-bottom: 1px dashed var(--color-dash); border-radius: 0; background: transparent; padding: var(--space-3) 0; margin-bottom: 0;
  }
  table:has(thead) tbody td[data-label]::before { font-size: 13px; font-weight: 600; color: var(--color-muted); margin-bottom: 2px; }
}

/* ---------- Bigger screens ---------- */
@media (min-width: 760px) {
  :root { --text-display: 58px; --text-h2: 34px; --text-intro: 19px; --gutter: 32px; --section-gap: 48px; }
  .stat .v { font-size: 34px; }
  .seat-list .top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; }
  .wordmark { font-size: 34px; }
}
