/* Finished HTML kit: the house layout for a single-page reading edition.
   Retune the edition through the tokens in :root; the rules below read only tokens.
   Breakpoints are literal because CSS cannot read a variable inside @media:
   901px docks the Contents panel (DOCK in the page script must match), 720px is narrow. */

:root {
  color-scheme: light;

  /* Palette, light theme.  The dark theme redefines the same names, in the same order, below. */
  --parchment: #f6f1e7;
  --parchment-mid: #eee7d6;
  --parchment-dark: #ddd3bd;
  --ink: #211c15;
  --ink-mid: #44392d;
  --ink-light: #665746;
  --rust: #842727;
  --rust-light: #a13a32;
  --gold: #7b6326;
  --rule: #c5b48f;
  --note-bg: #eee5cf;
  --note-border: #c0a070;
  --rail: #b7827d;            /* companion sections: the timeline rail and the cast-list hairlines */
  --hairline: #ddd0b4;
  --review-bg: #fbf8f1;       /* the Review essays: a sheet one step lighter than the page (the commentary is a step darker) */
  --shadow: rgba(30, 25, 18, 0.16);
  --paper-highlight: rgba(255, 255, 255, 0.82);
  --paper-texture: rgba(83, 64, 32, 0.018);
  --panel-highlight: rgba(255, 255, 255, 0.28);
  --link-hover-bg: rgba(132, 39, 39, 0.07);
  --backdrop-bg: rgba(22, 18, 14, 0.42);
  --on-accent: white;
  --title-bg: #f5f0e6;
  --title-ink: #1e1913;
  --title-kicker: #9a5c25;
  --title-rule: #b8a678;
  --cover-border: rgb(0, 0, 0);
  --header-shadow: rgba(0, 0, 0, 0.2);
  --toggle-hover-bg: rgba(255, 255, 255, 0.08);
  /* The masthead and footer are dark furniture in both themes. */
  --header-text: #f8f1df;
  --header-bg: rgba(32, 27, 20, 0.97);
  --toggle-hover-color: #e3c46b;
  --nav-accent: #d7b85b;
  --nav-meta: rgba(248, 241, 223, 0.82);
  --footer-text: #eee3ca;
  --footer-bg: #241f18;
  --focus-ring: #d19135;
  --print-ink: #000;
  --print-paper: #fff;
  --print-rule: #999;
  --img-dark-filter: brightness(0.85);

  /* Fonts. */
  --font-body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif CJK TC", Georgia, serif;
  --font-display: "Palatino Linotype", "Book Antiqua", "Noto Serif CJK TC", Georgia, serif;
  --font-title: "Bodoni MT", Didot, "Times New Roman", serif;

  /* Type scale. */
  --text-size: clamp(1.06rem, 0.98rem + 0.24vw, 1.24rem);
  --leading: 1.58;
  --title-size: clamp(3.25rem, 6vw, 6.75rem);
  --title-size-narrow: clamp(2.65rem, 14vw, 4.2rem);
  --h2-size: clamp(1.7rem, 4vw, 2.6rem);   /* the Prototype's section heading size */
  --chapter-title-size: 2.2rem;
  --box-title-size: 1.35rem;
  --note-size: 0.85rem;
  --label-size: 0.72rem;
  --footer-size: 0.86rem;
  --para-indent: 2em;
  --para-indent-narrow: 1.25em;

  /* Layout.  Column = min(100% - 2 * gutter, measure); body text = column - reading inset, split evenly
     (this page has no page markers). */
  --measure: 52rem;
  --gutter: 1rem;
  --reading-inset: 3.25rem;
  --nav-width: 76rem;
  --panel-width: 16rem;
  --toc-label-width: 6.6rem;
  --header-height: 3.55rem;
  --section-bar-height: 2.15rem;
  --cover-width: min(100%, var(--measure));   /* the title image takes the full reading-column width (Review 2 checklist) */
  --cover-max: 100%;
  --cover-width-narrow: min(100%, 30rem);
  --cover-frame: 5px;
  --figure-max-height: 72vh;

  /* Rhythm: one gap above and below every main-section rule, measured to the text's line box. */
  --section-gap: clamp(3.5rem, 8vw, 7rem);
  --divider-width: 1px;
  --chapter-gap: 3.5rem;
  --chapter-rule: 1px solid var(--rule);
  --box-pad: 2.5rem;
  --box-pad-narrow: 1.5rem;
  --end-space: 5rem;
}

@media (max-width: 900px) {
  :root { --reading-inset: 0rem; }
}

/* Dark theme: System follows the OS unless the reader chose Off; On always wins.
   The two blocks below must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --parchment: #1b1712;
    --parchment-mid: #241f18;
    --parchment-dark: #2c251c;
    --ink: #e8dfc9;
    --ink-mid: #c9bc9c;
    --ink-light: #a89877;
    --rust: #e0785f;
    --rust-light: #ef9478;
    --gold: #d4af5a;
    --rule: #4a4030;
    --note-bg: #2a2318;
    --note-border: #6b5636;
    --rail: #874c3c;
    --hairline: #383026;
    --review-bg: #221d17;
    --shadow: rgba(0, 0, 0, 0.5);
    --paper-highlight: rgba(255, 240, 210, 0.045);
    --paper-texture: rgba(0, 0, 0, 0.32);
    --panel-highlight: rgba(255, 255, 255, 0.06);
    --link-hover-bg: rgba(224, 120, 95, 0.18);
    --backdrop-bg: rgba(0, 0, 0, 0.6);
    --on-accent: #1b1712;
    --title-bg: #17130f;
    --title-ink: #f2e9d6;
    --title-kicker: #dba765;
    --title-rule: #6b5636;
    --cover-border: rgba(232, 223, 201, 0.4);
    --header-shadow: rgba(0, 0, 0, 0.5);
    --toggle-hover-bg: rgba(255, 255, 255, 0.12);
  }

  :root:not([data-theme="light"]) img { filter: var(--img-dark-filter); }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --parchment: #1b1712;
  --parchment-mid: #241f18;
  --parchment-dark: #2c251c;
  --ink: #e8dfc9;
  --ink-mid: #c9bc9c;
  --ink-light: #a89877;
  --rust: #e0785f;
  --rust-light: #ef9478;
  --gold: #d4af5a;
  --rule: #4a4030;
  --note-bg: #2a2318;
  --note-border: #6b5636;
  --rail: #874c3c;
  --hairline: #383026;
  --review-bg: #221d17;
  --shadow: rgba(0, 0, 0, 0.5);
  --paper-highlight: rgba(255, 240, 210, 0.045);
  --paper-texture: rgba(0, 0, 0, 0.32);
  --panel-highlight: rgba(255, 255, 255, 0.06);
  --link-hover-bg: rgba(224, 120, 95, 0.18);
  --backdrop-bg: rgba(0, 0, 0, 0.6);
  --on-accent: #1b1712;
  --title-bg: #17130f;
  --title-ink: #f2e9d6;
  --title-kicker: #dba765;
  --title-rule: #6b5636;
  --cover-border: rgba(232, 223, 201, 0.4);
  --header-shadow: rgba(0, 0, 0, 0.5);
  --toggle-hover-bg: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] img { filter: var(--img-dark-filter); }

/* Reading inset: the text sits inside the column, split evenly (this page has no page markers). */
body {
  --inset-start: calc(var(--reading-inset) / 2);
  --inset-end: calc(var(--reading-inset) / 2);
}

