/* Workpapers Meet White Papers. Pro-style tokens and type scale.
   One deliberate change: --accent is tick-mark red, because auditors mark
   verified figures in red pencil. Red is used for ticks and W/P references only. */
:root {
  --font-head: 'Clash Grotesk', 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Sentient', Georgia, 'Times New Roman', serif;
  --font-mono: ui-monospace, 'Cascadia Code', Consolas, monospace;

  --ink: #16181d;   --muted: #5b616e;  --paper: #f6f4ef;
  --card: #ffffff;  --line: #e3e0d8;   --accent: #b3261e;  --on-accent: #ffffff;
  --chart: #3f4552;
  --grid: color-mix(in srgb, var(--line) 70%, transparent);

  --radius-panel: 14px; --radius-card: 10px; --radius-btn: 8px; --radius-tag: 4px;
  --space: 8px;
  --measure: 64ch;
  --wrap: 1080px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #ecebe7; --muted: #a3a8b3; --paper: #121418;
    --card: #1b1e24; --line: #2b2f37; --accent: #ff8a80; --on-accent: #1a0d0c;
    --chart: #b9bdc6;
    --grid: color-mix(in srgb, var(--line) 45%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #ecebe7; --muted: #a3a8b3; --paper: #121418;
  --card: #1b1e24; --line: #2b2f37; --accent: #ff8a80; --on-accent: #1a0d0c;
  --chart: #b9bdc6;
  --grid: color-mix(in srgb, var(--line) 45%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  /* Faint grid paper, like a ruled workpaper. */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font: 400 17px/1.65 var(--font-body);
  overflow-wrap: break-word;
}
a { color: inherit; text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; top: 8px; }
.skip:focus { left: 16px; background: var(--card); padding: 8px 16px; z-index: 60; }

/* Masthead */
.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.masthead-row { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.brand { font: 600 16px/1.2 var(--font-head); letter-spacing: -0.01em; text-decoration: none; margin-right: auto; }
.masthead nav a { font: 500 15px var(--font-head); text-decoration: none; color: var(--muted); }
.masthead nav a[aria-current="page"], .masthead nav a:hover { color: var(--ink); }
.theme-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: var(--radius-btn);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.draft-banner { background: var(--card); border-bottom: 1px solid var(--accent); color: var(--ink); font: 500 14px/1.4 var(--font-head); padding: 8px 0; }

/* Type */
main { padding-bottom: 56px; }
.wp-head { padding: 48px 0 8px; }
.eyebrow { font: 600 13px/1.3 var(--font-head); text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin: 0 0 16px; }
.eyebrow .sep { color: var(--muted); margin: 0 4px; }
h1 { font: 600 clamp(34px, 6vw, 52px)/1.05 var(--font-head); letter-spacing: -0.02em; max-width: 15ch; margin: 0 0 16px; }
h2 { font: 600 clamp(24px, 3.5vw, 30px)/1.15 var(--font-head); letter-spacing: -0.01em; margin: 0 0 16px; }
h3 { font: 600 18px/1.3 var(--font-head); letter-spacing: -0.01em; margin: 24px 0 8px; }
p { margin: 0 0 16px; max-width: var(--measure); }
.lede { font-size: 19px; line-height: 1.6; color: var(--muted); }
.section-intro { color: var(--muted); }
.count { font-family: var(--font-head); font-weight: 600; color: var(--ink); }
.wp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.byline { color: var(--muted); }

/* Sections, like the tabbed parts of one workpaper */
.wp-section { border-top: 1px solid var(--line); margin-top: 40px; padding-top: 24px; }

/* Tags */
.tier { display: inline-block; font: 600 11px/1.6 var(--font-mono); padding: 1px 8px; border: 1px solid var(--muted); border-radius: var(--radius-tag); color: var(--muted); white-space: nowrap; background: var(--card); }
.tier-paper { border-color: var(--accent); color: var(--accent); }

/* Ticks */
.tick {
  display: inline-flex; align-items: center; gap: 2px; vertical-align: baseline;
  min-height: 24px; min-width: 24px; padding: 0 4px; margin: 0;
  border: 0; border-radius: var(--radius-tag); background: transparent;
  color: var(--accent); font: 600 11px/1 var(--font-mono); cursor: pointer;
  position: relative; top: 2px;
}
.tick-glyph { width: 16px; height: 16px; flex: none; }
button.tick:hover, button.tick[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tick-static { cursor: default; top: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 24px 0 0; padding: 0; font-size: 14px; color: var(--muted); }
.legend div { display: flex; align-items: center; gap: 4px; }
.legend dt, .legend dd { margin: 0; }
.workpaper > .legend { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 32px; }

/* Popover */
.pop {
  position: absolute; z-index: 50; width: min(380px, calc(100vw - 16px));
  background: var(--card); color: var(--ink); border: 1px solid var(--line);
  border-top: 2px solid var(--accent); border-radius: var(--radius-card);
  padding: 16px; box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 14%, transparent); font-size: 15px; line-height: 1.5;
}
.pop[hidden] { display: none; }
.pop-kind { font: 600 12px/1.3 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 8px; }
.pop-quote { margin: 0 0 8px; font-style: italic; max-height: 40vh; overflow: auto; white-space: pre-line; }
.pop-cite { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.pop-link { font: 500 14px var(--font-head); }
.pop-close {
  display: block; margin: 12px 0 0 auto; font: 500 14px var(--font-head);
  background: transparent; color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--radius-btn); padding: 4px 12px; min-height: 32px; cursor: pointer;
}
@media (prefers-reduced-motion: no-preference) {
  .pop:not([hidden]) { animation: pop-in 160ms ease-out; }
  @keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}

/* Source list */
.source-list { margin: 0; display: grid; gap: 8px; max-width: var(--measure); }
.source-list div { display: grid; grid-template-columns: 1fr; gap: 0; }
.source-list dt { font: 600 13px/1.4 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.source-list dd { margin: 0 0 8px; }
@media (min-width: 720px) {
  .source-list div { grid-template-columns: 12ch 1fr; gap: 16px; }
  .source-list dt { padding-top: 4px; }
}

/* John's post */
figure { margin: 0; }
.post blockquote, .pull blockquote {
  margin: 0; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: 24px; max-width: 72ch;
  overflow-wrap: anywhere;
}
.post blockquote p:last-child, .pull blockquote p { margin-bottom: 0; }
.pull { margin-bottom: 16px; }
.pull blockquote { font-size: 19px; line-height: 1.55; }
figcaption { font-size: 14px; line-height: 1.45; color: var(--muted); margin-top: 8px; }

/* Findings */
table { border-collapse: collapse; width: 100%; }
.findings { margin-top: 8px; }
.findings th { font: 600 13px/1.4 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); text-align: left; padding: 8px 16px 8px 0; border-bottom: 1px solid var(--ink); }
.findings td { vertical-align: top; padding: 16px 16px 16px 0; border-bottom: 1px solid var(--line); width: 50%; overflow-wrap: anywhere; }
.paper-fig + .paper-fig { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.val { margin: 0 0 4px; }
.num { font: 600 26px/1.1 var(--font-head); letter-spacing: -0.02em; }
.unit { font-size: 14px; color: var(--muted); }
.paper-quote { margin: 0; }
.john { font-style: italic; }
@media (max-width: 719px) {
  .findings thead { display: none; }
  .findings tr, .findings td { display: block; width: auto; }
  .findings tr { border-bottom: 1px solid var(--ink); padding: 8px 0 16px; }
  .findings td { border: 0; padding: 8px 0; }
  .findings td::before { content: attr(data-label); display: block; font: 600 12px/1.4 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
}

/* Cross-references */
.xref, .plain { padding-left: 0; list-style: none; margin: 0 0 16px; }
.xref li, .plain li { padding: 4px 0; }

/* What was checked */
.checked {
  margin-top: 48px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-panel); padding: 24px; display: grid; gap: 16px;
}
.checked p { margin: 0; font-size: 16px; }
.checked-h { font: 600 15px/1.3 var(--font-head); letter-spacing: 0; margin: 0 0 4px; }
@media (min-width: 720px) { .checked { grid-template-columns: 1fr 1fr; gap: 32px; } }

/* Lead schedule */
.charts { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) {
  .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-wide { grid-column: 1 / -1; }
}
.chart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px 16px 8px; min-width: 0; }
.chart-title { font: 600 15px/1.3 var(--font-head); color: var(--ink); margin: 0 0 12px; }
.chart-note { font-size: 14px; line-height: 1.5; color: var(--muted); margin: 8px 0 4px; }
.bars { list-style: none; margin: 0; padding: 0; }
.bar-row, .dot-row, .dot-axis {
  /* Fixed px columns so rows and the axis line up whatever their font size. */
  display: grid; grid-template-columns: minmax(0, 112px) minmax(0, 1fr) 32px;
  align-items: center; gap: 12px; padding: 4px 0;
}
.dot-row, .dot-axis { grid-template-columns: minmax(0, 128px) minmax(0, 1fr); }
.bar-label { font-size: 14px; line-height: 1.3; }
.bar-value { font: 600 14px var(--font-head); font-variant-numeric: tabular-nums; text-align: right; }
.bar, .dots { display: block; overflow: visible; }
.bar-fill { fill: var(--chart); }
.bar-hit, .dot-hit { fill: transparent; }
.track { stroke: var(--line); stroke-width: 1; }
.dot { fill: var(--chart); stroke: var(--card); stroke-width: 2; }
.dots a:hover .dot, .dots a:focus .dot { fill: var(--accent); }
.dot-axis { font: 500 12px var(--font-head); color: var(--muted); padding-top: 0; }
.axis-ends { display: flex; justify-content: space-between; }
.table-view { margin: 8px 0; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--muted); font: 500 13px var(--font-head); padding: 4px 0; }
.table-view table { margin-top: 8px; }
.table-view th, .table-view td { text-align: left; padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); }
.table-view th { font: 600 12px var(--font-head); color: var(--muted); }

/* Workpaper index */
.wp-index th, .wp-index td { text-align: left; vertical-align: top; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); }
.wp-index thead th { font: 600 13px/1.4 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid var(--ink); }
.wp-ref { font: 600 18px var(--font-head); color: var(--accent); text-decoration: none; white-space: nowrap; }
.wp-ref:hover { text-decoration: underline; }
.wp-index td:nth-child(2) { white-space: nowrap; }
@media (max-width: 719px) {
  .wp-index thead { display: none; }
  .wp-index tr, .wp-index th, .wp-index td { display: block; }
  .wp-index tr { border-bottom: 1px solid var(--ink); padding: 8px 0 12px; }
  .wp-index th, .wp-index td { border: 0; padding: 4px 0; }
  .wp-index td::before { content: attr(data-label); display: block; font: 600 12px/1.4 var(--font-head); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
}

/* Exhibits */
.exhibit-block { margin-top: 32px; }
.exhibit-block + .exhibit-block, .not-tested + .exhibit-block { margin-top: 40px; }
.exhibit-ref { font: 600 12px/1.3 var(--font-head); text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin: 0 0 4px; }
.exhibit-block > h3 { margin-top: 0; font-size: 20px; }

/* A block's night */
.tl { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px; }
@media (min-width: 720px) { .tl { padding: 24px; } }
.tl-controls { margin: 0 0 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.tl-controls[hidden] { display: none; }
.tl-label { display: block; font: 600 14px/1.3 var(--font-head); margin: 0 0 4px; }
/* The axis is inset by half the 20px thumb so marks sit under the thumb centre. */
.tl-axis-wrap { padding: 0 10px; }
.tl-axis { display: block; overflow: visible; }
.tl-axis-line { stroke: var(--line); stroke-width: 2; }
.tl-mark line { stroke: var(--muted); stroke-width: 2; }
.tl-mark text { fill: var(--muted); font: 600 12px var(--font-head); }
.tl-mark.is-current line { stroke: var(--ink); stroke-width: 3; }
.tl-mark.is-current text { fill: var(--ink); }
.tl-range { display: block; width: 100%; margin: 4px 0; height: 32px; background: transparent; cursor: pointer; -webkit-appearance: none; appearance: none; }
.tl-range::-webkit-slider-runnable-track { height: 4px; background: var(--line); border-radius: 2px; }
.tl-range::-moz-range-track { height: 4px; background: var(--line); border-radius: 2px; }
.tl-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--ink); border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--ink); }
.tl-range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--ink); box-sizing: border-box; }
.tl-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.tl-ends { display: flex; justify-content: space-between; font: 500 12px var(--font-head); color: var(--muted); }
.tl-now { font: 500 15px/1.4 var(--font-head); margin: 12px 0 0; min-height: 1.4em; }
.tl-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 24px; }
.tl-stage + .tl-stage { border-top: 1px solid var(--line); padding-top: 24px; }
.tl-live .tl-stage:not(.is-current) { display: none; }
.tl-live .tl-stage + .tl-stage { border-top: 0; padding-top: 0; }
.tl-clock { font: 600 14px/1.3 var(--font-head); color: var(--muted); margin: 0 0 4px; }
.tl-stage-h { font: 600 18px/1.3 var(--font-head); letter-spacing: -0.01em; margin: 0 0 8px; }
.tl-body { margin-bottom: 12px; }
.tl-note { font-size: 15px; color: var(--muted); }
.tl-findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.tl-finding { border-left: 2px solid var(--line); padding-left: 12px; }
.tl-show { margin: 0 0 2px; }
.tl-num { font: 600 17px/1.3 var(--font-head); font-variant-numeric: tabular-nums; }
.tl-text { margin: 0; font-size: 15px; line-height: 1.5; color: var(--muted); }
.reading { display: inline-block; font: 600 11px/1.6 var(--font-mono); padding: 0 6px; border: 1px solid var(--muted); border-radius: var(--radius-tag); color: var(--muted); white-space: nowrap; position: relative; top: -1px; }
@media (prefers-reduced-motion: no-preference) {
  .tl-live .tl-stage.is-current { animation: tl-in 200ms ease-out; }
  @keyframes tl-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* 2003 chart */
.ex-chart { padding: 16px; }
.ex-measure { font-size: 14px; line-height: 1.45; color: var(--muted); margin: 0 0 12px; }
.ex-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.ex-bar-label { font-size: 15px; line-height: 1.4; margin: 0 0 4px; }
.ex-bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; }
.ex-bar { display: block; }
.ex-bar-value { font: 600 15px var(--font-head); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-chart .ex-caption { font-size: 15px; line-height: 1.5; color: var(--ink); margin-top: 12px; max-width: var(--measure); }
.ex-note { font-size: 15px; margin: 12px 0 0; }

/* What the paper does not test */
.not-tested { margin-top: 40px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--ink); border-radius: var(--radius-card); padding: 16px 16px 8px 20px; }
.not-tested h3 { margin-top: 0; }
.not-tested ul { margin: 0; padding-left: 20px; max-width: var(--measure); }
.not-tested li { margin: 0 0 8px; }

/* Rules panel */
.rules-panel { list-style: none; margin: 0; padding: 0; }
.rule-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule-item:first-child { border-top: 1px solid var(--line); }
.rule-claim { margin: 0 0 4px; }
.rule-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 14px; color: var(--muted); margin: 0; }
.status { font: 600 11px/1.6 var(--font-mono); padding: 0 6px; border: 1px solid var(--muted); border-radius: var(--radius-tag); white-space: nowrap; }
.status-in-force { border-color: var(--ink); color: var(--ink); }

/* Audit questions */
.audit { margin: 0; padding-left: 24px; max-width: var(--measure); }
.audit > li { margin: 0 0 16px; }
.audit-q { margin: 0 0 4px; }
.audit-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 16px; font-size: 14px; color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--paper); padding: 24px 0 32px; }
.disclaimer, .footer-meta { font-size: 14px; line-height: 1.45; color: var(--muted); margin: 0 0 8px; }

@media (forced-colors: active) {
  .tick { color: LinkText; }
  .bar-fill, .dot { fill: CanvasText; }
}
@media print {
  body { background-image: none; }
  .masthead, .theme-toggle, .table-view, .tl-controls { display: none; }
  .tl-live .tl-stage:not(.is-current) { display: block; }
}
