:root {
  color-scheme: dark;
  /* palette */
  --void: #0A0A0A;
  --soot: #161616;
  --bone: #F2F2EF;
  --ash: #8E8E8A;
  --rule: #3B3B39;

  /* roles */
  --color-surface: var(--void);
  --color-surface-raised: var(--soot);
  --color-text: var(--bone);
  --color-text-muted: var(--ash);
  --color-border: var(--rule);
  --color-accent: var(--bone);
  --color-link: var(--bone);
  --color-focus: var(--bone);

  --font-display: "Archivo", "Arial Black", sans-serif;
  --font-body: "Archivo", Arial, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, monospace;

  --u: 8px;
  --edge: clamp(16px, 2.2vw, 32px);
  --rail: 232px;
  --shift: 124px; /* the book sits right of centre, clear of the contents rail */
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; overflow: hidden; background: var(--color-surface); color: var(--color-text); font: 400 14px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--color-link); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
:focus-visible { outline: 1px solid var(--color-focus); outline-offset: 3px; }
.mono { font: 400 10.5px/1.5 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.dim { color: var(--color-text-muted); }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
/* Zoomed in, the page fills the screen. The header, contents and ruler step aside; only the step
   buttons stay, as ink plates on the paper. */
.top, .toc, .count, .ticks { transition: opacity .3s, visibility 0s; }
/* The cursor over the book: an ink plate like the step buttons, its glyph saying what a click will do.
   The point it acts on is the plate's centre. */
.cur { position: fixed; left: 0; top: 0; z-index: 4; pointer-events: none; }
.cur .plate { position: absolute; left: -17px; top: -17px; width: 34px; height: 34px; display: grid; place-items: center; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-text); opacity: 0; transform: scale(.4); transition: opacity .14s, transform .2s cubic-bezier(.2,.7,.2,1); }
.cur.on .plate { opacity: 1; transform: none; }
.cur.on.down .plate { transform: scale(.86); }
/* One set of glyphs for the cursor and the step buttons. */
.cur svg, .step svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: square; }
.cur path { opacity: 0; transition: opacity .12s; }
.cur[data-state="in"] .g-in, .cur[data-state="out"] .g-out, .cur[data-state="next"] .g-next, .cur[data-state="prev"] .g-prev, .cur[data-state="move"] .g-move, .cur[data-state="link"] .g-link, .cur[data-state="close"] .g-close { opacity: 1; }
.zoomed .top, .zoomed .toc, .zoomed .count, .zoomed .ticks, .zoomed .dial { opacity: 0; visibility: hidden; transition: opacity .3s, visibility 0s .3s; }

/* Name over subtitle on the left, the view toggle on the right. On a narrow screen, where the subtitle
   would have to drop below, it goes: the name sits level with the toggle. */