/* ---- Base ---- */

* { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--header-h-actual, var(--header-height)) + var(--section-bar-height) + 0.75rem);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, var(--paper-highlight), transparent 34rem),
    repeating-linear-gradient(0deg, var(--paper-texture) 0, var(--paper-texture) 1px, transparent 1px, transparent 4px),
    var(--parchment);
  font-family: var(--font-body);
  font-size: var(--text-size);
  line-height: var(--leading);
  text-rendering: optimizeLegibility;
}

a {
  color: var(--rust);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover { color: var(--rust-light); }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 1rem;
  color: var(--on-accent);
  background: var(--rust);
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

/* ---- Masthead ---- */

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  color: var(--header-text);
  background: var(--header-bg);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 0.25rem 1rem var(--header-shadow);
}

.site-nav {
  width: min(100% - 2rem, var(--nav-width));
  min-height: var(--header-height);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-family: var(--font-display);
  font-size: var(--label-size);
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.site-nav a {
  color: inherit;
  text-decoration: none;
}

.nav-leading {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.contents-toggle,
.contents-close,
.contents-backdrop {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.contents-toggle {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--header-text);
  background: transparent;
  border-radius: 0.25rem;
  font-family: var(--font-body);
  font-size: 1.2rem;
  line-height: 1;
}

.contents-toggle:hover,
.contents-toggle[aria-expanded="true"] {
  color: var(--toggle-hover-color);
  background: var(--toggle-hover-bg);
}

.nav-brand {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.55rem;
  row-gap: 0.08rem;
  font-size: 0.86rem;
  line-height: 1.3;
}

.nav-title,
.nav-meta-group,
.top-link { white-space: nowrap; }

.nav-meta-group {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
}

.nav-separator {
  color: var(--nav-accent);
  font-size: 0.68rem;
}

.nav-meta {
  color: var(--nav-meta);
  font-size: 0.54rem;
  letter-spacing: 0.045em;
}

/* ---- Floating section bar: sticks under the masthead, names the current section ---- */

.section-bar {
  position: sticky;
  z-index: 25;
  top: var(--header-h-actual, var(--header-height));
  display: flex;
  align-items: center;
  min-height: var(--section-bar-height);
  color: var(--ink-light);
  background: var(--parchment-mid);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 0.15rem 0.4rem var(--shadow);
  font-family: var(--font-display);
  font-size: var(--label-size);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.35rem);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms, padding-left 180ms ease;
}

.section-bar.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 160ms ease, transform 160ms ease, padding-left 180ms ease;
}

.section-bar-inner {
  width: min(100% - 2 * var(--gutter), var(--measure));
  height: 100%;
  margin-inline: auto;
  padding-inline: var(--inset-start) var(--inset-end);
  display: flex;
  align-items: center;
}

main {
  min-height: 100vh;
  overflow-x: clip;
  transition: margin-left 180ms ease;
}

/* ---- Title page: fills the viewport below the masthead ---- */

.title-page {
  position: relative;
  min-height: calc(100vh - var(--header-height));
  padding: clamp(3rem, 6vw, 5rem) 1rem var(--section-gap);   /* side padding = the reading column's gutter, so the cover takes the full column */
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: space-between;
  background: var(--title-bg);
  text-align: center;
  text-indent: 0;
  --credit-gap: clamp(2.75rem, 5vw, 3.75rem);   /* the Prototype's gap between the title-page credit groups */
}

