/* sunzi-war.css -- Finished HTML stage (PIPE 3).
   House style (palette, panel chrome, toggle mechanism, page furniture)
   follows the Analects/Daodejing prototypes' shared design tokens.
   No PDF source for this build: no --source-rail gutter is reserved and
   no source-page-origin markers exist to style. The Part divisions and
   the Part 2 verse indentation ladder are this edition's own, re-themed
   into this palette and type scale rather than replaced. */

:root {
  --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);
  /* Formerly hard-coded outside the token set (14 values, Captain-ordered
     dark-mode audit): each is used at least once below and now lives here
     so a theme switch can retarget it. Names describe role, not the light
     value, since dark mode gives each a different value. */
  --paper-highlight: rgba(255, 255, 255, 0.82);
  --paper-texture: rgba(83, 64, 32, 0.018);
  --on-accent: white;
  --header-text: #f8f1df;
  --header-bg: rgba(32, 27, 20, 0.97);
  --header-shadow: rgba(0, 0, 0, 0.2);
  --toggle-hover-color: #e3c46b;
  --footer-text: #eee3ca;
  --footer-bg: #241f18;
  --toggle-hover-bg: rgba(255, 255, 255, 0.08);
  --nav-separator: #d7b85b;
  --nav-meta: rgba(248, 241, 223, 0.82);
  --link-hover-bg: rgba(132, 39, 39, 0.06);
  --link-hover-bg-strong: rgba(132, 39, 39, 0.07);
  --backdrop-bg: rgba(22, 18, 14, 0.42);
  --panel-highlight: rgba(255, 255, 255, 0.28);
  --contents-panel-width: 16rem;
  --header-height: 3.55rem;
  --section-bar-height: 2.15rem;
  --body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Noto Serif CJK TC", Georgia, serif;
  --display: "Palatino Linotype", "Book Antiqua", "Noto Serif CJK TC", Georgia, serif;
  /* Our own verse-ladder unit (Basic HTML, PIPE 1/2), re-themed to rem
     so it still lands every layer at the same absolute offset
     regardless of a paragraph's local font-size -- see
     build_basic_html.py's own reasoning for this, unchanged here. */
  --indent-unit: 1.5rem;
  /* Prototype paddings below reference --source-rail (their PDF
     page-marker gutter). This build has no PDF source, so it is
     zero -- carried as a token, not hand-omitted, so the rule
     stays copy-identical to the prototype's; zero means no
     visible gutter. */
  --source-rail: 0rem;
  /* Frame around the title plate. Black in light, as Daodejing has it; a
     warm light tone in dark, so the frame stays visible instead of going
     black on black. */
  --cover-border: rgb(0, 0, 0);
  color-scheme: light;
}

/* ---- Dark mode (Captain-ordered) -----------------------------------------
   Two paths reach the same palette: the System path follows the OS via
   prefers-color-scheme, suppressed when the reader has explicitly chosen
   Off (:root[data-theme="light"]); the explicit On path is
   :root[data-theme="dark"] and always wins regardless of the OS setting.
   A parchment-and-ink edition in the dark reads as ink-on-dark-paper --
   warm, not a generic inverted website -- so hue is kept close to the
   light values; only lightness/direction flips. Rust and gold are
   brightened (not merely lightened) to clear 4.5:1 against the dark
   paper while still reading as the same two accent colours. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --cover-border: rgba(232, 223, 201, 0.4);
    --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);
    --header-shadow: rgba(0, 0, 0, 0.5);
    --toggle-hover-bg: rgba(255, 255, 255, 0.12);
    --link-hover-bg: rgba(224, 120, 95, 0.14);
    --link-hover-bg-strong: rgba(224, 120, 95, 0.18);
    --backdrop-bg: rgba(0, 0, 0, 0.6);
    --panel-highlight: rgba(255, 255, 255, 0.06);
    --on-accent: #1b1712;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --cover-border: rgba(232, 223, 201, 0.4);
  --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);
  --header-shadow: rgba(0, 0, 0, 0.5);
  --toggle-hover-bg: rgba(255, 255, 255, 0.12);
  --link-hover-bg: rgba(224, 120, 95, 0.14);
  --link-hover-bg-strong: rgba(224, 120, 95, 0.18);
  --backdrop-bg: rgba(0, 0, 0, 0.6);
  --panel-highlight: rgba(255, 255, 255, 0.06);
  --on-accent: #1b1712;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* Title plate on the front matter. Sized so it never upscales past the
   image's own 640px width, and never wider than 70% of the column.
   The frame sits on the figure; the credit lives in the colophon. */
