/* anon-derga-hostel-stokes.css -- stylesheet for the Finished HTML of The Destruction of Da Derga's Hostel.
   Started from the Finished stylesheet of the sibling build Anon-Song-Roland-O'Hagan (the house layout) and
   owned by this build from then on: a real file, edited directly; the build script only hashes it, for the
   ?v= on the <link>.  The kit's page-marker and figure/table blocks are not here (no PDF source, no figures
   or tables); the rules for stanza numbers and Part headings are not here either (this text has neither).
   The room headings, the prose note boxes, the verse blockquotes and the closing formula are this build's own.
   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;
  --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);
  --toc-hover-bg: rgba(132, 39, 39, 0.06);
  --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);
  /* Narrow title: this build's longest title word, DESTRUCTION, is 11 capitals; 12vw keeps it whole from 320 up
     (the kit's 14vw breaks it at 420). */
  --title-size-narrow: clamp(2rem, 9.5vw, 3.6rem);
  --h2-size: clamp(1.7rem, 4vw, 2.6rem);
  --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 on both sides (this edition has no page markers).  The verse indent is the Basic page's. */
  --measure: 52rem;
  --verse-indent: 2rem;
  --gutter: 1rem;
  --reading-inset: 3.25rem;
  --nav-width: 76rem;
  --panel-width: 16rem;
  --header-height: 3.55rem;
  --section-bar-height: 2.15rem;
  --cover-width: min(47rem, 76vw);
  --cover-max: 70%;
  --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; }
}

/* The Basic page's narrow verse indent (560px and under). */
@media (max-width: 560px) {
  :root { --verse-indent: 1rem; }
}

/* 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;
    --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);
    --toc-hover-bg: rgba(224, 120, 95, 0.14);
    --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;
  --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);
  --toc-hover-bg: rgba(224, 120, 95, 0.14);
  --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: even on both sides. */
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 {
  flex-shrink: 0;
  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-title { text-wrap: balance; }

.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(4rem, 13vh, 9rem) 1.5rem var(--section-gap);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr auto;
  justify-items: center;
  background: var(--title-bg);
  text-align: center;
  text-indent: 0;
}

.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: 1.2;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  text-wrap: balance;
}

/* The name Da Derga's is one unit: it never splits across lines (inline markup; the letters are unchanged). */
.name-unit { white-space: nowrap; }

.kicker {
  margin: clamp(1.45rem, 2.8vw, 2.2rem) 0 0;
  color: var(--title-kicker);
  font-family: var(--font-title);
  font-size: clamp(0.74rem, 1.2vw, 1rem);
  letter-spacing: 0.34em;
  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);
}

/* The title page's credits: one line each, well apart, the role small and the name large; the imprint stands
   at the foot of the page, as on a printed title page. */
