/*
  Reading pages: learn, proof, rules, terms, privacy. The page head, the contents list, long-form text set to the measure,
  ruled rows, tables that stack on a phone, FAQ rows, definitions, mono for hashes and commands. Tokens only (see qz-scale.css
  for the rest); the few off-scale lengths are named here once.
*/
:root {
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --doc-toc-w: 15rem;
  --doc-num-w: 2.25rem;
  --doc-code-size: 0.875rem;
}
html { scroll-padding-block-start: var(--space-6); -webkit-tap-highlight-color: transparent; }

/* Page head: a label, the one h1, the lead. */
.doc-head { display: grid; gap: var(--space-4); justify-items: start; min-width: 0; }
.doc-head .qz-lead { margin: 0; }
.doc-meta { max-width: var(--measure); color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); overflow-wrap: anywhere; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); padding-block-start: var(--space-2); }

/* Contents: one 44px row per section. Numbers are a CSS counter, shared by the headings below. */
.doc-toc { display: grid; gap: var(--space-2); align-content: start; min-width: 0; }
.doc-toc__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); column-gap: var(--space-6); counter-reset: toc; }
.doc-toc__list a { counter-increment: toc; display: flex; align-items: baseline; gap: var(--space-2); min-height: var(--hit); padding-block: var(--space-2); border-block-end: var(--border-hair) solid var(--color-hairline); color: var(--color-ink); font-size: var(--text-nav-size); line-height: 1.3; text-decoration: none; overflow-wrap: anywhere; transition: color var(--duration-fast) var(--ease-out); }
.doc-toc__list a::before { content: counter(toc, decimal-leading-zero); flex: none; inline-size: var(--doc-num-w); color: var(--color-ink-muted); font-size: var(--text-caption-size); }
@media (hover: hover) and (pointer: fine) { .doc-toc__list a:hover { color: var(--color-accent); } }
@media (min-width: 48rem) { .doc-toc__list { column-gap: var(--space-8); } }

/* Rules, terms, privacy: the contents list beside the text from 64rem. */
.doc-layout { display: grid; gap: var(--space-8); }
@media (min-width: 64rem) {
  .doc-layout { grid-template-columns: var(--doc-toc-w) minmax(0, var(--measure)); justify-content: start; align-items: start; column-gap: var(--space-16); }
  .doc-layout .doc-toc { position: sticky; inset-block-start: var(--space-6); }
  .doc-layout .doc-toc__list { grid-template-columns: minmax(0, 1fr); }
}

/* Long-form text. Sections are numbered by a counter; the measure holds at 66ch. */
.doc-body { display: grid; gap: var(--space-8); min-width: 0; }
main { counter-reset: sec; }
.doc-sec { display: grid; gap: var(--space-4); align-content: start; min-width: 0; counter-increment: sec; }
.doc-body > section { padding-block-start: var(--space-8); border-block-start: var(--border-hair) solid var(--color-hairline); }
.doc-body > section:first-child { padding-block-start: 0; border-block-start: 0; }
:is(.doc-body, .doc-flow) :where(p, ul, ol, dl, figure, details) { max-width: var(--measure); }
:is(.doc-body, .doc-flow) :where(p, li) { text-wrap: pretty; }
.doc-sec > h2 { max-width: var(--size-display-max); }
.doc-sec > h2::before { content: counter(sec, decimal-leading-zero); display: block; margin-block-end: var(--space-2); color: var(--color-ink-muted); font-family: var(--font-body); font-size: var(--text-caption-size); font-weight: 600; letter-spacing: var(--text-caption-tracking); line-height: var(--text-caption-line); }
:is(.doc-body, .doc-flow) h3 { color: var(--color-ink); font-family: var(--font-body); font-size: var(--text-lead-size); font-weight: 600; line-height: var(--text-lead-line); letter-spacing: 0; text-transform: none; padding-block-start: var(--space-2); }
:is(.doc-body, .doc-flow) ul:not([class]) { padding-inline-start: 1.25em; list-style: disc; }
:is(.doc-body, .doc-flow) ul:not([class]) li + li { margin-block-start: var(--space-2); }
:is(.doc-body, .doc-flow) li::marker { color: var(--color-ink-muted); }
:is(.doc-body, .doc-flow) a { overflow-wrap: anywhere; }
.doc-note { color: var(--color-ink-muted); font-size: var(--text-caption-size); line-height: var(--text-caption-line); }

/* The one sentence that carries a section: set larger on a sheet, no stripe. */
.doc-key { padding: var(--space-4) var(--space-6); border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--color-sheet); font-size: var(--text-lead-size); font-weight: 600; line-height: var(--text-lead-line); }

/* Ruled rows, numbered like the CRT rows: a sheet of lines with a counter. */
.doc-rows { display: grid; gap: var(--border-hair); counter-reset: row; overflow: hidden; border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--color-hairline); }
.doc-rows > li { counter-increment: row; display: flex; align-items: baseline; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--color-sheet); }
.doc-rows > li::before { content: counter(row, decimal-leading-zero); flex: none; inline-size: var(--doc-num-w); color: var(--color-ink-muted); font-family: var(--font-display); font-size: var(--text-lead-size); font-weight: var(--font-display-weight); line-height: 1; }
.doc-rows > li > span { min-width: 0; }

