/*
 * The rubric's page components: every piece a page is built from, so a site
 * wearing the rubric composes its pages and writes no layout of its own,
 * exactly as it composes its figures from `draw.js` and places them with
 * `figures.css`.
 *
 * One class family per component, each with one job, each documented above
 * its rules with what it is and where it is used. The `qs-` prefix is the
 * one the wearer's markup already speaks.
 *
 * Every colour is a slot of the tokens, read through `var()` and never a
 * literal, so both themes follow. Every other value is a slot of the kit's
 * scale with the scale's own number as its fallback, so this file stands on
 * the tokens alone and on the whole skin in a site.
 *
 * Three figure sizes and no fourth, as `figures.css` says: a square scene at
 * 13rem, a wide scene at 18rem, a card's drawing at 10rem. The hero's figure
 * is the fourth frame and the only one this file sets, at 26rem by 16rem,
 * and at 36rem by 22rem for the home page's opening on a wide page.
 *
 * The type ramp: the display face announces at a hero's title and at a
 * clause's title, and nowhere else. The sans reads every paragraph. The mono
 * carries every byte, every command and every term of the spec.
 *
 * `DESIGN.md`, "The pages", is the story, and `design.json` lists the
 * classes a page may write.
 */

/* ---- the page frame -------------------------------------------------- */

/*
 * `.qs-shell` is the whole document's room, and it is what every component
 * below asks about instead of the window: a component inside a pane, a
 * preview or a phone gets the same answer. Used once, around the header, the
 * main and the footer. A wearer whose shell is the web kit's `Page.astro`
 * has `.nv-viewport` for that room, so it is named here too, and no wearer
 * adds a container of its own.
 */
.nv-viewport {
  container-name: nv-page qs-page;
  container-type: inline-size;
}

.qs-shell {
  container: qs-page / inline-size;
  min-height: 100%;
  background: var(--nv-color-bg);
  color: var(--nv-color-fg-body);
  font-family: var(--nv-font-sans);
  font-size: var(--nv-text-base, 1rem);
  line-height: var(--nv-leading-normal, 1.5);
}

/*
 * `.qs-page` is the frame: the column, centred, with the gutter at its
 * sides. 16px of gutter at a phone's width, wider once the page has room.
 * Used by the header, by every band's inner element and by the footer, so
 * the mark, every heading and the colophon share one left edge.
 *
 * `.qs-wide` is the wide column, for a hero and for a paper read
 * whole; the plain frame is the column a clause reads at.
 */
.qs-page {
  --qs-gutter: 1rem;

  width: 100%;
  max-width: var(--qs-column, 64rem);
  margin-inline: auto;
  padding-inline: var(--qs-gutter);
}

.qs-page.qs-wide {
  --qs-column: 75rem;
}

@container qs-page (min-width: 48rem) {
  .qs-page {
    --qs-gutter: 1.5rem;
  }
}

/* ---- the header ------------------------------------------------------ */

/*
 * `.qs-head` is the head of every page: the mark home, the pages in their
 * two lanes, the language switcher and the theme switcher.
 *
 * Wide, it is one line: the mark, the lanes, the switchers, and at its end
 * the way into the app where the site knows the reader. Narrow, it is a
 * crumb, the mark and the page the reader is on, and at its end that way in
 * beside a Menu that opens the pages one to a line. The panel is open until a script sets `data-fold` on
 * the head, so with no script every link is reachable and a crawler reads
 * the same head.
 */
.qs-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'crumb ends'
    'panel panel';
  gap: 0 var(--nv-space-5, 1.5rem);
  align-items: center;
  padding-block: var(--nv-space-3, 0.75rem);
}

.qs-head-crumb {
  grid-area: crumb;
  display: flex;
  gap: var(--nv-space-3, 0.75rem);
  align-items: center;
  min-width: 0;
}

/* The mark is an inlined drawing, so it wears the page's colour. */
.qs-head-mark {
  display: flex;
  flex: none;
  align-items: center;
  color: var(--nv-color-fg);
}

.qs-head-mark svg {
  display: block;
  width: auto;
  height: 1.75rem;
}

/* The crumb's second step: a rule, then the page the reader is on. */
.qs-head-here {
  display: flex;
  gap: var(--nv-space-3, 0.75rem);
  align-items: center;
  min-width: 0;
  overflow: hidden;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--nv-color-fg);
}

.qs-head-here::before {
  content: '/';
  color: var(--nv-color-fg-subtle);
}

/* The Menu, the one control in the head, at a thumb's height. */
.qs-head-menu {
  display: inline-flex;
  gap: var(--nv-space-2, 0.5rem);
  align-items: center;
  min-height: 2.75rem;
  padding: 0 var(--nv-space-3, 0.75rem);
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-md);
  background: transparent;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg);
  cursor: pointer;
}

.qs-head-menu svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.qs-head[data-open] .qs-head-menu {
  border-color: var(--nv-color-accent);
  color: var(--nv-color-accent);
}

.qs-head-menu [data-glyph='close'],
.qs-head[data-open] .qs-head-menu [data-glyph='open'] {
  display: none;
}

.qs-head[data-open] .qs-head-menu [data-glyph='close'] {
  display: inline;
}

/* The head's end: the way into the app, then the Menu, one height on one line. */
.qs-head-ends {
  grid-area: ends;
  display: flex;
  gap: var(--nv-space-2, 0.5rem);
  align-items: center;
  min-width: 0;
}

/* The panel spans the head under the crumb. A script that can close it says
   so with `data-fold`; until then it stands open. */
.qs-head-panel {
  grid-area: panel;
  min-width: 0;
}

.qs-head[data-fold]:not([data-open]) .qs-head-panel {
  display: none;
}

/*
 * `.qs-lanes` is the two lanes of the site, Understand and Implement. Narrow
 * they are two named groups, the pages one to a line with room for a thumb.
 * Wide they are one row, separated by a hairline, each led by its name.
 */
.qs-lanes {
  display: grid;
  gap: var(--nv-space-5, 1.5rem);
  padding-block: var(--nv-space-4, 1rem) var(--nv-space-3, 0.75rem);
}

.qs-lane {
  display: grid;
}

.qs-lane-name {
  padding-block-end: var(--nv-space-1, 0.25rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-2xs, 0.6875rem);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--nv-color-accent);
}

.qs-lanes a {
  display: block;
  padding-block: var(--nv-space-3, 0.75rem);
  border-block-end: 1px solid var(--nv-color-border);
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-2xl, 1.5rem);
  line-height: var(--nv-leading-tight, 1.2);
  color: var(--nv-color-fg-muted);
  text-decoration: none;
}

.qs-lanes a:hover {
  color: var(--nv-color-fg);
}

.qs-lanes a[aria-current='page'] {
  padding-inline-start: var(--nv-space-3, 0.75rem);
  box-shadow: inset 3px 0 0 var(--nv-color-accent);
  color: var(--nv-color-fg);
}