.title-page h1 {
  margin: 0;
  color: var(--title-ink);
  font-family: var(--font-title);
  font-size: var(--title-size);
  font-weight: 400;
  letter-spacing: 0.015em;
  line-height: 0.82; /* raise only for a title whose accented capital would touch the line above */
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.kicker {
  margin: clamp(1.45rem, 2.8vw, 2.2rem) 0 0;
  color: var(--title-kicker);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  line-height: 1.3;
  text-transform: uppercase;
}

.title-rule {
  width: 8rem;
  margin: clamp(2.5rem, 5vw, 4rem) 0 clamp(2.75rem, 5vw, 3.75rem);
  border-top: 1px solid var(--title-rule);
}

.cover-figure {
  width: var(--cover-width);
  max-width: var(--cover-max);
  margin: 0;
  border: var(--cover-frame) solid var(--cover-border);
}

.cover-figure img {
  display: block;
  width: 100%;
  height: auto;
  filter: sepia(0.1) contrast(1.03);
}

/* Credits: the author line sits under the rule, the other credits in .title-credits, the stamp after them. */
.title-page > .credit { margin-bottom: var(--credit-gap); }

.cover-figure + .title-credits { margin-top: var(--credit-gap); }

.title-credits {
  display: grid;
  gap: var(--credit-gap);
  align-content: start;
}

.credit {
  margin: 0;
  color: var(--title-ink);
  font-family: var(--font-display);
  line-height: 1.3;
  text-wrap: balance;
}

.credit-role {
  color: var(--title-kicker);
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.credit .credit-name {
  margin-left: 0.35em;
  font-size: clamp(1.3rem, 2.2vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Additional title-page text (version line, ornament): the role label's font, size, colour and letter spacing.
   Chinese or similar characters take the font stack, size and colour only: add .title-extra-cjk. */
.title-extra {
  margin: 0;
  color: var(--title-kicker);
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.22em;
  line-height: 1.3;
  text-transform: uppercase;
}

.title-extra-cjk {
  letter-spacing: normal;
  text-transform: none;
}

.edition {
  margin: 0.25rem 0 0;
  color: var(--rust);
  font-weight: 700;
}

.edition span { color: var(--ink); }

.library-edition {
  margin: 2.5rem 0 0;
  color: var(--ink-light);
  font-family: var(--font-display);
  font-size: var(--label-size);
  font-weight: 500;
  letter-spacing: 0.22em;
  line-height: 1.2;
  text-box: trim-end text;
  text-transform: uppercase;
}

.eyebrow {
  margin: 1rem 0 0.25rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---- Main sections: each opens with the spacing-line-spacing divider ---- */

.document-section {
  position: relative;
  width: min(100% - 2 * var(--gutter), var(--measure));
  margin-inline: auto;
  padding: var(--section-gap) var(--inset-end) var(--section-gap) var(--inset-start);
  border-top: var(--divider-width) solid var(--rule);
}

/* A section's padding is the gap the reader sees: its first and last lines are trimmed to the
   glyphs, and its first and last in-flow children lose their outer margins.  The trim sits on the
   text block itself; Chromium can skip a section-level trim when a marker is its first or last child. */
.document-section > :first-child { margin-top: 0; }

:is(.document-section, .chapter, .source-note) > :last-child {
  margin-bottom: 0;
}

.document-section > h2,
.chapter-title { text-box: trim-start text; }

:where(.document-section, .chapter) > :where(:not(.chapter, .note-box, .source-note):last-child) {
  text-box: trim-end text;
}

/* The trim is progressive enhancement.  Without text-box, these em offsets (measured for the house
   fonts) stand in for it: the heading glyphs' overhang above the line box, and the leading of a line. */
@supports not (text-box: trim-both text) {
  .document-section > h2,
  .source-note > h2 { padding-top: 0.09em; }

  .chapter-title { padding-top: 0.2em; }

  .document-section > :not(h2, .note-box):first-child {
    margin-top: -0.14em;
  }

  :is(.document-section, .chapter, .source-note) > :not(.chapter, .note-box, .source-note, table.contents):last-child {
    margin-bottom: -0.14em;
  }
}

.document-section > h2 {
  margin: 0 0 1.5rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--h2-size);
  line-height: 1.2;
  text-align: center;
}

:is(.document-section, .chapter) > p {
  margin: 0.8rem 0;
  /* Left-aligned, never justify (Captain order 2026-10-12): without
     hyphenation, justified lines before a long word stretch their word gaps. */
  text-align: left;
  text-indent: var(--para-indent);
  text-wrap: pretty;
}

/* ---- Small chapters: a lighter rule and gap between them, never the main divider ---- */

/* The rule spans the whole column; the negative margins and matching padding leave the text in place. */
.document-section > :is(.chapter, .companion) ~ :is(.chapter, .companion),
.document-section > h2 + .companion {
  margin: var(--chapter-gap) calc(-1 * var(--inset-end)) 0 calc(-1 * var(--inset-start));
  padding: var(--chapter-gap) var(--inset-end) 0 var(--inset-start);
  border-top: var(--chapter-rule);
}

.chapter-title {
  margin: 0 0 2rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: var(--chapter-title-size);
  line-height: 1;
  text-align: center;
}

.chapter-title .eyebrow { margin: 0 0.9rem 0 0; }

/* ---- Colophon: two-column label/value grid; the top rule comes from .document-section ---- */

.colophon { font-size: 0.9rem; }

.colophon dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  column-gap: 1.25rem;
  row-gap: 0.5rem;
}

.colophon dt {
  color: var(--ink-light);
  font-weight: 600;
}

.colophon dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* The grid rows have no trim of their own; trim the first and last row to their line boxes. */
.colophon :is(dt, dd):first-of-type { text-box: trim-start text; }
.colophon dd:last-of-type { text-box: trim-end text; }

@media (max-width: 560px) {
  .colophon dl {
    display: block;
  }
  .colophon dt {
    margin-top: 0.7rem;
  }
  .colophon dt:first-child {
    margin-top: 0;
  }
}

/* ---- Printed Table of Contents: the standard two-column table ---- */

/* The page's own heading element: centred, display font, regular weight. */
#table-of-contents-title {
  margin: 0 auto 1.25rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--h2-size);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

table.contents {
  margin: 0 auto;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.contents td {
  padding: 0.2rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

table.contents a {
  color: var(--rust);
  text-decoration: none;
}

table.contents a:hover { text-decoration: underline; }

/* The table's last row text sits 0.34rem (measured) above the line-box bottom a prose line is trimmed
   to; take it back so the divider after the table matches every other boundary.  The :is() copies the
   specificity of the rule above that zeroes a last child's margin, which this must outrank. */
.document-section > table.contents:last-child { margin-bottom: -0.34rem; }

/* A part or any group heading: bold cells, the part gap above. */
table.contents tr.toc-part td { padding-top: 1.8em; }
table.contents td:first-child { white-space: nowrap; }

/* A counted illustration, figure or map: its own marker, in the right column. */
table.contents tr.contents-figure td { padding-top: 0.2rem; }
table.contents tr.contents-figure a { color: inherit; }
table.contents tr.contents-figure a::before {
  content: "\2022";
  margin-right: 0.5em;
}

/* ---- Contents panel: group links ---- */

.major-links > a {
  display: block;
  color: var(--ink);
  background: var(--parchment-mid);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
}

.major-links > a:hover {
  border-color: var(--gold);
  color: var(--rust);
}

/* ---- Note boxes (optional; switched from the Contents panel) ---- */

.note-box {
  margin: 1.5rem 0 1.5rem 1.6rem;
  padding: 0.7rem 0.9rem;
  color: var(--ink-mid);
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  font-size: var(--note-size);
  line-height: var(--leading);
  text-align: left;
  text-indent: 0;
}

.note-box p { margin: 0 0 0.45rem; }
.note-box > :last-child { margin-bottom: 0; }

.note-ref {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.footnote-call {
  margin-left: 0.08em;
  color: var(--rust);
  font-size: 0.66em;
  line-height: 0;
  text-decoration: none;
  vertical-align: super;
}

.footnote-call:is(:hover, :focus-visible) { text-decoration: underline; }

body.notes-hidden .note-box,
.note-box.is-hidden { display: none; }

/* ---- Figures and tables (optional) ---- */

.source-figure {
  margin: 1.75rem auto;
  text-align: center;
}

.source-figure + .source-figure { margin-top: 3.5rem; }

.source-figure img {
  display: block;
  /* --iw and --ih are the file's own pixel size (set on each picture by the generator), so a picture that has not
     loaded yet holds the room it will fill and the page does not jump as lazy pictures arrive. */
  width: min(100%, calc(var(--iw) * 1px), calc(var(--figure-max-height) * var(--iw) / var(--ih)));
  height: auto;
  aspect-ratio: var(--iw) / var(--ih);
  max-width: 100%;
  margin-inline: auto;
  object-fit: contain;
}

.source-figure.framed img { border: var(--cover-frame) solid var(--cover-border); }

.source-figure figcaption {
  margin-top: 0.65rem;
  color: var(--ink-light);
  font-size: 0.83rem;
  font-style: italic;
}

.figure-full {
  display: block;
  cursor: zoom-in;
}

.figure-full img { transition: filter 140ms ease; }
.figure-full:is(:hover, :focus-visible) img { filter: brightness(1.04); }

/* ---- Reference: the last section; the archival-edition box follows it, with no divider between ---- */

.document-section.citations > p {
  margin: 1.1rem 0;
  padding-left: 2em;
  text-indent: -2em;
  text-align: left;
  text-wrap: pretty;
}

/* The box is Reference's closing element, so Reference has no space below it. */
.citations { padding-bottom: 0; }

.permalink { overflow-wrap: anywhere; }

/* The About box closes the page: 1.5rem under Reference's last line, the full column wide, and
   --end-space above the footer.  There is no rule above it. */
.source-note {
  position: relative;
  width: min(100% - 2 * var(--gutter), var(--measure));
  /* Captain order, 2026-11-27 ("Apply the two-line space to all the other Builds"): the Work on this Archival Edition box sits two lines of the Reference entries' line height (1.58em; same font size) below the last citation, as Scarlet Citadel.  Was 1.5rem.  Plus 0.14em, the leading the last citation's text trim removes (the @supports fallback's figure). */
  margin: calc(2 * 1.58em + 0.14em) auto var(--end-space);
  padding: var(--box-pad);
  background: var(--note-bg);
  border: 1px solid var(--rule);
  box-shadow: 0 0.8rem 2rem var(--shadow);
  text-box: trim-both text;
}

.source-note > h2 {
  margin: 0 0 1.5rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--box-title-size);
  line-height: 1.2;
  text-align: left;
}

/* ---- Footer: dark bar in both themes ---- */

.site-footer {
  padding: 2.5rem 1rem;
  color: var(--footer-text);
  background: var(--footer-bg);
  border-top: 3px solid var(--gold);
  font-size: var(--footer-size);
  text-align: center;
  text-indent: 0;
}

.site-footer p { margin: 0.2rem; }
.site-footer a { color: var(--toggle-hover-color); }

/* ---- Contents panel: docked on wide screens, an overlay on narrow ones ---- */

.contents-panel {
  position: fixed;
  z-index: 40;
  top: var(--header-h-actual, var(--header-height));
  bottom: 0;
  left: 0;
  width: min(var(--panel-width), calc(100vw - 3rem));
  padding: 1.25rem 1rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  background:
    repeating-linear-gradient(0deg, var(--paper-texture) 0, var(--paper-texture) 1px, transparent 1px, transparent 4px),
    var(--parchment);
  border-right: 1px solid var(--rule);
  box-shadow: 0.5rem 0 1.4rem var(--shadow);
  font-size: 1rem;
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 180ms ease, visibility 0s linear 180ms;
}

.contents-open .contents-panel {
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

.contents-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.contents-panel-head .eyebrow { margin-top: 0; }

.contents-panel-head h2 {
  margin: 0;
  font-size: 1.65rem;
}

.contents-close {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--ink-light);
  background: transparent;
  border-radius: 0.25rem;
  font-size: 1.6rem;
  line-height: 1;
}

.contents-close:hover {
  color: var(--rust);
  background: var(--link-hover-bg);
}

.contents-backdrop {
  position: fixed;
  z-index: 35;
  inset: var(--header-h-actual, var(--header-height)) 0 0;
  display: none;
  padding: 0;
  background: var(--backdrop-bg);
}

/* Display switches: one recessed control surface per group. */
.display-controls {
  margin: 1rem 0 1.25rem;
  padding: 0.55rem 0.7rem 0.6rem;
  background: var(--parchment-dark);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 2px 6px var(--shadow), inset 0 1px 0 var(--panel-highlight);
}

.display-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.28rem 0;
}

.display-toggle-master {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--note-border);
}

.display-toggle-child { padding-left: 0.85rem; }

.display-toggle-label {
  color: var(--ink-mid);
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.25;
  text-transform: uppercase;
}

.display-toggle-child .display-toggle-label {
  color: var(--ink-light);
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: none;
}

.display-toggle-switch,
.theme-switch-option {
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-light);
  cursor: pointer;
}

.display-toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  padding: 0.15rem;
  border: 0;
  background: none;
}