/* Tables: a ruled sheet on a wide screen, labelled cards on a phone. */
.doc-table { max-width: none; overflow: hidden; border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-md); background: var(--color-sheet); }
.doc-table table { width: 100%; border-collapse: collapse; text-align: start; }
.doc-table th, .doc-table td { padding: var(--space-2) var(--space-4); text-align: start; vertical-align: middle; overflow-wrap: anywhere; }
.doc-table thead th { border-block-end: var(--border-hair) solid var(--color-hairline); background: var(--color-sunk); color: var(--color-ink-muted); font-size: var(--text-caption-size); font-weight: 600; letter-spacing: var(--text-caption-tracking); line-height: var(--text-caption-line); text-transform: uppercase; }
.doc-table tbody tr + tr > :is(th, td) { border-block-start: var(--border-hair) solid var(--color-hairline); }
.doc-table tbody th { font-weight: 600; }
.doc-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.doc-table td a, .doc-table th a { display: inline-flex; align-items: center; min-height: var(--hit); margin-inline-end: var(--space-4); overflow-wrap: normal; }
.doc-sub { display: block; margin-block-start: var(--space-1); color: var(--color-ink-muted); font-size: var(--text-caption-size); font-weight: 400; line-height: var(--text-caption-line); }
@media (max-width: 47.999rem) {
  .doc-table thead { position: absolute; width: var(--border-hair); height: var(--border-hair); overflow: hidden; clip-path: inset(100%); white-space: nowrap; }
  .doc-table :is(table, tbody, tr, th, td) { display: block; }
  .doc-table tbody tr { padding-block: var(--space-3); }
  .doc-table tbody tr + tr { border-block-start: var(--border-hair) solid var(--color-hairline); }
  .doc-table tbody tr + tr > :is(th, td) { border-block-start: 0; }
  .doc-table th, .doc-table td { padding: var(--space-1) var(--space-4); }
  .doc-table td[data-label]::before { content: attr(data-label); display: block; color: var(--color-ink-muted); font-size: var(--text-caption-size); font-weight: 600; letter-spacing: var(--text-caption-tracking); line-height: var(--text-caption-line); text-transform: uppercase; }
}

/* Hashes, addresses, commands: fixed-width characters a reader can compare by eye. They wrap anywhere, so nothing pushes the page wide. */
:is(.doc-body, .doc-flow) code, .doc-table code { font-family: var(--font-mono); font-size: var(--doc-code-size); line-height: var(--text-caption-line); overflow-wrap: anywhere; }
.doc-cmd { display: block; max-width: none; padding: var(--space-3) var(--space-4); border: var(--border-hair) solid var(--color-hairline); border-radius: var(--radius-sm); background: var(--color-sheet); white-space: pre-wrap; }

/* FAQ rows: the whole row is the target. */
.doc-faq { display: grid; border-block-start: var(--border-hair) solid var(--color-hairline); }
.doc-faq details { max-width: none; border-block-end: var(--border-hair) solid var(--color-hairline); }
.doc-faq summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--hit); padding-block: var(--space-3); font-weight: 600; cursor: pointer; list-style: none; }
.doc-faq summary::-webkit-details-marker { display: none; }
.doc-faq summary::after { content: '+'; flex: none; inline-size: var(--space-6); color: var(--color-ink-muted); font-family: var(--font-display); font-size: var(--text-h3-size); font-weight: var(--font-display-weight); line-height: 1; text-align: center; }
.doc-faq details[open] summary::after { content: '\2212'; }
.doc-faq details > div { padding-block-end: var(--space-4); max-width: var(--measure); }
@media (hover: hover) and (pointer: fine) { .doc-faq summary:hover { color: var(--color-accent); } }

/* Definitions. */
.doc-defs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); column-gap: var(--space-8); max-width: none; }
.doc-defs > div { display: grid; gap: var(--space-1); align-content: start; padding-block: var(--space-4); border-block-start: var(--border-hair) solid var(--color-hairline); }
.doc-defs dt { color: var(--color-ink); font-weight: 600; }
.doc-defs dd { color: var(--color-ink-muted); text-wrap: pretty; }

@media (prefers-reduced-motion: reduce) { .doc-toc__list a { transition: none; } }

/* Two-column tables (data, reason): the row header takes about two fifths. */
.doc-table--pair tbody th { inline-size: 40%; }
@media (max-width: 47.999rem) { .doc-table--pair tbody th { inline-size: auto; } }

/* Rules head: the CRT panel sizes its own type from the screen width, so five rows fit a 320px phone. */
.doc-glance { --crt-size: 1.0625rem; max-width: 26rem; justify-self: start; width: 100%; }
@media (min-width: 30rem) { .doc-glance { --crt-size: 1.25rem; } }
@media (min-width: 48rem) { .doc-glance { justify-self: end; } }

/* The contents list laid out as a row of columns, under a hero. */
.doc-toc--wide .doc-toc__list { grid-template-columns: 1fr; }
@media (min-width: 30rem) { .doc-toc--wide .doc-toc__list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); } }