/*
 * `.qs-switchers` holds the language switcher and the theme switcher, the
 * only two controls in the head. Their own rules are `switchers.css`.
 */
.qs-switchers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nv-space-3, 0.75rem);
  align-items: center;
  justify-content: space-between;
  padding-block: var(--nv-space-2, 0.5rem) var(--nv-space-4, 1rem);
}

/* Wide, from 70rem, room enough for the lanes, the switchers and the way in
   on one line: the crumb giving way to the mark alone and the Menu going
   with it. */
@container qs-page (min-width: 70rem) {
  .qs-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: 'crumb panel ends';
    padding-block: var(--nv-space-5, 1.5rem) var(--nv-space-4, 1rem);
  }

  .qs-head-here,
  .qs-head .qs-head-menu {
    display: none;
  }

  .qs-head .qs-head-panel,
  .qs-head[data-fold]:not([data-open]) .qs-head-panel {
    display: flex;
    gap: var(--nv-space-5, 1.5rem);
    align-items: center;
  }

  .qs-lanes {
    display: flex;
    flex: 1;
    gap: var(--nv-space-5, 1.5rem);
    justify-content: center;
    padding-block: 0;
  }

  /* Each lane is its name, quiet, over its pages in a row: the name a kicker above, so it costs the line no width. */
  .qs-lane {
    position: relative;
    display: flex;
    gap: var(--nv-space-4, 1rem);
    align-items: center;
  }

  .qs-lane + .qs-lane {
    padding-inline-start: var(--nv-space-5, 1.5rem);
    border-inline-start: 1px solid var(--nv-color-border);
  }

  /* The name stands over the lane's first page, past the hairline, not on it. */
  .qs-lane + .qs-lane .qs-lane-name {
    inset-inline-start: var(--nv-space-5, 1.5rem);
  }

  .qs-lane-name {
    position: absolute;
    inset-block-end: calc(100% + 0.125rem);
    inset-inline-start: 0;
    padding-block-end: 0;
    line-height: 1;
    white-space: nowrap;
    font-size: var(--nv-text-2xs, 0.6875rem);
    color: var(--nv-color-fg-subtle);
  }

  .qs-lanes a {
    padding-block: var(--nv-space-1, 0.25rem);
    border-block-end: 2px solid transparent;
    font-family: inherit;
    font-size: var(--nv-text-sm, 0.875rem);
    white-space: nowrap;
  }

  .qs-lanes a[aria-current='page'] {
    padding-inline-start: 0;
    box-shadow: none;
    border-block-end-color: var(--nv-color-accent);
  }

  .qs-switchers {
    flex: none;
    flex-wrap: nowrap;
    padding-block: 0;
  }

  /* On the one line the three themes fold into one glyph, the one that stands: a press moves to the next, so the line
     keeps its room for the lanes and the way in. Narrow, in the panel, all three stand side by side. */
  .qs-head .qs-themes {
    --qs-theme-cycle: 1;
  }

  .qs-head .qs-themes .qs-theme[aria-pressed='false'] {
    display: none;
  }
}

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

/*
 * `.qs-foot` is the colophon at the foot of every page: who holds the thing,
 * under what licence, and where the repository is. Set in mono, as a
 * colophon is. Narrow it is a column read top to bottom; wide it is one
 * line with the licence at its end.
 */
.qs-foot {
  display: grid;
  justify-items: start;
  gap: var(--nv-space-3, 0.75rem);
  padding-block: var(--nv-space-7, 3rem) var(--nv-space-8, 4rem);
  /* Its hairline runs to the window's edges, as every section's does, while its words keep the column. */
  border-block-start: 1px solid var(--nv-color-border);
  border-image: linear-gradient(var(--nv-color-border), var(--nv-color-border)) 1 0 0 / 1px 0 0 / 0 100vw;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  color: var(--nv-color-fg-muted);
}

.qs-foot a {
  padding-block: var(--nv-space-1, 0.25rem);
  color: var(--nv-color-fg-muted);
}

.qs-foot-end {
  color: var(--nv-color-fg-subtle);
}

@container qs-page (min-width: 40rem) {
  .qs-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--nv-space-3, 0.75rem) var(--nv-space-6, 2rem);
  }

  .qs-foot-end {
    margin-inline-start: auto;
  }
}

/* ---- the hero -------------------------------------------------------- */

/*
 * `.qs-hero` is the opening of every page, and a page has exactly one. On
 * plain paper: no band, no glow, one hairline under whatever follows it.
 *
 * Two columns where the page has the room: the words, and one figure at the
 * hero's own frame, 26rem by 16rem. On a phone one column, and the figure
 * stands under the statement at the column's width, because the sentence
 * that says what this is always precedes the picture of it.
 *
 * `.qs-hero-section` is a section landing's quieter opening: the same
 * layout, one rung down the ramp.
 */
.qs-hero {
  padding-block: var(--nv-space-8, 4rem) var(--nv-space-7, 3rem);
}

.qs-hero > .qs-page {
  display: grid;
  gap: var(--nv-space-6, 2rem);
  align-items: center;
}

@container qs-page (min-width: 70rem) {
  .qs-hero > .qs-page {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 26rem);
    column-gap: var(--nv-space-7, 3rem);
  }
}

/* The words: the kicker, the title, the statement, one action. */
.qs-hero-words {
  display: grid;
  gap: var(--nv-space-5, 1.5rem);
  min-width: 0;
}

.qs-hero.qs-hero-section .qs-hero-words {
  gap: var(--nv-space-4, 1rem);
}

/* The kicker over the title: what this is, in mono and the muted ink. */
.qs-kicker {
  margin: 0;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  letter-spacing: 0.04em;
  color: var(--nv-color-fg-muted);
}

/* The one line that sells the whole thing, in the display face, one weight.
   The top rung of the ramp, one rung quieter on a section's landing. */
.qs-title {
  max-width: 17ch;
  margin: 0;
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-6xl, clamp(2.25rem, 1.5rem + 3.4vw, 4rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-display, 1.05);
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--nv-color-fg);
}

.qs-hero.qs-hero-section .qs-title {
  max-width: 20ch;
  font-size: var(--nv-text-5xl, clamp(2rem, 1.5rem + 2.6vw, 3.5rem));
}

/* The statement under the title: the sentence that says what it is, in the
   reading face at its own measure. */
.qs-statement {
  max-width: 58ch;
  margin: 0;
  font-size: var(--nv-text-xl, 1.25rem);
  line-height: var(--nv-leading-normal, 1.5);
  color: var(--nv-color-fg);
}

/* The hero's figure, at the one frame this file sets. The source order puts
   it after the words, so a phone reads the statement and then sees it. */
.qs-hero-figure {
  min-width: 0;
}