.cover-figure {
  width: min(40rem, 76vw);
  max-width: 70%;
  margin: clamp(1.75rem, 4vw, 2.75rem) auto 0;
  padding: 0;
  background: transparent;
  border: 5px solid var(--cover-border);
  box-shadow: none;
}

.cover-figure img {
  display: block;
  width: 100%;
  height: auto;
}

/* Preserved artefacts: image files themselves are never touched. Dark
   mode only dims them slightly so a bright scan does not glare on a
   dark page. This edition currently has no in-page <img>, so the rule
   presently matches nothing -- it is here for anything added later. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img {
    filter: brightness(0.85);
  }
}

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

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: auto;
  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(--body);
  font-size: clamp(1.06rem, 0.98rem + 0.24vw, 1.24rem);
  line-height: 1.58;
  text-rendering: optimizeLegibility;
}

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

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

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

/* ---- Header / nav ------------------------------------------------------ */
.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);
}

/* Floating section-title bar (CAP-011): a second, slimmer sticky strip
   directly beneath .site-header, showing the current section's title as
   the reader scrolls. Reserves its height at all times so the reading
   column never jumps when it fills in; only its own opacity/visibility
   toggle when a section is known. */
.section-bar {
  position: sticky;
  z-index: 25;
  /* the measured header height, set by script; the token is the fallback */
  top: var(--header-h-actual, var(--header-height));
  display: flex;
  align-items: center;
  min-height: var(--section-bar-height);
  padding: 0;
  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(--display);
  font-size: 0.72rem;
  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;
}

/* Inner wrapper mirrors .reading-shell's own width/centring rule (below)
   so the title's left edge tracks the running text column's left edge at
   every viewport and Contents-panel state. The bar's background stays
   full-bleed; only this wrapper -- and the text inside it -- is inset. */
