/* ==========================================================================
   base.css — reset, typography, focus, universal utilities
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  margin: 0;
  min-height: 100%;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--t-base);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Faint ledger grid + a warm bloom behind the top of the page.
   Purely decorative, sits under everything, never intercepts pointers. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--rule) 42%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--rule) 42%, transparent) 1px, transparent 1px);
  background-size: 64px 64px;
  opacity: 0.42;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 0%, transparent 78%);
}

img, svg, canvas { max-width: 100%; height: auto; display: block; }

/* The hidden attribute must beat any display rule we set elsewhere. Without
   this, a `display: block` on a class silently un-hides an element the script
   believes it has hidden — which is how both wordings ended up on screen at
   once during the first build. */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--s-3);
  text-wrap: balance;
}
h1 { font-size: var(--t-3xl); letter-spacing: -0.03em; }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); font-family: var(--font-ui); font-weight: 700; letter-spacing: -0.005em; }
h5 { font-size: var(--t-base); font-family: var(--font-ui); font-weight: 700; }

p { margin: 0 0 var(--s-4); max-width: 68ch; text-wrap: pretty; }
ul, ol { margin: 0 0 var(--s-4); padding-left: 1.25em; }
li { margin-bottom: var(--s-2); }
li > ul, li > ol { margin-top: var(--s-2); }

a {
  color: var(--info);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  border-radius: 2px;
  transition: color var(--d-1) var(--e-out), background-color var(--d-1) var(--e-out);
}
a:hover { color: var(--ink); background-color: color-mix(in srgb, var(--info) 12%, transparent); }

code, kbd, samp, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
code {
  font-size: 0.88em;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  padding: 0.06em 0.34em;
}
kbd {
  font-size: 0.8em;
  background: var(--card);
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-1);
  padding: 0.1em 0.42em;
  color: var(--ink-2);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--s-6) 0;
}

/* --- Focus: one visible treatment everywhere, including inside dark cards --- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-1);
  box-shadow: 0 0 0 5px var(--focus-halo);
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) {
  outline: none;
}
/* Range thumbs get their own ring — outline on the host is easy to miss. */
input[type="range"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

button { font: inherit; color: inherit; }

::selection { background: color-mix(in srgb, var(--g3) 28%, transparent); color: var(--ink); }

/* --- Utilities --- */
.visually-hidden:not(:focus):not(:active) {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.wrap { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
.wrap-narrow { width: min(100% - 2rem, var(--wrap-narrow)); margin-inline: auto; }
@media (max-width: 560px) { .wrap, .wrap-narrow { width: min(100% - 1.5rem, var(--wrap)); } }

.stack > * + * { margin-top: var(--s-4); }
.lede { font-size: var(--t-md); color: var(--ink-2); line-height: 1.55; max-width: 62ch; }
.muted { color: var(--ink-3); }
.small { font-size: var(--t-sm); }
.xsmall { font-size: var(--t-xs); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--rule), transparent);
}

.skip-link {
  position: absolute;
  left: var(--s-4);
  top: var(--s-2);
  z-index: 999;
  transform: translateY(-160%);
  background: var(--ink);
  color: var(--ink-inv);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-2);
  font-weight: 650;
  text-decoration: none;
  box-shadow: var(--sh-3);
  transition: transform var(--d-2) var(--e-out);
}
.skip-link:focus { transform: translateY(0); }

/* --- Reduced motion: strip non-essential animation everywhere --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1 !important; transform: none !important; }
}

@media print {
  body::before, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card, table { break-inside: avoid; }
}

/* --- Shrink safety -------------------------------------------------------
   Grid and flex children default to min-width:auto, which refuses to shrink
   below their longest unbreakable run and quietly pushes a phone sideways.
   Every two-column pattern on this page opts out of that.                  */
.claimline > *,
.callout > *,
.opt > *,
.radio > *,
.burnrow > *,
.shelfcard > *,
.verdict__why li > *,
.sim__ledger dt,
.sim__ledger dd,
.srcitem > *,
.statbox > *,
.cmp tbody td > * { min-width: 0; }

.claimline, .callout, .opt, .radio, .burnrow, .shelfcard, .statbox, .srcitem { max-width: 100%; }

.stamp { max-width: 100%; flex-wrap: wrap; }
.claimline b, .callout, .opt__t, .radio__t, .cell__v, .cell__x, .cell__alt,
.statbox__v, .verdict__why li, .tl__evt p { overflow-wrap: break-word; }