.qs-hero-figure .fig,
.qs-hero-figure svg {
  display: block;
  width: 100%;
  max-width: 26rem;
  height: auto;
  max-height: 16rem;
  /* Under the words, on a phone or a tablet, it stands in the middle of the column, never at its left with the right half empty. */
  margin-inline: auto;
}

/* The home page's opening is the hook, and on a wide page its figure is
   drawn larger, 36rem by 22rem, so the story is read as it plays. A
   section's opening keeps the hero's own frame. */
@container qs-page (min-width: 72rem) {
  .qs-hero:not(.qs-hero-section) > .qs-page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 36rem);
  }

  .qs-hero:not(.qs-hero-section) .qs-hero-figure :is(.fig, svg) {
    max-width: 36rem;
    max-height: 22rem;
  }
}

/* ---- a clause -------------------------------------------------------- */

/*
 * `.qs-clause` is a section of a page read as a clause of a document: a
 * hairline above it, its number in the margin in the accent, its title in
 * the display face, and `.qs-hold` for the text. The number sits in a margin
 * column where the page has the room and above the title where it does not.
 *
 * `.qs-plain` is a clause with no number: it wants the whole frame, and is
 * what a paper read whole stands in.
 */
.qs-clause {
  border-block-start: 1px solid var(--nv-color-border);
}

.qs-clause > .qs-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--nv-space-2, 0.5rem) var(--nv-space-7, 3rem);
  padding-block: var(--nv-space-8, 4rem);
}

@container qs-page (min-width: 52rem) {
  .qs-clause > .qs-page {
    grid-template-columns: 5rem minmax(0, 1fr);
  }
}

/* On a phone a clause breathes a rung less, so it does not open on a screen
   of empty paper. */
@container qs-page (max-width: 36rem) {
  .qs-clause > .qs-page {
    padding-block: var(--nv-space-7, 3rem);
  }
}

.qs-clause.qs-plain > .qs-page {
  display: block;
}

/* The clause's number, the one place a bare figure is red. */
.qs-no {
  padding-block-start: var(--nv-space-1, 0.25rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-accent);
}

/*
 * `.qs-hold` is the clause's text column, and the room everything inside it
 * asks about. A ruled row reflows on this column and not on the page: past
 * 52rem the clause gives 5rem of itself to the number, and a piece that
 * queried the page would believe it had room it was never given.
 */
.qs-hold {
  container: qs-column / inline-size;
  min-width: 0;
}

.qs-clause h2 {
  margin: 0 0 var(--nv-space-4, 1rem);
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-4xl, clamp(2rem, 1.55rem + 2vw, 2.625rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-tight, 1.2);
  color: var(--nv-color-fg);
}

.qs-clause p {
  max-width: 62ch;
  color: var(--nv-color-fg-body);
}

.qs-hold > p + p {
  margin-block-start: var(--nv-space-4, 1rem);
}

/* ---- the card grid --------------------------------------------------- */

/*
 * `.qs-cards` is a row of cards, two-up, three-up or four-up by `.qs-cards-2` to `.qs-cards-5`,
 * every card the same size and none of them floated. The card itself is
 * `.qs-card` of `figures.css`, the glossary card, so a concept is drawn
 * alike on every page. A row of five is `.qs-cards-5`: one row on a
 * wide column and three over two on a middling one, so no card stands
 * alone. Five-up, four-up and three-up fall to two on a narrow column and
 * to one on a phone; two-up falls straight to one.
 */
.qs-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--nv-space-6, 2rem) var(--nv-space-5, 1.5rem);
  margin-block: var(--nv-space-6, 2rem);
}

@container qs-column (min-width: 30rem) {
  .qs-cards.qs-cards-3,
  .qs-cards.qs-cards-4,
  .qs-cards.qs-cards-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container qs-column (min-width: 40rem) {
  .qs-cards.qs-cards-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--nv-space-7, 3rem);
  }

  .qs-cards.qs-cards-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .qs-cards.qs-cards-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* Five on a middling column are three over two, the two centred, so no
     card stands alone on a row. */
  .qs-cards.qs-cards-5 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .qs-cards.qs-cards-5 > * {
    grid-column: span 2;
  }

  .qs-cards.qs-cards-5 > :nth-child(4) {
    grid-column: 2 / span 2;
  }
}

/* Five on a wide column stand in one row. */
@container qs-column (min-width: 52rem) {
  .qs-cards.qs-cards-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .qs-cards.qs-cards-5 > *,
  .qs-cards.qs-cards-5 > :nth-child(4) {
    grid-column: auto;
  }
}

/* ---- a scene in the column ------------------------------------------- */

/*
 * A scene inside a clause: `figures.css` holds the frame, the caption under
 * it and the steps under that, and this file says only where it stands. It
 * stands apart from the words around it at the clause's own distance.
 */
.qs-hold > .qs-scene {
  margin-block: var(--nv-space-6, 2rem);
}

/* ---- a glyph beside a term ------------------------------------------- */

/*
 * `.qs-term` is a paragraph with the rubric's glyph for its concept in its
 * margin, `.qs-term-fig`. Floated at the end of the line, so on a phone the
 * words run on under it, and at one height whatever the glyph's own frame
 * is, so a lock and a row of numbers read at one size.
 */
.qs-term {
  display: flow-root;
}

.qs-term-fig {
  float: inline-end;
  display: grid;
  gap: var(--nv-space-2, 0.5rem);
  width: 5.5rem;
  margin: var(--nv-space-1, 0.25rem) 0 var(--nv-space-2, 0.5rem) var(--nv-space-4, 1rem);
}

.qs-term-fig svg {
  display: block;
  width: 100%;
  height: 3.5rem;
}

/* A glyph in a margin is a mark and says no word. It is drawn too small
   for one to be read, and the paragraph beside it says them. */
.qs-term-fig svg text {
  display: none;
}

/* A term that opens a chapter of a paper: its glyph stands under the
   chapter's rule, beside the heading, and never above the rule. */
.qs-paper .qs-term:has(> h2) > .qs-term-fig {
  margin-block-start: calc(var(--nv-space-8, 4rem) + var(--nv-space-6, 2rem));
}

@container qs-page (min-width: 40rem) {
  .qs-term-fig {
    width: 7.5rem;
    margin-inline-start: var(--nv-space-6, 2rem);
  }

  .qs-term-fig svg {
    height: 4.5rem;
  }
}

/* ---- a promise ------------------------------------------------------- */

/*
 * `.qs-promises` is the guarantees or the limits as rows under their anchors.
 * Each `.qs-promise` is a term: its glyph, its name as a link to itself, its
 * sentence, and the spec chapter that states it, ruled from the next. The
 * name reads as a name, and the link shows on a hover.
 */
.qs-promises {
  display: grid;
  margin-block-start: var(--nv-space-5, 1.5rem);
}

