/* ===== Papers — editorial stylesheet =====
   Shared by HTML (screen) and PDF (WeasyPrint).
   Body: serif ~18px / line-height 1.6 / max-width ~720px.
   Headings: sans-serif hierarchy. */

:root {
  --measure: 720px;
  --ink: #1a1a1a;
  --muted: #5b6066;
  --accent: #1f5fae;
  --rule: #e2e5e9;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --serif: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Self-hosted fonts: drop files in assets/fonts/ and enable these.
@font-face { font-family:"Inter"; src:url("/assets/fonts/Inter.woff2") format("woff2"); font-weight:100 900; font-display:swap; }
@font-face { font-family:"Source Serif Pro"; src:url("/assets/fonts/SourceSerif.woff2") format("woff2"); font-weight:200 900; font-display:swap; }
*/

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
  padding: 2.5rem 1.25rem 6rem;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.paper { max-width: var(--measure); margin: 0 auto; }

/* ---- Header ---- */
.paper-header { margin-bottom: 2.5rem; }
.paper-eyebrow {
  font-family: var(--sans); font-size: .8rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 1rem;
}
.paper-eyebrow a { color: inherit; text-decoration: none; }
.paper-title {
  font-family: var(--sans); font-size: 2.3rem; line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 .6rem;
}
.paper-meta { font-family: var(--sans); color: var(--muted); font-size: .95rem; margin: 0 0 1rem; }
.paper-summary {
  font-size: 1.15rem; color: var(--muted); line-height: 1.5;
  border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1.25rem 0 0;
}

/* ---- Headings (hierarchy) ----
   Authoring convention: nested numbered sections begin with their label,
   e.g. "## A1. Title" and "### A1.1 Sub-point". Each level gets a distinct,
   scannable treatment below. */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--sans); line-height: 1.2; letter-spacing: -0.01em;
  margin: 2.2rem 0 .8rem;
}
h2 { font-size: 1.6rem; padding-bottom: .3rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.25rem; border-left: 3px solid var(--rule); padding-left: .75rem; }
h4 { font-size: 1.05rem; color: var(--accent); }
h5, h6 { font-size: .95rem; color: var(--muted); }

/* ---- Body elements ---- */
p { margin: 0 0 1.1rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
strong { font-weight: 650; }
em { font-style: italic; }

ul, ol { margin: 0 0 1.2rem; padding-left: 1.4rem; }
li { margin: .3rem 0; }
li > ul, li > ol { margin: .3rem 0; }

blockquote {
  margin: 1.4rem 0; padding: .2rem 0 .2rem 1.2rem;
  border-left: 3px solid var(--rule); color: var(--muted); font-style: italic;
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

code, pre { font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-size: .9em; }
code { background: var(--bg-soft); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--bg-soft); padding: 1rem 1.1rem; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }

img { max-width: 100%; height: auto; }

table { border-collapse: collapse; width: 100%; margin: 1.4rem 0; font-size: .95rem; }
th, td { border-bottom: 1px solid var(--rule); padding: .55rem .6rem; text-align: left; }
th { font-family: var(--sans); }

/* ---- Table of contents ---- */
.toc {
  font-family: var(--sans); background: var(--bg-soft); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.2rem 1.4rem; margin: 0 0 2.5rem; font-size: .95rem;
}
.toc-title {
  font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 .6rem; border: 0; padding: 0;
}
.toc ul { list-style: none; margin: 0; padding-left: 0; }
.toc ul ul { padding-left: 1rem; }
.toc li { margin: .25rem 0; }
.toc a { color: var(--ink); text-decoration: none; }
.toc a:hover { color: var(--accent); }

/* ---- Page break (between chapters in the combined PDF) ---- */
.page-break { break-before: page; }

/* ---- Dark mode (screen only) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaed; --muted: #9aa0a6; --accent: #6fa8ff;
    --rule: #303338; --bg: #16181c; --bg-soft: #1f2228;
  }
}

/* ---- Print / PDF ---- */
@page {
  size: A4;
  margin: 22mm 20mm;
  @bottom-center { content: counter(page); font-family: "Inter", sans-serif; font-size: 9pt; color: #888; }
}
@media print {
  body { font-size: 11pt; line-height: 1.5; padding: 0; color: #000; background: #fff; }
  .paper { max-width: none; }
  .paper-eyebrow a, a { color: #000; }
  a { text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; word-break: break-all; }
  h2, h3, h4 { break-after: avoid; }
  pre, blockquote, table, figure { break-inside: avoid; }
  .toc { background: none; border: 1px solid #ccc; }
}
