/* ============================================================
   Made for One Reader — one stylesheet, served from this site.
   Hand-written. No frameworks, no CDN, no webfonts, no JS.
   Palette lives in :root; dark mode overrides tokens only.

   One vocabulary, used on every page:
     watched  · what we saw          grey   --muted
     measured · something measured   blue   --accent
     mended   · our mistake, mended  green  --mended
     open     · our mistake, open    red    --flag
   ============================================================ */

:root {
  /* --- type roles ------------------------------------------------ */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, "Times New Roman", serif;
  --font-sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  /* --- type scale ------------------------------------------------ */
  --fs-micro: 0.75rem;      /* 12px — status tags, folios, legend    */
  --fs-small: 0.9375rem;    /* 15px — captions, colophon             */
  --fs-body:  clamp(1.0625rem, 1.015rem + 0.22vw, 1.1875rem);  /* 17→19 */
  --fs-lede:  clamp(1.25rem, 1.15rem + 0.48vw, 1.4375rem);     /* 20→23 */
  --fs-h3:    clamp(1.3125rem, 1.19rem + 0.52vw, 1.5rem);      /* 21→24 */
  --fs-h2:    clamp(1.4375rem, 1.33rem + 0.48vw, 1.75rem);     /* 23→28 */
  --fs-h1:    clamp(2rem, 1.66rem + 1.5vw, 2.75rem);           /* 32→44 */

  /* --- leading --------------------------------------------------- */
  --lh-body: 1.68;
  --lh-lede: 1.5;
  --lh-head: 1.14;

  /* --- spacing: 8px base, 32px = one body line ------------------- */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;   --sp-6: 2rem;     --sp-7: 3rem;     --sp-8: 4rem;
  --sp-9: 6rem;

  /* --- measure & grid -------------------------------------------- */
  --measure: 66ch;
  --margin-col: 9.5rem;
  --gutter: clamp(1.25rem, 5vw, 3rem);

  /* --- palette: paper, ink, and three pencils -------------------- */
  --paper:       #F5F4F0;
  --paper-2:     #EBEAE3;   /* tint block: a plate laid on the paper  */
  --plate-page:  #FCFBF8;   /* the sheet drawn on the plate           */
  --ink:         #1A1C21;
  --ink-soft:    #4A4E58;
  --muted:       #63676F;   /* grey pencil — watched, never measured  */
  --rule:        #DAD8D0;
  --rule-strong: #B9B6AC;
  --link-rule:   #8A8880;   /* underlines: 3.2:1 on paper, visible    */
  --accent:      #2F4A7A;   /* blue pencil — measured                 */
  --accent-soft: #E3E8F1;
  --mended:      #2F6B4F;   /* green pencil — our mistake, mended     */
  --flag:        #97291F;   /* red pencil — our mistake, still there  */
  --selection:   #DDE4F0;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #14161A;
    --paper-2:     #1B1E23;
    --plate-page:  #262A31;
    --ink:         #E7E4DC;
    --ink-soft:    #B7B9BF;
    --muted:       #9298A2;
    --rule:        #2C3037;
    --rule-strong: #454A53;
    --link-rule:   #6C727C;
    --accent:      #9CB8E8;
    --accent-soft: #232C3D;
    --mended:      #8CC9A6;
    --flag:        #E4877B;
    --selection:   #2B3652;
  }
}

*, *::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-serif);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); color: var(--ink); }

/* --- links: ink-coloured, but the underline has to be seen ------- */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: max(1px, 0.06em);
  text-underline-offset: 0.18em;
  text-decoration-color: var(--link-rule);
}
a:hover { text-decoration-color: var(--accent); color: var(--accent); }

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

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--paper-2); color: var(--ink);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-sans); font-size: var(--fs-micro);
  border: 1px solid var(--rule-strong);
}
.skip:focus { left: var(--gutter); top: var(--sp-3); z-index: 10; }

/* ============================================================
   Page frame — one column of text, one narrow margin column
   ============================================================ */
