/* Benchmark Gains Do Not Guarantee Transfer — HTML edition.
   Palette is lifted from the PDF's own tcolorbox colours so the two editions read as
   one document: hdgmaroon accents, bgblue background boxes, tkgreen takeaways. */

:root {
  --ink:        #12263a;
  --body:       #22303f;
  --muted:      #5f7183;
  --faint:      #8496a6;
  --rule:       #e3e8ee;
  --rule-soft:  #eef2f6;
  --page:       #ffffff;
  --sheet:      #f7f9fb;
  --maroon:     #9a2436;
  --blue:       #2563eb;
  --blue-bg:    #eaf2ff;
  --green:      #15803d;
  --green-bg:   #eaf7ee;
  --amber:      #d97706;
  --amber-bg:   #fef3c7;
  --red:        #a02128;
  --code-bg:    #f1f4f8;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 43rem;      /* ~78 characters: the readable column for prose */
  --float:   58rem;      /* floats break out past the measure: 8-column tables need it */
  --gutter:  19rem;      /* sidebar width on wide screens */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef3f8; --body: #d3dde6; --muted: #9bacbc; --faint: #7d8fa0;
    --rule: #263443; --rule-soft: #1d2937; --page: #0f1720; --sheet: #131c26;
    --maroon: #f08a99; --blue: #7dabff; --blue-bg: #14263f; --green: #6ddb96;
    --green-bg: #102a1b; --amber: #fbbf5a; --amber-bg: #33260a; --red: #ff9ba1;
    --code-bg: #1a2430;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--page);
  color: var(--body);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: oldstyle-num proportional-nums;
}

/* ---------------------------------------------------------------- page furniture */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--sheet), var(--page));
}
.masthead-inner { max-width: calc(var(--measure) + var(--gutter) + 6rem); margin: 0 auto; padding: 3.5rem 2rem 2.5rem; }
.eyebrow {
  font-family: var(--sans); font-size: .6875rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--maroon);
  font-variant-numeric: lining-nums tabular-nums;
}
h1.doctitle {
  font-family: var(--serif); font-weight: 700; color: var(--ink);
  font-size: clamp(1.9rem, 3.6vw, 2.9rem); line-height: 1.14;
  margin: .9rem 0 .35rem; letter-spacing: -.012em;
}
.docsub {
  font-size: clamp(1.05rem, 1.6vw, 1.32rem); color: var(--muted);
  font-style: italic; margin: 0 0 1.6rem; max-width: 46rem; line-height: 1.4;
}
.byline { font-family: var(--sans); font-size: .9375rem; color: var(--body); }
.byline b { color: var(--ink); }
.byline .affil { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.5rem 0 0; }
.chip {
  font-family: var(--sans); font-size: .78125rem; font-weight: 600;
  padding: .34rem .7rem; border-radius: 100px; border: 1px solid var(--rule);
  background: var(--page); color: var(--muted); text-decoration: none;
  font-variant-numeric: lining-nums tabular-nums;
}
.chip b { color: var(--ink); font-weight: 700; }
a.chip:hover { border-color: var(--maroon); color: var(--maroon); }

/* ---------------------------------------------------------------- layout */
.shell {
  max-width: calc(var(--float) + var(--gutter) + 6rem);
  margin: 0 auto; padding: 2.5rem 2rem 6rem;
  display: grid; grid-template-columns: var(--gutter) minmax(0, 1fr); gap: 3.5rem;
  align-items: start;
}
main { min-width: 0; max-width: var(--float); }

/* Prose keeps the 43rem measure; floats get the full column. This is the one place the
   HTML edition can beat the PDF -- a letter page forces an 8-column table to shrink its
   type, whereas here the table can simply be wider than the paragraph above it. */
main > p, main > ul, main > ol, main > h2, main > h3, main > h4,
main > .callout, main > .eqwrap, .abstract, main > div.center {
  max-width: var(--measure);
}
main > h1 { max-width: calc(var(--measure) + 4rem); }

/* ---------------------------------------------------------------- sidebar / TOC */
.rail { position: sticky; top: 1.5rem; max-height: calc(100vh - 3rem); overflow-y: auto; }
.rail::-webkit-scrollbar { width: 6px; }
.rail::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.toc-head, .rail-head {
  font-family: var(--sans); font-size: .6875rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  padding-bottom: .6rem; border-bottom: 1px solid var(--rule); margin-bottom: .6rem;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: grid; grid-template-columns: 2.1rem 1fr; gap: .4rem;
  font-family: var(--sans); font-size: .84375rem; line-height: 1.35;
  color: var(--muted); text-decoration: none; padding: .3rem .5rem .3rem .25rem;
  border-radius: 5px; border-left: 2px solid transparent;
}
.toc a:hover { color: var(--ink); background: var(--sheet); }
.toc-num { color: var(--faint); font-variant-numeric: lining-nums tabular-nums; font-weight: 600; }
.toc-sub a { font-size: .8125rem; padding-left: 1.4rem; }
.toc-sub .toc-num { font-size: .75rem; }
.toc a.active { color: var(--maroon); border-left-color: var(--maroon); background: var(--sheet); font-weight: 600; }
.toc a.active .toc-num { color: var(--maroon); }

