/* Label & Literature — the offprint.
   One stylesheet. No framework, no build step, no external request.
   System font stacks only: adding a webfont would be blocked by the
   Content-Security-Policy in /_headers before anyone noticed the taste.

   Layout note for later pages: <main class="sheet"> is a two-column grid
   at >=1100px. Children default to the reading column. A child carrying
   .margin (a source stamp, a date, a figure number) is pulled into the
   apparatus column to its left; place it in the source IMMEDIATELY
   BEFORE the paragraph it annotates and the two share a grid row. Below
   1100px the grid collapses and the note reads inline, ruled off. */

:root {
  /* surfaces */
  --paper:      #FCFCFA;
  --field:      #F1F0EA;
  --card:       #FFFFFF;

  /* ink */
  --ink:        #191A17;
  --ink-soft:   #5B5D56;
  --rule:       #D7D5CB;

  /* exactly two accents */
  --accent:     #23406B;   /* links, the ampersand, rung marks, diagrams */
  --alert:      #7A2E2E;   /* the urgent-care band and nothing else */

  --font-body:  "Iowan Old Style", "Palatino Linotype", Palatino, Charter,
                Georgia, "Times New Roman", serif;
  --font-ui:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                monospace;

  --size-body:    1.0625rem;
  --size-margin:  0.8125rem;
  --leading-body: 1.62;
  --measure:      33em;
  --margin-col:   13em;

  --s1: .375rem; --s2: .75rem; --s3: 1.5rem; --s4: 3rem; --s5: 5rem;
  --radius: 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #131412;
    --field:    #1B1C19;
    --card:     #1B1C19;
    --ink:      #E9E7DE;
    --ink-soft: #A3A59C;
    --rule:     #33352F;
    --accent:   #8FB2DE;
    --alert:    #E09A93;
  }
}

/* ---------------------------------------------------------------- base */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--leading-body);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

p, ul, ol, dl, table, figure, blockquote { margin: 0 0 var(--s3); }
li { margin-bottom: var(--s1); }
ul, ol { padding-left: 1.3em; }

h1, h2, h3, h4 {
  font-family: var(--font-body);
  font-weight: 600;
  line-height: 1.22;
  margin: 0 0 var(--s2);
  text-wrap: balance;
}
h1 { font-size: 1.85rem; letter-spacing: -0.005em; }
h2 {
  font-size: 1.3rem;
  margin-top: var(--s4);
  padding-top: var(--s2);
  border-top: 1px solid var(--rule);
}
h3 { font-size: 1.0625rem; margin-top: var(--s3); }
h4 {
  font-family: var(--font-ui);
  font-size: .8125rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: var(--s3);
}

a { color: var(--accent); text-underline-offset: .16em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

strong { font-weight: 600; }
abbr[title] { text-decoration: none; border-bottom: 1px dotted var(--rule); }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s4) 0; }