.qs-promise {
  padding-block: var(--nv-space-5, 1.5rem);
  border-block-start: 1px solid var(--nv-color-border);
  scroll-margin-block-start: var(--nv-space-7, 3rem);
}

.qs-promise h3 {
  margin: 0 0 var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-2xl, 1.5rem);
  font-weight: var(--nv-weight-normal);
  line-height: var(--nv-leading-tight, 1.2);
}

.qs-promise h3 a {
  color: var(--nv-color-fg);
  text-decoration: none;
}

.qs-promise h3 a:hover {
  text-decoration: underline;
}

.qs-promise p {
  max-width: 58ch;
  margin: 0;
}

/* A promise with a glyph in its margin is as wide as its sentence and the glyph beside it, so the glyph stands by the words it
   marks and not at the far edge of the column. */
.qs-promise.qs-term {
  max-width: calc(58ch + 7.5rem + var(--nv-space-6, 2rem));
}

.qs-promise .qs-promise-link {
  margin-block-start: var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg-muted);
}

/* ---- the key to the picture ------------------------------------------ */

/*
 * `.qs-key` is the few glyphs every scene is drawn with, each beside the
 * picture's sentence for it, said quietly under a page's opening so a
 * stranger reads the scene. A glyph is a mark here and says no word.
 */