/* A child switch while the master is off: readable, not operable. */
.display-toggle-switch:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.display-toggle-track {
  display: inline-block;
  position: relative;
  width: 1.85rem;
  height: 0.85rem;
  border: 1px solid var(--note-border);
  border-radius: 0.85rem;
  transition: background-color 0.15s ease;
}

.display-toggle-track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.13rem;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--note-border);
  transform: translateY(-50%);
  transition: left 0.15s ease, background-color 0.15s ease;
}

.display-toggle-switch[aria-checked="true"] .display-toggle-track { background: var(--parchment); }

.display-toggle-switch[aria-checked="true"] .display-toggle-track::after {
  left: calc(100% - 0.68rem);
  background: var(--rust);
}

.display-toggle-state {
  min-width: 1.6rem;
  text-align: left;
}

/* Dark Mode: a three-way segmented control (System / Off / On). */
.theme-switch {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--note-border);
  border-radius: 0.85rem;
  overflow: hidden;
}

.theme-switch-option {
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--note-border);
  line-height: 1.4;
}

.theme-switch-option:first-child { border-left: 0; }

.theme-switch-option[aria-checked="true"] {
  color: var(--parchment);
  background: var(--rust);
}

.display-toggle-switch:focus-visible,
.theme-switch-option:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

.toc-heading {
  margin: 0;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
}