code, kbd, samp { font-family: var(--font-mono); font-size: .9em; }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus {
  left: 0;
  z-index: 10;
  display: block;
  padding: var(--s2) var(--s3);
  background: var(--card);
  border: 1px solid var(--ink);
  min-height: 44px;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* -------------------------------------------------------------- sheet */

.sheet {
  max-width: 52em;
  margin: 0 auto;
  padding: 0 var(--s3);
}

@media (min-width: 1100px) {
  .sheet {
    display: grid;
    grid-template-columns: var(--margin-col) minmax(0, var(--measure));
    column-gap: var(--s4);
    max-width: 56em;
  }
  .sheet > * { grid-column: 2; }
  .sheet > .margin { grid-column: 1; }
}

/* An apparatus note. Ruled off when it has to read inline. */
.margin {
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  line-height: 1.42;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: var(--s1);
  margin-bottom: var(--s3);
}
@media (min-width: 1100px) {
  .margin { text-align: right; }
}

/* --------------------------------------------------------- the masthead */

.masthead {
  border-bottom: 1px solid var(--rule);
  padding: var(--s4) 0 var(--s3);
  margin-bottom: var(--s4);
}

.wordmark {
  margin: 0;
  font-size: 1.55rem;
  font-variant-caps: small-caps;
  letter-spacing: .04em;
  line-height: 1.1;
  padding-bottom: var(--s2);
  border-bottom: 1px solid var(--rule);
}
.wordmark a { color: var(--ink); text-decoration: none; }
.wordmark .amp { color: var(--accent); }

.tagline {
  margin: var(--s2) 0 0;
  font-size: .9375rem;
  color: var(--ink-soft);
}

.nav {
  list-style: none;
  margin: var(--s3) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--s3);
  font-family: var(--font-ui);
  font-size: .8125rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.nav li { margin: 0; }
.nav a {
  display: inline-block;
  padding: .6rem 0;
  min-height: 44px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.nav a:hover, .nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ------------------------------------------------------------- footer */

.site-foot {
  margin-top: var(--s5);
  border-top: 1px solid var(--rule);
  padding: var(--s4) 0 var(--s5);
}
.site-foot .ident { font-size: .9375rem; }
.site-foot .nav { text-transform: none; letter-spacing: .02em; }

/* -------------------------------------------------------- the register */

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: .875rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  color: var(--ink-soft);
  padding-bottom: var(--s2);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: var(--s2) var(--s2) var(--s2) 0;
  border-bottom: 1px solid var(--rule);
}
thead th {
  border-bottom: 2px solid var(--ink);
  font-size: .75rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
tbody tr:nth-child(even) { background: var(--field); }
tbody th[scope="row"] { font-weight: 600; color: var(--ink); }

/* The register is the front page, so it gets the full width it needs. */
.register-wrap { grid-column: 1 / -1 !important; }

/* <720px: the table stops being a table and becomes stacked blocks. */
@media (max-width: 719px) {
  .register, .register tbody, .register tr, .register th, .register td {
    display: block;
    width: 100%;
  }
  .register thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .register tr {
    border-top: 2px solid var(--ink);
    padding: var(--s2) 0 var(--s3);
    background: none !important;
  }
  .register th, .register td { border: 0; padding: 0 0 var(--s2); }
  .register th[scope="row"] { font-size: 1rem; padding-bottom: var(--s1); }
  .register td::before {
    content: attr(data-label);
    display: block;
    font-size: .6875rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }
}

/* ------------------------------------------- signature components (6) */

/* 1. the audit line */
.audit-line {
  margin: 0 0 var(--s3);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-ui);
  font-size: .875rem;
  line-height: 1.45;
}
.audit-line div {
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--rule);
}
.audit-line div:last-child { border-bottom: 0; }
.audit-line b {
  display: block;
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 400;
}

/* 2. the label box — the only white card on the site */
.label-box {
  background: var(--card);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--ink);
  padding: var(--s3);
  margin: 0 0 var(--s3);
  font-family: var(--font-ui);
  font-size: .9375rem;
}
.label-box h3 {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 400;
  margin: 0 0 var(--s2);
}
.label-box p:last-child, .label-box dl:last-child { margin-bottom: 0; }

/* 3. the margin source stamp */
.stamp {
  font-family: var(--font-mono);
  font-size: .75rem;
  line-height: 1.4;
  letter-spacing: .01em;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: var(--s1);
  margin-bottom: var(--s3);
}
@media (min-width: 1100px) {
  .sheet > .stamp { grid-column: 1; text-align: right; }
}

/* 4. the in-article evidence table — inherits the table rules above */
.evidence-table td:last-child, .evidence-table th:last-child { padding-right: 0; }
/* The source column carries citation strings like 2021;41(8):932-941,
   one unbreakable run about eighteen characters wide. Three columns of
   that set the table's min-content width past a 320px viewport and push
   the whole page sideways, so this column alone may break inside a
   token. Every other cell, and all prose, still breaks only at spaces,
   and above phone width the rule is off so no column is ever re-sized
   by it. */
@media (max-width: 480px) {
  .evidence-table td:last-child { overflow-wrap: anywhere; }
}

/* 5. the urgent-care band — the only red on the site */
.urgent-band {
  border: 2px solid var(--alert);
  border-left-width: 6px;
  padding: var(--s3);
  margin: var(--s4) 0;
  font-family: var(--font-ui);
  font-size: .9375rem;
}
/* The band's heading takes whichever level the surrounding outline needs
   — h2 where the band follows the h1 directly, h3 inside a section — and
   looks identical either way. */
.urgent-band h2, .urgent-band h3 {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--alert);
  font-weight: 700;
  margin: 0 0 var(--s2);
}
.urgent-band p:last-child { margin-bottom: 0; }

/* 6. the question list — ruled, numbered, made to be screenshotted */
.questions {
  font-family: var(--font-ui);
  font-size: .9375rem;
  list-style: none;
  counter-reset: q;
  padding: 0;
  border-top: 2px solid var(--ink);
}
.questions li {
  counter-increment: q;
  border-bottom: 1px solid var(--rule);
  padding: var(--s2) 0 var(--s2) 2.4em;
  margin: 0;
  position: relative;
}
.questions li::before {
  content: counter(q, decimal-leading-zero);
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--ink-soft);
  top: .95em;
}

/* ------------------------------------------------ supporting classes */

.standfirst {
  font-size: 1.1875rem;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: var(--s3);
}