.qs-key {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--nv-space-3, 0.75rem) var(--nv-space-5, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.qs-key li {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: var(--nv-space-3, 0.75rem);
  align-items: center;
  font-family: var(--nv-font-sans);
  font-size: var(--nv-text-sm, 0.875rem);
  line-height: var(--nv-leading-snug, 1.35);
  color: var(--nv-color-fg-muted);
}

.qs-key svg {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
}

.qs-key svg text {
  display: none;
}

@container qs-column (min-width: 36rem) {
  .qs-key {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container qs-column (min-width: 60rem) {
  .qs-key {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .qs-key li {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
}

/* ---- a chapter ------------------------------------------------------- */

/*
 * `.qs-chapter` is one chapter of a paper, from its heading to the next, at
 * the paper's measure. A paper of chapters gives its measure to each.
 */
.qs-paper:has(> .qs-chapter) {
  max-width: none;
}

.qs-chapter {
  max-width: 68ch;
}

/*
 * One term, lit wherever it stands. The name a block of types defines, a
 * field of it and a value of an enum carry the class of their term,
 * `term-ward` or `term-ward-padlock`, and so does the part of a figure that
 * draws it. Where a reader points at one, every element of that term takes
 * `--lit`, and it is underlined in the red, because red is where a reader
 * looks. No script runs: the page is read by `:has()`.
 */
.qs-paper :is(.qi-def, .qi-field, .qi-value)[class*='term-'] {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: color-mix(in srgb, var(--nv-color-accent) calc(var(--lit, 0) * 100%), transparent);
  text-underline-offset: 0.25em;
}

/* Every term a reader can point at, each lit by the rule above. */
.qs-paper:has(.term-ward:hover) .term-ward,
.qs-paper:has(.term-ward-signingpk:hover) .term-ward-signingpk,
.qs-paper:has(.term-ward-pk:hover) .term-ward-pk,
.qs-paper:has(.term-ward-padlock:hover) .term-ward-padlock,
.qs-paper:has(.term-ward-lock:hover) .term-ward-lock,
.qs-paper:has(.term-ward-door:hover) .term-ward-door,
.qs-paper:has(.term-door:hover) .term-door,
.qs-paper:has(.term-door-handle:hover) .term-door-handle,
.qs-paper:has(.term-ward-standings:hover) .term-ward-standings,
.qs-paper:has(.term-ward-occupants:hover) .term-ward-occupants,
.qs-paper:has(.term-invitation:hover) .term-invitation,
.qs-paper:has(.term-invitation-text:hover) .term-invitation-text,
.qs-paper:has(.term-invitation-sig:hover) .term-invitation-sig,
.qs-paper:has(.term-invitationtext:hover) .term-invitationtext,
.qs-paper:has(.term-invitationtext-ward:hover) .term-invitationtext-ward,
.qs-paper:has(.term-invitationtext-heir:hover) .term-invitationtext-heir,
.qs-paper:has(.term-invitationtext-secret:hover) .term-invitationtext-secret,
.qs-paper:has(.term-invitationtext-lock:hover) .term-invitationtext-lock,
.qs-paper:has(.term-invitationtext-at:hover) .term-invitationtext-at,
.qs-paper:has(.term-askbox:hover) .term-askbox,
.qs-paper:has(.term-askbox-lid:hover) .term-askbox-lid,
.qs-paper:has(.term-askbox-head:hover) .term-askbox-head,
.qs-paper:has(.term-askbox-body:hover) .term-askbox-body,
.qs-paper:has(.term-relation:hover) .term-relation,
.qs-paper:has(.term-relation-standing:hover) .term-relation-standing,
.qs-paper:has(.term-relation-holders:hover) .term-relation-holders,
.qs-paper:has(.term-relation-occupant:hover) .term-relation-occupant,
.qs-paper:has(.term-relation-heir:hover) .term-relation-heir,
.qs-paper:has(.term-standing:hover) .term-standing,
.qs-paper:has(.term-occupant:hover) .term-occupant,
.qs-paper:has(.term-occupant-heir:hover) .term-occupant-heir,
.qs-paper:has(.term-heirstate-fresh:hover) .term-heirstate-fresh,
.qs-paper:has(.term-heirstate-spent:hover) .term-heirstate-spent,
.qs-paper:has(.term-heirstate-removed:hover) .term-heirstate-removed,
.qs-paper:has(.term-heirstate-gone:hover) .term-heirstate-gone,
.qs-paper:has(.term-heirstate-dropped:hover) .term-heirstate-dropped,
.qs-paper:has(.term-standingstate-unused:hover) .term-standingstate-unused,
.qs-paper:has(.term-standingstate-knocked:hover) .term-standingstate-knocked,
.qs-paper:has(.term-standingstate-bound:hover) .term-standingstate-bound,
.qs-paper:has(.term-standingstate-removed:hover) .term-standingstate-removed {
  --lit: 1;
}

/*
 * A figure that draws the term a reader points at dims the parts of it that
 * do not, and so does a figure whose part the reader points at. A part is a
 * `.qa-part`, and the rule is the figure's, so a scene of states and the
 * drawings of the types speak alike.
 */
.qs-paper :is(.qs-anatomy, .qs-scene):has(.qa-part:hover),
.qs-paper:has(.qs-code .term-ward:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward),
.qs-paper:has(.qs-code .term-ward-signingpk:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-signingpk),
.qs-paper:has(.qs-code .term-ward-pk:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-pk),
.qs-paper:has(.qs-code .term-ward-padlock:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-padlock),
.qs-paper:has(.qs-code .term-ward-lock:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-lock),
.qs-paper:has(.qs-code .term-ward-door:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-door),
.qs-paper:has(.qs-code .term-door:hover) :is(.qs-anatomy, .qs-scene):has(.term-door),
.qs-paper:has(.qs-code .term-door-handle:hover) :is(.qs-anatomy, .qs-scene):has(.term-door-handle),
.qs-paper:has(.qs-code .term-ward-standings:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-standings),
.qs-paper:has(.qs-code .term-ward-occupants:hover) :is(.qs-anatomy, .qs-scene):has(.term-ward-occupants),
.qs-paper:has(.qs-code .term-invitation:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitation),
.qs-paper:has(.qs-code .term-invitation-text:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitation-text),
.qs-paper:has(.qs-code .term-invitation-sig:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitation-sig),
.qs-paper:has(.qs-code .term-invitationtext:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext),
.qs-paper:has(.qs-code .term-invitationtext-ward:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext-ward),
.qs-paper:has(.qs-code .term-invitationtext-heir:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext-heir),
.qs-paper:has(.qs-code .term-invitationtext-secret:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext-secret),
.qs-paper:has(.qs-code .term-invitationtext-lock:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext-lock),
.qs-paper:has(.qs-code .term-invitationtext-at:hover) :is(.qs-anatomy, .qs-scene):has(.term-invitationtext-at),
.qs-paper:has(.qs-code .term-askbox:hover) :is(.qs-anatomy, .qs-scene):has(.term-askbox),
.qs-paper:has(.qs-code .term-askbox-lid:hover) :is(.qs-anatomy, .qs-scene):has(.term-askbox-lid),
.qs-paper:has(.qs-code .term-askbox-head:hover) :is(.qs-anatomy, .qs-scene):has(.term-askbox-head),
.qs-paper:has(.qs-code .term-askbox-body:hover) :is(.qs-anatomy, .qs-scene):has(.term-askbox-body),
.qs-paper:has(.qs-code .term-relation:hover) :is(.qs-anatomy, .qs-scene):has(.term-relation),
.qs-paper:has(.qs-code .term-relation-standing:hover) :is(.qs-anatomy, .qs-scene):has(.term-relation-standing),
.qs-paper:has(.qs-code .term-relation-holders:hover) :is(.qs-anatomy, .qs-scene):has(.term-relation-holders),
.qs-paper:has(.qs-code .term-relation-occupant:hover) :is(.qs-anatomy, .qs-scene):has(.term-relation-occupant),
.qs-paper:has(.qs-code .term-relation-heir:hover) :is(.qs-anatomy, .qs-scene):has(.term-relation-heir),
.qs-paper:has(.qs-code .term-standing:hover) :is(.qs-anatomy, .qs-scene):has(.term-standing),
.qs-paper:has(.qs-code .term-occupant:hover) :is(.qs-anatomy, .qs-scene):has(.term-occupant),
.qs-paper:has(.qs-code .term-occupant-heir:hover) :is(.qs-anatomy, .qs-scene):has(.term-occupant-heir),
.qs-paper:has(.qs-code .term-heirstate-fresh:hover) :is(.qs-anatomy, .qs-scene):has(.term-heirstate-fresh),
.qs-paper:has(.qs-code .term-heirstate-spent:hover) :is(.qs-anatomy, .qs-scene):has(.term-heirstate-spent),
.qs-paper:has(.qs-code .term-heirstate-removed:hover) :is(.qs-anatomy, .qs-scene):has(.term-heirstate-removed),
.qs-paper:has(.qs-code .term-heirstate-gone:hover) :is(.qs-anatomy, .qs-scene):has(.term-heirstate-gone),
.qs-paper:has(.qs-code .term-heirstate-dropped:hover) :is(.qs-anatomy, .qs-scene):has(.term-heirstate-dropped),
.qs-paper:has(.qs-code .term-standingstate-unused:hover) :is(.qs-anatomy, .qs-scene):has(.term-standingstate-unused),
.qs-paper:has(.qs-code .term-standingstate-knocked:hover) :is(.qs-anatomy, .qs-scene):has(.term-standingstate-knocked),
.qs-paper:has(.qs-code .term-standingstate-bound:hover) :is(.qs-anatomy, .qs-scene):has(.term-standingstate-bound),
.qs-paper:has(.qs-code .term-standingstate-removed:hover) :is(.qs-anatomy, .qs-scene):has(.term-standingstate-removed) {
  --dim: 1;
}

:is(.qs-anatomy, .qs-scene) .qa-part {
  opacity: calc(1 - 0.75 * var(--dim, 0) * (1 - var(--lit, 0)));
  transition: opacity 0.15s;
}

/* ---- the drawings of the types --------------------------------------- */

/*
 * `.qs-anatomy` is the figure of a chapter that defines types: the type
 * drawn as the picture's glyphs with a row for each field, beside the
 * chapter where the page has the room and held at the top of the window
 * while the chapter is read, so the fields a reader points at in the block
 * are lit in it. `.qs-chapter-drawn` is that chapter.
 */
.qs-anatomy {
  display: grid;
  gap: var(--nv-space-5, 1.5rem);
  max-width: 14rem;
  margin: var(--nv-space-4, 1rem) 0 var(--nv-space-6, 2rem);
}

.qs-anatomy svg {
  display: block;
  width: 100%;
  height: auto;
}

.qs-anatomy .qa-hit {
  fill: transparent;
}

.qs-anatomy .qa-name {
  fill: color-mix(in srgb, var(--nv-color-accent) calc(var(--lit, 0) * 100%), var(--nv-color-fg-body));
}

.qs-anatomy .qa-title {
  font-weight: 600;
  fill: color-mix(in srgb, var(--nv-color-accent) calc(var(--lit, 0) * 100%), var(--nv-color-fg));
}

.qs-page.qs-wide:has(.qs-chapter-drawn) {
  width: auto;
  max-width: none;
  margin-inline: max(0px, calc((100% - var(--qs-column)) / 2)) 0;
}

.qs-chapter-drawn {
  display: grid;
  grid-template-columns: minmax(0, 68ch) 11rem;
  column-gap: var(--nv-space-7, 3rem);
  align-items: start;
  max-width: none;
}

.qs-chapter-drawn > * {
  grid-column: 1;
}

.qs-chapter-drawn > .qs-anatomy {
  grid-area: 1 / 2 / span 200;
  position: sticky;
  inset-block-start: var(--nv-space-6, 2rem);
  margin-block-start: calc(var(--nv-space-8, 4rem) + var(--nv-space-6, 2rem));
}

@container qs-page (max-width: 52rem) {
  .qs-chapter-drawn {
    display: block;
  }

  .qs-chapter-drawn > .qs-anatomy {
    position: static;
    margin-block-start: var(--nv-space-4, 1rem);
  }
}

/* ---- ruled rows ------------------------------------------------------ */

/*
 * `.qs-rows` is several of one thing: a ruled list and never a box per row.
 * Each row is a name, `.qs-name`, and its text side by side where the column
 * has the room, and stacked where it has not.
 */
.qs-rows {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

p + .qs-rows {
  margin-block-start: var(--nv-space-6, 2rem);
}

.qs-rows > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--nv-space-1, 0.25rem) var(--nv-space-6, 2rem);
  padding-block: var(--nv-space-5, 1.5rem);
  border-block-start: 1px solid var(--nv-color-border);
}

.qs-rows > li:first-child {
  padding-block-start: 0;
  border-block-start: 0;
}

@container qs-column (min-width: 36rem) {
  .qs-rows > li {
    grid-template-columns: 14rem minmax(0, 1fr);
    align-items: baseline;
  }
}

.qs-rows p {
  max-width: 58ch;
  margin: 0;
  color: var(--nv-color-fg-body);
}

.qs-rows p + p,
.qs-rows .qs-commands + p {
  margin-block-start: var(--nv-space-2, 0.5rem);
}

/* The name of a row, in the display face and one rung under a clause. */
.qs-name {
  margin: 0;
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-2xl, 1.5rem);
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-tight, 1.2);
  color: var(--nv-color-fg);
}

/* ---- a short list ---------------------------------------------------- */

/*
 * `.qs-list` is several short sentences: a hairline before each, never a
 * bullet, because a document rules its lines and does not dot them.
 */
.qs-list {
  margin: var(--nv-space-2, 0.5rem) 0 0;
  padding: 0;
  list-style: none;
}

.qs-list li {
  padding-block: var(--nv-space-2, 0.5rem);
  border-block-start: 1px solid var(--nv-color-border);
  color: var(--nv-color-fg-body);
}

.qs-list li:first-child {
  border-block-start: 0;
}

/* ---- commands -------------------------------------------------------- */

/*
 * `.qs-commands` is a kit's commands, a label over each and the command in
 * mono under it, wrapping wherever the column is narrow rather than pushing
 * the page sideways.
 */
.qs-commands {
  display: grid;
  gap: var(--nv-space-2, 0.5rem);
  margin: var(--nv-space-3, 0.75rem) 0;
}

.qs-commands dt {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
}

.qs-commands dd {
  margin: 0;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  overflow-wrap: anywhere;
  color: var(--nv-color-fg);
}

/* ---- a quotation ----------------------------------------------------- */

/*
 * `.qs-quote` is a sentence quoted from a paper of `quo/`, ruled at its
 * start in the accent, because a quotation is a place the reader is asked
 * to look.
 */
.qs-quote {
  margin: var(--nv-space-4, 1rem) 0;
  padding-inline-start: var(--nv-space-4, 1rem);
  border-inline-start: 3px solid var(--nv-color-accent);
}

.qs-quote p {
  margin: 0 0 var(--nv-space-2, 0.5rem);
  color: var(--nv-color-fg);
}

.qs-quote cite {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  font-style: normal;
  color: var(--nv-color-fg-muted);
}

/* ---- what done looks like -------------------------------------------- */

/*
 * `.qs-done` is what done looks like at the end of a step of a road, ruled
 * above from the step it closes.
 */
.qs-done {
  margin-block-start: var(--nv-space-4, 1rem);
  padding-block-start: var(--nv-space-3, 0.75rem);
  border-block-start: 1px solid var(--nv-color-border);
  color: var(--nv-color-fg-body);
}

.qs-done strong {
  font-weight: var(--nv-weight-medium, 500);
  color: var(--nv-color-fg);
}

/* ---- code ------------------------------------------------------------ */

/*
 * `.qs-code` is code shown rather than run: a sunken block with a hairline,
 * scrolling sideways on its own so the page never does. Whatever follows it
 * keeps the distance, because the block carries no bottom margin.
 */
.qs-code {
  margin: var(--nv-space-5, 1.5rem) 0 0;
  padding: var(--nv-space-5, 1.5rem);
  overflow-x: auto;
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-lg);
  background: var(--nv-color-bg-sunken);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  line-height: var(--nv-leading-normal, 1.5);
  color: var(--nv-color-fg);
}

@container qs-column (max-width: 30rem) {
  .qs-code {
    padding: var(--nv-space-4, 1rem);
  }
}

/* The code is a `code` in a `pre`: the block's own face and size, its lines kept. */
.qs-code code {
  font: inherit;
}

.qs-code + * {
  margin-block-start: var(--nv-space-5, 1.5rem);
}

/* ---- a row of actions ------------------------------------------------ */

/*
 * `.qs-actions` is a row of places the reader may go, in the hero or closing
 * a clause. `.qs-action` is one of them: a mono word in a hairline box, the
 * accent one filled, because red is where a reader acts.
 */
.qs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nv-space-3, 0.75rem);
}