.top { position: fixed; inset: 0 0 auto 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name mode" "sub mode"; column-gap: calc(var(--u) * 3); align-items: start; padding: var(--edge); z-index: 3; pointer-events: none; }
.top > * { pointer-events: auto; }
.id { grid-area: name; margin: 0; font: 800 15px/1.1 var(--font-display); font-stretch: 125%; text-transform: uppercase; letter-spacing: 0.02em; }
.sub { grid-area: sub; margin: 3px 0 0; line-height: 1.2; }
.mode { grid-area: mode; display: flex; border: 1px solid var(--color-border); }
@media (max-width: 520px) {
  .top { grid-template-areas: "name mode"; }
  .id { align-self: center; padding-top: 3px; }
  .sub { display: none; }
}
.mode button { padding: 9px 14px; }
.mode button + button { border-left: 1px solid var(--color-border); }
.mode button[aria-pressed="true"] { background: var(--color-text); color: var(--color-surface); }

/* contents rail */
.toc { position: fixed; left: calc(var(--edge) + 14px); top: 50%; transform: translateY(-50%); z-index: 3; margin: 0; padding: 0; list-style: none; width: var(--rail); }
.toc button { display: grid; grid-template-columns: 30px 1fr; width: 100%; text-align: left; padding: 6px 0; color: var(--color-text-muted); }
.toc button:hover { color: var(--color-text); }
.toc button[aria-current="true"] { color: var(--color-text); position: relative; }
.toc button[aria-current="true"]::before { content: ""; position: absolute; left: -14px; top: 11px; width: 6px; height: 6px; background: var(--color-text); }

/* The caption text lives on the printed page. This copy is for screen readers, and for phones where the page is too small to read. */
.read { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.read .item + .item { margin-top: calc(var(--u) * 4); }
.read h2 { margin: 6px 0 2px; font: 700 19px/1.08 var(--font-display); font-stretch: 125%; text-transform: uppercase; }
.read p { margin: 10px 0 0; color: var(--color-text); }
.read p.dim { color: var(--color-text-muted); }
.read dl { margin: 14px 0 0; display: grid; grid-template-columns: 76px 1fr; border-top: 1px solid var(--color-border); }
.read dt, .read dd { margin: 0; padding: 5px 0; border-bottom: 1px solid var(--color-border); }
.read dt { color: var(--color-text-muted); }
.read ol { margin: 10px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--color-border); }
.read ol li { padding: 7px 0; border-bottom: 1px solid var(--color-border); }
.read ol a { text-decoration: none; display: block; }
.read ol a:hover { text-decoration: underline; }
.read .say { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ruler */
.rule { position: fixed; left: var(--edge); right: var(--edge); bottom: var(--edge); z-index: 3; pointer-events: none; display: grid; grid-template-columns: var(--rail) 1fr auto; align-items: end; gap: calc(var(--u) * 3); }
.rule > * { pointer-events: auto; }
.count b { display: block; font: 800 34px/0.9 var(--font-display); font-stretch: 125%; font-variant-numeric: tabular-nums; }
/* margin-right: the ruler stands as far from the buttons as from the counter's figures (the rail less
   their ~191px, plus the gap: 65px). */
.ticks { position: relative; height: 52px; margin-right: 41px; border-bottom: 1px solid var(--color-border); }
.ticks button { position: absolute; bottom: 0; width: 14px; margin-left: -7px; height: 100%; }
.ticks button::after { content: ""; position: absolute; left: 6.5px; bottom: 0; width: 1px; height: 9px; background: var(--color-text-muted); }
.ticks button.ch::after { height: 20px; background: var(--color-text); }
/* Labels clear the tallest mark (the current spread's, 30px) by 6px. */
.ticks button.ch span { position: absolute; left: 7px; bottom: 36px; transform: translateX(-50%); color: var(--color-text-muted); }
.ticks button.ch span.crowded { visibility: hidden; } /* too close to the label before it at this width */
.ticks button:hover::after { background: var(--color-text); height: 26px; }
.ticks button[aria-current="true"]::after { left: 4px; width: 6px; height: 30px; background: var(--color-text); }
.steps { display: flex; gap: var(--u); }
.step { display: flex; border: 1px solid var(--color-border); transition: background-color .3s; }
.zoomed .step { background: var(--color-surface); }
.step button { width: 46px; height: 44px; display: grid; place-items: center; }
.step button + button { border-left: 1px solid var(--color-border); }
.step button:disabled { opacity: .3; cursor: default; }
/* Placed under the closed book by the framing code. */
/* How to open the book, for screen readers only: on screen the cursor, the cover's lift on hover and
   one unprompted lift after arriving say it (see nudge()). Floating text under the book read as a tooltip. */
.hint { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* the index ("unbound"): the whole volume as one page, plates as contact sheets, the rest as lists */
/* --top-h: the header's height (set in resize()). In the index the header is a solid band, and the page
   scrolls under it rather than through the name, fading out over the 32px below it rather than cut off
   at its edge. The page starts below the fade. */
.sheet { position: fixed; inset: 0; z-index: 2; overflow: auto; padding: calc(var(--top-h, 104px) + 32px) var(--edge) 120px; background: var(--color-surface); visibility: hidden; opacity: 0; transition: opacity .35s, visibility 0s .35s; }
.unbound .sheet { visibility: visible; opacity: 1; transition: opacity .35s; }
.unbound .top { background: var(--color-surface); }
.unbound .top::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 32px; background: linear-gradient(var(--color-surface), transparent); pointer-events: none; }
.unbound .toc, .unbound .read, .unbound .rule, .unbound .hint { visibility: hidden; }
.sheet h2 { margin: 0; padding: 10px 0; border-top: 1px solid var(--color-text); display: grid; grid-template-columns: auto 1fr auto; column-gap: 14px; font: 800 22px/1 var(--font-display); font-stretch: 125%; text-transform: uppercase; align-items: baseline; }
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; margin: 0 0 56px; border-left: 1px solid var(--color-border); border-top: 1px solid var(--color-border); }
.frames button { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; width: 100%; height: 100%; text-align: left; padding: 10px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); transform: translateY(14px); opacity: 0; }
.unbound .frames button { transform: none; opacity: 1; transition: transform .5s cubic-bezier(.2,.7,.2,1) calc(var(--i) * 14ms), opacity .4s calc(var(--i) * 14ms); }
.frames button:hover { background: var(--color-surface-raised); }
.frames .ph { flex: 0 0 auto; width: 100%; aspect-ratio: 1; display: grid; place-items: center; margin: 8px 0; overflow: hidden; }
.frames img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.frames .t { display: block; font: 600 12px/1.25 var(--font-body); font-stretch: 112%; text-transform: uppercase; }
/* A section's title opens the book there. */
.sheet h2 button { justify-self: start; font: inherit; font-stretch: inherit; text-transform: inherit; text-align: left; }
.sheet h2 button::after { content: " →"; opacity: 0; transition: opacity .2s; }
.sheet h2 button:hover::after, .sheet h2 button:focus-visible::after { opacity: 1; }
.ix-about { max-width: 720px; margin: 18px 0 56px; }
.ix-about .lede { margin: 0 0 16px; font: 800 19px/1.1 var(--font-display); font-stretch: 125%; text-transform: uppercase; }
.ix-about p { margin: 0 0 12px; font-size: 15px; line-height: 1.55; }
.ix-about .links { display: flex; gap: 20px; margin-top: 18px; font-size: 10.5px; }
.ix-list { list-style: none; margin: 0 0 56px; padding: 0; border-top: 1px solid var(--color-border); }
.ix-list li { border-bottom: 1px solid var(--color-border); }
.ix-list li > * { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: baseline; padding: 12px 10px; text-decoration: none; }
.ix-list a:hover { background: var(--color-surface-raised); }
.ix-list .t { font: 600 15px/1.35 var(--font-body); }
@media (max-width: 520px) { .ix-list li > * { grid-template-columns: 76px 1fr; gap: 12px; } .ix-about .lede { font-size: 17px; } }

