/* After Costs – research log. Tokens first; every color below comes from them. */
:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --ink: #111820;
  --ink-2: #3d4752;
  --muted: #69737f;
  --rule: #dadfe3;
  --rule-strong: #bcc4cb;
  --accent: #1b45b4;
  --accent-soft: #e6ecfa;
  --code-bg: #edf0f2;
  --grid: #e7eaed;
  --axis: #b9c1c8;
  --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100;
  --s4: #e87ba4; --s5: #008300; --s6: #4a3aa7; --s7: #e34948;
  --good: #0ca30c; --warn: #fab219; --critical: #d03b3b;
  --good-ink: #006300; --warn-ink: #7a5200; --critical-ink: #b42323;
  --good-bg: #e5f4e5; --warn-bg: #fdf1d6; --critical-bg: #fbe7e7;
  --font-display: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-body: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --measure: 40rem;
  --wide: 58rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1318; --surface: #141a21; --ink: #e8ecef; --ink-2: #b9c2cb; --muted: #8b97a3;
    --rule: #26303a; --rule-strong: #3a4652; --accent: #8aa8ff; --accent-soft: #1b2540; --code-bg: #1a222b;
    --grid: #212a33; --axis: #3a4652;
    --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500;
    --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
    --good-ink: #3fcf3f; --warn-ink: #f5c04a; --critical-ink: #ff8a8a;
    --good-bg: #13301a; --warn-bg: #33290f; --critical-bg: #3a1717;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1318; --surface: #141a21; --ink: #e8ecef; --ink-2: #b9c2cb; --muted: #8b97a3;
  --rule: #26303a; --rule-strong: #3a4652; --accent: #8aa8ff; --accent-soft: #1b2540; --code-bg: #1a222b;
  --grid: #212a33; --axis: #3a4652;
  --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500;
  --s4: #d55181; --s5: #008300; --s6: #9085e9; --s7: #e66767;
  --good-ink: #3fcf3f; --warn-ink: #f5c04a; --critical-ink: #ff8a8a;
  --good-bg: #13301a; --warn-bg: #33290f; --critical-bg: #3a1717;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.62 var(--font-body);
  padding-inline: 16px;
  font-optical-sizing: auto;
}
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
img, svg { max-width: 100%; }
::selection { background: var(--accent-soft); }

.wrap { max-width: var(--wide); margin-inline: auto; }

/* ---------- masthead */
.masthead {
  max-width: var(--wide); margin: 0 auto; padding-block: 22px 14px;
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px 24px;
  border-bottom: 1px solid var(--rule);
}
.wordmark {
  font-family: var(--font-display); font-weight: 800; font-stretch: 118%;
  font-size: 1.35rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none;
  display: inline-flex; align-items: baseline; gap: 0.5rem;
}
.wordmark .tick { font-family: var(--font-mono); font-weight: 500; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.04em; font-stretch: 100%; }
.nav { display: flex; flex-wrap: wrap; gap: 4px 18px; font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.02em; }
.nav a { color: var(--ink-2); text-decoration: none; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* ---------- type */
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); text-wrap: balance; margin: 0; }
h1 { font-weight: 800; font-stretch: 112%; font-size: clamp(2rem, 1.3rem + 3.2vw, 3.3rem); line-height: 1.04; letter-spacing: -0.02em; }
h2 { font-weight: 750; font-stretch: 108%; font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); line-height: 1.15; letter-spacing: -0.01em; }
h3 { font-weight: 700; font-stretch: 104%; font-size: 1.14rem; line-height: 1.25; }
.eyebrow, .meta, .label {
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted);
}
.dek { font-size: 1.22rem; line-height: 1.5; color: var(--ink-2); max-width: var(--measure); }
.num, td.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- article */
.article { max-width: var(--wide); margin: 0 auto; padding-block: 40px 72px; }
.article-head { display: grid; gap: 16px; padding-bottom: 26px; border-bottom: 1px solid var(--rule); margin-bottom: 30px; }
.prose { max-width: var(--measure); }
.prose > * { margin-block: 0; }
.prose > * + * { margin-top: 1.05em; }
.prose > figure.chart, .prose > .table-wrap, .prose > .keybox { margin-block: 1.7em; }
.prose > :first-child { margin-top: 0; }
.prose h2 { margin-top: 2.1em; }
.prose h3 { margin-top: 1.7em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.55em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.35em; }
.prose strong { font-weight: 650; }
.prose code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); padding: 0.08em 0.32em; border-radius: 3px; }
.prose blockquote { margin: 0; padding-left: 1em; border-left: 3px solid var(--rule-strong); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2em; }
.prose .footnote { font-size: 0.88rem; color: var(--ink-2); }
.prose sup { line-height: 0; }

/* wide elements break out of the measure */
.prose > .table-wrap, .prose > figure.chart, .prose > .callout.wide { max-width: var(--wide); width: min(var(--wide), calc(100vw - 32px)); }

/* key findings box – the one set-off element per article */
.keybox {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 6px;
  padding: 18px 20px 16px; max-width: var(--measure);
}
.keybox .label { display: block; margin-bottom: 8px; }
.keybox ul { margin: 0; padding-left: 1.15em; }
.keybox li + li { margin-top: 0.4em; }

.callout { border-left: 3px solid var(--accent); padding: 4px 0 4px 16px; color: var(--ink-2); }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; line-height: 1.4; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-family: var(--font-mono); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom-color: var(--rule-strong); }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: var(--accent-soft); }