.toc-heading a {
  color: inherit;
  text-decoration: none;
}

.major-links {
  margin: 1.25rem 0 1.75rem;
  display: grid;
  gap: 0.55rem;
}

.major-links > a {
  padding: 0.65rem 0.75rem;
  font-size: var(--label-size);
  letter-spacing: 0.04em;
  text-align: center;
}

.major-links > .toc-group { margin-bottom: 1.1rem; }
.toc-group .toc-heading { margin-block: 1em; }

@media (min-width: 901px) {
  .contents-open main,
  .contents-open .site-footer { margin-left: var(--panel-width); }
  .contents-open .section-bar { padding-left: var(--panel-width); }
  .site-footer { transition: margin-left 180ms ease; }
}

@media screen and (max-width: 900px) {
  body.contents-open { overflow: hidden; }
  .contents-open .contents-backdrop { display: block; }
}

/* ---- Narrow screens ---- */

@media (max-width: 720px) {
  html { scroll-padding-top: calc(8rem + var(--section-bar-height)); }
  .site-nav { gap: 0.75rem; }
  .nav-brand { padding-block: 0.38rem; }
  .nav-meta { font-size: 0.5rem; }
  .title-page {
    min-height: calc(100vh - 6.5rem);
    padding: 2.75rem 1rem var(--section-gap);
  }

  .title-page h1 {
    font-size: var(--title-size-narrow);
    line-height: 0.86;
  }

  .kicker {
    max-width: 23rem;
    letter-spacing: 0.22em;
  }

  .title-rule {
    width: 6rem;
    margin-block: 2.25rem 2.5rem;
  }

  .cover-figure { width: var(--cover-width-narrow); }

  :is(.document-section, .chapter) > p {
    text-align: left;
    text-indent: var(--para-indent-narrow);
  }

  .note-box { margin-left: 0.55rem; }
  .source-note { padding: var(--box-pad-narrow); }
}

/* ---- Print: the page follows whatever the reader chose on screen ---- */

@media print {
  @page {
    size: letter;
    margin: 0.65in 0.7in;
  }

  body {
    color: var(--print-ink);
    background: var(--print-paper);
    font-size: 11pt;
  }

  main { overflow-x: visible; }

  .site-header,
  .section-bar,
  .skip-link,
  .contents-backdrop,
  .contents-toggle,
  .contents-close,
  .display-controls,
  .site-footer a[href="#top"] { display: none; }

  a {
    color: var(--print-ink);
    text-decoration: none;
  }

  .title-page {
    min-height: 8.4in;
    padding: 0.5in 0;
    background: var(--print-paper);
  }

  .cover-figure,
  .cover-figure img {
    width: auto;
    max-width: 100%;
    max-height: 4in;
  }

  .document-section {
    width: 100%;
    break-before: page;
  }

  .contents-panel {
    position: static;
    width: 100%;
    padding: 0.35in 0;
    overflow: visible;
    border-right: 0;
    box-shadow: none;
    transform: none;
    visibility: visible;
    break-before: page;
    break-after: page;
  }

  h2,
  h3,
  h4 { break-after: avoid; }

  .note-box,
  figure,
  tr { break-inside: avoid; }

  .source-note {
    background: none;
    border: 0;
    box-shadow: none;
  }

  .site-footer {
    margin-top: 0.3in;
    padding-top: 0.15in;
    color: var(--print-ink);
    background: none;
    border-top: 1px solid var(--print-rule);
  }

}

/* !important is unavoidable here: reduced motion must beat every transition, whatever its specificity.
   "none", not a 0.01ms duration: a tiny duration with the default transition-property "all"
   animates every property change on every element for one frame. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Captain's order: Map, Table, Illustration and Figure rows indented slightly, as sub-entries of their parent. */
table.contents tr.contents-figure td:last-child { padding-left: 1.6rem; }

/* ---- Table of Contents and Contents panel versions (TOC-LAYOUTS.md) ----
   Every rule below matches only a version's own classes; the default table and the default panel
   above do not use them.  A build keeps the blocks of the versions it uses and deletes the rest. */

/* Boxed group heading (every printed version): <h3 class="contents-page-part"><a href="#part">. */
.contents-page-part {
  margin: 0 0 0.75rem;
  text-align: left;
}

.contents-page-part a,
table.contents .contents-page-part a {
  display: block;
  padding: 0.6rem 0.85rem;
  color: var(--ink);
  background: var(--parchment-mid);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

.contents-page-part a:hover,
table.contents .contents-page-part a:hover {
  border-color: var(--gold);
  color: var(--rust);
  text-decoration: none;
}

/* Printed version "table", with boxed group headings: <tr class="toc-box"><td colspan="2">.
   The table then spans the column, and the label column takes --toc-label-width. */
table.contents:has(tr.toc-box, tr.toc-two-row) {
  width: 100%;
  table-layout: fixed;
}

table.contents:has(tr.toc-box) td:first-child:not([colspan]) { width: var(--toc-label-width); }
table.contents tr.toc-box td { padding: 0; }
table.contents tr.toc-box-later td { padding-top: 2rem; }
table.contents tr.toc-box + tr td { padding-top: 0.2rem; }

/* Panel version "lines": one entry a line, <ul class="panel-toc"><li><a>. */
.panel-toc,
.panel-toc ul {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.05rem;
  list-style: none;
}

.panel-toc a {
  display: block;
  padding: 0.28rem 0.3rem;
  color: var(--ink-mid);
  border-radius: 3px;
  font-size: 0.82rem;
  line-height: 1.35;
  text-decoration: none;
}

.panel-toc a:hover {
  color: var(--rust);
  background: var(--link-hover-bg);
}

.toc-group .toc-heading { text-wrap: balance; }

/* ---- Part dividers: this section's top rule and the next section's make line, heading, line ---- */

/* The heading's last line sits 1px (measured) nearer the next rule than a prose line does. */
.part-divider {
  padding-bottom: calc(var(--section-gap) + 1px);
  text-align: center;
}

.part-divider > h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 400;
  line-height: 1.25;
  text-transform: uppercase;
}