.sheet {
  max-width: calc(var(--margin-col) + 2rem + var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.col {
  max-width: var(--measure);
  margin-left: 0;
}
@media (min-width: 56rem) {
  .col { margin-left: calc(var(--margin-col) + 2rem); }
}

/* ============================================================
   Masthead — a nameplate, not a hero.
   Wide, it uses the margin column, so the black rule above it
   does not start 184px to the left of everything under it.
   ============================================================ */
.masthead {
  border-top: 3px solid var(--ink);
  padding-top: var(--sp-3);
  margin-top: var(--sp-4);
}
.nameplate {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
}
@media (min-width: 56rem) {
  .masthead .nameplate,
  .masthead .nav { margin-left: calc(-1 * (var(--margin-col) + 2rem)); }
}
.wordmark {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.nameplate-link {
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.tagline {
  margin: var(--sp-4) 0 var(--sp-3);
  max-width: 60ch;
  font-style: italic;
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-soft);
}
.masthead-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}

/* --- the one navigation, on every page -------------------------- */
.nav { margin: var(--sp-4) 0 var(--sp-3); }
.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.6;
}
.nav a { color: var(--ink-soft); }
.nav [aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 1px;
}

/* ============================================================
   Long-form prose
   ============================================================ */
main { display: block; }

h1 {
  font-size: var(--fs-h1);
  line-height: var(--lh-head);
  letter-spacing: -0.017em;
  font-weight: 600;
  margin: var(--sp-8) 0 var(--sp-5);
  text-wrap: balance;
}
h2 {
  font-size: var(--fs-h2);
  line-height: 1.24;
  letter-spacing: -0.008em;
  font-weight: 600;
  margin: 0 0 var(--sp-4);
}
h3 {
  font-size: var(--fs-h3);
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 var(--sp-3);
}

/* printer's paragraphing: a first-line indent and no blank line —
   one or the other does the job, and half of each does neither. */
.prose p { margin: 0; }
.prose p + p { text-indent: 1.5em; }

.prose p.lede,
.lede {
  font-size: var(--fs-lede);
  line-height: var(--lh-lede);
  color: var(--ink);
  margin: 0 0 var(--sp-6);
  text-wrap: pretty;
}
.prose .lede + p,
.prose .label + p { text-indent: 0; }

section { margin-block: var(--sp-9); }

.label {
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.label::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}

/* ============================================================
   Catalogue record, sitting directly under the title
   ============================================================ */
.field {
  margin: 0 0 var(--sp-7);
  border-top: 1px solid var(--rule-strong);
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  line-height: 1.5;
}
.field > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 0 var(--sp-4);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--rule);
}
.field > div > * { min-width: 0; }
.field dt {
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.field dd { margin: 0; color: var(--ink-soft); }

@media (max-width: 30rem) {
  .field > div { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); }
}

/* ============================================================
   Evidence grade — one component, two forms.
   .status  sits in the margin column beside a section
   .grade   sits inline, inside a catalogue record
   The square trails the words in both, so it is drawn in CSS
   rather than depending on where a span sits in the markup.
   ============================================================ */
.status,
.grade {
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-wrap: balance;
  color: var(--muted);
}
.status { margin: 0; padding: 0.1em 0 0.1em 0.7em; border-left: 3px solid currentColor; }
.status::after,
.grade::after {
  content: "";
  display: inline-block;
  width: 0.5em; height: 0.5em;
  margin-left: 0.5em;
  vertical-align: 0.05em;
  background: currentColor;
}
[data-evidence="watched"]  { color: var(--muted); }
[data-evidence="measured"] { color: var(--accent); }
[data-evidence="mended"]   { color: var(--mended); }
[data-evidence="open"]     { color: var(--flag); }

@media (min-width: 56rem) {
  .status {
    text-align: right;
    padding: 0.35em 0.7em 0.1em 0;
    border-right: 3px solid currentColor;
    border-left: 0;
  }
}

.legend {
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 var(--sp-6);
  max-width: 58ch;
  border-left: 2px solid var(--rule-strong);
  padding-left: var(--sp-4);
}

/* ============================================================
   Specimen figures. Two kinds, and the difference is the point:
     .gauge — a diagram we drew, inline SVG, no request.
              Meaningful strokes stay >= 3:1 (WCAG 1.4.11).
     .plate — a bitmap: interior pages out of our own finished
              books, so the reader can look at the thing the
              diagrams are measuring instead of taking our word.
   ============================================================ */
