/* The Cromo Guide: the pages and the print version (tools/book.py). */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --border: #e1e6ed;
  --border-2: #cfd7e2;
  --text: #121826;
  --muted: #4d596b;
  --dim: #7a8597;
  --ink: #141b28;
  --accent: #0a8fae;
  --accent-rgb: 10, 143, 174;
  --link: #0a7d99;
  --code-text: #263142;
  --code-bg: #ffffff;
  --term-bg: #f3f6f9;
  --inline-code: #0b5d72;
  --tk-k: #2c56c9; --tk-s: #2a7d3a; --tk-n: #c2410c; --tk-c: #8a94a3; --tk-t: #0b7f93; --tk-f: #7a3fd1; --tk-a: #b7700b;
  --error: #d23a4f;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e131b;
  --surface: #141b25;
  --surface-2: #1b2430;
  --border: #253041;
  --border-2: #314055;
  --text: #e6ebf2;
  --muted: #a3afbf;
  --dim: #7c889a;
  --ink: #e6ebf2;
  --link: #4cc3e0;
  --code-text: #d5dde8;
  --code-bg: #111821;
  --term-bg: #0b1118;
  --inline-code: #7fd6ea;
  --tk-k: #7aa2ff; --tk-s: #8fd18f; --tk-n: #ff9e64; --tk-c: #6b7789; --tk-t: #4fd1e6; --tk-f: #c39bff; --tk-a: #e8b45a;
  --error: #ff6b81;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131b; --surface: #141b25; --surface-2: #1b2430; --border: #253041; --border-2: #314055;
    --text: #e6ebf2; --muted: #a3afbf; --dim: #7c889a; --ink: #e6ebf2; --link: #4cc3e0;
    --code-text: #d5dde8; --code-bg: #111821; --term-bg: #0b1118; --inline-code: #7fd6ea;
    --tk-k: #7aa2ff; --tk-s: #8fd18f; --tk-n: #ff9e64; --tk-c: #6b7789; --tk-t: #4fd1e6; --tk-f: #c39bff; --tk-a: #e8b45a;
    --error: #ff6b81;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16.5px/1.7 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* The bar at the top */
.bar {
  position: sticky; top: 0; z-index: 20; height: 60px;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand b { font: 700 19px/1 var(--display); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
:root[data-theme="dark"] .brand .orbit { stroke: #c9d1dc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand .orbit { stroke: #c9d1dc; } }
.book-title { color: var(--muted); font: 500 15px/1 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-title:hover { color: var(--text); text-decoration: none; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search {
  width: 220px; height: 36px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font: 14px var(--sans);
}
.search:focus { outline: 2px solid rgba(var(--accent-rgb), 0.45); border-color: transparent; }
.pdf, .lang {
  font: 500 13px/1 var(--mono); color: var(--muted); padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--border-2); background: var(--surface);
}
.pdf:hover, .lang:hover { color: var(--text); text-decoration: none; border-color: var(--dim); }
.theme, .menu {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0;
}
.theme::before { content: "◐"; font-size: 17px; line-height: 1; }
.menu { display: none; }
.menu span, .menu span::before, .menu span::after { display: block; width: 16px; height: 2px; background: var(--muted); border-radius: 2px; position: relative; }
.menu span::before, .menu span::after { content: ""; position: absolute; left: 0; }
.menu span::before { top: -5px; }
.menu span::after { top: 5px; }

/* Search results */
.results {
  position: fixed; top: 64px; right: 20px; z-index: 30; width: min(520px, calc(100vw - 40px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18); padding: 6px;
}
.results a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); }
.results a:hover, .results a.selected { background: var(--surface-2); text-decoration: none; }
.results small { display: block; color: var(--dim); font-size: 12.5px; }
.results p { margin: 10px 12px; color: var(--dim); }

/* Layout */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); }
aside {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto;
  border-right: 1px solid var(--border); padding: 22px 14px 40px 18px; background: var(--bg);
  scrollbar-width: thin;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a { display: flex; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 14.5px; line-height: 1.4; }
.toc li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.toc li.active > a { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); font-weight: 500; }
.toc .num { color: var(--dim); font-variant-numeric: tabular-nums; min-width: 22px; }
.toc .sections { margin: 2px 0 8px 30px; border-left: 1px solid var(--border); }
.toc .separator { height: 1px; background: var(--border); margin: 12px 10px; }
.toc .sections a { font-size: 13.5px; padding: 4px 10px; }
main { min-width: 0; padding: 40px 48px 60px; }
article { max-width: 780px; margin: 0 auto; }

/* Text */
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.015em; line-height: 1.25; position: relative; }
h1 { font-size: 40px; margin: 0 0 24px; letter-spacing: -0.03em; }
h2 { font-size: 27px; margin: 48px 0 14px; padding-top: 8px; }
h3 { font-size: 20.5px; margin: 34px 0 10px; }
h4 { font-size: 17px; margin: 26px 0 8px; }
.anchor { position: absolute; left: -0.9em; color: var(--dim); opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; text-decoration: none; }
p { margin: 0 0 16px; }
ul, ol { margin: 0 0 18px; padding-left: 26px; }
li { margin: 5px 0; }
strong { font-weight: 600; }
code {
  font-family: var(--mono); font-size: 0.86em; color: var(--inline-code); font-variant-ligatures: none;
  background: rgba(var(--accent-rgb), 0.08); border: 1px solid rgba(var(--accent-rgb), 0.16);
  padding: 0.08em 0.35em; border-radius: 6px;
}
a code { color: inherit; }
blockquote {
  margin: 22px 0; padding: 14px 18px; border-radius: 12px;
  border: 1px solid rgba(var(--accent-rgb), 0.28); background: rgba(var(--accent-rgb), 0.06);
}
blockquote p:last-child { margin-bottom: 0; }