.qs-hold > .qs-actions {
  margin-block-start: var(--nv-space-5, 1.5rem);
}

.qs-action {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 var(--nv-space-5, 1.5rem);
  border: 1px solid var(--nv-color-border-strong);
  border-radius: var(--nv-radius-md);
  background: transparent;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg);
  text-decoration: none;
}

.qs-action.qs-action-accent {
  border-color: var(--nv-color-accent);
  background: var(--nv-color-accent);
  color: var(--nv-color-fg-on-accent);
}

.qs-action:hover {
  border-color: var(--nv-color-accent);
  color: var(--nv-color-accent);
}

.qs-action.qs-action-accent:hover {
  background: var(--nv-color-accent-hover);
  border-color: var(--nv-color-accent-hover);
  color: var(--nv-color-fg-on-accent);
}

/* ---- a quiet line ---------------------------------------------------- */

/*
 * `.qs-quiet` is a line said quietly: a note under a block, a caveat, an
 * aside. The muted ink, one rung small.
 */
.qs-quiet {
  font-size: var(--nv-text-sm, 0.875rem);
  color: var(--nv-color-fg-muted);
}

/* ---- a paper read whole ---------------------------------------------- */

/*
 * `.qs-reading` is a whole document read on the page: its sections in a rail
 * beside the reading column where there is room, and folded into a bar at
 * the top of the window where there is not. It stands inside a
 * `.qs-clause.qs-plain`, which rules it above and gives it the frame.
 */
.qs-reading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--nv-space-7, 3rem) var(--nv-space-8, 4rem);
}

@container qs-page (min-width: 56rem) {
  .qs-reading {
    grid-template-columns: 15rem minmax(0, 1fr);
  }
}

.qs-rail-hold {
  align-self: start;
  min-width: 0;
}

.qs-rail {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  scrollbar-width: thin;
}

/* Beside the column, the rail is sticky and scrolls inside the window's
   height, so a section far down the list is reachable while the reader is
   far down the text. */
