/* PDFCarry worked example. Local stylesheet: no external fonts, scripts or images, no inline styles.

   Design reasons, written down:
   - Colour. The sample PDFs carry a teal header rule; that teal is the page's structural colour.
     The only other colours are the four ledger states (kept, reopened, none, refused), so every
     coloured thing on the page is a state. State is never colour alone: each cell carries its word,
     and "none" is hatched as well.
   - Type. A sans (Bahnschrift, the DIN-style face shipped with Windows, where PDFCarry runs) for
     everything we say. A serif (Palatino) only for words quoted from the PDFs themselves, so a reader
     can tell document text from our explanation. Mono for hashes and recorded values.
   - Layout. An editorial opening: title and deck on the left, standfirst on the right, then the
     page pair, the scope bar and the key at full width. The numbered walkthrough follows beside a
     sticky section list. The numbers mark a real sequence.
   - Motion. None beyond hover and focus. An evidence page should hold still. */

:root {
  --paper: #FAFAF7;
  --panel: #FFFFFF;
  --ink: #142129;
  --ink-soft: #3D4B52;
  --rule: #335254;
  --rule-light: #C9D3D3;
  --kept-bg: #DCEFE6;
  --kept-ink: #124B3B;
  --reopen-bg: #F7E4C3;
  --reopen-ink: #5F3704;
  --none-bg: #E7E9EB;
  --none-ink: #3A434B;
  --refused-bg: #F4DBD6;
  --refused-ink: #6B2114;
  --sans: Bahnschrift, "Segoe UI Variable Text", "Segoe UI", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "Iowan Old Style", "URW Palladio L", Georgia, serif;
  --mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --measure: 66ch;
  --hatch: repeating-linear-gradient(135deg, transparent 0 6px, rgba(58, 67, 75, 0.14) 6px 7px);
}

* { box-sizing: border-box; }

html { background: var(--paper); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.55;
  text-wrap: pretty;
}

h1, h2, h3 { font-weight: 600; line-height: 1.15; text-wrap: balance; }
h2 {
  font-size: 1.55rem;
  margin: 3.25rem 0 0.75rem;
  padding-top: 0.9rem;
  border-top: 3px solid var(--rule);
  max-width: 32ch;
}
h3 { font-size: 1.15rem; margin: 1.9rem 0 0.4rem; }

p, ul, ol, dl { max-width: var(--measure); }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin-bottom: 0.4rem; }
b, strong { font-weight: 600; }

/* Words quoted from the PDFs are set in the serif. */
q, .doc { font-family: var(--serif); }
q { quotes: "\201C" "\201D"; }

a { color: var(--rule); text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { text-decoration-thickness: 2px; }

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

code, kbd, samp {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--panel);
  border: 1px solid var(--rule-light);
  padding: 0.05em 0.3em;
  border-radius: 2px;
  overflow-wrap: anywhere;
}

.skip {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--ink);
  color: #fff;
  padding: 0.5rem 0.8rem;
  z-index: 10;
}
.skip:focus { top: 0.5rem; }

/* Top bar: what this is, in one line, before anything else. */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  align-items: baseline;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--rule-light);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.topbar strong { color: var(--ink); }
.topbar .hide-print { margin-left: auto; }

/* Opening: the demonstration, full width. */

.opening {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 0;
}
.opening-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 3rem;
  margin: 0 0 1.75rem;
}
.opening h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.1rem);
  line-height: 1.04;
  letter-spacing: -0.018em;
  margin: 0;
}
.deck {
  font-size: clamp(1.05rem, 1.4vw, 1.2rem);
  line-height: 1.35;
  color: var(--ink-soft);
  margin: 0.6rem 0 0;
  max-width: 48ch;
}
.lede {
  font-size: 1.0625rem;
  line-height: 1.5;
  max-width: 52ch;
  margin: 0;
  padding-top: 0.35rem;
  border-top: 3px solid var(--rule);
}

.pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem 2rem;
  margin: 0 0 0.75rem;
}
.pair figure { margin: 0; }
/* The crop shows the upper left of a 714 x 1011 preview, from 18 px below the top edge to 618 px,
   520 px wide: header rule, headings and the paragraph block, with the page's empty right margin
   left out so the text reads larger. 714 / 520 = 137.31%; 18 / 520 = 3.46%. The PNG files are untouched. */
.crop {
  aspect-ratio: 520 / 600;
  overflow: hidden;
  border: 1px solid var(--rule-light);
  background: #fff;
}
.crop img {
  display: block;
  width: 137.31%;
  max-width: none;
  height: auto;
  margin-top: -3.46%;
}
.pair figcaption {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-top: 0.6rem;
  max-width: 60ch;
}
.pair figcaption strong { display: block; color: var(--ink); }
.cropnote { font-size: 0.88rem; color: var(--ink-soft); margin: 0 0 2rem; }

