/* ============================================================
   doc.css — document typography & themes (processed by Paged.js)
   All sizes in pt/mm for faithful print output.
   CSS vars (--accent, tints, fonts, page vars) injected by app.
   ============================================================ */

.doc {
  font-family: var(--font-body);
  font-size: 11pt;      /* exactly 22 half-points, so Word matches it exactly */
  line-height: 1.59;    /* 11 x 1.59 = 17.49pt leading — the baseline everything below divides */
  color: #1c2128;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  counter-reset: fig;
  /* Never strand a single line of a paragraph at the foot or head of a page.
     Inherited, so this covers list items, quotes and callout bodies too. */
  orphans: 2;
  widows: 2;
}

/* ---------- base blocks ---------- */
/* text-wrap:pretty ships in the print engine (Chromium 117+): no orphan word alone on
   a paragraph's last line. Older engines simply ignore it. */
.doc p { margin: 0 0 8.75pt; text-wrap: pretty; }
.doc.justify .content p {
  text-align: justify;
  hyphens: auto; -webkit-hyphens: auto;
  /* never hyphenate short words, never leave fewer than three letters on a line */
  hyphenate-limit-chars: 6 3 3;
}

.doc h1, .doc h2, .doc h3, .doc h4 {
  font-family: var(--font-head);
  color: #12161c;
  break-after: avoid;
  break-inside: avoid;   /* a two-line heading must not split across pages */
  line-height: 1.25;
  margin: 0;
  text-wrap: balance;    /* a two-line heading breaks evenly, not 90/10 */
}
.doc h1 {
  font-size: 20.5pt;
  font-weight: 700;
  letter-spacing: -0.012em;
  margin: 21.9pt 0 8.75pt;   /* 1.25 / 0.5 line */
  padding-bottom: 6pt;
  border-bottom: 1.4pt solid var(--a600);
}
.doc .content > h1:first-child, .doc .content > *:first-child h1 { margin-top: 0; }
.doc h2 {
  font-size: 14.5pt;
  font-weight: 700;
  letter-spacing: -0.008em;
  margin: 17.5pt 0 6.6pt;    /* 1 / 0.375 line */
  color: var(--a800);
}
.doc h3 { font-size: 12pt; font-weight: 700; margin: 13.1pt 0 4.4pt; }   /* 0.75 / 0.25 line */
.doc h4 { font-size: 11pt; font-weight: 700; font-style: italic; margin: 10.9pt 0 4.4pt; color: #333a45; }

.doc .hnum { color: var(--a600); margin-right: 3.5pt; font-variant-numeric: tabular-nums; }
.doc h1 .hnum { color: var(--a600); }

.doc.h1break .content h1 { break-before: page; }
.doc.h1break .content > h1:first-child { break-before: auto; }

.doc a { color: var(--a700); text-decoration: none; }
.doc strong { font-weight: 700; }
.doc em { font-style: italic; }
.doc del { color: #8a8f98; }

.doc hr {
  border: 0; height: 0.8pt; background: #d7dbe0;
  margin: 17.5pt auto; width: 100%;
}

.doc ul, .doc ol { margin: 0 0 8.75pt; padding-left: 18pt; }
.doc li { margin: 0 0 2.2pt; }
.doc li > ul, .doc li > ol { margin: 2.2pt 0 2.2pt; }
.doc ul li::marker { color: var(--a600); }
.doc ol li::marker { color: var(--a700); font-variant-numeric: tabular-nums; }

.doc blockquote {
  margin: 8.75pt 0 13.1pt;
  padding: 2pt 0 2pt 12pt;
  border-left: 2.2pt solid var(--a300);
  color: #3d434d;
  font-style: italic;
}
.doc blockquote p:last-child { margin-bottom: 0; }

/* ---------- code ---------- */
.doc code {
  font-family: "DocForge Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, Menlo, monospace;
  font-size: 0.86em;
}
.doc :not(pre) > code {
  background: #f0f2f5;
  border: 0.6pt solid #e0e3e8;
  border-radius: 2.5pt;
  padding: 0.5pt 3.5pt;
  color: #24303d;
}
.doc pre {
  background: #f6f8fa;
  border: 0.7pt solid #e2e5ea;
  border-radius: 4pt;
  padding: 8pt 10pt;
  margin: 8.75pt 0 13.1pt;
  font-size: 9pt;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  break-inside: avoid;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* ---------- tables ---------- */
.doc table {
  width: 100%;
  border-collapse: collapse;
  margin: 8.75pt 0 13.1pt;
  font-size: 9.5pt;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;   /* figures line up down a column */
}
.doc thead { break-inside: avoid; }
.doc th {
  background: var(--a75);
  color: var(--a900);
  font-weight: 700;
  text-align: left;
  padding: 5.5pt 8pt;
  border-bottom: 1.3pt solid var(--a600);
  border-top: 0.8pt solid var(--a600);
}
.doc td {
  padding: 5pt 8pt;
  border-bottom: 0.7pt solid #dfe2e7;
  vertical-align: top;
}
.doc tr { break-inside: avoid; }
.doc table caption {
  caption-side: top;
  text-align: left;
  font-size: 9pt;
  color: #5b6270;
  line-height: 1.4;
  padding-bottom: 4.4pt;
}
.doc table caption .tbl-label { font-weight: 700; color: var(--a800); }

/* cross-references — [#fig:setup] resolved to "Figure 3" */
.doc a.xref { color: var(--a700); white-space: nowrap; }
.doc a.xref-missing { color: #bb2432; }
/* GFM alignment ( :--- / :---: / ---: ) arrives as an align attribute, whose
   presentational specificity loses to the rules above — so restate it. */
.doc th[align="left"],   .doc td[align="left"]   { text-align: left; }
.doc th[align="center"], .doc td[align="center"] { text-align: center; }
.doc th[align="right"],  .doc td[align="right"]  { text-align: right; }

/* ---------- callouts ---------- */
.doc .callout {
  border-left: 2.6pt solid var(--co, var(--a600));
  background: var(--co-bg, var(--a50));
  border-radius: 0 4pt 4pt 0;
  padding: 8pt 11pt 8.5pt;
  margin: 8.75pt 0 13.1pt;
  break-inside: avoid;
  font-size: 10.5pt;
}
.doc .callout .co-title {
  font-weight: 700;
  font-size: 9.5pt;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--co, var(--a700));
  margin-bottom: 3.5pt;
  font-family: var(--font-head);
}
.doc .callout .co-title::before {
  content: "";
  display: inline-block;
  width: 6pt; height: 6pt;
  border-radius: 50%;
  background: var(--co, var(--a600));
  margin-right: 5pt;
  vertical-align: 0.2pt;
}
.doc .callout .co-body > p:last-child { margin-bottom: 0; }
.doc .callout.note      { --co: #2458c5; --co-bg: #eef3fc; }
.doc .callout.tip       { --co: #0e7a52; --co-bg: #ebf7f1; }
.doc .callout.warning   { --co: #b26205; --co-bg: #fdf4e7; }
.doc .callout.important { --co: #bb2432; --co-bg: #fcedee; }

/* ---------- title plate ---------- */
/* `:::banner` — the filled band a title page hangs its subject on. The fill is a
   fixed deep slate, not an accent tint, so the plate reads the same under every
   accent; the accent survives in the subordinate lines. Mirrored in the .docx as a
   one-cell shaded table (docx-export.js, banner()). */
.doc .banner {
  background: #1f2733;
  color: #ffffff;
  padding: 9pt 14pt 10pt;
  margin: 13.1pt 0;
  text-align: center;
  break-inside: avoid;
}
.doc .banner > p { margin: 0 0 3.5pt; text-align: center; }
.doc .banner > p:last-child { margin-bottom: 0; }
.doc .banner > p:first-child {
  font-family: var(--font-head);
  font-size: 17pt;
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.008em;
  text-wrap: balance;
}
.doc .banner > p:not(:first-child) { font-size: 10.5pt; line-height: 1.45; color: var(--a200); }
.doc .banner a { color: var(--a200); }
/* justified body text must not reach inside the plate */
.doc.justify .content .banner p { text-align: center; }

/* ---------- figures & screenshot placeholders ---------- */
.doc figure {
  margin: 13.1pt 0 13.1pt;
  text-align: center;
  break-inside: avoid;
}
.doc figure img {
  max-width: 100%;
  border: 0.8pt solid #dcdfe4;
  border-radius: 2.5pt;
}
.doc figcaption {
  font-size: 9pt;
  color: #5b6270;
  margin-top: 4.4pt;
  line-height: 1.4;
}
.doc figcaption .fig-label { font-weight: 700; color: var(--a800); }

.doc .shot-box {
  border: 1.4pt dashed var(--a400);
  background:
    repeating-linear-gradient(45deg, transparent 0 9pt, var(--a50) 9pt 18pt),
    #fdfdfe;
  border-radius: 5pt;
  min-height: 130pt;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5pt;
  padding: 14pt;
}
.doc .shot-box .shot-ic { width: 26pt; height: 26pt; opacity: 0.9; }
.doc .shot-box .shot-t {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 9.5pt;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--a700);
}
.doc .shot-box .shot-c { font-size: 9.5pt; color: #4a5160; max-width: 80%; }

/* ---------- TOC ---------- */
/* Front matter is its own page sequence — see the PageNumbering handler in main.js. */
.doc .toc-wrap { break-after: page; page: front; }
.doc .toc-title {
  font-family: var(--font-head);
  font-size: 18pt;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 14pt;
  padding-bottom: 6pt;
  border-bottom: 1.4pt solid var(--a600);
}
.doc .toc a {
  display: flex;
  align-items: baseline;
  gap: 6pt;
  color: #1c2128;
  margin: 0 0 4.5pt;
}
.doc .toc a .t  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 78%; }
.doc .toc a .dots { flex: 1; border-bottom: 1pt dotted #b9bec6; transform: translateY(-2.5pt); min-width: 18pt; }
.doc .toc a::after {
  /* Written per entry by the PageNumbering handler, so the contents quote the folio
     the reader sees rather than the absolute sheet number. */
  content: var(--df-tocnum, "");
  font-variant-numeric: tabular-nums;
  color: #454c58;
  font-size: 9.5pt;
}
.doc .toc a.l1 { font-weight: 700; font-size: 11pt; margin-top: 6.6pt; }
.doc .toc a.l1 .t { color: var(--a900); }
.doc .toc a.l2 { padding-left: 14pt; font-size: 10.5pt; }
.doc .toc a.l3 { padding-left: 28pt; font-size: 9.5pt; color: #3d434d; }
.doc .toc a .hnum { margin-right: 4pt; }

/* ---------- mathematics ---------- */
.doc .math-display {
  margin: 8.75pt 0 13.1pt;
  text-align: center;
  break-inside: avoid;
}
.doc .math-display .katex-display { margin: 0; }
.doc .math-inline .katex { font-size: 1.02em; }
.doc .math-error { color: #bb2432; font-family: "DocForge Mono", monospace; font-size: 0.86em; }

/* ---------- syntax highlighting ----------
   A quiet light theme tuned for paper: darker inks than screen themes, no background
   fills, so it prints crisply and photocopies legibly. Word colours mirror these —
   keep HL_WORD in docx-export.js in sync. */
.doc .hljs-comment, .doc .hljs-quote { color: #62717e; font-style: italic; }
.doc .hljs-keyword, .doc .hljs-selector-tag, .doc .hljs-literal, .doc .hljs-type { color: #8f3f9c; }
.doc .hljs-string, .doc .hljs-regexp, .doc .hljs-addition { color: #1a7f37; }
.doc .hljs-number, .doc .hljs-symbol, .doc .hljs-bullet, .doc .hljs-meta { color: #a05a00; }
.doc .hljs-title, .doc .hljs-section, .doc .hljs-name, .doc .hljs-function .hljs-title { color: #1f56b3; }
.doc .hljs-attr, .doc .hljs-attribute, .doc .hljs-variable, .doc .hljs-template-variable, .doc .hljs-params { color: #953800; }
.doc .hljs-built_in, .doc .hljs-class .hljs-title { color: #0f6f74; }
.doc .hljs-deletion { color: #bb2432; }
.doc .hljs-emphasis { font-style: italic; }
.doc .hljs-strong { font-weight: 700; }

/* ---------- references ---------- */
.doc .refs { break-before: auto; }
.doc .refs-title {
  font-family: var(--font-head);
  font-size: 14.5pt;
  font-weight: 700;
  letter-spacing: -0.008em;
  margin: 17.5pt 0 6.6pt;
  color: var(--a800);
}
.doc .ref {
  margin: 0 0 4.4pt;
  padding-left: 22pt;
  text-indent: -22pt;   /* hanging indent, the convention for reference lists */
  font-size: 10pt;
  line-height: 1.5;
}
.doc .ref .ref-n { font-variant-numeric: tabular-nums; color: var(--a800); font-weight: 700; }
.doc .cite { color: var(--a700); }
.doc .cite-missing { color: #bb2432; font-family: "DocForge Mono", monospace; font-size: 0.86em; }

/* ---------- footnotes ----------
   The note text sits inline at the call site; Paged.js moves it to the foot of whatever
   page the call lands on and numbers both ends with CSS counters. Never give @footnote a
   percentage max-height — it resolves against the footnote area's own height and silently
   truncates every note. */
.footnote {
  float: footnote;
  footnote-display: block;
  font-size: 8.5pt;
  line-height: 1.35;
  color: #3d434d;
  text-align: left;
}
.footnote::footnote-call { color: var(--a700); font-weight: 700; }
.footnote::footnote-marker { color: var(--a700); font-weight: 700; }

/* ---------- explicit page break ---------- */
.doc .page-break { break-after: page; height: 0; }

/* ============================================================
   COVER — full-bleed named page
   ============================================================ */
.cover {
  page: cover;
  height: calc(var(--page-h) - 0.6mm);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: 26mm 24mm;
  position: relative;
  overflow: hidden;
  font-family: var(--font-body);
}
.cover h1.cv-title { border-bottom: 0; padding-bottom: 0; }
.cover .cv-kicker {
  font-family: var(--font-head);
  font-size: 10pt;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--a700);
  margin-bottom: 10mm;
}
.cover .cv-title {
  font-family: var(--font-head);
  font-size: 33pt;
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.018em;
  color: #10141a;
  margin: 0 0 7mm;
  max-width: 92%;
  text-wrap: balance;
}
.cover .cv-sub {
  font-size: 13.5pt;
  line-height: 1.5;
  color: #4a5160;
  max-width: 80%;
  text-wrap: pretty;
}
.cover .cv-spacer { flex: 1; }
.cover .cv-rule { width: 22mm; height: 1.2mm; background: var(--a600); margin: 8mm 0; }
.cover .cv-meta { font-size: 10.5pt; line-height: 1.75; color: #2a303a; }
.cover .cv-meta .m-strong { font-weight: 700; font-size: 11.5pt; color: #171c23; }
.cover .cv-meta .m-dim { color: #6a7180; }

/* default (modern/executive) top band */
.cover::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 7mm;
  background: linear-gradient(90deg, var(--a800), var(--a500));
}
.cover::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2mm;
  background: var(--a200);
}

/* --- theme: executive — vertical spine --- */
.doc[data-theme="executive"] .cover { padding-left: 34mm; }
.doc[data-theme="executive"] .cover::before {
  top: 0; bottom: 0; left: 0; right: auto;
  width: 9mm; height: auto;
  background: linear-gradient(180deg, var(--a900), var(--a600));
}
.doc[data-theme="executive"] .cover::after { display: none; }

/* --- theme: academic — centered, ruled --- */
.doc[data-theme="academic"] .cover { align-items: center; text-align: center; padding-top: 40mm; }
.doc[data-theme="academic"] .cover::before, .doc[data-theme="academic"] .cover::after { display: none; }
.doc[data-theme="academic"] .cover .cv-kicker { letter-spacing: 0.3em; }
.doc[data-theme="academic"] .cover .cv-title {
  font-weight: 700; font-size: 27pt;
  /* an Oxford rule — heavy above, hairline below — the letterpress thick–thin
     signature, mirrored in the .docx cover (docx-export.js, centred branch) */
  border-top: 2.6pt solid #14181f; border-bottom: 0.9pt solid #14181f;
  padding: 9mm 4mm; max-width: 100%;
}
.doc[data-theme="academic"] .cover .cv-sub { max-width: 95%; }
.doc[data-theme="academic"] .cover .cv-rule { margin: 8mm auto; }

/* --- theme: minimal — quiet --- */
.doc[data-theme="minimal"] .cover::before { height: 1.2mm; background: #14181f; }
.doc[data-theme="minimal"] .cover::after { display: none; }
.doc[data-theme="minimal"] .cover .cv-title { font-weight: 700; }

/* ---------- theme body tweaks ---------- */
.doc[data-theme="modern"] h2 {
  padding-left: 8pt;
  border-left: 3pt solid var(--a500);
}
.doc[data-theme="academic"] h1 { border-bottom-color: #14181f; }
.doc[data-theme="academic"] h2 { color: #12161c; }
.doc[data-theme="academic"] th { background: #f0f0ee; color: #12161c; border-color: #14181f; }
.doc[data-theme="minimal"] h1 { border-bottom: 0.9pt solid #d7dbe0; }
.doc[data-theme="minimal"] h2 { color: #12161c; }
.doc[data-theme="minimal"] th { background: #f4f5f7; color: #12161c; border-color: #3c434e; }

/* letter-style block (no cover): tighter top */
.doc .content > .letter-head { margin-bottom: 14pt; }

/* ---------- Word-ribbon marks ---------- */
.doc mark { background: #ffff00; color: inherit; padding: 0 0.08em; border-radius: 1px; }
.doc u { text-underline-offset: 0.12em; }
.doc sub, .doc sup { font-size: 0.72em; line-height: 0; }
.doc .dfspan { border-radius: 1px; }
/* Alignment containers. Same specificity as the justify rule above but declared later,
   so an explicit :::center wins inside a justified document. */
.doc .content .align-center, .doc .content .align-center p { text-align: center; }
.doc .content .align-right,  .doc .content .align-right p  { text-align: right; }
.doc .content .align-left,   .doc .content .align-left p   { text-align: left; }
.doc .content .align-justify, .doc .content .align-justify p { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