@container qs-page (min-width: 56rem) {
  .qs-rail-hold {
    position: sticky;
    inset-block-start: var(--nv-space-5, 1.5rem);
  }

  .qs-rail {
    max-height: calc(100vh - var(--nv-space-7, 3rem));
    overflow-y: auto;
  }

  .qs-rail-hold .qs-rail-toggle {
    display: none;
  }
}

/* Narrow, and only where a script has said it can fold, the rail is a bar
   held at the top: the word for the list and the section under the eye. It
   opens into the same links, which scroll in their own box. */
@container qs-page (max-width: 55.99rem) {
  .qs-rail-hold[data-fold] {
    position: sticky;
    z-index: var(--nv-z-sticky, 10);
    inset-block-start: 0;
    margin-inline: calc(-1 * var(--qs-gutter, 1rem));
    padding-inline: var(--qs-gutter, 1rem);
    border-block-end: 1px solid var(--nv-color-border);
    background: var(--nv-color-bg);
  }

  .qs-rail-hold[data-fold] .qs-rail {
    display: none;
  }

  .qs-rail-hold[data-fold][data-open] .qs-rail {
    display: block;
    max-height: 60vh;
    overflow-y: auto;
    padding-block: var(--nv-space-2, 0.5rem) var(--nv-space-4, 1rem);
    overscroll-behavior: contain;
  }

  .qs-rail-hold[data-fold] .qs-rail li {
    padding-block: var(--nv-space-2, 0.5rem);
  }

  /* A heading followed from the bar lands under it, not behind it. */
  .qs-paper :is(h2, h3) {
    scroll-margin-block-start: var(--nv-space-9, 6rem);
  }
}

.qs-rail-toggle {
  display: flex;
  align-items: baseline;
  gap: var(--nv-space-3, 0.75rem);
  width: 100%;
  min-height: 2.75rem;
  padding: var(--nv-space-3, 0.75rem) 0;
  border: 0;
  background: transparent;
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  text-align: start;
  color: var(--nv-color-fg);
  cursor: pointer;
}

/* The chevron says the bar opens, and turns when it has. */
.qs-rail-toggle::after {
  content: '';
  flex: none;
  align-self: center;
  width: 0.45rem;
  height: 0.45rem;
  margin-inline-start: auto;
  border-inline-end: 1.5px solid currentColor;
  border-block-end: 1.5px solid currentColor;
  transform: translateY(-25%) rotate(45deg);
}

.qs-rail-hold[data-open] .qs-rail-toggle::after {
  transform: translateY(25%) rotate(-135deg);
}

.qs-rail-label {
  flex: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-accent);
}

.qs-rail-now {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The number keeps its own column, so a heading with none lines up under the
   text of the one above it and an entry that wraps keeps its indent. */
.qs-rail li {
  display: grid;
  grid-template-columns: 2ch minmax(0, 1fr);
  gap: var(--nv-space-3, 0.75rem);
  padding-block: var(--nv-space-1, 0.25rem);
}

.qs-rail li[data-level='3'],
.qs-rail li[data-level='4'] {
  padding-inline-start: var(--nv-space-4, 1rem);
}

.qs-rail .qs-no {
  padding-block-start: 0;
}

.qs-rail a {
  color: var(--nv-color-fg-muted);
  text-decoration: none;
}

.qs-rail a:hover {
  color: var(--nv-color-fg);
}

.qs-rail a[aria-current] {
  margin-inline-start: calc(-1 * var(--nv-space-2, 0.5rem));
  padding-inline-start: var(--nv-space-2, 0.5rem);
  box-shadow: inset 3px 0 0 var(--nv-color-accent);
  color: var(--nv-color-accent);
}

/*
 * `.qs-paper` is the read document itself, at its own measure, which is
 * wider than a clause's: its paragraphs, lists, tables and code share one
 * right edge. Its headings are the only place besides a hero and a clause
 * where the display face announces.
 */
.qs-paper {
  /* A paper is a column too, so a row of cards placed in it is as many
     across as the paper has room for. */
  container: qs-column / inline-size;
  max-width: 68ch;
  min-width: 0;
  font-size: var(--nv-text-lg, 1.125rem);
  line-height: var(--nv-leading-normal, 1.5);
}

.qs-paper :is(p, li)[id] {
  scroll-margin-block-start: var(--nv-space-9, 6rem);
}

/* A paper's own title: a heading under the page's one, drawn as the paper's name, not as one of its sections. */
.qs-paper h2.qs-paper-title {
  margin: 0 0 var(--nv-space-5, 1.5rem);
  padding: 0;
  border: 0;
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-5xl, clamp(2rem, 1.5rem + 2.6vw, 3.5rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-tight, 1.2);
  color: var(--nv-color-fg);
}

.qs-paper h2 {
  margin: var(--nv-space-8, 4rem) 0 var(--nv-space-3, 0.75rem);
  padding-block-start: var(--nv-space-6, 2rem);
  border-block-start: 1px solid var(--nv-color-border);
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-4xl, clamp(2rem, 1.55rem + 2vw, 2.625rem));
  font-weight: var(--nv-weight-normal, 400);
  line-height: var(--nv-leading-tight, 1.2);
  color: var(--nv-color-fg);
}

.qs-paper h3 {
  margin: var(--nv-space-7, 3rem) 0 var(--nv-space-2, 0.5rem);
  font-family: var(--nv-font-display);
  font-size: var(--nv-text-2xl, 1.5rem);
  font-weight: var(--nv-weight-normal, 400);
  color: var(--nv-color-fg);
}

.qs-paper :is(p, ul, ol) {
  max-width: none;
  margin: 0 0 var(--nv-space-4, 1rem);
  color: var(--nv-color-fg-body);
}

.qs-paper :is(ul, ol) {
  padding-inline-start: var(--nv-space-5, 1.5rem);
}

.qs-paper li {
  margin-block-end: var(--nv-space-2, 0.5rem);
}

.qs-paper strong {
  font-weight: var(--nv-weight-medium, 500);
  color: var(--nv-color-fg);
}

.qs-paper code {
  padding: var(--nv-space-05, 0.125rem) var(--nv-space-1, 0.25rem);
  border-radius: var(--nv-radius-sm);
  background: var(--nv-color-bg-sunken);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.qs-paper pre {
  margin: var(--nv-space-4, 1rem) 0 var(--nv-space-5, 1.5rem);
  padding: var(--nv-space-4, 1rem);
  overflow-x: auto;
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-lg);
  background: var(--nv-color-bg-sunken);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-sm, 0.875rem);
  line-height: var(--nv-leading-normal, 1.5);
  color: var(--nv-color-fg);
}

.qs-paper pre code {
  padding: 0;
  background: none;
}

.qs-paper table {
  width: 100%;
  margin: 0 0 var(--nv-space-5, 1.5rem);
  border-collapse: collapse;
  font-size: var(--nv-text-sm, 0.875rem);
}

