/* Reading stylesheet for the exported HTML and PDF editions.
   Deliberately plain: this is a 110,000-word technical manual with 180 code
   listings, so the job is legibility over long sittings, not decoration. */

:root {
  --ink: #1e1c1a;
  --ink-soft: #5b554e;
  --paper: #fbfaf7;
  --rule: #e2ddd3;
  --accent: #7a3020;
  --code-bg: #f3f0ea;
  --measure: 34rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8e4dd;
    --ink-soft: #a49d92;
    --paper: #161514;
    --rule: #322e2a;
    --accent: #d98b5f;
    --code-bg: #201e1c;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 18px;
  line-height: 1.62;
  margin: 0 auto;
  max-width: var(--measure);
  padding: 3rem 1.4rem 6rem;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
  line-height: 1.22;
  margin: 2.6em 0 0.7em;
}

/* Parts open a new page in print and carry a rule on screen. */
h1 {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  border-top: 2px solid var(--accent);
  padding-top: 1.6rem;
}
h1.title {
  border-top: none;
  padding-top: 0;
  font-size: 2.4rem;
  margin-top: 0;
}
.subtitle { color: var(--ink-soft); font-size: 1.05rem; font-style: italic; }
.author, .date { color: var(--ink-soft); font-size: 0.95rem; }

h2 { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
h3 { font-size: 1.05rem; font-weight: 700; }
h4 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

p { margin: 0 0 1.05em; }

a { color: var(--accent); }

blockquote {
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  margin: 1.4em 0;
  padding: 0.1em 0 0.1em 1.1em;
}

/* Code is the whole point of a manual like this: never let a listing wrap
   mid-token or spill past the measure. Long lines scroll inside their block. */
code, pre, kbd, samp {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.84em;
}
code { background: var(--code-bg); border-radius: 3px; padding: 0.1em 0.32em; }
pre {
  background: var(--code-bg);
  border-left: 3px solid var(--rule);
  border-radius: 4px;
  line-height: 1.5;
  margin: 1.3em 0;
  overflow-x: auto;
  padding: 0.9em 1em;
}
pre code { background: none; padding: 0; }

table {
  border-collapse: collapse;
  display: block;
  font-size: 0.9em;
  margin: 1.4em 0;
  overflow-x: auto;
  width: 100%;
}
th, td { border: 1px solid var(--rule); padding: 0.45em 0.65em; text-align: left; vertical-align: top; }
th { background: var(--code-bg); font-family: "Helvetica Neue", Arial, sans-serif; font-size: 0.9em; }

hr { border: none; border-top: 1px solid var(--rule); margin: 2.4em 0; }

ul, ol { margin: 0 0 1.05em; padding-left: 1.3em; }
li { margin-bottom: 0.35em; }

/* Table of contents */
#TOC {
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin: 2.5rem 0 3rem;
  padding: 1.2rem 1.4rem;
}
#TOC > ul { margin: 0; padding-left: 1.1rem; }
#TOC ul { list-style: none; padding-left: 1rem; }
#TOC > ul > li { margin-top: 0.55em; }
#TOC > ul > li > a {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  text-decoration: none;
}
#TOC a { color: var(--ink); text-decoration: none; }
#TOC a:hover { color: var(--accent); text-decoration: underline; }
#TOC li li a { color: var(--ink-soft); font-size: 0.93em; }

@media print {
  :root { --paper: #fff; --ink: #000; --code-bg: #f4f2ee; }
  body { max-width: none; font-size: 10.5pt; padding: 0; }
  h1 { page-break-before: always; }
  h1.title { page-break-before: avoid; }
  h2, h3, h4 { page-break-after: avoid; }
  pre, table, blockquote { page-break-inside: avoid; }
  #TOC { page-break-after: always; }
  a { color: inherit; text-decoration: none; }
}

/* web edition additions */
main { max-width: 42rem; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.sub { color: var(--ink-soft); }
ol.toc { padding-left: 1.2rem; }
ol.toc li { margin: .35rem 0; }
nav.pager { display: flex; gap: 1.5rem; margin-top: 3rem; padding-top: 1rem;
            border-top: 1px solid var(--rule); font-size: .9rem; }
