/* ---------- fonts (self-hosted, so the page works without any outside server) ---------- */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap; src: url("../assets/fonts/newsreader-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400; font-display: swap; src: url("../assets/fonts/newsreader-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 600; font-display: swap; src: url("../assets/fonts/newsreader-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 600; font-display: swap; src: url("../assets/fonts/newsreader-latin-600-italic.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../assets/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../assets/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../assets/fonts/inter-latin-600-normal.woff2") format("woff2"); }

/* ---------- design tokens: change colours / sizes here and the whole page follows ---------- */
:root {
  /* page */
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1f2328;
  --muted: #5b6370;
  --line: #e4dfd5;
  --accent: #2f8f8f;          /* teal: same as coset 0 */
  --accent-soft: #e6f2f1;

  /* the lattice colours, shared with the notebook (used by the figures) */
  --coset0: #2f8f8f;
  --coset1: #d9633b;
  --coset0-rest: #a9d6d3;
  --coset1-rest: #f0b49b;
  --selected: #43a047;
  --winner: #e3b23c;
  --dense: #4a90d9;
  --non-lattice: #4a4a4a;

  /* type */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* body text grows smoothly from 17px on a phone to 19px on a large screen */
  --text: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);

  /* ONE width for text AND figures, so they always line up */
  --col: 860px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--text);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a { color: #1d6f74; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: #0f4f54; }
:focus-visible { outline: 3px solid var(--winner); outline-offset: 2px; border-radius: 3px; }

/* ---------- text ---------- */
.section h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.7rem, 1.35rem + 1.4vw, 2.25rem);
  line-height: 1.2;
  margin: 0 0 1.1rem;
  letter-spacing: -0.01em;
}
.section h3 {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 2rem 0 0.6rem;
}
.section p, .section ul, .section ol { margin: 0 0 1.1em; }
.section li { margin-bottom: 0.35em; }
.section strong { font-weight: 600; }
.section code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: #efebe2;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* equations scroll sideways on a narrow phone instead of breaking the layout */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.4em 0; margin: 1em 0; }

/* tables (Section 9) */
.section table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.86rem;
  margin: 1.2rem 0 1.6rem;
  display: block;
  overflow-x: auto;
}
.section th, .section td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; }
.section td:first-child, .section th:first-child { white-space: nowrap; }
@media (max-width: 640px) { .section table { font-size: 0.8rem; } .section th, .section td { padding: 0.4rem 0.45rem; } }
.section th { font-weight: 600; background: #f1ede4; }