.section-bar-inner {
  max-width: 52rem;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.section-bar-part:not(:empty) {
  color: var(--rust);
}

.section-bar-part:not(:empty)::after {
  content: "\00B7";
  margin: 0 0.5em;
  color: var(--gold);
}

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

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

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

.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(--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 {
  white-space: nowrap;
}

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

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

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

.top-link {
  white-space: nowrap;
}

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

/* ---- Contents panel ------------------------------------------------------ */
.contents-panel {
  position: fixed;
  z-index: 40;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  width: min(var(--contents-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);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 180ms ease, visibility 0s linear 180ms;
}

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

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

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

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

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

/* The Part entries used to appear twice: once as a boxed quick-link in
   a now-removed .major-links block, once as each toc-group's plain-text
   heading. The Captain's ruling: keep the box, drop the duplicate --
   each group's own <h3><a> IS that boxed Part link now, doing double
   duty as a real heading (kept for aria-labelledby/screen-reader
   structure) and as the link. .major-links itself, and the CSS that
   styled only it, are gone -- nothing else used that class. */
.toc-columns {
  display: grid;
  gap: 1.75rem;
}

.toc-group h3 {
  margin: 0 0 0.75rem;
}

.toc-group h3 a {
  display: block;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: var(--parchment-mid);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.toc-group h3 a:hover {
  border-color: var(--gold);
  color: var(--rust);
}

/* Captain-ordered 2026-09-13, both editions: "End of Document" (and, per
   the same order, "Title" -- the toc-title box's two links, Title and the
   2026-09-11 Table of Contents) take the Analects build's heading style
   instead of this panel's boxed-button look above -- rust small-caps
   display text, uppercase, letter-spaced, no box. Measured live from
   Analects' `.toc-group h3` / `.toc-end h3, .toc-title h3` / `.toc-end a,
   .toc-title a` (analects.css, read-only): color rgb(132,39,39) light /
   rgb(224,120,95) dark, "Palatino Linotype"/"Book Antiqua"/"Noto Serif CJK
   TC"/Georgia/serif, 13.76px (0.86rem), 700 weight (the browser's own h3
   bold -- Analects never sets font-weight for this rule either), 1.2384px
   (0.09em) letter-spacing, uppercase, left-aligned, no background, no
   border, no underline, and (confirmed by hovering the live element) no
   hover colour change. Every token used here (--rust, --display) already
   exists in this file under the same name at the same light/dark values as
   Analects -- nothing was substituted. Selector specificity
   (.toc-group.toc-end / .toc-group.toc-title, two classes) is raised above
   the boxed `.toc-group h3 a` / `:hover` rules just above (one class, two
   elements) so this wins regardless of source order; Part 1/Part 2 groups
   match neither selector and keep the boxed style exactly as it was. */
.toc-group.toc-end h3,
.toc-group.toc-title h3 {
  margin: 0;
  text-align: left;
}

.toc-group.toc-end h3 a,
.toc-group.toc-title h3 a {
  display: inline;
  padding: 0;
  color: var(--rust);
  background: none;
  border: none;
  border-radius: 0;
  font-family: var(--display);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-decoration: none;
  text-transform: uppercase;
}

.toc-group.toc-end h3 a:hover,
.toc-group.toc-title h3 a:hover {
  border-color: transparent;
  color: var(--rust);
}

.chapter-links {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.05rem;
}

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

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

/* ---- Display (note-box) controls ---------------------------------------- */
.display-controls {
  margin: 1rem 0 1.25rem;
  padding: 0.55rem 0.7rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--parchment-dark);
  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 {
  padding-top: 0.15rem;
}

.display-toggle-child {
  margin-top: 0.15rem;
  padding: 0.28rem 0 0.28rem 0.85rem;
  border-top: 1px solid var(--note-border);
}

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

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

.display-toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: none;
  padding: 0.15rem;
  border: 0;
  background: none;
  color: var(--ink-light);
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.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;
  background: transparent;
  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-switch:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

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

/* Dark Mode: a three-way segmented control, not a track-and-thumb switch
   (that shape only ever honestly shows two states). Kept in the same
   .display-toggle row/label rhythm as the note-box switches above so it
   reads as one family of controls, not a bolted-on extra. */
.theme-switch {
  display: inline-flex;
  flex: none;
  border: 1px solid var(--note-border);
  border-radius: 0.85rem;
  overflow: hidden;
}

.theme-switch-option {
  border: 0;
  border-left: 1px solid var(--note-border);
  padding: 0.2rem 0.5rem;
  background: transparent;
  color: var(--ink-light);
  cursor: pointer;
  font: inherit;
  font-family: var(--display);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
}

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

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

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

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

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

@media (min-width: 901px) {
  .contents-open main,
  .contents-open .site-footer {
    margin-left: var(--contents-panel-width);
  }

  .contents-open .section-bar {
    padding-left: var(--contents-panel-width);
  }

  .site-footer {
    transition: margin-left 180ms ease;
  }

  /* Captain order 2026-09-28 (body text width uniform with Daodejing):
     the Prototype's own >=901px reading column is not simply its base
     52rem cap -- its rail-toggle mechanism makes it fluid (mainWidth -
     84px total inset) until 864px of main remains, only flattening at
     780px beyond that. The base rule (52rem cap, 1rem/side padding =
     32px) is the <901px value; this raises it to match the Prototype's
     own knee exactly at every measured viewport. .reading-shell's own
     override sits with its base rule below (source order matters here:
     this block precedes that rule, so it cannot win against it). */
  .section-bar-inner {
    max-width: 54rem;
    padding-left: 2.625rem;
    padding-right: 2.625rem;
  }
}

@media (max-width: 900px) {
  body.contents-open {
    overflow: hidden;
  }

  .contents-open .contents-backdrop {
    display: block;
  }
}

@media (max-width: 600px) {
  .section-bar-part {
    display: none;
  }
}

/* ---- Reading shell ------------------------------------------------------- */
.reading-shell {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 6rem;
}

/* Captain order 2026-09-28 (body text width uniform with Daodejing): the
   >=901px half of the same fix as .section-bar-inner's own override
   above (see that block's comment) -- must come after this base rule in
   source order to win against it, unlike .section-bar-inner's, whose
   base rule sits earlier in the file. */
@media (min-width: 901px) {
  .reading-shell {
    max-width: 54rem;
    padding-left: 2.625rem;
    padding-right: 2.625rem;
  }
}

h1 {
  font-family: "Bodoni MT", Didot, "Times New Roman", serif;
  text-align: center;
  line-height: 1.1;
}

h2 {
  font-family: var(--display);
  text-align: center;
}

h4, h5 {
  text-align: center;
  font-family: var(--display);
  color: var(--ink-light);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

h3 {
  font-family: var(--display);
  text-align: center;
}

p.center {
  text-align: center;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  width: 60%;
  margin: 2rem auto;
}

table {
  margin: 1.5rem auto;
  border-collapse: collapse;
}

td {
  padding: 0.2em 0.6em;
}

/* ---- In-page Contents list (Captain-ordered) -----------------------------
   The publication's own contents list, restyled from a bare table into a
   list -- the panel's own .toc-group/.chapter-links treatment (boxed Part
   heading, plain-link entries below it) is the reference, adapted to sit
   full-width in the reading measure instead of a narrow sidebar column.
   Deliberately quieter than h1.part further down the page -- a small
   uppercase label, not a rule-framed heading -- so it never competes with
   the real Part dividers it is merely a table of contents for. */
.contents-page {
  display: grid;
  gap: 2rem;
  margin-top: 1.75rem;
}

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

.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(--display);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
}

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

.contents-page-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.15rem;
}

.contents-page-list a {
  display: block;
  padding: 0.32rem 0.4rem;
  color: var(--ink-mid);
  border-radius: 3px;
  font-size: 0.94rem;
  text-decoration: none;
  line-height: 1.4;
}

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

/* ---- Source tables (Analects house treatment, carried faithfully) -------- */
/* A source table is always wrapped: <div class="table-scroll"> around the
   <table class="source-table">. The scroll container is what keeps a wide
   table from forcing the whole page to scroll sideways on a narrow screen. */

.source-table {
  margin: 1.6rem 0;
}

.source-table figcaption {
  margin-bottom: 0.45rem;
  color: var(--ink-light);
  font-family: var(--display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.source-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: left;
}

.source-table caption {
  padding-bottom: 0.4rem;
  font-size: 1.1rem;
  font-weight: bold;
  text-align: left;
}

.source-table th,
.source-table td {
  padding: 0.42rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  text-indent: 0;
}

.source-table thead th {
  border-bottom: 2px solid var(--note-border);
  color: var(--rust);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.source-table tbody tr:last-child th,
.source-table tbody tr:last-child td {
  border-bottom: 0;
}

.source-table tbody tr:nth-child(even) {
  background: var(--parchment-mid);
}

/* Row-header tables -- first cell of each row identifies the row. Our
   chronology table's date column is exactly this: the year identifies
   the row, so it is marked up as <th scope="row"> rather than <td>. The
   nowrap keeps a two-part date ("509 or 508", "478 to 476") on one
   line instead of wrapping merely because the column is narrow. */
.source-table tbody th[scope="row"] {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

/* The chronology event cells carry the Basic HTML two-space sentence
   rule. Like every prose context in this sheet they need
   white-space: pre-wrap for the literal double spaces to render -- a
   <td> defaults to `normal`, which collapses them silently.
   overflow-wrap: break-word is paired with it as elsewhere, so a long
   token cannot overflow a narrow cell. */
.source-table td {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

@media (max-width: 720px) {
  .source-table table {
    font-size: 0.8rem;
  }

  .source-table th,
  .source-table td {
    padding: 0.34rem 0.5rem;
  }
}

/* ---- Note boxes (house treatment) ---------------------------------------- */
.note-box {
  margin: 1.5rem 0 1.5rem 1.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  color: var(--ink-mid);
  font-size: 0.85rem;
  line-height: 1.58;
  text-align: left;
}

/* The two-space sentence rule (Basic HTML) depends on white-space:
   pre-wrap to render its literal double spaces; the house .note-box
   rule would otherwise reset text to white-space: normal and silently
   collapse them back to one. */
.note-box p.content-note {
  margin: 0;
  text-align: left;
  text-indent: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Quotation passages (Captain-ordered): visually kin to note boxes --
   same background, border, padding, font -- but a structurally separate
   class, so the notes toggle (which only ever queries .note-box) can
   never hide one. */
.quotation {
  margin: 1.5rem 0 1.5rem 1.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--note-bg);
  border-left: 3px solid var(--note-border);
  color: var(--ink-mid);
  font-size: 0.85rem;
  line-height: 1.58;
  text-align: left;
}

.quotation p.quotation-text {
  margin: 0 0 0.45rem;
  text-align: left;
  text-indent: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.quotation p.quotation-text:last-child {
  margin-bottom: 0;
}

/* ---- Colophon / source note ------------------------------------------------ */
.source-note {
  margin: 3rem auto 0;
  max-width: 42rem;
  padding: 1.5rem 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}

/* Captain order 2026-09-28: "update all the 'About this archival edition'
   sections to look like Analects (color, text box, spacing, etc.)"; then
   "...no section line / space divider as requested for all sections.
   Again, reference Analects for correct example." #end-note (the "About
   the Arsinoe Library Edition" box; heading and text ruled unchanged --
   style only) takes Analects' aside#source-note card (analects.css
   ~1717-1755): note-bg fill, 1px --rule border, 0 0.8rem 2rem shadow,
   2.5rem padding (1.5rem at <=720px), body-size text with no indent, the
   heading 1.35rem / 1.2 / 3px top padding / 1.5rem below, the last
   paragraph's bottom margin 0 so the inner bottom gap equals the padding.
   Width is Analects' min(100% - 2rem, 52rem) of <main>: wider than this
   build's reading column by (its padding - 1rem) a side, hence the
   negative side margins (main clips overflow-x). The divider is the
   box's own `::before`, outside the box, drawn in its margin-top gap the
   full width of the box (left/right -1px = the border's outer edge), with
   equal space above and below: the gap is this build's own main-section
   divider gap, 3.5rem + 1.38em (79.4 / 80.2 / 81.9 / 83.4px at 420 / 768
   / 1280 / 1920; the other dividers measure 79.1 / 79.8 / 82.3 / 83.7);
   +2px = the box border and the line's own 1px, which the pseudo's
   containing block (the padding box) leaves out. margin-bottom -1rem
   brings the box-to-footer distance to Analects' 5rem (this shell's
   padding-bottom is 6rem). Scoped to #end-note on purpose: the front
   colophon (aside#source-note) shares .source-note and is unchanged.
   Supersedes the 2026-09-24 `#end-note { border-top: none }` (that line
   removed a doubled rule; the chap21 line is now this ::before). */
#end-note {
  --end-note-gap: calc(3.5rem + 1.38em + 2px);
  position: relative;
  max-width: none;
  margin: var(--end-note-gap) calc(-1 * max(0px, min(1rem, (100vw - 52rem) / 2))) -1rem;
  padding: 2.5rem;
  background: var(--note-bg);
  border: 1px solid var(--rule);
  box-shadow: 0 0.8rem 2rem var(--shadow);
  font-size: inherit;
}

#end-note::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--end-note-gap));
  left: -1px;
  right: -1px;
  border-top: 1px solid var(--rule);
}

#end-note > h2 {
  margin: 0 0 1.5rem;
  padding-top: 3px;
  font-size: 1.35rem;
  line-height: 1.2;
}

#end-note > p {
  margin: 1em 0;
  text-indent: 0;
}

#end-note > p:last-child {
  margin-bottom: 0;
}

@media (min-width: 901px) {
  /* the reading shell's own side padding is 2.625rem here (1rem below) */
  #end-note {
    margin-inline: -1.625rem;
  }
}

@media (max-width: 720px) {
  #end-note {
    padding: 1.5rem;
  }
}

.source-note h2 {
  text-align: left;
  font-size: 1.1rem;
}

.source-note dl {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  column-gap: 1em;
  row-gap: 0.4em;
}

.source-note dt {
  font-weight: bold;
}

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

/* ---- Footer ---------------------------------------------------------------- */
/* Footer: the Analects presentation (Captain order 2026-09-28) -- the dark
   "furniture" bar in both themes, gold top rule, 0.86rem, body typeface. */
.site-footer {
  padding: 2.5rem 1rem;
  color: var(--footer-text);
  background: var(--footer-bg);
  border-top: 3px solid var(--gold);
  font-size: 0.86rem;
  text-align: center;
}

.site-footer p {
  margin: 0.2rem;
}

.site-footer a {
  color: var(--toggle-hover-color);
}

/* =====================================================================
   Part 2 verse indentation ladder -- this edition's own mechanism
   (Basic HTML, PIPE 1/2), re-themed into this palette/type scale only.
   Rules kept mutually exclusive (not "baseline plus override") because
   a :not()-heavy baseline selector can outrank the plain .verse-label /
   .sub-line rules meant to override it -- see build_basic_html.py.
   ===================================================================== */

.verse-chapter p:not(.verse-label):not(.sub-line):not(.poem):not(.center):not(.noindent):not(.signature),
.verse-chapter .content-note {
  text-indent: 0;
  padding-left: var(--indent-unit);
}

.verse-chapter p.verse-label {
  text-indent: calc(-1 * var(--indent-unit));
  padding-left: var(--indent-unit);
}

.verse-chapter p.sub-line {
  text-indent: 0;
  padding-left: calc(2 * var(--indent-unit));
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-indent: 1.5em;
}

p:not(.center):not(.poem):not(.noindent):not(.signature):not(.content-note) {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

p.center, p.poem, p.noindent, p.signature {
  text-indent: 0;
  white-space: normal;
}

p.poem {
  margin-left: 10%;
}

p.signature {
  text-align: right;
  font-style: italic;
}

div.chapter.editorial h3 {
  font-size: 1.1em;
  font-weight: bold;
  text-align: left;
}

h1.part {
  font-size: 1.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-block: 2rem 0;
  padding: calc(79.530px + 0.3761vw) 1rem calc(78.530px + 0.3761vw) 1rem;
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
  color: var(--rust);
}

/* Every .chapter div in this build -- Part 1's front-matter sections,
   the six Introduction sections, the section holding the Bibliography
   and Footnotes, the two editorial sections, and Part 2's thirteen
   chapters alike -- gets this rhythm: 3.5rem of breathing room above
   and below (matching consecutive .chapter/.document-section in the
   prototypes) plus a dividing rule after it. Deliberately uniform
   rather than scoped to Part 2 only: every one of these IS a document
   section, and a reader should feel the same separation between all of
   them. The two editorial sections (div.chapter.editorial) get this
   too -- checked after the change: they read exactly like the other
   sections, just with more air, which is the point. --source-rail is
   0 for this build (see :root), so the right-hand padding component
   is inert -- no gutter. */
div.chapter {
  padding: 3.5rem var(--source-rail) 3.5rem 0;
  border-bottom: 1px solid var(--rule);
}

/* A Part divider (h1.part, inside div.part-division) already draws its
   own top and bottom rule. Where a .chapter's border-bottom would sit
   immediately above one, it doubles the divider's own top rule --
   two parallel hairlines framing an empty band, not a design. Suppress
   it declaratively (by relationship, not by naming the two sections
   that happen to precede a divider today) so a future third Part never
   reintroduces the defect. */
div.chapter:has(+ .part-division) {
  border-bottom: none;
}

/* Divider Apply 2026-09-24 -- Captain's spacing-line-spacing ruling: the
   gap above a main-section/large-chapter rule must equal the gap below it
   (heading TEXT top, not box top), within 1px, at 1280px and 420px alike.
   div.chapter carries no per-chapter id of its own (the id sits on the
   <a> inside its <h2>), so these are matched by :has() rather than by id,
   the same relational technique div.chapter:has(+ .part-division) already
   uses above. Two independent causes needed two independent corrections:
   (1) a chapter's own trailing content sets its "gap above" baseline
   before any of this -- a plain paragraph's 0.5em margin measures to a
   different glyph-bottom than a boxed aside.note-box's 1.5rem margin, so
   the eight paragraph-ending chapters and the eight note-box-ending
   chapters below need different padding-bottom top-ups; (2) the target
   itself (a standard chapter's padding-top plus its h2's own metrics)
   grows a few px between 420 and 1280 because the body font uses a vw
   term, so every top-up carries a small vw term of its own to track it
   at both measured widths rather than just one. #pref02 and #chap06 (the
   two small chapters) and their neighbours are deliberately absent below
   -- their lines and spacing stay exactly as delivered. */
div.chapter:has(#chap01),
div.chapter:has(#chap02),
div.chapter:has(#chap09),
div.chapter:has(#chap10),
div.chapter:has(#chap12),
div.chapter:has(#chap15),
div.chapter:has(#chap16),
div.chapter:has(#chap20) {
  padding-bottom: calc(66.646px + 0.2889vw);
}

div.chapter:has(#chap04),
div.chapter:has(#chap07),
div.chapter:has(#chap11),
div.chapter:has(#chap13),
div.chapter:has(#chap14),
div.chapter:has(#chap17),
div.chapter:has(#chap18),
div.chapter:has(#chap19) {
  padding-bottom: calc(53.530px + 0.3761vw);
}

div.chapter:has(#chap08) {
  padding-bottom: calc(34.646px + 0.2889vw);
}

/* Captain order 2026-09-28 (About box styled like Analects): the
   chap21->end-note line is no longer #chap21's own border-bottom -- it is
   the box's `#end-note::before` (see the #end-note block, above), the full
   width of the box, as in Analects. So this chapter drops its border and
   its padding-bottom is re-set so the ink above that line equals the
   gap below it (this build's main-section divider gap, 3.5rem + 1.38em):
   padding + the "THE END" line's own 0.5em margin and leading residual
   (~0.5em + 2.6px) + the 1px the line sits below this chapter's edge. */
div.chapter:has(#chap21) {
  padding-bottom: calc(3.5rem + 0.88em - 3.6px);
  border-bottom: none;
}

/* The title/colophon/dedication/Table-of-Contents wrapper (its last
   visible content is a boxed Contents-page link, not running text). */
.chapter.front-matter {
  padding-bottom: calc(33.530px + 0.3761vw);
}

/* Maps the prototypes' .chapter-header (a wrapper we do not have)
   2rem margin-bottom onto the heading itself. */
div.chapter > h2 {
  margin-bottom: 2rem;
}

.part-title {
  display: block;
  font-size: 0.6em;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-top: 0.4rem;
  color: var(--ink-light);
}

a.part-link {
  font-weight: bold;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ---- Print -------------------------------------------------------------- */
@media print {
  @page {
    size: letter;
    margin: 0.65in 0.7in;
  }

  body {
    color: #000;
    background: #fff;
    font-size: 11pt;
  }

  .site-header,
  .section-bar,
  .skip-link,
  .contents-backdrop,
  .contents-toggle,
  .contents-close,
  .display-controls,
  .top-link {
    display: none !important;
  }

  main {
    margin-left: 0 !important;
  }

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

  .contents-panel {
    break-after: page;
  }

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

  /* #end-note's id-level screen rules outrank the class rule just above. */
  #end-note {
    margin-inline: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }

  .site-footer {
    margin-top: 0.3in;
    padding-top: 0.15in;
    border-top: 1px solid #999;
    background: none;
    text-align: center;
  }

  .site-footer a[href="#top"] {
    display: none !important;
  }

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

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

  a {
    color: #000;
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Captain order, 2026-09-28 ("All builds should match": the title-page
   `Arsinoe Library Edition, 2026` stamp follows Analects in gap above and
   colour). The stamp's 1rem margin-top collapsed with the 0.5em
   margin-bottom of the "1910" p.center above it (both are block siblings)
   and left 17.78 / 17.67 / 17.63 / 17.34px of ink gap (Range-rect) against
   Analects' 7.38 / 7.27 / 7.22 / 6.94 at 420 / 768 / 1280 / 1920. That
   margin is zeroed for the line directly above the stamp (`:has()`, as
   div.chapter:has(#chap..) above already does) and margin-top set to
   Analects' 0.35rem (analects.css:415): 7.38 / 7.27 / 7.22 / 6.94px, equal
   to Analects at every width. Colour was already var(--ink-light). Nothing
   below the stamp changes spacing, so the stamp -> source-note line gap
   stays 47.81px above / 40.59px below at every width (measured before and
   after). */
p.center:has(+ .library-edition) {
  margin-bottom: 0;
}

.library-edition {
  margin: 0.35rem 0 0;
  color: var(--ink-light);
  font-family: var(--display);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-align: center;
  text-indent: 0;
  text-transform: uppercase;
}

/* Footer lines are centred; cancel the body paragraph indent so the text sits on the centre line. */
.site-footer p {
  text-indent: 0;
}