.title-credits {
  display: grid;
  gap: clamp(1.75rem, 4vh, 2.75rem);
  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 strong {
  margin-left: 0.35em;
  font-size: clamp(1.3rem, 2.2vw, 1.75rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.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:not(.source-page-origin),
.document-section > .source-page-origin:first-child + * { margin-top: 0; }

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

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

:where(.document-section, .chapter) > :where(:not(.source-page-origin, .chapter, .note-box, .source-note, .table-scroll):is(:last-child, :has(+ .source-page-origin: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(.source-page-origin, h2, .note-box, .table-scroll):is(:first-child, .source-page-origin:first-child + *) {
    margin-top: -0.14em;
  }

  :is(.document-section, .chapter, .source-note) > :not(.source-page-origin, .chapter, .note-box, .source-note, .table-scroll, .contents-page):is(:last-child, :has(+ .source-page-origin: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. */
.chapter ~ .chapter {
  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;
  }
}

/* ---- In-page Contents ---- */

.contents-page { margin-top: 1.75rem; }

.contents-page-group + .contents-page-group { margin-top: 2rem; }

.contents-page-part {
  margin: 0 0 0.75rem;
  text-align: left;
}

.contents-page-part a,
.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;
}

.contents-page-part a {
  padding: 0.6rem 0.85rem;
  font-size: 0.76rem;
  letter-spacing: 0.05em;
}

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

.contents-page-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents-page-list li + li { margin-top: 0.15rem; }

/* Captain order, Review 1: every entry of the printed Contents is one font, one size and one weight,
   in capitals, at every nesting level.  The entries are typed as in the Basic HTML; the capitals
   come from here. */
.contents-page-list a {
  display: block;
  padding: 0.32rem 0.4rem;
  color: var(--ink-mid);
  border-radius: 3px;
  font-family: var(--font-body);
  font-size: 0.94rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-decoration: none;
  text-transform: uppercase;
}

.contents-page-list a[href="#work-title"] { text-wrap: balance; }

.contents-page-list ul {
  margin: 0.15rem 0 0;
  padding: 0 0 0 1.5rem;
  list-style: none;
}

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

/* Counted illustrations, figures, maps and tables, listed under the section
   that holds them, take a dot (Captain order 2026-10-12). */
.contents-page-illustration > a::before {
  content: "\2022";
  margin-right: 0.5em;
}

/* A chapter's counted entries sit in a sublist inside the chapter's own <li>,
   so `.two-col li { break-inside: avoid }` keeps the group in one column. */
.contents-page-sublist {
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
}

/* The section's last ink is this label, not its click padding. */
.contents-page-list > li:last-child li:last-child a { padding-bottom: 0; }

/* The Table of Contents, set as the standard two-column table (the pattern of the Clausewitz build's Contents). */
#contents-page-title {
  margin: 0 auto 1.25rem;
  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-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;
}

table.contents tr.toc-part td {
  padding-top: 1.8em;
}
table.contents td:first-child { white-space: nowrap; }

/* Analects-style group boxes around the Clausewitz label/title table. */
#contents-page table.contents {
  width: 100%;
  table-layout: fixed;
}

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; }
table.contents td:first-child:not([colspan]) { width: 3.5rem; }

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;
}

/* Captain order, 2026-11-26: a boxed group title wraps inside its box when the column is narrow (the table cells are nowrap); a .name-unit stays together. */
table.contents .contents-page-part a {
  white-space: normal;
}
table.contents .contents-page-part a:hover {
  border-color: var(--gold);
  color: var(--rust);
  text-decoration: none;
}

/* Clausewitz/Analects part dividers: this section's top rule and the next
   document section's top rule produce line, heading, line. */
.part-divider {
  padding-top: calc(var(--section-gap) - 2px);
  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;
}

/* The boundary after the table: table-row text sits 5.44px higher than body prose in its line box, which
   left this gap 5.44px over the other dividers' (measured with audit_divider_rhythm.py, 1280 and 420). */
#contents-page { padding-bottom: calc(var(--section-gap) - 5.44px); }

.contents-page-list.two-col { columns: 2; column-gap: 2rem; }
.contents-page-list.two-col li { break-inside: avoid; }

/* ---- 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;
}

.source-footnote-call {
  margin-left: 0.08em;
  font-size: 0.66em;
  line-height: 0;
  vertical-align: super;
}

.source-footnote-call a {
  color: var(--rust);
  text-decoration: none;
}

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

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

/* With note boxes hidden (all, or one kind) the boxes are display:none but may still be a section's last children, so the :last-child
   rules above would miss the paragraph before them.  The last element that is not a hidden box takes the same margin and trim,
   so the gap above a divider is the same in every state.  With nothing hidden the last element not hidden is the last child. */
body.notes-hidden .document-section > :not(.source-page-origin, .note-box):not(:has(~ :not(.note-box))) { margin-bottom: 0; }

body.notes-hidden .document-section > :not(.source-page-origin, .chapter, .note-box, .source-note, .table-scroll):not(:has(~ :not(.note-box))) {
  text-box: trim-end text;
}

.document-section > :not(.source-page-origin, .note-box.is-hidden):not(:has(~ :not(.note-box.is-hidden))) { margin-bottom: 0; }

:where(.document-section) > :where(:not(.source-page-origin, .chapter, .note-box, .source-note, .table-scroll):not(:has(~ :not(.note-box.is-hidden)))) {
  text-box: trim-end text;
}

/* Call mark AL 1 (editorial) goes with note AL 1. */
body.notes-hidden a.footnote-call[href="#al-note-1"],
body.al-notes-hidden a.footnote-call[href="#al-note-1"] { display: none; }

/* ---- The tale: the Introductory Note's heading, the room headings, the verse and the closing formula ---- */

/* A section heading in italics (the Introductory Note's, as the source prints it) is set upright, so
   every section heading has one treatment; the italic tag stays in the text. */
.document-section > h2 i { font-style: normal; }

/* The Introductory Note's heading is typed in capitals in the source and shown in title case (Captain order):
   the source's letters stay in the markup, and this rule sets the case of each word. */
.title-case-word {
  display: inline-block;
  text-transform: lowercase;
}

.title-case-word::first-letter { text-transform: uppercase; }

#introductory-note-title { text-wrap: balance; }

/* The Introductory Note's body is italic in the source and regular here (Captain order): the <i> tags stay in
   the markup, this rule sets them upright.  Only the Introductory Note is touched; the <i> in the tale
   (cumals, not) keep the source's italic. */
.introductory-note i { font-style: normal; }

/* Each room is a main section of its own (a section.document-section.room): it opens with the divider and the
   section gap like every other, and its heading is its first line.  An anchor to the heading lands the
   section's rule under the masthead.  The room headings are set as the Sunzi build's chapter headings
   (Captain order, as the sibling build's scene headings): display face, 1.5em, bold, centred, body leading.
   The balance keeps the long headings (the room of Munremar son of Gerrchenn ...) from ending on a lone word. */
.room-heading {
  margin: 0 0 2.5rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.5em;
  font-weight: 700;
  text-align: center;
  text-wrap: balance;
}

.document-section > .room-heading {
  text-box: trim-start text;
  scroll-margin-top: calc(var(--section-gap) + var(--divider-width));
}

/* The tale's own title anchors the same way: its section's rule lands under the masthead and section bar. */
#work-title {
  scroll-margin-top: calc(var(--section-gap) + var(--divider-width));
  text-wrap: balance;
}

/* A call-mark jump lands on the note's paragraph; the margin leaves room above it for the note's label and padding. */
.note-box > .footnote { scroll-margin-top: 2.5rem; }

/* The closing formula is the last line of the last room, centred. */
.closing-formula {
  margin: 2rem 0 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.05em;
  font-weight: 700;
  text-align: center;
  text-indent: 0;
}

/* The source's two verse passages: each line is its own line, never re-flowed into the next; a stanza is the
   lines between blank lines.  The Basic page's layout in the house type: a block at the verse indent, a line
   that wraps continues 1.5em in from its own start, and the 13 lines the source indents start 1em in. */
blockquote.verse {
  margin: 0.8rem 0 0.8rem var(--verse-indent);
  text-align: left;
  text-indent: 0;
}

blockquote.verse .stanza { margin: 0 0 0.8rem; }
blockquote.verse .stanza:last-child { margin-bottom: 0; }

.verse-line {
  padding-left: 1.5em;
  text-indent: -1.5em;
}

.verse-line.indent-1 { padding-left: 2.5em; }

/* The footnote call keeps its text, "[3]", and is set as a raised mark, as the Prototype's call marks are; its
   note box follows the paragraph, in the Prototype's prose-note position (the default .note-box). */
a.footnote-call {
  margin-left: 0.08em;
  color: var(--rust);
  font-size: 0.66em;
  line-height: 0;
  text-decoration: none;
  vertical-align: super;
}

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

/* ---- 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; }
.foot-unit { white-space: nowrap; }
.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; text-wrap: balance; }

/* The Contents panel's list of the 40 rooms, set as the sibling build's panel sets its scene entries, which are
   set as Sunzi's panel sets its chapters (Sun-Art-of-War-Giles-Sutton, sunzi-war.css `.chapter-links a`, read-only;
   values measured in the browser): plain entries, no indent and no hanging.  This text has no Parts, so the list
   is the rooms alone, directly under the title heading, with the same 0.05rem gap between entries. */
.panel-toc {
  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(--toc-hover-bg);
}

@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: 4rem 1rem var(--section-gap);
  }

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

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

  .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);
  }

  .contents-page-list.two-col { columns: 1; }
  .note-box { margin-left: 0.55rem; }
  .source-note { padding: var(--box-pad-narrow); }
}

/* The masthead title of this build (The Destruction of Da Derga's Hostel, about 320px wide in the masthead face)
   no longer fits beside the menu button and the Top link below 480px, so it may wrap there. */
@media (max-width: 480px) {
  .nav-title { white-space: normal; }
}

/* ---- 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;
  }

  .document-section.room { break-before: auto; }

  .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;
  }
}