/* ======================================================================================================
   This build: Among Heroes, Lu Bu.  The kit above, plus the block kinds of this page.
   ====================================================================================================== */

/* A block that opens a short-divider block has no margin of its own above it (the rule's gap is the padding). */
.chapter > :first-child,
.companion > :first-child { margin-top: 0; }

.chapter > h3.chapter-title:first-child { text-box: trim-start text; }

/* ---- Title page ---- */
.title-credits .title-extra { text-wrap: balance; max-width: 34rem; margin-inline: auto; }
.title-credits .credit.translator { max-width: 38rem; font-size: 0.96rem; }
.title-credits .credit.translator { letter-spacing: 0.03em; }

/* ---- Headings inside a section ---- */
h3.subhead {
  margin: 2.75rem 0 1rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-wrap: balance;
}

.document-section > h3.subhead:first-child { text-box: trim-start text; }

.chapter-title.story-title {
  margin: 0 0 1.5rem;
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-wrap: balance;
  text-box: none;
}

.document-section.part-divider > h2 { text-box: trim-start text; }

/* ---- Lines of the text that are not running prose ---- */
:is(.document-section, .chapter, .companion) > p.era-line,
:is(.document-section, .chapter, .companion) > p.intro-line,
:is(.document-section, .chapter, .companion) > p.scene-break {
  text-align: center;
  text-indent: 0;
}

p.era-line {
  margin: 1.6rem 0;
  color: var(--ink-mid);
  font-family: var(--font-display);
  font-weight: 600;
}

p.intro-line {
  margin: 0.8rem 0 1.4rem;
  color: var(--ink-light);
  font-style: italic;
}

p.scene-break {
  margin: 1.6rem 0;
  font-weight: 700;
  letter-spacing: 0.3em;
}

/* Verse: lines kept as lines; indent layers in equal steps; a wrapped line hangs under its own start. */
:is(.document-section, .chapter) > p.verse {
  margin: 1.5rem 0 1.5rem 2rem;
  font-size: 0.96em;
  font-style: italic;
  text-align: left;
  text-indent: 0;
}

@supports (text-indent: -1.5em each-line) {
  :is(.document-section, .chapter) > p.verse {
    padding-left: 1.5em;
    text-indent: -1.5em each-line;
  }
}

p.verse [class^="verse-indent-"] { display: inline-block; }
.verse-indent-1 { padding-left: 1.5em; }
.verse-indent-2 { padding-left: 3em; }
.verse-indent-3 { padding-left: 4.5em; }
.verse-indent-4 { padding-left: 6em; }

blockquote.quotation,
blockquote.epigraph { margin: 1.6rem 0 1.6rem 2rem; }

blockquote p { margin: 0.6rem 0; text-indent: 0; }
blockquote p.quote-text { font-style: italic; }
blockquote p.quote-attribution { margin-top: 0.2rem; font-style: italic; text-align: right; }

ul.bullet-list { margin: 0.8rem 0; padding-left: 2.5rem; }

/* ---- Ornaments: the aL mark and the pencil rule.  White-ground files, so the page shows through. ---- */
.ornament {
  margin: 0 0 1.5rem;
  text-align: center;
}

.ornament img {
  display: inline-block;
  max-width: 7rem;
  height: auto;
  mix-blend-mode: multiply;
}

.ornament:has(img[width="648"]) img { max-width: min(100%, 24rem); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ornament img { filter: invert(1); mix-blend-mode: screen; opacity: 0.85; }
}

:root[data-theme="dark"] .ornament img { filter: invert(1); mix-blend-mode: screen; opacity: 0.85; }

/* ---- Front matter ---- */
.copyright-page { font-size: 0.95rem; }
.copyright-page > p { text-indent: 0; }
.copyright-page > p.list-label { margin: 1.2rem 0 0.3rem; font-weight: 600; letter-spacing: 0.05em; }
.copyright-page ul.keyword-list { margin: 0 0 0.8rem; padding-left: 2rem; }
.epigraph-section > blockquote.epigraph { margin-left: 0; margin-right: 0; }

/* ---- Pictures ---- */
.source-figure figcaption { text-align: center; text-indent: 0; }
.source-figure.story-banner { margin: 0 auto 1.5rem; }
/* Captain 2026-11-21 ("Yes, fix captions"): the banner captions carry full text since CAP-004, so they take the same caption style
   as every other illustration and map (.source-figure figcaption); the label-only small upper-case style is retired. */
.source-figure.front-map img,
.source-figure.map-captioned img,
.source-figure.chapter-map-figure img { width: min(100%, calc(var(--iw) * 1px)); }

.figure-pair {
  margin: 1.75rem 0;
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  justify-content: center;
}

.figure-pair > .source-figure { flex: 1 1 0; min-width: 0; margin: 0; }

@media (max-width: 560px) {
  .figure-pair { flex-direction: column; align-items: stretch; }
  .figure-pair > .source-figure + .source-figure { margin-top: 1.75rem; }
}

/* ---- Commentary boxes (author commentary; publication text) ---- */
.note-box.commentary {
  margin: 1.75rem 0 1.75rem 1.6rem;
  padding: 1.1rem 1.1rem;
  text-box: trim-both text;
}

.note-box.commentary > p { margin: 0 0 0.6rem; }
.note-box.commentary > :last-child { margin-bottom: 0; }

.note-box.commentary h4.commentary-title {
  margin: 0 0 0.7rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
}

/* ---- Review essays (the editor's titled articles; publication text): a sheet of their own, not a commentary box ----
   aside.note-box.review-essay[data-note-group="review"] > h4.review-title > span.editorial ("Review N: ") + the title.
   One step off the page (lighter in light mode, lighter in dark), a hairline frame with a double rule at the head,
   equal inner padding; switched by its own Contents-panel toggle. */
.note-box.review-essay {
  margin: 2.25rem 0;
  padding: 1.6rem;
  color: var(--ink);
  background: var(--review-bg);
  border: 1px solid var(--rule);
  border-top: 3px double var(--rule);
  box-shadow: 0 1px 4px var(--shadow);
  font-size: 0.92rem;
  text-box: trim-both text;
}