/* verdict chips: icon + label, never color alone */
.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 8px 2px 6px; border-radius: 999px;
}
.chip::before { font-size: 0.8rem; line-height: 1; }
.chip.pass { background: var(--good-bg); color: var(--good-ink); }
.chip.pass::before { content: "✓"; }
.chip.marginal { background: var(--warn-bg); color: var(--warn-ink); }
.chip.marginal::before { content: "~"; }
.chip.fail { background: var(--critical-bg); color: var(--critical-ink); }
.chip.fail::before { content: "✕"; }
.chip.pending { background: var(--code-bg); color: var(--ink-2); }
.chip.pending::before { content: "…"; }

/* ---------- charts */
figure.chart { margin-inline: 0; padding: 18px 18px 12px; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
figure.chart .chart-title { font-family: var(--font-display); font-weight: 700; font-stretch: 104%; font-size: 1.02rem; line-height: 1.3; margin: 0; }
figure.chart .chart-sub { font-size: 0.9rem; color: var(--ink-2); margin: 3px 0 0; line-height: 1.45; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 12px 0 2px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend i.ref { height: 0; border-top: 2px dashed var(--ink); background: none; }
.chart-ylabel { margin-top: 10px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }
.chart-plot { position: relative; margin-top: 4px; min-height: 120px; }
.chart-plot svg { display: block; width: 100%; overflow: visible; }
.chart-plot text { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.chart-plot .axis-label { fill: var(--ink-2); font-size: 11px; }
.chart-plot .grid { stroke: var(--grid); stroke-width: 1; }
.chart-plot .axis { stroke: var(--axis); stroke-width: 1; }
.chart-plot .ref line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart-plot .ref text { fill: var(--ink); font-size: 11px; font-weight: 500; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart-plot .zero { stroke: var(--rule-strong); stroke-width: 1; }
.chart-plot path.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-plot .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-plot .dot { stroke: var(--surface); stroke-width: 2; }
.chart-plot .bar { stroke: var(--surface); stroke-width: 1; }
.chart-plot .bar.dim { opacity: 0.35; }
.chart-plot .pt { stroke: var(--surface); stroke-width: 1.5; }
.c0 { stroke: var(--s0); fill: var(--s0); } .c1 { stroke: var(--s1); fill: var(--s1); }
.c2 { stroke: var(--s2); fill: var(--s2); } .c3 { stroke: var(--s3); fill: var(--s3); }
.c4 { stroke: var(--s4); fill: var(--s4); } .c5 { stroke: var(--s5); fill: var(--s5); }
.c6 { stroke: var(--s6); fill: var(--s6); } .c7 { stroke: var(--s7); fill: var(--s7); }
path.line.c0, path.line.c1, path.line.c2, path.line.c3, path.line.c4, path.line.c5, path.line.c6, path.line.c7 { fill: none; }
.bg-c0 { background: var(--s0); } .bg-c1 { background: var(--s1); } .bg-c2 { background: var(--s2); } .bg-c3 { background: var(--s3); }
.bg-c4 { background: var(--s4); } .bg-c5 { background: var(--s5); } .bg-c6 { background: var(--s6); } .bg-c7 { background: var(--s7); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 120px; max-width: 280px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); padding: 7px 9px; font-family: var(--font-mono); font-size: 0.74rem; line-height: 1.45;
}
.chart-tip b { font-weight: 600; display: block; margin-bottom: 2px; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 12px; }
.chart-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
figure.chart figcaption { margin-top: 8px; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }
figure.chart details { margin-top: 6px; font-size: 0.82rem; }
figure.chart summary { cursor: pointer; font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink-2); letter-spacing: 0.03em; }
figure.chart details .table-wrap { max-height: 320px; overflow: auto; margin-top: 8px; }
figure.chart details table { font-size: 0.78rem; }
figure.chart details td, figure.chart details th { padding: 4px 8px; }

/* ---------- index */
.hero { max-width: var(--wide); margin: 0 auto; padding-block: 48px 36px; display: grid; gap: 18px; }
.hero h1 { max-width: 16ch; }
.hero .dek { font-size: 1.28rem; }
.stats { display: flex; flex-wrap: wrap; gap: 14px 40px; margin-top: 6px; }
.stat { display: grid; gap: 2px; }
.stat .v { font-family: var(--font-display); font-weight: 800; font-stretch: 112%; font-size: 2.1rem; line-height: 1; }
.stat .k { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.section { max-width: var(--wide); margin: 0 auto; padding-block: 30px; border-top: 1px solid var(--rule); }
.section > h2 { margin-bottom: 6px; }
.section > .sub { color: var(--ink-2); margin: 0 0 16px; max-width: var(--measure); }
.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.posts li { padding-block: 16px; border-bottom: 1px solid var(--rule); display: grid; gap: 4px; }
.posts li:first-child { padding-top: 4px; }
.posts a.t { font-family: var(--font-display); font-weight: 750; font-stretch: 106%; font-size: 1.22rem; line-height: 1.2; color: var(--ink); text-decoration: none; }
.posts a.t:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.posts .d { color: var(--ink-2); max-width: var(--measure); }
.scoreboard td:first-child a { color: var(--ink); font-weight: 600; text-decoration: none; }
.scoreboard td:first-child a:hover { text-decoration: underline; }

/* ---------- footer */
.footer { max-width: var(--wide); margin: 0 auto; padding-block: 26px 40px; border-top: 1px solid var(--rule); font-size: 0.86rem; color: var(--muted); display: grid; gap: 8px; }
.footer p { margin: 0; max-width: var(--measure); }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--rule); font-family: var(--font-mono); font-size: 0.82rem; }

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .hero { padding-block: 30px 24px; }
  .stat .v { font-size: 1.7rem; }
  figure.chart { padding: 14px 12px 10px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