/* the six-rung certainty ladder — typographic, never colour-coded */
.rung {
  display: inline-flex;
  align-items: baseline;
  gap: .14em;
  vertical-align: baseline;
  margin: 0 .18em;
}
.rung i {
  display: inline-block;
  width: .26em;
  height: .8em;
  background: var(--accent);
}
.rung-none::before {
  content: "\2014";
  color: var(--ink-soft);
  font-family: var(--font-mono);
}

.risk-tiers h3 { margin-top: var(--s3); }

.cost-block {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: var(--s3) 0;
  font-family: var(--font-ui);
  font-size: .9375rem;
}

.figure { margin: var(--s4) 0; }
.figure svg, .figure img { display: block; width: 100%; height: auto; }
.figure img { background: var(--field); }

/* The hero plates are drawn on a cream ground. Against the dark sheet
   that ground is the brightest thing on the page and reads as a lamp
   rather than as a figure, so it is taken down to sit with the text.
   Light mode leaves them exactly as printed. */
@media (prefers-color-scheme: dark) {
  .figure img { filter: brightness(.78) contrast(1.05); }
}

/* Hand-written inline diagrams. The CSP forbids inline styles, so figure
   SVGs carry presentation attributes only and paint with currentColor;
   these two rules are the sole place the ink and accent are chosen, so a
   diagram themes with the page instead of hard-coding a hex. */
.figure svg { color: var(--ink); background: var(--field); padding: var(--s3) 0; }
.figure svg .ac { color: var(--accent); }
.fig-caption {
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  line-height: 1.45;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: var(--s1);
  margin-top: var(--s2);
}

.sources { font-size: .9375rem; }
.sources li { margin-bottom: var(--s2); }

.dates {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .02em;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
  padding-top: var(--s2);
  margin-top: var(--s4);
}

a.term {
  text-decoration: underline dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}

/* the one boxed callout a page is allowed */
.callout {
  background: var(--card);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  padding: var(--s3);
  margin: 0 0 var(--s4);
  font-size: 1.0625rem;
}
.callout p:last-child { margin-bottom: 0; }
.callout cite {
  display: block;
  margin-top: var(--s2);
  font-style: normal;
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  color: var(--ink-soft);
}

/* the findings list on the front page */
.findings { list-style: none; padding: 0; border-top: 2px solid var(--ink); }
.findings li {
  border-bottom: 1px solid var(--rule);
  padding: var(--s2) 0;
  margin: 0;
}
.findings span {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  color: var(--ink-soft);
}

/* the glossary */
.glossary { margin: 0; }
.glossary dt {
  font-weight: 600;
  border-top: 1px solid var(--rule);
  padding-top: var(--s2);
  margin-top: var(--s2);
  scroll-margin-top: var(--s3);
}
.glossary dd {
  margin: var(--s1) 0 var(--s2);
  font-size: 1rem;
}
.index-strip {
  font-family: var(--font-mono);
  font-size: .8125rem;
  letter-spacing: .08em;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: var(--s2) 0;
}

/* ---------------------------------------------------------- the form */

.form-row { margin-bottom: var(--s3); }
.form-row label {
  display: block;
  font-family: var(--font-ui);
  font-size: .8125rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: var(--s1);
}
.form-row .hint {
  font-family: var(--font-ui);
  font-size: var(--size-margin);
  color: var(--ink-soft);
  text-transform: none;
  letter-spacing: 0;
  display: block;
  margin-top: var(--s1);
}
input[type="text"], input[type="email"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
  padding: .55rem .6rem;
  min-height: 44px;
}
textarea { min-height: 11rem; resize: vertical; line-height: 1.5; }
input[type="submit"] {
  font-family: var(--font-ui);
  font-size: .875rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .75rem 0;
  min-height: 44px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
input[type="submit"]:hover { color: var(--accent); border-top-color: var(--accent); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --------------------------------------------------------- print */

@media print {
  :root {
    --paper: #fff; --field: #fff; --card: #fff;
    --ink: #000; --ink-soft: #444; --rule: #bbb;
    --accent: #000; --alert: #000;
  }
  .masthead .nav, .site-foot .nav, .skip { display: none; }
  body { font-size: 11pt; }
  .sheet { display: block; max-width: none; padding: 0; }
  .margin, .stamp { text-align: left; }
  a { color: #000; text-decoration: underline; }
  main a[href^="http"]::after,
  main a[href^="/"]::after {
    content: " <" attr(href) ">";
    font-family: var(--font-mono);
    font-size: 8pt;
    word-break: break-all;
  }
  h2, h3, .urgent-band, .label-box, table { break-inside: avoid; }
  .urgent-band { border: 2pt solid #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