/* ---------------------------------------------------------------- abstract */
.abstract {
  background: var(--sheet); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.6rem 1.75rem; margin: 0 0 2.5rem;
}
.abstract .rail-head { border-bottom-color: var(--rule); }
.abstract p { margin: .8rem 0 0; font-size: 1.015rem; line-height: 1.68; }
.abstract p:first-of-type { margin-top: .4rem; }

/* ---------------------------------------------------------------- headings */
h2, h3, h4 { font-family: var(--serif); color: var(--ink); line-height: 1.22; letter-spacing: -.008em; }
h2 {
  font-size: 1.72rem; margin: 3.4rem 0 1rem; padding-top: 1.5rem;
  border-top: 2px solid var(--rule); font-weight: 700;
}
h2:first-child { margin-top: 0; border-top: none; padding-top: 0; }
h3 { font-size: 1.28rem; margin: 2.4rem 0 .7rem; font-weight: 700; }
h4 { font-size: 1.08rem; margin: 1.8rem 0 .5rem; font-weight: 700; }

.secnum {
  display: inline-block; min-width: 2.4rem; color: var(--maroon);
  font-family: var(--sans); font-weight: 700; font-size: .82em;
  font-variant-numeric: lining-nums tabular-nums;
}
h3 .secnum, h4 .secnum { min-width: 2.9rem; font-size: .8em; }

p { margin: 0 0 1.05rem; }
main > p:first-of-type::first-line { font-variant-caps: normal; }

strong, b { color: var(--ink); font-weight: 700; }
em, i { font-style: italic; }
a { color: var(--maroon); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--maroon) 30%, transparent); }
a:hover { border-bottom-color: var(--maroon); }

code, .mono, tt {
  font-family: var(--mono); font-size: .855em; background: var(--code-bg);
  padding: .1em .34em; border-radius: 4px; color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums; word-break: break-word;
}
pre { background: var(--code-bg); padding: 1rem 1.1rem; border-radius: 8px; overflow-x: auto; }
pre code { background: none; padding: 0; }