/* Result: the scope bar. One bar, 58 cells long, in the ledger's own colours.
   The flex-grow values are the three counts from results.json for the guide case
   (revision_scope_states: prior-reviewed 35, reopened 17, imported-baseline 6). */

.result {
  border-top: 3px solid var(--rule);
  padding-top: 1rem;
  margin: 0 0 1.75rem;
}
.result h2 { border: 0; padding: 0; margin: 0 0 0.85rem; font-size: 1.4rem; max-width: none; }
.bar {
  list-style: none;
  display: flex;
  gap: 2px;
  padding: 0;
  margin: 0 0 0.85rem;
  height: 2.75rem;
  max-width: 900px;
}
.bar li {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-width: 2.4rem;
  font-weight: 600;
  border: 1px solid;
}
.bar .kept { flex-grow: 35; background: var(--kept-bg); color: var(--kept-ink); border-color: var(--kept-ink); }
.bar .reopened { flex-grow: 17; background: var(--reopen-bg); color: var(--reopen-ink); border-color: var(--reopen-ink); }
.bar .none { flex-grow: 6; background: var(--none-bg); background-image: var(--hatch); color: var(--none-ink); border-color: var(--none-ink); }

.legend {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.5rem 1.5rem;
  font-size: 0.92rem;
  line-height: 1.4;
  max-width: 900px;
}
.legend li { margin: 0; display: grid; grid-template-columns: 1.1rem 1fr; gap: 0.5rem; align-items: start; }
.legend .swatch {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
  border: 1px solid var(--rule-light);
}
.legend .swatch.kept { background: var(--kept-bg); border-color: var(--kept-ink); }
.legend .swatch.reopened { background: var(--reopen-bg); border-color: var(--reopen-ink); }
.legend .swatch.none { background: var(--none-bg); background-image: var(--hatch); border-color: var(--none-ink); }
.legend .swatch.refused { background: var(--refused-bg); border-color: var(--refused-ink); }
.legend.inline { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; }
.legend.inline li { display: flex; align-items: center; }
.legend.inline .swatch { margin-top: 0; }

.key {
  font-size: 0.95rem;
  max-width: 72ch;
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border: 1px solid var(--rule-light);
}

/* The pointer to the second case borrows the refused state's ink. */
.pointer {
  border-left: 3px solid var(--refused-ink);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 0 0 2rem;
  max-width: var(--measure);
}

.status {
  border: 1px solid var(--rule);
  background: var(--panel);
  padding: 0.9rem 1.1rem;
  font-size: 0.93rem;
  line-height: 1.45;
  max-width: 78ch;
  margin: 0 0 1rem;
}
.status p { margin: 0 0 0.5rem; max-width: none; }
.status p:last-child { margin: 0; }

/* Walkthrough frame: sticky section list beside the numbered steps. */