.specimen {
  margin: var(--sp-7) 0;
  padding: var(--sp-6) var(--sp-5);
  background: var(--paper-2);
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--sp-5);
  align-items: start;
}
.specimen > * { min-width: 0; }
@media (min-width: 40rem) {
  .specimen {
    grid-template-columns: 15rem minmax(0, 1fr);
    column-gap: var(--sp-6);
    padding: var(--sp-6);
  }
  .specimen.wide { grid-template-columns: minmax(0, 1fr); }
}
.gauge {
  display: block;
  width: 100%;
  max-width: 19rem;
  height: auto;
  margin-inline: auto;
}
.gauge.wide { max-width: 30rem; }

/* Bitmap plates. width/height are set on the element too, so the box is
   reserved before the bytes land and nothing below it jumps. */
.plate {
  display: block;
  width: 100%;
  height: auto;
  background: var(--plate-page);
  border: 1px solid var(--rule-strong);
}
/* A contact sheet of a whole book is not legible at column width. The plate
   links to its own full-size file so "count them yourself" is a thing the
   reader can actually do — a plain href, no script, nothing to load. */
a.plate-link { display: block; text-decoration: none; }
a.plate-link:hover .plate { border-color: var(--accent); }

.gz-page   { fill: var(--plate-page); stroke: var(--ink-soft); stroke-width: 1.4; }
.gz-grid   { stroke: var(--rule-strong); stroke-width: 1; }
.gz-band   { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.gz-mark   { stroke: var(--accent); stroke-width: 1.4; }
.gz-face   { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.gz-other  { fill: none; stroke: var(--ink-soft); stroke-width: 1.3; }
.gz-textline { stroke: var(--rule-strong); stroke-width: 2.4; stroke-linecap: round; }
.gz-namebar  { stroke: var(--ink); stroke-width: 2.6; stroke-linecap: round; }
.gz-path   { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.gz-on     { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.6; }
.gz-off    { fill: var(--plate-page); stroke: var(--ink-soft); stroke-width: 1.2; }
.gz-name   { fill: var(--accent); }
.gz-line   { fill: var(--ink-soft); }
.gz-bar    { fill: var(--accent); }
.gz-bar-open { fill: var(--plate-page); stroke: var(--ink); stroke-width: 1.4; }
.gz-axis   { stroke: var(--ink-soft); stroke-width: 1.2; }
.gz-drop   { stroke: var(--ink-soft); stroke-width: 1.2; stroke-dasharray: 3 3; }
.gz-num    { fill: var(--accent); font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.gz-cap    { fill: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
.gz-key    { fill: var(--ink-soft); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; }
/* a 360-unit drawing scales to about 0.8 on a phone: type set for that */
.wide .gz-cap, .wide .gz-key { font-size: 12px; }
.wide .gz-num { font-size: 15px; }

figcaption {
  max-width: 52ch;
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
}
figcaption b { font-weight: 600; color: var(--ink); }

/* ============================================================
   Graded sections and the index of findings
   ============================================================ */
.index { list-style: none; margin: 0; padding: 0; }

.entry,
.graded {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-6) 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}
.entry > *, .graded > * { min-width: 0; }
.entry:last-child, .entry:last-of-type { border-bottom: 1px solid var(--rule); }
.graded { border-top: 0; padding: var(--sp-5) 0 0; }

@media (min-width: 56rem) {
  .entry, .graded {
    grid-template-columns: var(--margin-col) minmax(0, 1fr);
    column-gap: 2rem;
    margin-left: calc(-1 * (var(--margin-col) + 2rem));
  }
}

.entry-title { margin-bottom: var(--sp-3); text-wrap: pretty; }
.entry p { margin: 0 0 var(--sp-4); }
.entry p:last-child { margin-bottom: 0; }

/* ============================================================
   Quoted rules — our own wording, set apart from our prose
   ============================================================ */
blockquote.rule {
  margin: var(--sp-5) 0;
  padding: var(--sp-3) 0 var(--sp-3) var(--sp-4);
  border-left: 3px solid var(--rule-strong);
}
blockquote.rule p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink);
  text-indent: 0;
}
blockquote.rule cite {
  display: block;
  margin-top: var(--sp-2);
  font-family: var(--font-sans);
  font-style: normal;
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ============================================================
   The check — something the reader can do tonight
   ============================================================ */
.prose p.check,
.check {
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
  border-left: 2px solid var(--rule-strong);
  padding-left: var(--sp-4);
  text-indent: 0;
  margin: var(--sp-5) 0 0;
}
.check b {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-1);
}
.num { font-family: var(--font-mono); font-size: 0.94em; letter-spacing: -0.01em; }

/* --- numbered questions and plain step lists -------------------- */
.questions { margin: var(--sp-5) 0 0; padding: 0; list-style: none; counter-reset: q; }
.questions > li {
  counter-increment: q;
  border-top: 1px solid var(--rule);
  padding: var(--sp-4) 0;
}
.questions > li:last-child { border-bottom: 1px solid var(--rule); }
.questions > li::before {
  content: counter(q);
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  color: var(--muted);
  display: block;
  margin-bottom: var(--sp-1);
}
.questions p { margin: 0; }
.questions .q { font-weight: 600; margin-bottom: var(--sp-2); }

.steps { margin: var(--sp-5) 0 0; padding-left: 1.4em; }
.steps li { margin-bottom: var(--sp-3); }
.steps li:last-child { margin-bottom: 0; }

/* --- a plain data table: the dialogue sweep --------------------- */
.tabwrap { overflow-x: auto; margin: var(--sp-5) 0 0; }
table.data {
  border-collapse: collapse;
  width: 100%;
  min-width: 26rem;
  font-family: var(--font-sans);
  font-size: var(--fs-small);
  line-height: 1.5;
}
table.data caption {
  text-align: left;
  font-size: var(--fs-micro);
  letter-spacing: 0.06em;
  color: var(--muted);
  padding-bottom: var(--sp-2);
}
table.data th, table.data td {
  text-align: left;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.data thead th {
  font-size: var(--fs-micro);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule-strong);
}
table.data td.n { font-family: var(--font-mono); white-space: nowrap; }
table.data tr.bad td { color: var(--flag); }
table.data tr.good td.n { color: var(--mended); }

/* ============================================================
   Annotated lists — outbound reading, and the read-next block
   ============================================================ */
.links { list-style: none; margin: var(--sp-5) 0 0; padding: 0; }
.links li {
  border-top: 1px solid var(--rule);
  padding: var(--sp-4) 0;
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
}
.links li:last-child { border-bottom: 1px solid var(--rule); }
.links .t {
  display: block;
  font-size: var(--fs-body);
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: var(--sp-1);
}
.links .t:hover { color: var(--accent); }
.links [aria-current="page"],
.links [aria-current="page"] .t { color: var(--muted); }

.also { margin-block: var(--sp-8); }
.also .links { margin-top: 0; }

/* ============================================================
   Colophon
   ============================================================ */
.colophon {
  margin-top: var(--sp-9);
  padding: var(--sp-6) 0 var(--sp-8);
  border-top: 3px solid var(--ink);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
}
.colophon p { margin: 0 0 var(--sp-4); max-width: 60ch; }
.colophon p:last-child { margin-bottom: 0; }
.colophon .label { margin-bottom: var(--sp-4); }

@media (max-width: 34rem) {
  .prose, .entry, .graded, .check { hyphens: auto; }
  .prose p + p { text-indent: 1.2em; }
}

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

/* people print field notes */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .skip, .nav, .also { display: none; }
  a { color: #000; }
  .col { margin-left: 0; }
  .entry, .graded {
    break-inside: avoid;
    margin-left: 0;
    grid-template-columns: 1fr;
  }
  .status { border-left: 3px solid currentColor; border-right: 0;
            text-align: left; padding: 0.1em 0 0.1em 0.7em; }
  .specimen, figure, blockquote, .questions > li, table.data { break-inside: avoid; }
  .specimen { background: none; border-color: #999; }
}