/* Small screens: the caption is on the printed page only (the copy stays for screen readers). The ruler
   becomes a dial on its own full-width row, above the counter and the step buttons: a strip of ticks,
   18px a spread, sliding under a fixed needle. Ticks swell near the needle and fade to lines at the
   edges. Above the needle is the section; while scrubbing, the spread under it too. */
.dial { display: none; }
@media (max-width: 980px) {
  .toc { display: none; }
  .rule { grid-template-columns: auto 1fr; grid-template-areas: "ticks ticks" "count steps"; row-gap: 14px; }
  .ticks { display: none; }
  .dial { display: block; grid-area: ticks; position: relative; height: 112px; touch-action: none; cursor: grab; transition: opacity .3s, visibility 0s; }
  .dial:active { cursor: grabbing; }
  .dial .rd { position: absolute; left: 0; right: 0; top: 0; text-align: center; pointer-events: none; }
  .dial .rd span { display: block; color: var(--color-text); }
  .dial .rd b { display: block; padding: 0 24px; font: 700 14px/1.2 var(--font-display); font-stretch: 112%; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; transform: translateY(-3px); transition: opacity .2s, transform .2s; }
  .dial.scrub .rd b { opacity: 1; transform: none; }
  /* Tall enough for a chapter number at full magnification: a 45px tick, then the number scaled 1.35×.
     (The edge fade is a mask, which clips anything outside the strip.) */
  .dial .strip { position: absolute; left: 0; right: 0; bottom: 0; height: 78px; border-bottom: 1px solid var(--color-border);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent); mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent); }
  .dial .t { position: absolute; left: 0; bottom: 0; width: 1px; }
  .dial .t i { display: block; width: 1px; background: var(--color-text-muted); }
  .dial .t.ch i, .dial .t.cover i { background: var(--color-text); }
  .dial .t .n { position: absolute; left: 0; bottom: calc(100% + 5px); transform-origin: 50% 100%; color: var(--color-text-muted); }
  .dial .needle { position: absolute; left: 50%; bottom: 0; width: 2px; height: 44px; margin-left: -1px; background: var(--color-text); pointer-events: none; }
  .dial .needle::before { content: ""; position: absolute; left: -2px; top: -6px; width: 6px; height: 6px; background: var(--color-text); }
  .rule { column-gap: 12px; }
  .count { grid-area: count; align-self: center; }
  .steps { grid-area: steps; justify-self: end; }
  .count b { font-size: clamp(17px, 5.6vw, 22px); white-space: nowrap; } /* one line, however narrow */
  .count .mono { display: none; }
  .step button { width: 44px; }
}
@media (max-width: 380px) {
  .step button { width: 40px; }
  .mode button { padding: 9px 11px; }
}
@media (prefers-reduced-motion: reduce) { .frames button, .sheet, .read, .top, .toc, .count, .ticks, .dial, .dial .rd b, .step, .cur .plate, .cur path { transition: none !important; } }