.note-box.review-essay > p { margin: 0 0 0.7rem; text-wrap: pretty; }
.note-box.review-essay > :last-child { margin-bottom: 0; }

.note-box.review-essay h4.review-title {
  margin: 0 0 1.1rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.review-title > .editorial {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--title-kicker);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .note-box.review-essay { padding: 1.1rem; }
}

/* Printed Table of Contents: the Review essays and the chapters' companion sections are sub-entries, set like the
   Map and Illustration rows (a bullet, indented under their chapter). */
table.contents tr.contents-sub td { padding-top: 0.2rem; }
table.contents tr.contents-sub td:last-child { padding-left: calc(1.6rem + 0.9em); text-indent: -0.9em; }
table.contents tr.contents-sub a { color: inherit; }
table.contents tr.contents-sub a::before {
  content: "\2022";
  margin-right: 0.5em;
}
table.contents .contents-label { font-weight: 600; }
/* Captain 2026-11-14: "let's make an exception.  Use the rust color on the chapter name in the TOC." */
table.contents tr:has(> td:first-child > a[href^="#chapter-"]) > td:last-child { color: var(--rust); }
/* Captain 2026-11-14: section titles before "Among Heroes, Lu Bu" and under the Appendices in uppercase (not the sub-entries). */
table.contents tr:not([class]):has(~ tr.toc-box a[href="#work-part"]) > td:last-child,
table.contents tr.toc-box:has(a[href="#appendices-part"]) ~ tr:not([class]) > td:last-child { text-transform: uppercase; }

/* A chapter heading followed by its first companion section: the heading's last line is trimmed to its glyphs, so the
   short divider below it keeps the same gap as every other short divider. */
.document-section > h2:has(+ .companion) { text-box: trim-both text; }

/* A chapter's opening text starts with the era line: trimmed to its glyphs like the heading that opens a story, so the short
   divider above it keeps the same gap as every other short divider. */
.chapter-opening > p.era-line:first-child { text-box: trim-start text; }
.chapter-opening > p.era-line:first-child:last-child { text-box: trim-both text; }   /* an opening that is only the era line is also its own last block */
/* Captain 2026-11-21: an era line with no opening text leads into the chapter's first story, as Chapter 1's leads into its text. */
.chapter.story > p.era-line:first-child { text-box: trim-start text; }
/* Captain 2026-11-21: "add 2.5 times the space between the "In the Era..." line and the start of the text", all chapters.
   The seen gap was about 30 px (1.6rem margin plus the line spacing); 4.4rem makes it about 75 px. */
:is(.chapter-opening, .chapter.story) > p.era-line { margin-bottom: 4.4rem; }
/* Captain 2026-11-21: the Epilogue's opening is an era line too ("Consider it an era line"), with the same space below it. */
#epilogue > p.era-line { margin-bottom: 4.4rem; }

/* ---- Companion sections: the cast roll, the chronology, the chapter map ----
   Hooks: section.companion.dramatis-personae > div.cast-group > h4.cast-group-title + ul.cast-list > li.cast-entry > strong.cast-name + span.cast-desc
          section.companion.timeline > ol.timeline > li.timeline-period[.decade-start] > h4.timeline-date + ul.timeline-events > li.timeline-event[.timeline-battle]
          section.companion.chapter-map > figure.source-figure.chapter-map-figure
          the two general appendices carry the same classes on a section.document-section (with .general).
   Not boxes: each companion opens like a title card (heading, intro line, a short double rule) and is laid out with
   type, hairlines and one mark per kind -- a seal for each faction, a rail for time. */
.companion > h3.companion-title { margin: 0 0 0.6rem; text-box: trim-start text; }

.companion > p.intro-line { margin-bottom: 2.2rem; }

.companion > p.intro-line::after {
  content: "";
  display: block;
  width: 4.5rem;
  height: 4px;
  margin: 0.95rem auto 0;
  border-block: 1px solid var(--title-rule);
}

.companion > p.intro-line + :is(.cast-group, ol.timeline) { margin-top: 0; }