.qs-paper :is(th, td) {
  padding: var(--nv-space-2, 0.5rem) var(--nv-space-3, 0.75rem);
  text-align: start;
  vertical-align: top;
  border-block-end: 1px solid var(--nv-color-border);
}

.qs-paper th {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-2xs, 0.6875rem);
  font-weight: var(--nv-weight-normal, 400);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--nv-color-fg-muted);
  border-block-end-color: var(--nv-color-border-strong);
}

/* On a phone a table wider than the column scrolls inside itself, as a
   block of code does, and the page never scrolls sideways. */
@container qs-column (max-width: 36rem) {
  .qs-paper table {
    display: block;
    overflow-x: auto;
  }
}

/* ---- links ----------------------------------------------------------- */

/* A link in running text is red, because red is where a reader acts. */
.qs-hold a,
.qs-paper a,
.qs-statement a {
  color: var(--nv-color-link);
}

.qs-hold a:hover,
.qs-paper a:hover,
.qs-statement a:hover {
  color: var(--nv-color-link-hover);
}

/* ---- the inks of code ------------------------------------------------ */

/*
 * A block of types, read token by token by `inks.js`, inside `.qs-code` or
 * a paper's `pre`. A reader tells a sentence from a type and a type from a
 * field by the ink alone. The name a block defines is the display black,
 * heavier. A type used is the first figure ink, and it is a link to where
 * the document defines it, which the red would overstate: a type is looked
 * up, and nothing is acted on. A value of an enum is the third figure ink.
 * A field is the body's ink. A sentence is said quietly, and a keyword and
 * a mark more quietly still, because the words carry the block.
 */
/* A block of types wraps rather than scrolls. Each line hangs from its own
   indent, so a wrapped sentence reads under its first words, two further
   in, and a line never hides past the block's edge. A block takes the
   paper's whole measure, clear of a glyph in the margin. */
:is(.qs-code, .qs-paper pre):has(.qi-line) {
  clear: both;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.qi-line {
  display: block;
  padding-inline-start: 2ch;
  text-indent: -2ch;
}

.qi-line.qi-i2 {
  padding-inline-start: 4ch;
  text-indent: -4ch;
}

.qi-line.qi-i4 {
  padding-inline-start: 6ch;
  text-indent: -6ch;
}

.qi-line.qi-i6 {
  padding-inline-start: 8ch;
  text-indent: -8ch;
}

.qi-def {
  font-weight: 600;
  color: var(--nv-color-fg);
  scroll-margin-top: var(--nv-space-8, 4rem);
}

.qi-def:target {
  text-decoration: underline;
  text-decoration-color: var(--nv-color-accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.25em;
}

:is(.qs-code, .qs-paper pre) .qi-type {
  color: var(--nv-color-role-figure-1);
  text-decoration: none;
}

:is(.qs-code, .qs-paper pre) a.qi-type:hover {
  color: var(--nv-color-role-figure-1);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.qi-value {
  color: var(--nv-color-role-figure-3);
}

.qi-field {
  color: var(--nv-color-fg-body);
}

.qi-doc {
  color: var(--nv-color-fg-muted);
}

.qi-key,
.qi-mark {
  color: var(--nv-color-fg-subtle);
}

/* ---- what each kit answers ------------------------------------------- */

/*
 * `.qs-answers` is what each of several kits answers to one question, folded
 * under it: a summary in the accent, and a ruled row for each kit, its name
 * a link to where it holds its answers.
 */
.qs-answers {
  margin-block: var(--nv-space-3, 0.75rem) var(--nv-space-5, 1.5rem);
}

.qs-answers > summary {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nv-color-accent);
  cursor: pointer;
}

.qs-answers dl {
  margin: var(--nv-space-3, 0.75rem) 0 0;
}

.qs-answers dt {
  padding-block-start: var(--nv-space-3, 0.75rem);
  border-block-start: 1px solid var(--nv-color-border);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qs-answers dd {
  min-width: 0;
  margin: var(--nv-space-1, 0.25rem) 0 0;
  padding-block-end: var(--nv-space-3, 0.75rem);
  font-size: var(--nv-text-base, 1rem);
  overflow-wrap: break-word;
}

.qs-answers dd > :last-child {
  margin-block-end: 0;
}

/* The line that names the key to the picture, said quietly above it. */
.qs-key-label {
  margin: 0 0 var(--nv-space-3, 0.75rem);
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.75rem);
  letter-spacing: 0.08em;
  color: var(--nv-color-fg-muted);
}

/* ---- the way into the app -------------------------------------------- */

/*
 * `.qs-head-continue` is the head's one way into the app, shown only to
 * someone the site knows, `Continue as` and their name's first word: the
 * accent action at the head's end, beside the Menu at its height on a narrow
 * page and at the line's end on a wide one, a step smaller. It keeps one
 * width from its first moment, so nothing beside it moves: while the name
 * is asked (`nv-enter[data-state='waiting']`) it holds, not pressable, the
 * site's turning mark small at its centre in the ink on the red; once it
 * comes, the words rise in its place. A long word is cut, never the line.
 */
.qs-action.qs-head-continue {
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 13rem;
  height: 2.75rem;
  min-height: 0;
  padding: 0 var(--nv-space-4, 1rem);
  font-size: var(--nv-text-xs, 0.75rem);
}

.qs-head-continue-wait,
.qs-head-continue-words {
  grid-area: 1 / 1;
  max-width: 100%;
}

.qs-head-continue-words {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 180ms var(--nv-ease-out, ease-out);
}

.qs-head-continue-wait {
  display: flex;
  visibility: hidden;
}

.qs-head-continue-wait .qs-ui-mark {
  width: 1.25rem;
  height: 1.25rem;
}

.qs-head-continue-wait .qs-ui-mark-ring,
.qs-head-continue-wait .qs-ui-mark-dot {
  stroke: var(--nv-color-fg-on-accent);
  fill: none;
}

.qs-head-continue-wait .qs-ui-mark-dot {
  fill: var(--nv-color-fg-on-accent);
  stroke: none;
}

.qs-head-continue-wait .qs-ui-mark-track {
  stroke: var(--nv-color-fg-on-accent);
  stroke-opacity: 0.3;
}

nv-enter[data-state='waiting'] .qs-head-continue {
  cursor: progress;
  opacity: 0.85;
}

nv-enter[data-state='waiting'] .qs-head-continue-wait {
  visibility: visible;
}

nv-enter[data-state='waiting'] .qs-head-continue-words {
  opacity: 0;
}

@container qs-page (max-width: 24rem) {
  .qs-action.qs-head-continue {
    width: 11.5rem;
    padding: 0 var(--nv-space-3, 0.75rem);
  }
}

@container qs-page (min-width: 70rem) {
  .qs-action.qs-head-continue {
    width: 12rem;
    height: 2.25rem;
    padding: 0 var(--nv-space-3, 0.75rem);
  }
}
