/* ============================================================
   Residual Notes — single hand-maintained stylesheet.
   Body: XCharter (Bitstream Charter free licence), self-hosted, subsetted.
   Cargo: IBM Plex Mono (OFL 1.1) — numbers, labels, metadata.
   Ground: cool blue-grey. Print is first-class; the PDF is built by
   XeLaTeX, so @media print here only serves browser "Print this page".
   ============================================================ */

@font-face {
  font-family: "XCharter"; src: url("/static/fonts/xcharter-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "XCharter"; src: url("/static/fonts/xcharter-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "XCharter"; src: url("/static/fonts/xcharter-bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "XCharter"; src: url("/static/fonts/xcharter-bolditalic.woff2") format("woff2");
  font-weight: 700; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "PlexMono"; src: url("/static/fonts/plexmono-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "PlexMono"; src: url("/static/fonts/plexmono-medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

/* XCharter has no U+2248, U+221E or U+21A9 in any face, and no Greek in bold
   italic. Plex Mono carries all four, so these codepoints — and only these —
   fall through to a font the page has already loaded. Declared after the
   XCharter faces so it wins for exactly this range. */
@font-face {
  font-family: "XCharter"; src: url("/static/fonts/plexmono-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+2248, U+221E, U+21A9;
}
/* The mirror of the above: Plex Mono carries no Greek, and memo tables use
   σ, μ and ρ constantly. Serve just that range from XCharter. */
@font-face {
  font-family: "PlexMono"; src: url("/static/fonts/xcharter-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
  unicode-range: U+0391-03A9, U+03B1-03C9;
}
@font-face {
  font-family: "PlexMono"; src: url("/static/fonts/xcharter-bold.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
  unicode-range: U+0391-03A9, U+03B1-03C9;
}

:root {
  --bg:        #eef1f5;   /* cool ground — settled against rendered specimens */
  --ink:       #1b1e24;   /* blue-black, never pure #000 */
  --ink-soft:  #565d6b;   /* dates, metadata, secondary prose */
  --ink-faint: #89909e;   /* labels, hairlines, tertiary */
  --rule:      #dbe0e8;
  --rule-firm: #c2c9d4;
  --box-bg:    #e6eaf1;   /* methodology box, code, table surfaces */
  --accent:    #3b5ba5;   /* steel blue — links and focus only */
  --accent-dk: #2e4880;

  /* verdicts — desaturated enough to print, distinct enough to scan */
  --keep: #39604a;
  --reject: #8b3a2b;
  --cond: #5c6270;

  --measure: 68ch;        /* inside the 62–72ch band */
  --serif: "XCharter", Charter, "Bitstream Charter", Georgia, "Times New Roman", serif;
  --mono:  "PlexMono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
/* Root at 112.5% of the reader's default (18px at the usual 16px): every rem
   size below (subtitle, labels, dates, footer) scales with it, and a reader
   who raises their browser's default text size still gets a larger site. */
html { -webkit-text-size-adjust: 100%; font-size: 112.5%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.58;
  font-feature-settings: "pnum" 1, "kern" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
/* Desktop is the design target. Mobile narrows the column but never trades
   away table legibility — wide tables scroll inside their own container. */
@media (max-width: 640px) { body { font-size: 19px; line-height: 1.55; } }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 4.5rem 1.5rem 3rem; }
.wrap.index-wrap { max-width: 78ch; }
@media (max-width: 640px) { .wrap { padding: 2.75rem 1.25rem 2.25rem; } }

a { color: var(--accent); text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
a:hover { color: var(--accent-dk); border-bottom-color: currentColor; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-bottom-color: transparent; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5rem .8rem;
                   border: 1px solid var(--rule-firm); z-index: 10; }

/* ---------- masthead ---------- */
.masthead { margin-bottom: 2.5rem; }
.site-title { font-size: 1.65rem; font-weight: 700; letter-spacing: -.015em; margin: 0; }
.site-title a { color: var(--ink); border: 0; }
/* The line, then its longer gloss on its own line beneath. Full column width,
   so the line fits on one line at desktop width; balanced when it does wrap,
   and the gloss never ends on a one-word line. */
.subtitle { margin: .6rem 0 0; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.45; text-wrap: balance; }
.subtitle .contract { display: block; margin-top: .35rem; text-wrap: pretty; }

/* ---------- index ---------- */
.notes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule-firm); }
.notes-lede {
  margin: 0 0 .3rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule-firm);
  font-family: var(--mono); font-size: .66rem; letter-spacing: .11em;
  text-transform: uppercase; color: var(--ink-faint);
}
/* Date gutter, then one flexible column: question on top, answer beneath.
   No verdict column — the answer clause states the verdict in words. */
.note {
  display: grid; grid-template-columns: 6.6em 1fr;
  column-gap: 1rem; row-gap: .3rem; align-items: baseline;
  padding: .85rem 0; border-bottom: 1px solid var(--rule);
}
.note:last-child { border-bottom: 0; }
.note .row-date {
  grid-column: 1; grid-row: 1; font-family: var(--mono); font-size: .8rem;
  color: var(--ink-soft); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
}
.note .row-q { grid-column: 2; grid-row: 1; min-width: 0; line-height: 1.38; color: var(--ink); border: 0; }
.note .row-q:hover { color: var(--accent); }
.note .row-answer {
  grid-column: 2; grid-row: 2; font-size: .88rem; line-height: 1.45;
  color: var(--ink-soft); font-variant-numeric: lining-nums;
}
@media (max-width: 480px) {
  .note { display: block; padding: .95rem 0; }
  .note .row-date { display: block; margin-bottom: .15rem; }
  .note .row-q { display: block; }
  .note .row-answer { display: block; margin-top: .2rem; }
}

/* ---------- verdict chip (memo pages only) ---------- */
.verdict {
  font-family: var(--mono); font-size: .64rem; font-weight: 500; letter-spacing: .1em;
  text-transform: uppercase; white-space: nowrap; padding: .16em .5em;
  border: 1px solid currentColor; border-radius: 2px; line-height: 1; display: inline-block;
}
.verdict-keep { color: var(--keep); }
.verdict-reject { color: var(--reject); }
.verdict-conditional { color: var(--cond); }

/* ---------- memo ---------- */
.memo-header { margin-bottom: 2rem; }
.memo-title {
  font-size: 1.85rem; font-weight: 700; line-height: 1.22; letter-spacing: -.015em;
  margin: 0 0 .9rem; text-wrap: balance;
}
@media (max-width: 640px) { .memo-title { font-size: 1.5rem; } }
.memo-meta {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: .76rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums lining-nums;
}
.memo-meta .sep { color: var(--ink-faint); }
.memo-meta a { border: 0; color: var(--ink-soft); }
.memo-meta a:hover { color: var(--accent); }

/* Section headings carry the argument: a short statement (or the one question
   the reader brings), so someone reading only the headings gets the note. */
.prose h2 {
  font-size: 1.12rem; font-weight: 700; line-height: 1.3; color: var(--ink);
  margin: 2.6rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule);
  text-wrap: balance;
}
.prose h3 { font-size: 1rem; font-weight: 700; margin: 1.6rem 0 .5rem; }
.prose p { margin: 0 0 1.1rem; text-wrap: pretty; }
.prose > *:last-child { margin-bottom: 0; }
.prose strong { font-weight: 700; }
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.3rem; }
.prose li { margin: 0 0 .4rem; }
.prose blockquote { margin: 1.4rem 0; padding-left: 1rem; border-left: 2px solid var(--rule-firm); color: var(--ink-soft); }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.2rem 0; }

/* Numbers keep the source artifact's precision and line up in columns. */
.prose code, .num {
  font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; font-size: .9em;
}
.prose code { background: var(--box-bg); padding: .08em .32em; border-radius: 2px; }
.prose pre { background: var(--box-bg); border: 1px solid var(--rule); padding: .9rem 1rem;
             overflow-x: auto; font-size: .82em; line-height: 1.5; }
.prose pre code { background: none; padding: 0; font-size: 1em; }

/* ---------- methodology box: the one depth anchor ---------- */
.methodology {
  margin: 2.2rem 0; padding: 1.1rem 1.3rem; border: 1px solid var(--rule-firm);
  background: var(--box-bg); font-size: .94rem; line-height: 1.56;
}
.methodology::before {
  content: "Methodology"; display: block;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .8rem;
}
.methodology > *:last-child { margin-bottom: 0; }
.methodology h3 { font-size: .96rem; margin-top: 0; }

/* ---------- callout: the one finding worth stopping on ----------
   A pull-quote, not a box: a rule and a slightly larger line, no fill and no
   bold, so it does not compete with the methodology box or with bold in prose. */
.callout {
  margin: 1.8rem 0; padding: .1rem 0 .1rem 1.1rem;
  border-left: 2px solid var(--ink-soft);
  font-size: 1.08em; line-height: 1.5; color: var(--ink);
}
.callout > *:last-child { margin-bottom: 0; }
.callout strong { font-weight: inherit; }

/* ---------- open question: a possible next note, not a promise ---------- */
.question {
  margin: 1.8rem 0; padding: .85rem 1.2rem; border: 1px dashed var(--rule-firm);
  font-style: italic; color: var(--ink);
}
.question::before {
  content: "Open question"; display: block; font-style: normal;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: .5rem;
}
.question > *:last-child { margin-bottom: 0; }

/* MathML, emitted by pandoc at build time. No script, no CDN. */
math { font-family: var(--serif); font-size: 1.02em; }
math[display="block"] { display: block; margin: 1.1rem 0; overflow-x: auto; }

/* ---------- exhibits ----------
   Built by methodology.lua: label and title above, chart or table, note below,
   ruled off from the next one so each reads as a unit. */
.exhibit { margin: 2.4rem 0 2.8rem; padding-top: 1rem; border-top: 1px solid var(--rule-firm); }
/* The section heading already draws a rule; the first exhibit does not add a second. */
.prose h2 + .exhibit { border-top: 0; padding-top: 0; margin-top: 1.4rem; }
.exhibit-head { margin: 0 0 1rem; font-weight: 700; line-height: 1.4; text-wrap: pretty; }
.exhibit-head .fig-no {
  display: block; margin-bottom: .3rem; font-family: var(--mono); font-weight: 500;
  font-size: .66rem; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-faint);
}
.exhibit-note { margin-top: .8rem; font-size: .84rem; line-height: 1.5; color: var(--ink-soft); }
.exhibit-note p { margin: 0; text-wrap: pretty; }
.exhibit .table-wrap { margin: 0; }
.exhibit p:has(> img) { margin: 0; }
.exhibit img, .exhibit svg { display: block; width: 100%; height: auto; margin: 0 auto;
                             border: 1px solid var(--rule-firm); background: #fff; }
/* A tall chart set to a narrower width in the markdown ({width=70%}) stays
   centred, and never shrinks below what a phone can read. */
.exhibit img[style*="width"], .prose p > img[style*="width"] { min-width: min(100%, 22rem); }
/* An uncaptioned image (an appendix chart) is not a figure, so it needs its own fit. */
.prose p > img { display: block; width: 100%; height: auto; margin: 0 auto;
                 border: 1px solid var(--rule-firm); background: #fff; }
.exhibit figcaption {
  margin-top: .7rem; font-size: .86rem; line-height: 1.5; color: var(--ink-soft); text-wrap: pretty;
}
.exhibit figcaption .fig-no { font-family: var(--mono); font-weight: 500; color: var(--ink); letter-spacing: .02em; }

/* Tables carry the numbers, so they get the tightest rules on the page. */
.table-wrap { overflow-x: auto; margin: 1.6rem 0; }
/* A wide table scrolls under its first column, which stays put as the row label. */
.table-wrap th:first-child, .table-wrap td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--bg);
  min-width: 10rem; max-width: 14rem; padding-right: 1rem;
  box-shadow: inset -1px 0 0 var(--rule);
}
.table-wrap + .table-caption { margin: -1rem 0 1.6rem; font-size: .83rem; line-height: 1.5;
                               color: var(--ink-soft); text-wrap: pretty; }
.table-wrap th { white-space: normal; vertical-align: bottom; }
.prose table { border-collapse: collapse; width: 100%; font-size: .87em; }
.prose th {
  font-family: var(--mono); font-size: .74em; font-weight: 500; letter-spacing: .04em;
  color: var(--ink-soft); text-align: right;
  padding: 0 0 .4rem; border-bottom: 1px solid var(--rule-firm); white-space: nowrap;
}
.prose th:first-child, .prose td:first-child { text-align: left; }
.prose td {
  padding: .34rem 0; border-bottom: 1px solid var(--rule); text-align: right;
  font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; white-space: nowrap;
}
.prose td:first-child { font-family: var(--serif); font-variant-numeric: normal; white-space: normal; }
.prose th + th, .prose td + td { padding-left: 1.4rem; }
.prose tr:last-child td { border-bottom: 0; }
.prose table caption { caption-side: bottom; text-align: left; padding-top: .6rem;
                       font-size: .95em; color: var(--ink-soft); line-height: 1.5; text-wrap: pretty; }

/* ---------- footnotes ---------- */
.prose sup a, .footnote-ref { font-family: var(--mono); font-size: .72em; border: 0; padding: 0 .1em; }
.footnotes {
  margin-top: 3.2rem; padding-top: 1.1rem; border-top: 1px solid var(--rule);
  font-size: .86rem; line-height: 1.55; color: var(--ink-soft);
}
.footnotes::before {
  content: "Notes"; display: block; font-family: var(--mono); font-size: .62rem;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .8rem;
}
.footnotes hr { display: none; }
.footnotes ol { margin: 0; padding-left: 1.6rem; }
.footnotes li { margin: 0 0 .6rem; }
.footnotes a { border: 0; }
:target { scroll-margin-top: 1.5rem; }

/* ---------- footers ---------- */
.memo-footer, .site-footer {
  margin-top: 3.2rem; padding-top: 1.1rem; border-top: 1px solid var(--rule-firm);
  font-family: var(--mono); font-size: .73rem; letter-spacing: .03em; color: var(--ink-soft);
}
.site-footer { display: flex; gap: 1.5rem; flex-wrap: wrap; }
/* The note list already ends on the last row's padding; a full 3.2rem on top
   of it leaves the index looking unfinished. */
.index-wrap .site-footer { margin-top: 1.4rem; }
.memo-footer { display: flex; flex-direction: column; gap: .55rem; }
.memo-footer .row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.memo-footer a, .site-footer a { color: var(--ink-soft); border: 0; }
.memo-footer a:hover, .site-footer a:hover { color: var(--accent); }
.errata { color: var(--ink-faint); border-left: 2px solid var(--rule); padding-left: .8rem; line-height: 1.5; }

/* ---------- about ---------- */
/* Small mono label over a rule marks where the bio starts, in the same voice
   as the index lede. */
.section-label {
  margin: 0 0 1.5rem; padding-bottom: .5rem; border-bottom: 1px solid var(--rule-firm);
  font-family: var(--mono); font-size: .8rem; font-weight: 500; letter-spacing: .12em;
  line-height: 1.4; text-transform: uppercase; color: var(--ink-soft);
}
.about-bio p { margin: 0 0 1.15rem; text-wrap: pretty; }
.about-bio p:last-child { margin-bottom: 0; }

/* ---------- print (browser "Print this page"; the shipped PDF is XeLaTeX) ---------- */
@media print {
  :root { --bg: #fff; --ink: #000; --ink-soft: #333; --ink-faint: #555;
          --rule: #bbb; --rule-firm: #888; --box-bg: #f0f2f6; --accent: #000; }
  @page { margin: 18mm 20mm; }
  html, body { background: #fff; color: #000; font-size: 11pt; line-height: 1.5; }
  .wrap { max-width: none; padding: 0; }
  .site-footer, .skip-link, .print-hide { display: none !important; }
  a { color: #000; border: 0 !important; }
  .methodology, .callout, .question, .exhibit, .footnotes, .table-wrap { break-inside: avoid; }
  .prose h2, .memo-title { break-after: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