ul.cast-list,
ol.timeline,
ul.timeline-events {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Dramatis personae: a cast roll.  A faction is a band (a seal, its name as a kicker, a hairline to the margin); a player
   is a row, the name in a hanging column and the description beside it, stacked on a phone.  Nothing is cut short. */
.cast-group { margin: 2.75rem 0 0; }

.cast-group-title {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 0.3rem;
  color: var(--title-kicker);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  line-height: 1.3;
  text-transform: uppercase;
}

.cast-group-title::before {
  content: "";
  flex: none;
  width: 0.78rem;
  height: 0.78rem;
  background: var(--rust);
  border: 1px solid var(--rust);
  box-shadow: inset 0 0 0 1px var(--parchment);
  transform: rotate(-3deg);
}

.cast-group-title::after {
  content: "";
  flex: 1 1 0;
  min-width: 1.5rem;
  border-top: 1px solid var(--rule);
}

.cast-entry {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  column-gap: 1.75rem;
  align-items: baseline;
  margin: 0;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 0.9em;
  line-height: 1.55;
}

.cast-entry:last-child { padding-bottom: 0; border-bottom: 0; }

.cast-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.06em;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

@media (min-width: 561px) {
  .cast-name {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
  }

  .cast-name::after {
    content: "";
    flex: 1 1 0;
    min-width: 1rem;
    border-bottom: 2px dotted var(--rule);
  }
}

.cast-desc {
  color: var(--ink-mid);
  text-wrap: pretty;
}

/* Timelines: a chronology on a rail.  Each date is a ring on the rail (filled where a new decade begins), its events hang
   off the rail on ticks, a battle's tick ends in a crossed mark.  On a wide screen the date column holds the date in view
   while its events scroll past. */
ol.timeline {
  --tl-date: 8.5rem;
  --tl-lane: 3.2rem;
  --tl-axis: calc(var(--tl-date) + var(--tl-lane) / 2);
  --tl-tick: 0.85rem;
  position: relative;
}

ol.timeline::before {
  content: "";
  position: absolute;
  top: 0.4rem;
  bottom: 0;
  left: calc(var(--tl-axis) - 1px);
  width: 2px;
  background: linear-gradient(to bottom, var(--rail), var(--rail) calc(100% - 3rem), transparent);
}

.timeline-period {
  display: grid;
  grid-template-columns: var(--tl-date) var(--tl-lane) minmax(0, 1fr);
  margin: 1.6rem 0 0;
}

.timeline-period:first-child { margin-top: 0; }
.timeline-period.decade-start { margin-top: 2.6rem; }

.timeline-date {
  position: sticky;
  top: calc(var(--header-h-actual, var(--header-height)) + var(--section-bar-height) + 1rem);
  z-index: 1;
  grid-column: 1;
  grid-row: 1;
  align-self: start;
  margin: 0;
  padding-top: 0.2rem;
  color: var(--rust);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-align: right;
}

.timeline-date::after {
  content: "";
  position: absolute;
  top: 0.4rem;
  right: calc(-0.5 * var(--tl-lane) - 0.42rem);
  width: 0.84rem;
  height: 0.84rem;
  background: var(--parchment);
  border: 2px solid var(--rust);
  border-radius: 50%;
}

.decade-start > .timeline-date::after {
  background: var(--rust);
  box-shadow: 0 0 0 3px var(--parchment);
}

ul.timeline-events {
  grid-column: 3;
  grid-row: 1;
}

.timeline-event {
  position: relative;
  margin: 0 0 0.8rem;
  font-size: 0.9em;
  line-height: 1.55;
  text-wrap: pretty;
}

.timeline-event::before {
  content: "";
  position: absolute;
  top: 0.77em;
  left: calc(-0.5 * var(--tl-lane));
  width: var(--tl-tick);
  border-top: 1px solid var(--rail);
}

.timeline-event.timeline-battle::after {
  content: "";
  position: absolute;
  top: calc(0.77em - 0.36rem);
  left: calc(-0.5 * var(--tl-lane) + var(--tl-tick) - 0.3rem);
  width: 0.72rem;
  height: 0.72rem;
  background:
    linear-gradient(var(--rust), var(--rust)) center / 100% 1.8px no-repeat,
    linear-gradient(var(--rust), var(--rust)) center / 1.8px 100% no-repeat;
  transform: rotate(45deg);
}

@media (max-width: 560px) {
  .cast-entry {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0.15rem;
  }

  ol.timeline {
    --tl-lane: 2.3rem;
    --tl-axis: calc(var(--tl-lane) / 2);
    --tl-tick: 0.5rem;
  }

  .timeline-period { grid-template-columns: var(--tl-lane) minmax(0, 1fr); }

  .timeline-date {
    position: relative;
    top: auto;
    grid-column: 2;
    margin: 0 0 0.35rem;
    text-align: left;
  }

  .timeline-date::after { right: auto; left: calc(-0.5 * var(--tl-lane) - 0.42rem); }

  ul.timeline-events {
    grid-column: 2;
    grid-row: 2;
  }
}

/* The section's padding is the gap: the last line of a companion is trimmed to its glyphs, inside the roll or the rail. */
.companion > .cast-group:last-child .cast-entry:last-child > *,
.companion > ol.timeline:last-child > li:last-child > .timeline-date,
.companion > ol.timeline:last-child > li:last-child .timeline-event:last-child { text-box: trim-end text; }

.companion.chapter-map > .source-figure { margin-bottom: 0; }
.document-section.companion > p.intro-line { margin-top: 0; }

@media print {
  ol.timeline::before,
  .timeline-date::after,
  .timeline-event::before,
  .timeline-event::after,
  .cast-group-title::before { display: none; }

  .timeline-period { display: block; }
  .timeline-date { position: static; margin-bottom: 0.3rem; text-align: left; }
  .cast-entry,
  .timeline-event { break-inside: avoid; }
  .cast-group-title,
  .cast-name,
  .cast-desc,
  .timeline-date { color: var(--print-ink); }
}

/* ---- Reference ---- */
.citations > p.intro-line { padding-left: 0; text-indent: 0; text-align: center; }
.ref-key { font-weight: 700; }

/* ---- Printed Table of Contents: long lists ---- */
table.contents td:last-child { overflow-wrap: anywhere; }

/* Long web addresses (the Basic's Reference links carry no .permalink class) wrap instead of widening the page. */
main a { overflow-wrap: anywhere; }

/* The masthead's subtitle group is longer than the kit's example: below 480px it may wrap inside the column. */
@media (max-width: 480px) {
  .nav-meta-group { min-width: 0; max-width: 100%; white-space: normal; }
}

/* A block that closes a section or a short-divider block has no margin below it: the padding is the gap the reader sees. */
:is(.document-section, .chapter, .companion) > :is(p, blockquote, figure, aside, div, ul, ol):last-child { margin-bottom: 0; }
:is(blockquote, .cast-group, .timeline-period, .note-box.commentary) > :last-child { margin-bottom: 0; }
.cast-group > ul > li:last-child,
.timeline-period > ul > li:last-child { margin-bottom: 0; }
.timeline > li:last-child { margin-bottom: 0; }

/* The kit trims a section's last line to its line box (so the padding is the gap); a companion section is trimmed the same way. */
.companion > :last-child { text-box: trim-end text; }

/* ---- Picture viewer (Captain 2026-11-22): a map or an illustration opens at full resolution in a pop-up box ---- */
.picture-viewer {
  width: min(96vw, 1600px);
  max-width: 96vw;
  height: 92vh;
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--parchment);
  color: var(--ink);
  box-shadow: 0 12px 40px var(--shadow);
  overflow: hidden;
}
.picture-viewer[open] { display: flex; flex-direction: column; }
.picture-viewer::backdrop { background: rgba(10, 8, 6, 0.72); }
.picture-viewer-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  background: var(--header-bg);
  color: var(--header-text);
}
.picture-viewer-title { flex: 1; font-variant-caps: small-caps; letter-spacing: 0.04em; }
.picture-viewer-open { color: var(--nav-accent); font-size: 0.85rem; }
.picture-viewer-close {
  border: 0;
  background: transparent;
  color: var(--header-text);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}
.picture-viewer-close:is(:hover, :focus-visible) { color: var(--toggle-hover-color); }
.picture-viewer-scroll { flex: 1; overflow: auto; display: grid; place-items: center; }
/* the full-resolution picture, at its own pixels; never dimmed by the dark theme */
:root .picture-viewer img.picture-viewer-image { display: block; max-width: none; height: auto; filter: none; margin: auto; }