/* Code */
.code, .output { position: relative; margin: 0 0 20px; border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.code { background: var(--code-bg); }
.output { background: var(--term-bg); }
.output pre { color: var(--muted); }
.code + .output { margin-top: -21px; border-top-left-radius: 0; border-top-right-radius: 0; }
.code:has(+ .output) { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.does-not-compile { border-color: color-mix(in srgb, var(--error) 55%, var(--border)); }
.does-not-compile + .output pre { color: var(--error); }
pre { margin: 0; padding: 16px 18px; overflow-x: auto; font: 13.8px/1.62 var(--mono); color: var(--code-text); tab-size: 4; scrollbar-width: thin; font-variant-ligatures: none; }
pre code { all: unset; font: inherit; white-space: pre; }
.code-name { font: 500 12.5px/1 var(--mono); color: var(--dim); padding: 10px 18px 0; }
.code-lang { position: absolute; top: 8px; right: 12px; font: 11.5px/1 var(--mono); color: var(--dim); text-transform: lowercase; user-select: none; }
.copy {
  position: absolute; top: 6px; right: 8px; font: 500 12px/1 var(--sans); padding: 6px 9px; border-radius: 7px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.code:hover .copy { opacity: 1; }
.code:hover .code-lang { opacity: 0; }
.toggle {
  position: absolute; top: 6px; right: 66px; font: 500 12px/1 var(--sans); padding: 6px 9px; border-radius: 7px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.code:hover .toggle { opacity: 1; }
.hidden-line { display: none; }
.code.expanded .hidden-line { display: inline; opacity: 0.6; }
.tk-k { color: var(--tk-k); } .tk-s { color: var(--tk-s); } .tk-n { color: var(--tk-n); }
.tk-c { color: var(--tk-c); font-style: italic; } .tk-t { color: var(--tk-t); } .tk-f { color: var(--tk-f); } .tk-a { color: var(--tk-a); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 0 20px; border: 1px solid var(--border); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14.8px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* Previous and next */
.pager { max-width: 780px; margin: 56px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { display: block; padding: 14px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font-weight: 500; }
.pager a:hover { border-color: var(--border-2); text-decoration: none; }
.pager small { display: block; color: var(--dim); font-weight: 400; font-size: 13px; }
.pager .next { text-align: right; grid-column: 2; }
footer { max-width: 780px; margin: 40px auto 0; color: var(--dim); font-size: 14px; text-align: center; }
footer a { color: var(--dim); }

/* Narrow screens */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  aside { display: none; position: fixed; top: 60px; left: 0; width: min(320px, 88vw); z-index: 15; box-shadow: 12px 0 40px rgba(0, 0, 0, 0.15); }
  body.menu-open aside { display: block; }
  .menu { display: grid; }
  main { padding: 28px 18px 48px; }
  .search { width: 150px; }
  .book-title { display: none; }
  h1 { font-size: 32px; }
}
@media (max-width: 560px) {
  .pdf { display: none; }
  .search { width: 110px; }
  .bar { gap: 10px; padding: 0 12px; }
  .brand b { display: none; }
}

/* The print version (print.html): a book of 178 x 235 mm, which tools/book.py prints to PDF */
@page {
  size: 178mm 235mm;
  margin: 19mm 19mm 21mm;
  @bottom-left { font: 500 7pt/1 "Inter", sans-serif; color: #8a94a3; letter-spacing: 0.08em; text-transform: uppercase; vertical-align: top; padding-top: 6.4mm; }
  @bottom-right { content: counter(page); font: 600 8pt/1 "Inter", sans-serif; color: #4d596b; vertical-align: top; padding-top: 6mm; }
}
@page cover { margin: 0; @bottom-right { content: none; } }
@page front { @bottom-right { content: none; } }
body.print {
  background: #ffffff; color: #1b2230; font: 10pt/1.5 "Source Serif 4", Georgia, serif; -webkit-font-smoothing: auto;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
body.print a { color: #0a7d99; }

/* Cover and colophon */
body.print .cover {
  page: cover; position: relative; overflow: hidden; height: 235mm; padding: 26mm 22mm 20mm;
  display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(120% 80% at 85% 10%, #1d2a3b 0%, #0e131b 55%, #0a0e14 100%); color: #e6ebf2;
}
body.print .cover .orbit { stroke: #c9d1dc; }
body.print .cover-orbit { position: absolute; width: 190mm; height: 190mm; right: -62mm; top: -38mm; opacity: 0.13; }
body.print .cover-top { display: flex; align-items: center; gap: 4mm; font: 700 17pt/1 var(--display); letter-spacing: -0.02em; }
body.print .cover-logo { width: 15mm; height: 15mm; }
body.print .cover-title h1 { font: 700 34pt/1.08 var(--display); letter-spacing: -0.03em; margin: 0 0 6mm; color: #ffffff; }
body.print .cover-title p { font: 400 13pt/1.4 "Inter", sans-serif; color: #a3afbf; margin: 0; }
body.print .cover-title::before { content: ""; display: block; width: 22mm; height: 1.4mm; border-radius: 1mm; margin-bottom: 9mm; background: linear-gradient(90deg, #0ea5c6, #4cc3e0); }
body.print .cover-bottom { display: flex; justify-content: space-between; font: 500 9pt/1 var(--mono); color: #7c889a; }
body.print .colophon {
  page: front; break-before: page; height: 190mm; display: flex; flex-direction: column; justify-content: flex-end;
  font: 8.5pt/1.55 "Inter", sans-serif; color: #4d596b;
}
body.print .colophon p { margin: 0 0 4mm; max-width: 110mm; text-align: left; hyphens: manual; }
body.print .colophon strong { color: #1b2230; font-weight: 600; }

/* Contents */
body.print .contents { break-before: page; }
body.print .contents h1 { font: 700 22pt/1.1 var(--display); letter-spacing: -0.02em; margin: 6mm 0 9mm; }
body.print .toc-print, body.print .toc-print ol { list-style: none; margin: 0; padding: 0; }
body.print .toc-print a { display: flex; align-items: baseline; color: inherit; }
body.print .toc-print .n { flex: none; width: 9mm; color: #0a8fae; font-variant-numeric: tabular-nums; }
body.print .toc-print .t { flex: none; max-width: 100mm; }
body.print .toc-print .dots { flex: 1; min-width: 4mm; margin: 0 2mm; border-bottom: 0.7pt dotted #b4bdc9; transform: translateY(-1.2mm); }
body.print .toc-print .p { flex: none; width: 8mm; text-align: right; font-variant-numeric: tabular-nums; }
body.print .toc-chapter { margin-top: 3.2mm; break-inside: avoid-page; }
body.print .toc-chapter > a { font: 600 9.8pt/1.45 "Inter", sans-serif; color: #121826; }
body.print .toc-section a { font: 400 8.6pt/1.6 "Inter", sans-serif; color: #4d596b; }
body.print .toc-section .n { width: 9mm; margin-left: 9mm; color: #8a94a3; }
body.print .toc-section .dots { border-bottom-color: #d5dce5; }

/* Chapters */
body.print .chapter { break-before: page; }
body.print .opener { padding-top: 16mm; margin-bottom: 11mm; }
body.print .opener .label { font: 600 7.5pt/1 "Inter", sans-serif; letter-spacing: 0.2em; text-transform: uppercase; color: #0a8fae; }
body.print .opener .number { font: 700 52pt/1 var(--display); color: #d3dae3; margin: 2mm 0 1mm; letter-spacing: -0.02em; }
body.print .opener h1 { font: 700 23pt/1.15 var(--display); letter-spacing: -0.025em; margin: 0; padding-bottom: 5mm; border-bottom: 1.2pt solid #1b2230; }
body.print h2 { font: 600 13pt/1.3 "Inter", sans-serif; letter-spacing: -0.01em; margin: 7mm 0 2.5mm; padding: 0; break-after: avoid; }
body.print h3 { font: 600 10.5pt/1.35 "Inter", sans-serif; margin: 5mm 0 1.5mm; break-after: avoid; }
body.print h4 { font: 600 10pt/1.35 "Inter", sans-serif; margin: 4mm 0 1mm; break-after: avoid; }
body.print .section-number { color: #0a8fae; margin-right: 2.6mm; font-variant-numeric: tabular-nums; }
body.print p { margin: 0 0 2.6mm; text-align: justify; hyphens: auto; orphans: 3; widows: 3; }
body.print ul, body.print ol { margin: 0 0 3mm; padding-left: 5mm; }
body.print li { margin: 0.8mm 0; text-align: justify; hyphens: auto; }
body.print .contents li { margin: 0; text-align: left; hyphens: manual; }
body.print strong { font-weight: 600; }
body.print code { font-size: 0.84em; color: #0b5d72; background: #eef4f7; border: 0; padding: 0.05em 0.28em; border-radius: 2px; hyphens: manual; }
body.print blockquote { margin: 3.5mm 0; padding: 2.5mm 4mm; border: 0; border-left: 2pt solid #0ea5c6; border-radius: 0 3px 3px 0; background: #f1f8fa; break-inside: avoid; }

/* Code */
body.print .code, body.print .output { margin: 0 0 3.5mm; border: 0; border-radius: 3px; overflow: visible; }
body.print .code { background: #f4f6f9; border-left: 2pt solid #0ea5c6; }
body.print .output { background: #ffffff; border: 0.6pt solid #d9e0e8; border-left: 2pt solid #b4bdc9; }
body.print .code + .output { margin-top: -3.5mm; border-radius: 0 0 3px 3px; border-top: 0; }
body.print .code:has(+ .output) { border-radius: 3px 3px 0 0; }
body.print .does-not-compile { border-left-color: #d23a4f; }
body.print .does-not-compile + .output { border-left-color: #d23a4f; }
body.print pre { padding: 2.4mm 3.4mm; font: 7.8pt/1.45 var(--mono); color: #263142; white-space: pre-wrap; overflow: visible; orphans: 6; widows: 6; font-variant-ligatures: none; }
body.print pre code { white-space: pre-wrap; background: none; padding: 0; color: inherit; font-size: inherit; }
body.print .output pre { color: #4d596b; }
body.print .keep { break-inside: avoid; }
body.print .code-name { font: 500 7pt/1 var(--mono); color: #6b7686; padding: 2.4mm 3.4mm 0; }
body.print .hidden-line, body.print .code-lang, body.print .copy, body.print .toggle { display: none; }

/* Tables */
body.print .table-wrap { margin: 1mm 0 4mm; border: 0; border-radius: 0; overflow: visible; }
body.print table { font: 8.4pt/1.45 "Inter", sans-serif; border-top: 1pt solid #1b2230; border-bottom: 1pt solid #1b2230; }
body.print th { background: none; font-weight: 600; border-bottom: 0.6pt solid #1b2230; padding: 1.6mm 2.4mm; }
body.print td { padding: 1.4mm 2.4mm; border-bottom: 0.5pt solid #e1e6ed; }
body.print tr { break-inside: avoid; }
body.print td code, body.print th code { font-size: 0.92em; }