.frame {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 3rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.rail {
  align-self: start;
  border-left: 3px solid var(--rule);
  padding-left: 1rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}
.rail ol {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1.5rem;
  counter-reset: step;
}
.rail details { border: 0; background: none; padding: 0; margin: 0; max-width: none; }
.rail summary { font-weight: 600; padding: 0.75rem 0; }
.rail details[open] summary { border-bottom: 0; margin-bottom: 0.2rem; }
.rail li { margin: 0 0 0.45rem; break-inside: avoid; }
.rail a { color: var(--ink); text-decoration: none; }
.rail a:hover, .rail a:focus-visible { text-decoration: underline; }
.rail .step::before {
  content: counter(step) ". ";
  counter-increment: step;
  color: var(--ink-soft);
}

main { min-width: 0; }
main > section:first-child h2 { margin-top: 0; }

/* Ledger: a real table, one row per item, one cell per scope. Item text is the document's own words. */

.ledger {
  border-collapse: collapse;
  width: 100%;
  max-width: 900px;
  font-size: 0.92rem;
  line-height: 1.3;
  margin: 1rem 0 0.5rem;
  background: var(--panel);
  border: 1px solid var(--rule);
}
.ledger caption {
  text-align: left;
  caption-side: top;
  font-weight: 600;
  padding: 0 0 0.6rem;
}
.ledger th, .ledger td {
  border: 1px solid var(--rule-light);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.ledger thead th {
  background: var(--paper);
  font-weight: 600;
  border-bottom: 2px solid var(--rule);
}
.ledger tbody th {
  font-family: var(--serif);
  font-weight: normal;
  font-size: 0.98rem;
  width: 52%;
}
.ledger tbody th small {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.ledger .group th {
  background: var(--paper);
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  border-top: 2px solid var(--rule);
  width: auto;
}
.ledger .group.refused th { background: var(--refused-bg); color: var(--refused-ink); }
.ledger td.state { text-align: center; font-weight: 600; width: 12%; white-space: nowrap; }
.ledger td.kept { background: var(--kept-bg); color: var(--kept-ink); }
.ledger td.reopened { background: var(--reopen-bg); color: var(--reopen-ink); }
.ledger td.none { background: var(--none-bg); background-image: var(--hatch); color: var(--none-ink); }
.ledger td.blank { color: var(--ink-soft); text-align: center; }

/* Facts: definition list as a compact grid. */

.facts {
  display: grid;
  grid-template-columns: minmax(10rem, 16rem) 1fr;
  gap: 0;
  max-width: 900px;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
  border-top: 1px solid var(--rule);
}
.facts dt, .facts dd {
  margin: 0;
  padding: 0.5rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid var(--rule-light);
}
.facts dt { font-weight: 600; }
.facts dd code { font-size: 0.8em; }

/* Page previews. */

.pages {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  max-width: 900px;
  margin: 1rem 0 1.5rem;
}
.pages figure { margin: 0; }
.pages img, figure > img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule-light);
  background: #fff;
}
.pages figcaption, figure > figcaption {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  line-height: 1.4;
}
figure { margin: 1.5rem 0; max-width: 900px; }
figure.single { max-width: 440px; }

.note {
  border-left: 3px solid var(--reopen-ink);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1.5rem 0;
  max-width: var(--measure);
}
.note.refusal { border-left-color: var(--refused-ink); }
.note p:last-child { margin-bottom: 0; }

details {
  border: 1px solid var(--rule-light);
  background: var(--panel);
  padding: 0.6rem 1rem;
  margin: 1rem 0 1.5rem;
  max-width: 900px;
}
/* Summaries are the page's only tap controls: padded to at least 44px tall. */
summary { font-weight: 600; cursor: pointer; padding: 0.65rem 0; }
details[open] summary { border-bottom: 1px solid var(--rule-light); margin-bottom: 0.6rem; }

.files, .checks {
  border-collapse: collapse;
  width: 100%;
  max-width: 900px;
  font-size: 0.9rem;
  margin: 1rem 0 1.5rem;
}
.files th, .files td, .checks th, .checks td {
  border-bottom: 1px solid var(--rule-light);
  padding: 0.45rem 0.6rem 0.45rem 0;
  text-align: left;
  vertical-align: top;
}
.files thead th, .checks thead th { border-bottom: 2px solid var(--rule); }
.files code { font-size: 0.72rem; display: block; margin-top: 0.2rem; background: none; border: 0; padding: 0; }

footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 3px solid var(--rule);
  font-size: 0.92rem;
  color: var(--ink-soft);
}
footer p { max-width: 78ch; }

@media (min-width: 600px) {
  .pair { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 900px) {
  .opening-top {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: end;
    margin-bottom: 2.25rem;
  }
  .frame {
    grid-template-columns: 13rem minmax(0, 1fr);
    padding-top: 2.5rem;
  }
  .rail {
    position: sticky;
    top: 1.5rem;
    margin-bottom: 0;
  }
  .rail ol { columns: 1; }
  .rail summary { display: none; }
}

@media (max-width: 600px) {
  body { font-size: 1rem; }
  .opening { padding-top: 1.5rem; }
  .pair { gap: 1rem; }
  .bar { height: 2.4rem; }
  .ledger { font-size: 0.82rem; }
  .ledger th, .ledger td { padding: 0.35rem 0.4rem; }
  .ledger tbody th { width: auto; }
  .ledger td.state { white-space: normal; }
  .facts { grid-template-columns: 1fr; }
  .facts dt { border-bottom: 0; padding-bottom: 0; }
  .topbar .hide-print { margin-left: 0; }
}

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

@media print {
  html { background: #fff; }
  body { font-size: 10.5pt; line-height: 1.45; color: #000; }
  .skip, .rail, .topbar .hide-print { display: none; }
  .opening, .frame { display: block; padding: 0; max-width: none; }
  .opening-top { display: block; }
  .opening h1 { font-size: 22pt; }
  .lede { border-top: 0; padding-top: 0; margin-top: 0.5rem; }
  h2 { font-size: 15pt; margin-top: 1.6rem; page-break-after: avoid; break-after: avoid; }
  h3 { page-break-after: avoid; break-after: avoid; }
  .pair { display: flex; gap: 1rem; }
  .pair figure { flex: 1 1 0; }
  .pair, .pages, figure, .ledger, .facts, details, .checks, .files, .result, .status { page-break-inside: avoid; break-inside: avoid; }
  .pages img { max-height: 32vh; width: auto; margin: 0 auto; }
  .bar { height: 2rem; }
  details { border: 0; padding: 0; }
  summary { list-style: none; }
  a { color: #000; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #333; }
  .bar li, .legend .swatch, .ledger td.kept, .ledger td.reopened, .ledger td.none, .ledger .group.refused th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .status, .key { border: 1px solid #000; }
}