/* cross-references and citations */
.xref { white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
sup.cite { font-family: var(--sans); font-size: .68em; font-weight: 600; }
sup.cite a { border: none; color: var(--blue); font-variant-numeric: lining-nums tabular-nums; }
.xref-missing { color: var(--faint); }

/* ---------------------------------------------------------------- lists */
ul, ol { margin: 0 0 1.05rem; padding-left: 1.5rem; }
li { margin: .34rem 0; }
li > p { margin: .3rem 0; }

/* ---------------------------------------------------------------- tables */
.tablewrap {
  margin: 2.2rem 0; padding: 0; border: 1px solid var(--rule);
  border-radius: 10px; background: var(--page); overflow: hidden;
}
/* the caption sits outside .tablescroll so it never scrolls with a wide table */
.tablescroll { overflow-x: auto; }
.tablescroll::-webkit-scrollbar { height: 8px; }
.tablescroll::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 4px; }
table {
  width: 100%; border-collapse: collapse;
  font-family: var(--sans); font-size: .8125rem; line-height: 1.45;
  font-variant-numeric: lining-nums tabular-nums;
}
caption, figcaption {
  caption-side: top; text-align: left;
  font-family: var(--sans); font-size: .8125rem; line-height: 1.55;
  color: var(--muted); padding: .95rem 1.1rem; background: var(--sheet);
  border-bottom: 1px solid var(--rule);
}
.figwrap figcaption { border-bottom: none; border-top: 1px solid var(--rule); }
.tablewrap figcaption { border-bottom: 1px solid var(--rule); border-top: none; }
caption strong, figcaption strong, caption b, figcaption b { color: var(--ink); }
.floatnum {
  font-weight: 700; color: var(--maroon); letter-spacing: .01em;
  font-variant-numeric: lining-nums tabular-nums;
}
thead th {
  font-weight: 700; color: var(--ink); text-align: left;
  padding: .6rem .7rem; border-bottom: 1.5px solid var(--ink);
  background: var(--page); vertical-align: bottom; font-size: .78125rem;
}
tbody td { padding: .5rem .7rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--sheet); }
td[style*="right"], th[style*="right"] { text-align: right !important; }
td[style*="center"], th[style*="center"] { text-align: center !important; }
/* first column reads as a row label */
tbody td:first-child { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- figures */
.figwrap {
  margin: 2.2rem 0; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--page); overflow: hidden;
}
.figwrap img { display: block; width: 100%; height: auto; padding: 1.1rem; background: #fff; }
@media (prefers-color-scheme: dark) {
  /* the plots are drawn on white; keep them legible without inverting the data colours */
  .figwrap img { background: #f7f9fb; border-radius: 6px; }
}

/* ---------------------------------------------------------------- callouts */
.callout {
  margin: 2rem 0; border-radius: 10px; border: 1px solid var(--rule);
  border-left: 4px solid var(--muted); background: var(--sheet); overflow: hidden;
}
.callout-title {
  font-family: var(--sans); font-size: .875rem; font-weight: 700; color: var(--ink);
  padding: .85rem 1.15rem .1rem;
}
.callout-body { padding: .25rem 1.15rem 1rem; }
.callout-body > p:last-child { margin-bottom: 0; }
.callout-body p, .callout-body li { font-size: .96875rem; }

.callout-takeaway   { border-left-color: var(--green); background: var(--green-bg); }
.callout-takeaway   .callout-title { color: var(--green); }
.callout-background { border-left-color: var(--blue);  background: var(--blue-bg); }
.callout-background .callout-title { color: var(--blue); }
.callout-case       { border-left-color: var(--amber); background: var(--amber-bg); }
.callout-case       .callout-title { color: var(--amber); }

/* The end-of-question Evidence / Decision / Boundary modules. These used to be emitted with
   class `editor` and hidden by `display: none` under the comment "editorial notes are
   print-draft only" -- but they are not editorial notes, they are the four boxes that state
   what each question's result licenses and what it does not. The PDF prints all four; the
   web edition silently dropped them. */
.callout-result     { border-left-color: var(--muted); background: var(--sheet); }
.callout-result     .callout-title { color: var(--ink); }

.callout-takeaway .callout-title::before,
.callout-background .callout-title::before,
.callout-result .callout-title::before {
  font-size: .6875rem; letter-spacing: .14em; text-transform: uppercase;
  display: block; margin-bottom: .25rem; opacity: .8;
}
.callout-takeaway .callout-title::before   { content: "Takeaway"; }
.callout-background .callout-title::before { content: "Background"; }
.callout-result .callout-title::before     { content: "Result"; }

/* ---------------------------------------------------------------- math */
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: .35rem 0; }
mjx-container { font-size: 1.02em; }

/* numbered display equations: number in the right margin, as in the PDF */
.eqwrap {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
  margin: 1.5rem 0; padding: .85rem 1rem; background: var(--sheet);
  border: 1px solid var(--rule-soft); border-radius: 8px;
}
.eqwrap > :first-child { margin: 0; min-width: 0; overflow-x: auto; }
.eqnum {
  font-family: var(--sans); font-size: .8125rem; font-weight: 600; color: var(--faint);
  font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.eqwrap:target { border-color: var(--maroon); background: var(--page); }

/* \paragraph — an unnumbered run-in heading, not a section */
h4.runin { font-size: 1.02rem; margin: 1.7rem 0 .4rem; }
h4.runin .secnum { display: none; }

/* a layout tabular inside another float (the case-study rows) is not "Table N" */
table.plaintable { margin: 1rem 0; font-size: .78125rem; }
table.plaintable thead th { border-bottom-width: 1px; }

/* ---------------------------------------------------------------- flowchart */
.flowchart .flow { padding: 1.5rem 1.2rem; display: flex; flex-direction: column; align-items: center; gap: 0; }
.flow-step {
  width: min(100%, 30rem); background: var(--sheet); border: 1px solid var(--rule);
  border-radius: 8px; padding: .7rem .95rem; font-family: var(--sans); font-size: .8125rem;
  line-height: 1.45; text-align: center;
}
.flow-step b { display: block; color: var(--ink); font-size: .84375rem; }
.flow-step span { color: var(--muted); }
.flow-gate { background: var(--blue-bg); border-color: var(--blue); text-align: left; }
.flow-gate b { color: var(--blue); }
.flow-arrow { width: 0; height: 1.15rem; border-left: 2px solid var(--faint); position: relative; }
.flow-arrow::after {
  content: ""; position: absolute; bottom: -1px; left: -4px;
  border: 5px solid transparent; border-top-color: var(--faint);
}
.flow-dec {
  margin: 1.15rem 0; padding: .6rem 1.6rem; background: var(--amber-bg);
  border: 1px solid var(--amber); border-radius: 100px; font-family: var(--sans);
  font-size: .8125rem; font-weight: 700; color: var(--ink);
}
.flow-split { display: flex; gap: 1.1rem; width: 100%; justify-content: center; flex-wrap: wrap; }
.flow-branch { flex: 1 1 15rem; max-width: 20rem; display: flex; flex-direction: column; align-items: center; gap: .45rem; }
.flow-label { font-family: var(--sans); font-size: .6875rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.flow-yes { color: var(--green); }
.flow-no  { color: var(--red); }
.flow-ship { background: var(--green-bg); border-color: var(--green); }
.flow-ship b { color: var(--green); }
.flow-stop { background: color-mix(in srgb, var(--red) 10%, var(--page)); border-color: var(--red); }
.flow-stop b { color: var(--red); }

/* --------------------------------------------------------------- regime map */
/* fig:regime-map is a TikZ 2x2 in the PDF and an ARIA grid of divs here (a real <table>
   inside a <figure> breaks the float-numbering pass). Three columns on a wide screen; one
   column on a phone, where the row headers become section labels above their cells. */
.regimemap .regime {
  display: grid; grid-template-columns: minmax(8rem, 1fr) 1.35fr 1.35fr;
  gap: .5rem; padding: 1.3rem 1.2rem .4rem; font-family: var(--sans); font-size: .8125rem;
}
.regimemap [role="row"] { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: .5rem; }
.regimemap [role="columnheader"] { text-align: center; padding: 0 .3rem .1rem; }
.regimemap [role="columnheader"] b { color: var(--ink); }
.regimemap [role="rowheader"] { text-align: right; align-self: center; padding-right: .2rem; }
.regimemap [role="rowheader"] b { color: var(--ink); }
.regimemap [role="cell"] {
  border: 1px solid var(--rule); border-radius: 8px; background: var(--sheet);
  padding: .65rem .8rem; text-align: center; align-self: stretch;
}
.regimemap .win { background: var(--green-bg); border-color: var(--green); }
.regimemap .win b { color: var(--green); }
.regimemap .lose { color: var(--muted); }
.regimemap i { display: block; font-style: normal; color: var(--muted); font-size: .71875rem;
               line-height: 1.4; margin-top: .2rem; }
.regimemap .regime-note {
  margin: .5rem 1.2rem 1.2rem; padding: .6rem .9rem; background: var(--blue-bg);
  border: 1px solid var(--blue); border-radius: 8px; font-family: var(--sans);
  font-size: .78125rem; text-align: center; color: var(--muted);
}
.regimemap .regime-note b { color: var(--ink); }
@media (max-width: 46rem) {
  .regimemap .regime { grid-template-columns: 1fr; }
  .regimemap [role="row"] { grid-template-columns: 1fr; }
  .regimemap .regime-head { display: none; }
  .regimemap [role="rowheader"] { text-align: left; padding-top: .5rem; }
}

/* ---------------------------------------------------------------- bibliography */
.bib { list-style: none; padding: 0; margin: 0; }
.bib li {
  display: grid; grid-template-columns: 2.6rem 1fr; gap: .5rem;
  font-family: var(--sans); font-size: .84375rem; line-height: 1.55;
  padding: .55rem 0; border-bottom: 1px solid var(--rule-soft); color: var(--muted);
}
.bib li:target { background: var(--blue-bg); border-radius: 6px; padding-left: .5rem; }
.bibnum { color: var(--faint); font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.bibtext em { color: var(--ink); font-style: italic; }

/* ---------------------------------------------------------------- footer */
.colophon {
  margin-top: 4rem; padding-top: 1.6rem; border-top: 2px solid var(--rule);
  font-family: var(--sans); font-size: .8125rem; color: var(--muted); line-height: 1.6;
}
.colophon b { color: var(--ink); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 62rem) {
  .shell { grid-template-columns: 1fr; gap: 0; padding: 1.5rem 1.25rem 4rem; }
  .rail {
    position: static; max-height: none; margin-bottom: 2rem;
    border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.1rem; background: var(--sheet);
  }
  .rail details { margin: 0; }
  .masthead-inner { padding: 2.25rem 1.25rem 1.75rem; }
  body { font-size: 1.03125rem; }
  main { max-width: none; }
}

@media print {
  .rail, .chips { display: none; }
  .shell { display: block; padding: 0; }
  body { font-size: 10.5pt; }
  h2 { page-break-after: avoid; }
  .tablewrap, .figwrap, .callout { page-break-inside: avoid; }
}
