/* /whitepaper — the published paper.
 *
 * A paper has a contents page after its title, not a navigation rail. The
 * contents scrolls away with everything else, prints, and behaves identically
 * at every width, so there is no collapsed state to design. */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* One measure for the whole site: 760px, matching /check. Prose caps at 68ch
   inside it, so tables and the appendix use the full width while reading stays
   comfortable. */
.shell { max-width: 760px; margin: 0 auto; padding: 0 24px; }
.doc { min-width: 0; padding: 34px 0 0; }

.masthead {
  display: flex; flex-direction: column; gap: 14px;
  padding-bottom: 32px; margin-bottom: 40px; border-bottom: 1px solid var(--line);
}
.masthead h1 {
  margin: 0; font-size: clamp(30px, 5vw, 40px); font-weight: 600;
  letter-spacing: -0.03em; line-height: 1.1; color: var(--fg);
  text-wrap: balance; max-width: 20ch;
}
.masthead .sub { margin: 0; font-size: 17px; color: var(--muted); max-width: 54ch; text-wrap: pretty; }
.masthead .sub a { color: var(--signal); text-decoration: none; border-radius: 3px; }
.masthead .sub a:hover { text-decoration: underline; }
.masthead .sub a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.masthead .stamp {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 6px;
  font-family: var(--mono); font-size: 11.5px;
  font-variant-numeric: tabular-nums; color: var(--faint);
}

.contents {
  max-width: 68ch; margin: 0 0 52px; padding: 14px 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.contents ol { list-style: none; margin: 0; padding: 0; }
.contents a {
  display: grid; grid-template-columns: 2.1rem minmax(0, 1fr); gap: 14px;
  padding: 6px 0; font-size: 15px; color: var(--body);
  text-decoration: none; transition: color 0.12s ease;
}
.contents a .n {
  font-family: var(--mono); font-size: 11.5px; font-variant-numeric: tabular-nums;
  color: var(--faint); text-align: right; padding-top: 3px; transition: color 0.12s ease;
}
.contents a:hover, .contents a:hover .n { color: var(--signal); }
.contents a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 3px; }

/* --- Long-form prose ---------------------------------------------------- */

.prose { max-width: 68ch; }
.prose section { scroll-margin-top: 24px; margin-bottom: 52px; }
.prose h2 {
  display: grid; grid-template-columns: 2.4rem minmax(0, 1fr); align-items: baseline;
  margin: 0 0 18px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  color: var(--fg); text-wrap: balance;
}
.prose h2 .n {
  font-family: var(--mono); font-size: 13px; font-weight: 400;
  font-variant-numeric: tabular-nums; color: var(--faint);
}
/* A page whose sections are not a sequence. The numbered grid above exists so a reader can
   cite "§7.2" in an argument; nothing on the API page is cited that way, and a number there
   would be decoration claiming to be structure. */
.prose.plain h2 { display: block; margin-top: 0; }

.prose h3 { margin: 34px 0 12px; font-size: 16px; font-weight: 600; color: var(--fg); }
.prose p { margin: 0 0 18px; font-size: 16.5px; line-height: 1.7; color: var(--body); text-wrap: pretty; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--fg); font-weight: 600; }
.prose em { font-style: italic; color: var(--fg); }
.prose ul { margin: 0 0 18px; padding-left: 1.15rem; }
.prose li { margin-bottom: 10px; font-size: 16.5px; line-height: 1.65; padding-left: 4px; }
.prose li::marker { color: var(--faint); }
.prose code {
  font-family: var(--mono); font-size: 0.86em; color: var(--fg);
  background: var(--card-2); padding: 1px 5px; border-radius: 4px;
}
.prose a { color: var(--signal); text-decoration: none; border-radius: 3px; }
.prose a:hover { text-decoration: underline; }
.prose a:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* The one typographic flourish: a claim the document is willing to be held to,
   set apart. Never used for a finding. */
.claim {
  margin: 28px 0; padding: 20px 22px; background: var(--card);
  border-radius: var(--r-card); box-shadow: var(--lift);
  font-size: 17.5px; line-height: 1.55; color: var(--fg); text-wrap: pretty;
}

/* --- Tables ------------------------------------------------------------- */

.scroll-x { overflow-x: auto; margin: 0 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 16px 10px 0; vertical-align: baseline; }
th:last-child, td:last-child { padding-right: 0; }
thead th {
  font-size: 12px; font-weight: 500; color: var(--faint);
  padding-bottom: 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody tr + tr td { border-top: 1px solid var(--line); }
td.mono, th.mono { font-family: var(--mono); font-size: 12.5px; }
td.n { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* A bar behind a count is a picture of a statistic about 4,272 files — not a
   statement about any one document. */
.freq { position: relative; min-width: 190px; }
.freq .fbar {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 15px; background: var(--line-strong); border-radius: 2px;
}
.freq .v {
  position: relative; font-family: var(--mono); font-size: 12.5px;
  font-variant-numeric: tabular-nums; padding-left: 8px; color: var(--body);
}

pre {
  margin: 0 0 20px; padding: 18px 20px; background: var(--well);
  border-radius: var(--r-control); overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
  color: var(--body); tab-size: 2;
}
pre .k { color: var(--muted); }
pre .s { color: var(--fg); }

/* --- Inline instrument -------------------------------------------------- */

.instrument { margin: 24px 0 22px; display: flex; flex-direction: column; gap: 9px; }
.instrument .readout {
  height: 16px; margin: 0; font-family: var(--mono); font-size: 11.5px;
  font-variant-numeric: tabular-nums; color: var(--signal);
  opacity: 0; transition: opacity 0.13s ease;
}
.instrument .readout .region { color: var(--faint); }
.instrument:hover .readout, .instrument:focus-within .readout { opacity: 1; }
.instrument .track {
  position: relative; height: 30px; border-radius: 3px; background: var(--well);
  box-shadow: var(--inset-hi); overflow: hidden; cursor: crosshair; outline: none;
  transition: box-shadow 0.18s ease;
}
.instrument .track:hover { box-shadow: inset 0 0 0 1px var(--signal-line), var(--inset-hi); }
.instrument .track:focus-visible {
  box-shadow: var(--inset-hi), 0 0 0 2px var(--paper), 0 0 0 4px var(--signal);
}
.instrument .cursor {
  position: absolute; top: 0; bottom: 0; width: 1px; background: var(--signal);
  opacity: 0; transition: opacity 0.13s ease; pointer-events: none;
}
.instrument:hover .cursor, .instrument:focus-within .cursor { opacity: 1; }

/* The sample in §6.2: a 439,520-byte file whose first signature does not reach
   the end, because a second signature was applied after it. */
.track .w1 { left: 0; width: 14.263%; }
.track .w2 { left: 14.263%; width: 81.753%; }
.track .w3 { left: 96.016%; width: 1.355%; }
.track .w4 { left: 97.371%; width: 2.629%; }

@media (max-width: 560px) {
  .shell { padding: 0 16px; }
  .prose p, .prose li { font-size: 16px; }
}

@media print {
  @media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.progress { display: none !important; }
  .prose section { break-inside: auto; }
  .prose h2, .prose h3 { break-after: avoid; }
  pre, table, .claim { break-inside: avoid; }
}
