/*
 * The book's typography, shared by the paginated Read view (Paged.js) and the continuous Edit view.
 * Numbers come from template.tex (memoir, XeLaTeX) of the 8 November 2026 proof:
 *   trim 5.5 x 8.5 in; margins spine 0.82, fore-edge 0.62, top 0.72, bottom 0.82 in;
 *   TeX Gyre Pagella 10.5/14, justified, indent 1.3em, no paragraph space;
 *   small 9.3/12.2; chapter sink 1.05in; title 23/27; scene heads 2.3 lines above, 1.2 below.
 *
 * Font sizes are the template's numbers as printed: template.tex loads the faces at their nominal size
 * (it dropped Scale=MatchLowercase on 9 November 2026, which had set the body at 9.6 pt and italic 11 %
 * smaller than roman). Proofs before that date are set smaller than this file.
 */

@font-face { font-family: "TeX Gyre Pagella"; src: url("../fonts/texgyrepagella-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: "TeX Gyre Pagella"; src: url("../fonts/texgyrepagella-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: block; }
@font-face { font-family: "TeX Gyre Pagella"; src: url("../fonts/texgyrepagella-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: block; }
@font-face { font-family: "TeX Gyre Pagella"; src: url("../fonts/texgyrepagella-bolditalic.woff2") format("woff2"); font-weight: 700; font-style: italic; font-display: block; }
@font-face { font-family: "TeX Gyre Heros"; src: url("../fonts/texgyreheros-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "TeX Gyre Heros"; src: url("../fonts/texgyreheros-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --paper: #fffefb;
  --ink: #1b1d1a;
  --muted-ink: #6b6f6a;
  --rule: #1b1d1a;
  --line: 14pt;
}

/* ---------- body text ---------- */
.book {
  font-family: "TeX Gyre Pagella", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  font-size: 10.5pt;
  line-height: 14pt;
  color: var(--ink);
  font-variant-numeric: oldstyle-nums proportional-nums;
  font-kerning: normal;
  font-feature-settings: "kern" 1, "liga" 1;
  text-align: justify;
  word-spacing: -0.04em;   /* TeX may shrink interword space; browsers only stretch it. Tuned against the proof. */
  text-wrap: pretty;       /* closer to TeX's whole-paragraph line breaking where supported */
  hyphens: auto;
  -webkit-hyphens: auto;
  hyphenate-limit-chars: 5 2 3;  /* TeX british: \lefthyphenmin 2, \righthyphenmin 3 */
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
.book p { margin: 0; text-indent: 1.3em; orphans: 2; widows: 2; }
.book p.first, .book .chap-head + p, .book hr + p { text-indent: 0; }
.book .lead { font-variant-caps: small-caps; }
.book em { font-style: italic; }
.book strong { font-weight: 700; }
.book a { color: inherit; text-decoration: none; }

/* ---------- chapter openers ---------- */
.book .chap-head { text-align: center; padding-top: 1.05in; hyphens: manual; }
.book .chap-num {
  margin: 0 0 14pt; text-indent: 0; text-align: center;
  font-size: 9.3pt; line-height: 12.2pt;
  font-variant-caps: small-caps; letter-spacing: 0.14em; font-variant-numeric: lining-nums;
}
.book .chap-title {
  margin: 0 0 36.4pt; font-size: 23pt; line-height: 27pt; font-weight: 400;
  text-align: center; font-variant-numeric: lining-nums; string-set: chaptitle content(text);
}
.book .epigraph {
  width: 84%; margin: 0 auto 19.6pt; font-style: italic; text-align: center; hyphens: auto;
}
.book .interlude .chap-head { padding-top: 0.25in; }
.book .interlude .chap-title { margin-bottom: 22.4pt; }

/* ---------- scenes ---------- */
.book .scene-head {
  margin: 32.2pt 0 16.8pt; font-size: 10.5pt; line-height: 14pt; font-weight: 400;
  text-align: center; font-variant-caps: small-caps; letter-spacing: 0.01em;
  break-after: avoid; page-break-after: avoid; hyphens: manual;
}
.book .scene-head .num { font-variant-numeric: lining-nums; margin-right: 1.1em; }
.book .subhead { margin: 22pt 0 8pt; font-size: 10.5pt; font-weight: 400; font-style: italic; text-align: center; break-after: avoid; }
.book hr.scene-break {
  border: 0; height: 0.4pt; width: 0.9cm; background: var(--rule);
  margin: 12.6pt auto; break-before: avoid; break-after: avoid;
}

/* reflection (verse) and poem */
.book .reflection { margin: 19.6pt 0 14pt; text-align: center; font-style: italic; hyphens: manual; break-inside: avoid; }
.book .reflection .line { display: block; }
.book .reflection .line + .line { margin-top: 12.6pt; }
.book .poem { width: fit-content; max-width: 100%; margin: 0 auto 14pt; font-style: italic; text-align: left; hyphens: manual; }
.book .poem .line { display: block; padding-left: 1.5em; text-indent: -1.5em; }
.book .poem .stanza { break-inside: avoid; }
.book .poem .stanza + .stanza { margin-top: 8.4pt; }

/* editorial notes */
.book .poemnote { width: 80%; margin: 0 auto 11.2pt; font-size: 9.3pt; line-height: 12.2pt; font-style: italic; text-align: center; text-indent: 0; }
.book .draftnote { width: 84%; margin: 16.8pt auto 0; font-size: 9.3pt; line-height: 12.2pt; font-style: italic; text-align: center; text-indent: 0; color: var(--muted-ink); }
.book .journalnote { margin: 0 0 14pt; font-size: 9.3pt; line-height: 12.2pt; font-style: italic; text-indent: 0; }

/* ---------- contents ---------- */
.book .contents .chap-title { margin-bottom: 28pt; }
.book .toc, .book .toc ol { list-style: none; margin: 0; padding: 0; text-align: left; }
.book .toc > li { margin-top: 8.4pt; }
.book .toc ol { margin-left: 1.6em; font-size: 9.3pt; line-height: 12.2pt; }
.book .toc .n { display: inline-block; width: 1.6em; font-variant-numeric: lining-nums; }
.book .toc > li > a > .n { width: 1.6em; }
.book .toc a::after { content: "\2003" target-counter(attr(href), page); font-variant-numeric: lining-nums; }
.book.is-flow .toc a::after { content: none; }

/* ---------- back matter ---------- */
.book .notes-intro, .book .refintro { margin: 0 0 8.4pt; font-size: 9.3pt; line-height: 12.2pt; font-style: italic; text-indent: 0; }
.book .notes-head { margin: 18.2pt 0 7pt; font-size: 9.3pt; font-weight: 400; font-variant-caps: small-caps; text-align: left; break-after: avoid; }
.book .note { font-size: 9.3pt; line-height: 12.2pt; text-indent: -1.6em; padding-left: 1.6em; }
.book .note .pageref::before { content: "(page " target-counter(attr(href), page) ") "; font-variant-numeric: lining-nums; }
.book.is-flow .note .pageref::before { content: "↑ "; }
.book .note .cite { text-decoration: none; }
.book .ref { font-size: 9.3pt; line-height: 12.2pt; text-indent: -1.6em; padding-left: 1.6em; margin-bottom: 3.5pt; text-align: left; hyphens: manual; }
.book .jentry { text-indent: -1.3em; padding-left: 1.3em; margin-bottom: 4.9pt; }
.book .jentry .jdate { font-variant-caps: small-caps; margin-right: 1em; }

/* ---------- front pages ---------- */
.book .frontpage { text-align: center; text-indent: 0; }
.book .frontpage p { text-indent: 0; }
.book .halftitle p { string-set: booktitle content(text); }
.book .halftitle { padding-top: 2.3in; font-size: 15pt; font-variant-caps: small-caps; letter-spacing: 0.22em; }
.book .titlepage { padding-top: 1.7in; }
.book .titlepage .t { font-family: "TeX Gyre Heros", Helvetica, Arial, sans-serif; font-weight: 700; font-size: 22pt; line-height: 26pt; letter-spacing: 0.06em; }
.book .titlepage .s { margin-top: 12.6pt; font-style: italic; font-size: 14pt; line-height: 17pt; }
.book .titlepage .a { margin-top: 2.4in; font-size: 13pt; font-variant-caps: small-caps; letter-spacing: 0.18em; }
.book .titlepage .proof { margin-top: 0.9in; font-size: 9.3pt; font-variant-caps: small-caps; letter-spacing: 0.12em; }
.book .titlepage .proof span { letter-spacing: 0; font-variant-caps: normal; }
.book .copyright { padding-top: 4.6in; font-size: 9.3pt; line-height: 12.2pt; text-align: left; }
.book .copyright p + p { margin-top: 11pt; }
.book .motto { padding-top: 2.6in; font-style: italic; }

/* ---------- continuous flow (Edit view and the unpaginated Read view) ---------- */
.book.is-flow { width: 4.06in; max-width: 100%; margin: 0 auto; }
.book.is-flow .frontpage { display: none; }
.book.is-flow > section + section { margin-top: 3.5rem; border-top: 1px solid color-mix(in srgb, var(--ink) 10%, transparent); }
.book.is-flow .chap-head { padding-top: 0.7in; }

/* ---------- paginated (Paged.js) ---------- */
/*
 * Vertical margins: TeX hangs the first line from \topskip (about 10 pt) instead of a full 14 pt line,
 * so the proof's 6.96 in text block holds 36 lines, first baseline 0.858 in from the top of the page.
 * A CSS line box is 14 pt with its baseline 9 pt down, so the same grid needs a 504 pt (36 x 14) box
 * starting 52.78 pt down: top 0.733 in, bottom 0.767 in. Measured against the 8 November proof.
 */
@page {
  size: 5.5in 8.5in;
  margin: 0.733in 0.62in 0.767in 0.82in;
  @top-left { content: none; }
}
@page :left {
  margin-left: 0.62in; margin-right: 0.82in;
  @top-left { content: counter(page); font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; font-variant-numeric: lining-nums; vertical-align: bottom; padding-bottom: 15pt; }
  @top-center { content: string(booktitle); font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; font-variant-caps: small-caps; vertical-align: bottom; padding-bottom: 15pt; }
}
@page :right {
  margin-left: 0.82in; margin-right: 0.62in;
  @top-center { content: string(chaptitle); text-transform: lowercase; font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; font-variant-caps: small-caps; vertical-align: bottom; padding-bottom: 15pt; }
  @top-right { content: counter(page); font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; font-variant-numeric: lining-nums; vertical-align: bottom; padding-bottom: 15pt; }
}
@page chapter:first {
  @top-left { content: none; } @top-center { content: none; } @top-right { content: none; }
  @bottom-center { content: counter(page); font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; font-variant-numeric: lining-nums; vertical-align: top; padding-top: 20pt; }
}
@page front:first {
  @top-left { content: none; } @top-center { content: none; } @top-right { content: none; }
  @bottom-center { content: counter(page, lower-roman); font: 9.3pt/12.2pt "TeX Gyre Pagella", serif; vertical-align: top; padding-top: 20pt; }
}
@page front:left { @top-left { content: counter(page, lower-roman); } }
@page front:right { @top-right { content: counter(page, lower-roman); } }
@page empty { @top-left { content: none; } @top-center { content: none; } @top-right { content: none; } @bottom-center { content: none; } }
@page interlude:first { @top-left { content: none; } @top-center { content: none; } @top-right { content: none; } }
@page :blank { @top-left { content: none; } @top-center { content: none; } @top-right { content: none; } @bottom-center { content: none; } }

/* Page assignment and breaks. No .book.is-paged prefix: Paged.js matches these against the content before
   it is placed in the #pages container. They have no effect on a continuous screen. */
.frontpage { page: empty; break-before: page; break-after: page; }
.halftitle, .titlepage { break-before: right; }
.chapter, .plain-chapter { page: chapter; break-before: right; }
.interlude { page: interlude; break-before: right; }
.front { page: front; }
.mainstart { counter-reset: page 1; }
