/* ---- Fonts (self-hosted, copied into dist/fonts by the build) ---- */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: italic; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400-italic.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: italic; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600-italic.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format("woff2"); }

/* ---- Theme: change these to restyle the whole site ----
   Ink & vermilion: black, white and greys with a single vermilion accent for
   the page. Code and figures keep the report's colours (pink keywords, green
   operators, purple strings, blue names). */
:root {
  --bg: #0a0a0a;
  --text: #ececec;
  --strong: #ffffff;
  --muted: #8c8c8c;
  --faint: #4a4a4a;
  --line: #222222;
  --accent: #ff6a3d;
  /* code and figure colours as in the report (and the site's first theme) */
  --tok-kw: #f08fc0;
  --tok-op: #7fd08a;
  --tok-str: #c8a2f5;
  --tok-com: #8a8880;
  --tok-fn: #7aa7ff;
  --fig-blue: #7aa7ff;
  --fig-purple: #d58cf0;
  --panel: #141414;
  --column: 40rem;
  --sans: "IBM Plex Sans", "Helvetica Neue", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
/* Light theme: follows the system unless the toggle (site.js) picked one. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafafa;
    --text: #141414;
    --strong: #000000;
    --muted: #6b6b6b;
    --faint: #b3b3b3;
    --line: #e4e4e4;
    --accent: #d4380d;
    --tok-kw: #b0206f;
    --tok-op: #1c7a2e;
    --tok-str: #7a2bb8;
    --tok-com: #77746c;
    --tok-fn: #1f4fd0;
    --fig-blue: #1f4fd0;
    --fig-purple: #8a1fb0;
    --panel: #f1f1f1;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #fafafa;
  --text: #141414;
  --strong: #000000;
  --muted: #6b6b6b;
  --faint: #b3b3b3;
  --line: #e4e4e4;
  --accent: #d4380d;
  --tok-kw: #b0206f;
  --tok-op: #1c7a2e;
  --tok-str: #7a2bb8;
  --tok-com: #77746c;
  --tok-fn: #1f4fd0;
  --fig-blue: #1f4fd0;
  --fig-purple: #8a1fb0;
  --panel: #f1f1f1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
strong { color: var(--strong); font-weight: 600; }

/* ---- Hero ---- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem 5rem;
  position: relative;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--strong);
  max-width: 14em;
  margin: 0 0 1.5rem;
  text-wrap: balance;
}
.hero .subtitle {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 28em;
  margin: 0 0 2.5rem;
  text-wrap: balance;
}
.hero .subtitle:empty, .hero .actions:empty, .hero-visual:empty { display: none; }
.byline { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; justify-content: center; margin: 0 0 1.5rem; color: var(--muted); font-size: 0.95rem; }
.byline.people { font-size: 0.85rem; margin-top: -0.75rem; }
.byline .author { color: var(--strong); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; margin: 0; }
.button {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--strong);
  font-weight: 600;
  font-size: 0.9rem;
}
.button:hover { border-color: var(--accent); text-decoration: none; }
.button .icon { width: 1.05em; height: 1.05em; margin-right: 0.45em; vertical-align: -0.17em; flex: none; }
.button.primary { background: var(--strong); border-color: var(--strong); color: var(--bg); }
.button.primary:hover { background: var(--accent); border-color: var(--accent); }
.hero-visual { margin-top: 2.5rem; width: min(100%, 34rem); }
.scroll-hint {
  position: absolute;
  bottom: 1.75rem;
  font: 0.7rem var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---- Article column ---- */
.post {
  max-width: var(--column);
  margin: 0 auto;
  padding: 2rem 1.5rem 8rem;
}
.post p, .post ul, .post ol { margin: 0 0 1.1rem; }
.post h2, .post h3, .post h4 { position: relative; color: var(--strong); font-weight: 600; line-height: 1.2; text-wrap: balance; }
.post h2 { font-size: 1.9rem; margin: 7rem 0 1.5rem; }
.post h3 { font-size: 1.3rem; margin: 3.5rem 0 1rem; }
.post h4 { font-size: 1.05rem; margin: 2.5rem 0 0.8rem; }
.post h2:first-child { margin-top: 0; }

/* Section numbers hang in the left margin. */
.post h2[data-num]::before, .post h3[data-num]::before, .post h4[data-num]::before {
  content: attr(data-num);
  position: absolute;
  right: calc(100% + 1.25rem);
  bottom: 0.2em;
  font: 400 0.75rem var(--mono);
  color: var(--faint);
  white-space: nowrap;
}
@media (max-width: 56rem) {
  .post h2[data-num]::before, .post h3[data-num]::before, .post h4[data-num]::before {
    position: static;
    display: block;
    margin-bottom: 0.4rem;
  }
}

.post ul { list-style: none; padding-left: 1.3rem; }
.post ul > li { position: relative; margin-bottom: 0.5rem; }
.post ul > li::before {
  content: "";
  position: absolute;
  left: -1.2rem;
  top: 0.62em;
  width: 5px;
  height: 5px;
  background: var(--accent);
}
.post ol { padding-left: 1.6rem; }
.post ol > li { margin-bottom: 0.5rem; }
.post ol > li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }

.post blockquote { margin: 1.5rem 0; padding-left: 1.2rem; border-left: 2px solid var(--line); color: var(--muted); }
.post hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

/* ---- Code and math ---- */
code { font: 0.88em var(--mono); }
pre {
  margin: 1.5rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.katex { font-size: 1.05em; }
.katex-display { margin: 1.5rem 0; overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }
.katex-display > .katex > .katex-html > .tag { position: relative; margin-left: 2em; }

/* ---- Theorems, definitions and proofs ---- */
.thm { margin: 1.75rem 0; padding: 0.1rem 0 0.1rem 1.1rem; border-left: 2px solid var(--accent); }
.thm > p:first-child > strong:first-child { font: 0.78rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.thm em { font-style: normal; color: var(--strong); font-weight: 600; }
.thm > :last-child, .proof-block > :last-child { margin-bottom: 0; }
.proof-block { margin: 1.75rem 0; padding-left: 1.1rem; border-left: 2px solid var(--line); color: var(--muted); font-size: 0.95rem; }
.proof-block::after { content: "□"; display: block; text-align: right; color: var(--faint); }
.proof-block > p:first-child > em:first-child { font: 0.78rem var(--mono); font-style: normal; letter-spacing: 0.08em; text-transform: uppercase; }
:target.thm, figure:target { outline: 1px solid var(--accent); outline-offset: 0.6rem; }

/* ---- Listings, algorithms and syntax colours ---- */
.tok-kw { color: var(--tok-kw); font-weight: 600; }
.tok-op { color: var(--tok-op); font-weight: 600; }
.tok-fn { color: var(--tok-fn); }
.tok-str { color: var(--tok-str); }
.tok-com { color: var(--tok-com); }
.tok-id { color: var(--tok-fn); }
pre.listing { font-size: 0.78rem; line-height: 1.55; background: var(--panel); border: 0; padding: 1rem 1rem 1rem 0; width: 100%; }
pre.listing .line { counter-increment: line; }
pre.listing .line::before { content: counter(line); display: inline-block; width: 2.6rem; padding-right: 1rem; text-align: right; color: var(--faint); user-select: none; }
figure.algorithm { background: var(--panel); border-radius: 6px; padding: 1rem 1.2rem; }
figure.algorithm figcaption { margin: 0 0 0.8rem; }
ol.algorithm-lines { margin: 0; padding-left: 1.8rem; font-size: 0.88rem; overflow-x: auto; }
ol.algorithm-lines > li { margin: 0 0 0.3rem; padding-left: 0.4rem; }
ol.algorithm-lines > li::marker { font: 0.72rem var(--mono); color: var(--faint); }
svg.diagram { font-family: var(--sans); color: var(--text); overflow: visible; }
svg.diagram .mono { font-family: var(--mono); }

/* ---- Figures and tables ---- */
figure { margin: 3rem 0; }
.figure-body { font-size: 0.9rem; }
.figure-body > * { width: fit-content; max-width: 100%; margin-inline: auto; overflow-x: auto; }
/* Diagrams and images are inline by default, which auto margins do not centre. */
.figure-body > svg, .figure-body > img { display: block; }
.figure-body > * + * { margin-top: 1rem; }
.figure-body > pre.listing { width: 100%; }
.figure-body td { border-bottom: 0; padding: 0.2rem 0.9rem; white-space: nowrap; }
.figure-body td img { width: 2.2rem; height: 2.2rem; max-width: none; object-fit: contain; display: block; }
/* The logos are dark on transparent (as in the PDF). On the dark theme, invert
   their lightness but keep their hue: black marks turn white, and DeepL's navy
   mark turns light blue with a dark glyph. */
.figure-body td img { filter: invert(1) hue-rotate(180deg); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .figure-body td img { filter: none; } }
:root[data-theme="light"] .figure-body td img { filter: none; }
/* A column holding only a logo keeps the logo's width. */
.figure-body td:has(> img:only-child) { width: 2.2rem; }
.figure-body ol.algorithm-lines { background: var(--panel); border-radius: 6px; padding: 1rem 1.2rem 1rem 3rem; margin-inline: auto; }
.figure-body .katex-display { margin: 0.5rem 0; }
.figure-body .katex-display > .katex { white-space: normal; }
.figure-body blockquote { font-size: 0.95rem; }
/* Figures may grow wider than the text column on large screens. */
@media (min-width: 64rem) { figure:not(.algorithm):not(.table) { margin-inline: -7rem; } figure:not(.algorithm):not(.table) > figcaption { max-width: var(--column); } }
.figure-body img, .figure-body svg, .figure-body video, .figure-body canvas { max-width: 100%; height: auto; }
/* Like LaTeX: a caption that fits on one line is centred under the figure; a
   longer one is a centred block of left-aligned text. */
figcaption { margin-top: 1rem; font-size: 0.85rem; line-height: 1.55; color: var(--muted); width: fit-content; margin-inline: auto; }
tr.rule-before td { border-top: 1px solid var(--line); padding-top: 0.5rem; }
/* Tables with vertical rules in LaTeX: compact rows, rules between columns,
   top and bottom rules, and group labels centred against their rows. */
.figure-body table.ruled, table.ruled { width: auto; margin-inline: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table.ruled td { padding: 0.05rem 0.9rem; line-height: 1.55; border-bottom: 0; }
table.ruled tr:first-child td, table.ruled tr.rule-before td { padding-top: 0.45rem; }
table.ruled tr:last-child td, table.ruled tr:has(+ tr.rule-before) td { padding-bottom: 0.45rem; }
table.ruled td.span { vertical-align: middle; border-bottom: 0; }
table.ruled .rule-left { border-left: 1px solid var(--line); }
/* A merged table (two tables side by side) may grow past the figure, up to
   the window edges, before it has to scroll. */
.figure-body > .table-scroll:has(> table.merged) { width: max-content; max-width: calc(100vw - 3rem); position: relative; left: 50%; transform: translateX(-50%); margin-inline: 0; }
table.ruled.merged { font-size: 0.84rem; }
table.ruled.merged td { padding-inline: 0.75rem; }
figcaption p { display: inline; margin: 0; }
figcaption .label {
  font: 0.78rem var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin-right: 0.8em;
}
figure.table figcaption { margin: 0 auto 0.9rem; }
.table-scroll { overflow-x: auto; }
/* Boxes that scroll sideways fade out on each edge with more content beyond
   it (site.js sets data-more). */
[data-more="right"] { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 3.5rem), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 3.5rem), transparent); }
[data-more="left"] { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 3.5rem), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 3.5rem), transparent); }
[data-more="both"] { -webkit-mask-image: linear-gradient(to right, transparent, #000 3.5rem, #000 calc(100% - 3.5rem), transparent); mask-image: linear-gradient(to right, transparent, #000 3.5rem, #000 calc(100% - 3.5rem), transparent); }
.figure-body > .table-scroll.prose { width: 100%; }
/* A display formula fills the column (KaTeX centres it), so its own width
   cannot come out a pixel too narrow and scroll for nothing. */
.figure-body > .katex-display, .figure-body > :has(> .katex-display) { width: 100%; }
.figure-body .table-scroll.prose td { white-space: normal; vertical-align: top; min-width: 7rem; }
.figure-body .table-scroll.prose td:first-child { min-width: 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
th {
  font: 400 0.72rem var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--faint);
  white-space: nowrap;
}
td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.missing { color: #e5484d; font: 0.8rem var(--mono); }

/* ---- Citations, footnotes, references ---- */
.cite { font-size: 0.85em; color: var(--muted); white-space: nowrap; }
.footnote-ref a { font: 0.7em var(--mono); padding: 0 0.15em; }
.footnotes-sep { margin: 5rem 0 1.5rem; }
.footnotes { font-size: 0.85rem; color: var(--muted); margin-top: 5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
a.ref { font-variant-numeric: tabular-nums; }
.footnotes p { margin: 0; }
.references { font-size: 0.9rem; color: var(--muted); padding-left: 2.2rem; overflow-wrap: anywhere; }
.link-original { font-size: 0.9em; font-style: italic; color: var(--muted); }
.references .ref-original { display: block; margin-top: 0.2rem; font-size: 0.8rem; font-style: italic; }
.references li:target, .footnote-item:target { color: var(--text); }
.references .ref-link { white-space: nowrap; }
.references .ref-link::before { content: "\2197\00a0"; }
:target { scroll-margin-top: 2rem; }

/* ---- Section rail (right edge) ---- */
.rail {
  position: fixed;
  top: 12vh;
  bottom: 12vh;
  right: 1.75rem;
  width: 1px;
  background: var(--line);
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}
.rail.visible { opacity: 1; }
.rail::before {
  /* filled part of the line; site.js sets --p (0..1) on the rail only, and
     the fill scales on the compositor, so scrolling stays smooth */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 100%;
  transform: scaleY(var(--p, 0));
  transform-origin: top;
  will-change: transform;
  background: var(--accent);
}
.rail::after {
  content: "";
  position: absolute;
  left: -3.5px;
  top: -4px;
  transform: translateY(var(--py, 0px));
  will-change: transform;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.rail:not(.visible) { pointer-events: none; }
/* Ticks end at the line: long for chapters, medium for sections, short for
   subsections. Each tick box is 14px wide, so all labels share one edge. */
.rail a { position: absolute; right: 0; width: 14px; height: 9px; transform: translateY(-50%); }
.rail .tick { position: absolute; right: 0; top: 4px; height: 1px; background: var(--faint); }
.rail a.l1 .tick { width: 14px; }
.rail a.l2 .tick { width: 9px; }
.rail a.l3 .tick { width: 5px; }
.rail a.passed .tick { background: var(--muted); }
.rail a.hot .tick, .rail a:focus-visible .tick { background: var(--accent); }
.rail .name {
  position: absolute;
  right: calc(100% + 0.55rem);
  top: 50%;
  transform: translateY(-50%);
  font: 0.72rem var(--mono);
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s linear;
  pointer-events: none;
}
.rail a.near .name, .rail a.hot .name, .rail a:focus-visible .name {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 0.3rem 0.3rem 0.3rem 1.2rem;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 1.2rem), linear-gradient(to bottom, transparent, #000 0.3rem, #000 calc(100% - 0.3rem), transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 1.2rem), linear-gradient(to bottom, transparent, #000 0.3rem, #000 calc(100% - 0.3rem), transparent);
  mask-composite: intersect;
}
/* The highlighted name is cut to the free margin like the trail: number
   bright, title grey. */
.rail a.hot .name { max-width: var(--room, 12rem); overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.rail a.hot .name .num { color: var(--text); }
.rail a.hot .name, .rail a:focus-visible .name { opacity: 1; color: var(--text); }
/* Hovering anywhere in this band left of the line names the nearest tick. */
.rail-zone { position: absolute; top: -6px; bottom: -6px; right: 0; width: 9rem; cursor: pointer; }
/* Where you are: chapter above, current section below, riding with the dot. */
.rail-trail {
  position: absolute;
  right: calc(14px + 0.55rem);
  top: 0;
  transform: translateY(calc(var(--py, 0px) - 50%));
  text-align: right;
  pointer-events: none;
  will-change: transform;
  transition: opacity 0.1s ease;
  /* soft plate so the label stays legible over figures wider than the text:
     frosted and rounded, fading out on its left edge rather than a hard box */
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  padding: 0.4rem 0.3rem 0.45rem 1.6rem;
  /* fades out on the left, top and bottom edges */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 1.6rem), linear-gradient(to bottom, transparent, #000 0.4rem, #000 calc(100% - 0.4rem), transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 1.6rem), linear-gradient(to bottom, transparent, #000 0.4rem, #000 calc(100% - 0.4rem), transparent);
  mask-composite: intersect;
}
/* Both lines are cut to the free margin (--room, measured by site.js), so the
   label never runs into the text. The section number stays bright and the
   title is grey, so the number survives even in a narrow margin. */
.rail-trail > span { display: block; white-space: nowrap; font-family: var(--mono); max-width: var(--room, 12rem); margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.rail-trail .c { font-size: 0.66rem; letter-spacing: 0.04em; color: var(--muted); }
.rail-trail .s { font-size: 0.72rem; color: var(--muted); }
.rail-trail .s .num { color: var(--text); }
.rail-trail .s:empty { display: none; }
.rail.hovering .rail-trail { opacity: 0; }
@media (max-width: 68rem) { .rail { display: none; } }

/* Thin progress bar, shown where the rail is hidden. */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 17; display: none; }
.progress span { display: block; height: 100%; width: 100%; transform: scaleX(var(--p, 0)); transform-origin: left; background: var(--accent); will-change: transform; }
@media (max-width: 68rem) { .progress { display: block; } }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.site-footer span:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .rail, .progress, .scroll-hint, .actions, .hero-visual { display: none; }
  .hero { min-height: 0; }
}

/* ---- Web-only illustrations (site.config.json: heroVisual, inserts) ---- */
.hero-layers, .refinement-tree svg { display: block; width: 100%; height: auto; overflow: visible; }
:is(.hero-layers, .refinement-tree) .mono { font-family: var(--mono); }
:is(.hero-layers, .refinement-tree) .txt { fill: var(--text); }
:is(.hero-layers, .refinement-tree) .mut { fill: var(--muted); }
:is(.hero-layers, .refinement-tree) .acc { fill: var(--accent); }
.refinement-tree .fn { fill: var(--tok-fn); }
.refinement-tree .kw { fill: var(--tok-kw); font-weight: 600; }
.refinement-tree .op { fill: var(--tok-op); font-weight: 600; }
.refinement-tree .cap { font: 600 8.5px var(--mono); letter-spacing: 0.14em; text-transform: uppercase; fill: var(--muted); }
.refinement-tree .pill { fill: var(--panel); stroke: var(--line); }
.refinement-tree .pill.on { stroke: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.refinement-tree .pill.gone { fill: none; stroke: var(--line); stroke-dasharray: 3 3; }
.refinement-tree .tw { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.refinement-tree .tw.gone { stroke: var(--faint); stroke-width: 1.2; stroke-dasharray: 3 4; }
/* Branches draw in once the figure scrolls into view (site.js adds .in-view). */
.refinement-tree.animate .tw:not(.gone) { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); }
.refinement-tree.animate.in-view .tw:not(.gone) { animation: tree-draw 0.9s ease-out forwards; }
@keyframes tree-draw { to { stroke-dashoffset: 0; } }
.refinement-tree svg { max-width: 44rem; margin-inline: auto; }
.refinement-tree .tree-narrow { display: none; }
@media (max-width: 34rem) {
  .refinement-tree .tree-wide { display: none; }
  .refinement-tree .tree-narrow { display: block; max-width: 22rem; }
}
.refinement-tree figcaption .webonly { font-style: italic; }
.hero-layers .ring { fill: none; stroke: var(--muted); }
/* On phones the drawing is small: larger layer names, no subtitles. */
@media (max-width: 34rem) { .hero-layers .name { font-size: 17px; } .hero-layers .sub { display: none; } }
.hero-layers .ripple { fill: none; stroke: var(--accent); }

/* ---- Talk pages (talks/*.html, built by lib/talk.mjs) ---- */
button.button { font-family: inherit; background: none; cursor: pointer; line-height: inherit; }
.talk .slide.part h2 { margin-top: 8rem; }
.talk .slide + .slide:not(.part) { margin-top: 0; }
.talk .post h3 { margin-top: 4rem; }
.thesis-link::before { content: "\2192\00a0"; }
var { font-style: normal; font-family: var(--mono); font-size: 0.88em; color: var(--accent); }

/* Blocks that may grow past the text column, up to the window edges. */
.lexdoc, .side-by-side, .derivations { width: min(56rem, calc(100vw - 3rem)); position: relative; left: 50%; transform: translateX(-50%); }

.code-block { margin: 1.5rem 0; }
.code-title { font: 0.68rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.code-block pre.listing { margin: 0; }
.side-by-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1.25rem; margin: 1.5rem 0; }
/* Code shown side by side, or a lone code block, grows to fit its longest line
   (up to the window edges); only code that still does not fit scrolls. */
.side-by-side:has(> .code-block) { width: max-content; min-width: min(56rem, calc(100vw - 3rem)); max-width: calc(100vw - 3rem); grid-template-columns: repeat(2, minmax(0, auto)); }
.post section > .code-block, .post > .code-block { width: max-content; min-width: 100%; max-width: calc(100vw - 3rem); position: relative; left: 50%; transform: translateX(-50%); }
.side-by-side > pre.listing, .side-by-side > .code-block { margin: 0; }
.side-by-side.code-pair:not(:has(> .code-block)) { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.label-path { list-style: none; margin: 0; padding: 0.6rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.post .label-path > li { margin: 0; padding: 0.15rem 0 0.15rem calc(var(--d, 0) * 1.1rem); }
.post .label-path > li::before { display: none; }
.label-path > li:nth-child(2) { --d: 1; } .label-path > li:nth-child(3) { --d: 2; } .label-path > li:nth-child(4) { --d: 3; }
.label-path > li:nth-child(5) { --d: 4; } .label-path > li:nth-child(6) { --d: 5; } .label-path > li:nth-child(7) { --d: 6; }
.lvl { color: var(--accent); }

/* A mock-up of Lex's generated HTML documentation. */
.lexdoc { margin: 2rem 0; border: 1px solid var(--line); border-radius: 6px; font-size: 0.9rem; }
.lexdoc-head, .lexdoc-sub, .lexdoc-xml { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.35rem 1rem; border-bottom: 1px solid var(--line); }
.lexdoc-head { font-size: 1.15rem; padding-top: 0.7rem; border-bottom: 0; }
.lexdoc-xml { color: var(--muted); padding-top: 0; }
.lexdoc .path { margin-left: auto; font-size: 0.72rem; color: var(--muted); text-align: right; }
.xml { font: 0.68rem var(--mono); padding: 0.1rem 0.4rem; border-radius: 3px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--strong); white-space: nowrap; }
.lexdoc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
.lexdoc-body > pre.listing { margin: 0; border-radius: 0 0 0 6px; }
.reading { padding: 0.9rem 1.1rem; border-left: 1px solid var(--line); }
.reading-label { font: 0.68rem var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem; }
.post .reading p, .post .reading ul { margin-bottom: 0.6rem; }
.post .reading ul > li { margin-bottom: 0.25rem; }
.reading .source { margin: 1rem 0 0; padding-top: 0.8rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
@media (max-width: 44rem) {
  .lexdoc-body, .side-by-side, .side-by-side.code-pair, .side-by-side:has(> .code-block) { grid-template-columns: minmax(0, 1fr); }
  .side-by-side:has(> .code-block) { width: calc(100vw - 3rem); min-width: 0; }
  .lexdoc-body > pre.listing { border-radius: 0; }
  .reading { border-left: 0; border-top: 1px solid var(--line); }
}

.derivations { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 1rem 3rem; margin: 2rem 0; }
.post .derivations > figure { margin: 0; }
.derivations figcaption { margin: 0.25rem auto 0; text-align: center; }
table.ruled.operators td:nth-child(odd) { color: var(--muted); }
table.ruled.patterns td:first-child { white-space: nowrap; }

/* A statute with its phrases marked by the kind of rule they become. */
.post blockquote.statute { color: var(--text); font-size: 0.95rem; }
.statute mark { color: inherit; padding: 0 0.1em; border-radius: 2px; }
.statute .m-a { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.statute .m-b { background: none; text-decoration: underline 2px color-mix(in srgb, var(--accent) 80%, transparent); text-underline-offset: 0.2em; }
.statute .m-c { background: color-mix(in srgb, var(--muted) 30%, transparent); }
.mark-key { font-size: 0.85rem; color: var(--muted); }
.mark-key mark { color: var(--text); }

/* Pipeline: representations (stages) alternate with the steps between them. */
.post ol.pipeline { list-style: none; padding: 0; margin: 2rem 0; display: grid; grid-template-columns: max-content 1fr; gap: 0 1rem; }
.post ol.pipeline > li { margin: 0; }
.pipeline .stage { grid-column: 1; justify-self: start; padding: 0.3rem 0.9rem; border: 1px solid var(--line); border-radius: 999px; font-weight: 600; color: var(--strong); background: var(--panel); }
.pipeline .step { grid-column: 1 / 3; position: relative; padding: 0.55rem 0 0.55rem 2.2rem; margin-left: 1.2rem; border-left: 1px solid var(--accent); color: var(--muted); font-size: 0.88rem; }
.pipeline .step::after { content: ""; position: absolute; left: -4px; bottom: -1px; border: 4px solid transparent; border-top-color: var(--accent); border-bottom: 0; }

/* ---- Slides: the deck view and present mode (talk.js) ----
   Every slide is laid out on the same 960x540 stage, so text size and title
   position match from slide to slide. Content that does not fit is zoomed out
   below the title (talk.js). On a wide screen the talk page shows each slide
   as a card (body.deck, zoomed to the page with --deck-z) that grows taller
   instead of shrinking its content; present mode shows one stage at a time,
   scaled to the window. */
.present-bar { display: none; }
body.presenting { overflow: hidden; }
body.presenting .rail, body.presenting .progress, body.presenting .site-footer, body.presenting .site-nav,
body.presenting .scroll-hint, body.presenting .hero .actions, body.presenting .present-fab { display: none !important; }
body.presenting .hero:not(.current), body.presenting .slide-frame:not(:has(.current)) { display: none; }
body.presenting .slide-frame:has(.current) { margin: 0; }
body.presenting .slide-frame .slide-notes, body.presenting .present-here { display: none; }
body.presenting .slide.current, body.presenting .hero.current {
  position: fixed; left: 50%; top: 50%; z-index: 5;
  transform: translate(-50%, -50%) scale(var(--scale, 1));
  transform-origin: center;
}
body.presenting .slide.current, body.presenting .hero.current, body.deck .slide {
  width: 960px; height: 540px; min-height: 0;
  margin: 0; padding: 48px 64px 40px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-start;
  background: var(--bg);
}
body.presenting .hero.current, body.presenting .slide.part.current, body.deck .slide.part { justify-content: center; }
body.presenting .slide.current > *, body.deck .slide > * { max-width: 100%; }
body.presenting .slide.current > :first-child, body.deck .slide > :first-child { margin-top: 0; }
body.presenting .slide.current > :last-child, body.deck .slide > :last-child { margin-bottom: 0; }
/* Slide titles: the same size and place on every slide. */
body.presenting .post .slide.current h3, body.deck .post .slide h3 { font-size: 1.75rem; margin: 0 0 1.4rem; }
body.presenting .post .slide.part.current h2, body.deck .post .slide.part h2 { font-size: 3rem; margin: 0; }
body.presenting .post .slide.part.current h2::before, body.deck .post .slide.part h2::before { position: static; display: block; margin-bottom: 0.6rem; font-size: 0.9rem; }
/* Blocks that break out of the article column fill the stage instead. */
:is(body.presenting, body.deck) :is(.lexdoc, .side-by-side, .derivations, .slide > .code-block) {
  width: 100%; min-width: 0; max-width: 100%; left: auto; transform: none;
}
body.presenting figure, :is(body.presenting, body.deck) .slide figure:not(.algorithm):not(.table) { margin: 1.25rem 0; }
/* No scroll fades on a slide: it is fitted so that nothing needs scrolling. */
:is(body.presenting .slide.current, body.deck .slide) [data-more] { -webkit-mask-image: none; mask-image: none; }
/* The pipeline runs in rows: each representation, then the step that follows it. */
:is(body.presenting, body.deck) .post ol.pipeline { gap: 0.45rem 1rem; align-items: center; }
:is(body.presenting, body.deck) .pipeline .step { grid-column: 2; margin: 0; padding: 0; border: 0; }
:is(body.presenting, body.deck) .pipeline .step::before { content: "\2192\00a0\00a0"; color: var(--accent); }
:is(body.presenting, body.deck) .pipeline .step::after { display: none; }

/* Deck view: each slide is a card, centred on the page, with its number,
   a button to present from it, and the reader's notes underneath. */
.slide-frame { margin: 3rem 0; }
.slide-box { position: relative; }
.slide-notes { display: flex; gap: 1rem; align-items: baseline; margin-top: 0.75rem; }
.slide-no { font: 0.72rem var(--mono); color: var(--faint); flex: none; }
.post .slide-notes .notes { margin: 0; font-size: 0.9rem; color: var(--muted); }
body:not(.deck) .slide-notes .slide-no { display: none; }
.present-here { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 1; font: 0.72rem var(--mono); color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; opacity: 0; transition: opacity 0.2s; }
.slide-box:hover .present-here, .present-here:focus-visible { opacity: 1; }
.present-here:hover { color: var(--accent); border-color: var(--accent); }
body:not(.deck) .present-here { display: none; }
body.deck .slide-frame { width: calc(960px * var(--deck-z, 1)); position: relative; left: 50%; transform: translateX(-50%); margin: 2.5rem 0; }
body.deck .slide-frame:has(.part) { margin-top: 5rem; }
body.deck .slide { height: auto; min-height: 540px; zoom: var(--deck-z, 1); border: 1px solid var(--line); border-radius: calc(12px / var(--deck-z, 1)); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12); }
body.deck .talk-intro { text-align: center; }
/* A Present button that stays in view once the title is scrolled away: it
   glides from the title's Present button into the top-left corner (talk.js). */
.present-fab { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 0.45rem; font: 600 0.85rem var(--sans); color: var(--bg); background: var(--strong); border: 0; border-radius: 999px; padding: 0.38rem 0.95rem; cursor: pointer; opacity: 0; pointer-events: none; }
.present-fab .icon { width: 0.95em; height: 0.95em; }
.present-fab.show { opacity: 1; pointer-events: auto; }
.present-fab:hover { background: var(--accent); }
body.presenting .present-bar {
  display: flex; align-items: center; gap: 0.75rem; position: fixed; right: 1rem; bottom: 1rem; z-index: 20;
  font: 0.75rem var(--mono); color: var(--muted); opacity: 0.35; transition: opacity 0.2s;
}
body.presenting .present-bar:hover { opacity: 1; }
.present-bar button { font: inherit; color: inherit; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.6rem; cursor: pointer; }
.present-bar button:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Bachelor's thesis additions ---- */
/* Result plots are white-background images: show them on a light card. */
.figure-body img.plot { width: 30rem; background: #fff; border-radius: 6px; padding: 0.5rem; }

/* ---- PDF reader (pdf/*.html): the PDF's pages as images ---- */
.reader-bar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; padding: 0.8rem 1.5rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.reader-bar .title { font-weight: 600; color: var(--strong); margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-bar .archive { margin-left: 0.75rem; font: 400 0.72rem var(--mono); color: var(--muted); text-decoration: none; }
.reader-bar .archive:hover { color: var(--accent); }
.reader-bar .count { font: 0.75rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.reader-bar .button { padding: 0.3rem 0.9rem; font-size: 0.82rem; }
.icon-button { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--line); color: var(--text); }
.icon-button svg { width: 1rem; height: 1rem; }
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.reader-close { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 0.9rem; line-height: 1; }
.reader-close:hover { color: var(--accent); border-color: var(--accent); }
.pages { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; padding: 2rem 1rem 6rem; }
main.pages figure.sheet { margin: 0; outline: none; }
.pages .sheet { width: min(100%, var(--page-w, 52rem)); scroll-margin-top: 4rem; }
.pages img { display: block; width: 100%; height: auto; aspect-ratio: var(--ratio); background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--line), 0 8px 30px rgba(0, 0, 0, 0.18); }
.pages .page-no { font: 0.7rem var(--mono); color: var(--faint); margin-top: 0.5rem; text-align: center; }
/* Slides: one row that scrolls sideways, the current slide centred and its
   neighbours dimmed at the sides. */
body.reader:has(.pages.slides) { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.pages.slides {
  --slide-w: min(84vw, calc((100dvh - 9rem) * var(--ratio)));
  flex: 1; min-height: 0; flex-direction: row; align-items: center; gap: 2rem;
  padding: 0 calc((100vw - var(--slide-w)) / 2);
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; outline: none;
}
.pages.slides::-webkit-scrollbar { display: none; }
.pages.slides .sheet { flex: none; width: var(--slide-w); scroll-snap-align: center; scroll-margin: 0; opacity: 0.35; transform: scale(0.92); transition: opacity 0.3s, transform 0.3s; cursor: pointer; }
.pages.slides .sheet.cur { opacity: 1; transform: none; cursor: default; }
@media (prefers-reduced-motion: reduce) { .pages.slides .sheet { transition: none; } }
.deck-nav button { position: fixed; top: 50%; z-index: 10; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--text); font: 1rem var(--mono); cursor: pointer; backdrop-filter: blur(6px); }
.deck-nav button:hover { color: var(--accent); border-color: var(--accent); }
.deck-nav [data-go="-1"] { left: 1rem; }
.deck-nav [data-go="1"] { right: 1rem; }
.deck-nav button:disabled { opacity: 0.25; cursor: default; }
@media (max-width: 40rem) { .deck-nav { display: none; } .pages.slides { --slide-w: 88vw; gap: 0.75rem; } }
/* Highlights carried over from the slides (red and blue in the Beamer deck). */
.katex .acc, pre .acc, code .acc { color: var(--accent); }
.katex .blu { color: var(--tok-fn); }

/* ---- Web-only illustrations of the bachelor's pages (art.js) ---- */
.hero-art { display: block; width: 100%; height: auto; overflow: visible; }
.hero-art .mono, .eri-art .mono { font-family: var(--mono); }
.hero-art .name { font-size: 11.5px; }
.hero-art .sub { font-size: 9px; fill: var(--muted); }
.hero-art .txt { fill: var(--text); }
.hero-art .acc { fill: var(--accent); }
.hero-art .lane, .hero-art .tie { stroke: var(--line); }
.hero-art .now { stroke: var(--faint); stroke-dasharray: 2 3; }
/* The trace (thesis title) */
#hero-trace .db { fill: var(--panel); stroke: var(--line); }
#hero-trace .rowname { font-size: 9px; fill: var(--faint); }
#hero-trace .ev { fill: var(--muted); transition: fill 0.4s, opacity 0.4s; }
#hero-trace .ev.keep { fill: var(--accent); }
#hero-trace .ev.skip { fill: var(--faint); opacity: 0.45; }
#hero-trace .verdict { stroke: var(--muted); stroke-width: 1.4; }
#hero-trace .verdict.bad { stroke: var(--accent); stroke-width: 2; }
#hero-trace .spark { fill: var(--tok-fn); }
#hero-trace .ring { fill: none; stroke: var(--accent); stroke-width: 1.2; }
#hero-trace .change { opacity: 0; transition: opacity 0.5s; }
#hero-trace .change.on { opacity: 1; }
#hero-trace .window { fill: color-mix(in srgb, var(--tok-fn) 9%, transparent); stroke: color-mix(in srgb, var(--tok-fn) 55%, transparent); }
#hero-trace .bracket { fill: none; stroke: var(--tok-fn); }
#hero-trace .ri { font-size: 10px; fill: var(--tok-fn); }
#hero-trace .change .acc { font-size: 10px; }
/* The wrapper at work (talk title) */
#hero-flow .wire { stroke: var(--line); }
#hero-flow .node { fill: var(--panel); stroke: var(--line); }
#hero-flow .node.hub { stroke: color-mix(in srgb, var(--accent) 55%, var(--line)); }
#hero-flow .flash { fill: none; stroke: var(--accent); stroke-width: 1.5; }
#hero-flow .pkt.event { fill: var(--tok-fn); }
#hero-flow .pkt.verdict { fill: var(--accent); }
#hero-flow .pkt.query, #hero-flow .pkt.answer { fill: var(--fig-purple); }
@media (max-width: 34rem) { .hero-art .name { font-size: 15px; } .hero-art .sub { display: none; } }

/* Which events the extended relative intervals keep (inline figure) */
.eri-fig .figure-body > svg { max-width: min(100%, 44rem); }
.eri-art .name { font-size: 11px; fill: var(--text); }
.eri-art .name.dim { fill: var(--muted); }
.eri-art .sub { font-size: 9.5px; fill: var(--muted); }
.eri-art .lane { stroke: var(--line); }
.eri-art .axis { stroke: var(--faint); fill: none; }
.eri-art .now { stroke: var(--faint); stroke-dasharray: 2 3; }
.eri-art .ri path { fill: none; stroke: var(--tok-fn); }
.eri-art .ri text { font-size: 10px; fill: var(--tok-fn); }
.eri-art .band { fill: color-mix(in srgb, var(--accent) 13%, transparent); stroke: color-mix(in srgb, var(--accent) 45%, transparent); }
.eri-art .ev.keep { fill: var(--accent); }
.eri-art .ev.skip { fill: none; stroke: var(--muted); stroke-width: 1; }
.eri-art .legend text { font-size: 10px; fill: var(--muted); }
.eri-art .legend .count { fill: var(--text); }
.eri-fig figcaption .webonly { font-style: italic; }
.eri-fig.animate .band { transform: scaleX(0); transform-box: fill-box; transform-origin: right; transition: transform 0.9s ease-out; }
.eri-fig.animate .ev.keep { opacity: 0; transition: opacity 0.5s ease-out 0.8s; }
.eri-fig.animate.in-view .band { transform: scaleX(1); }
.eri-fig.animate.in-view .ev.keep { opacity: 1; }

/* ---- Phones: nothing may widen the page ---- */
/* Long identifiers in inline code break anywhere rather than run off the screen. */
:not(pre) > code { overflow-wrap: anywhere; }
/* An inline formula wider than its line scrolls on its own (art.js marks it). */
.katex.wide { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: bottom; }
/* Backstop: the page itself never pans sideways. */
html, body { overflow-x: clip; }

/* ---- Site-wide: header link home, and the home page ---- */
/* The site header stays at the top of the window: the name links home. Once
   the page scrolls, it gets a background so text passes under it cleanly. */
.site-nav { position: fixed; top: 0; left: 0; right: 0; z-index: 16; height: 3.25rem; padding: 0 1.5rem; font-size: 0.85rem; display: flex; align-items: center; gap: 1rem; transition: background-color 0.25s, border-color 0.25s, transform 0.2s ease-out; border-bottom: 1px solid transparent; }
body.scrolled .site-nav { background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom-color: var(--line); }
.site-nav .site-name { color: var(--muted); text-decoration: none; font-weight: 600; letter-spacing: 0.01em; }
.site-nav .site-name:hover { color: var(--accent); }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--accent); }
/* ---- Home page ---- */
body.home .hero { min-height: auto; padding-bottom: 1rem; }
body.home .hero .subtitle { max-width: 36rem; }
body.home .scroll-hint, body.home .rail, body.home .progress { display: none; }
body.home main { max-width: 68rem; margin: 0 auto; padding: 0 1.5rem; }
body.home .post { max-width: none; }
.home-section { margin: 3.5rem 0 4.5rem; }
.post .section-label { font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); border: 0; margin: 0 0 1.75rem; padding: 0 0 0.6rem; border-bottom: 1px solid var(--line); }
.post .section-label::before { content: none; }
.kicker { font: 0.75rem var(--mono); color: var(--muted); margin: 0 0 0.6rem; }
.kicker .year { color: var(--accent); margin-right: 0.75rem; font-weight: 600; }

/* A thesis: its illustration beside its text, alternating sides. */
.feature { display: grid; grid-template-columns: 1.15fr 1fr; gap: 2.5rem; align-items: center; margin-bottom: 4rem; }
.feature.flip .feature-visual { order: 2; }
.feature-visual { display: block; padding: 1.75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); transition: border-color 0.2s, transform 0.2s; }
.feature-visual:hover { border-color: var(--accent); transform: translateY(-2px); }
.feature-visual svg { display: block; width: 100%; height: auto; overflow: visible; }
.post .feature h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); line-height: 1.2; margin: 0 0 0.8rem; border: 0; padding: 0; }
.post .feature h2::before { content: none; }
.feature h2 a { color: var(--strong); text-decoration: none; }
.feature h2 a:hover { color: var(--accent); }
.talk-card h3 a:hover, .talk-card:has(.talk-thumb:hover) h3 a { color: var(--accent); }
:is(.feature h2, .talk-card h3) .go .icon { width: 0.8em; height: 0.8em; margin-left: 0.35em; vertical-align: -0.02em; color: var(--accent); transition: transform 0.2s; }
.feature h2 a:hover .go .icon, .feature:has(.feature-visual:hover) h2 .go .icon, .talk-card h3 a:hover .go .icon, .talk-card:has(.talk-thumb:hover) h3 .go .icon { transform: translateX(4px); }
.feature:has(.feature-visual:hover) h2 a { color: var(--accent); }
.feature .summary { color: var(--muted); margin: 0 0 1.4rem; }
.feature-actions, .talk-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; }

/* Talks: a card per talk, led by the first slide. */
.talk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.75rem; }
.talk-thumb { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: #fff; margin-bottom: 0.9rem; }
.talk-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; transition: transform 0.35s; }
.talk-thumb .play { position: absolute; inset: auto 0.6rem 0.6rem auto; padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--strong); color: var(--bg); opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; }
.talk-thumb.visual { background: var(--panel); display: grid; place-items: center; padding: 0; }
.talk-thumb.visual svg { transform: scale(1.12); }
.talk-thumb.visual svg { width: 100%; height: 100%; }
.talk-card:hover .talk-thumb img { transform: scale(1.03); }
.talk-card:hover .talk-thumb .play { opacity: 1; transform: none; }
.talk-card:hover .talk-thumb { border-color: var(--accent); }
.post .talk-card h3 { font-size: 1.05rem; line-height: 1.3; margin: 0 0 0.8rem; }
.post .talk-card h3::before { content: none; }
.talk-card h3 a { color: var(--strong); text-decoration: none; }
.talk-card h3 a:hover { color: var(--accent); }
.button.small { padding: 0.35rem 0.85rem; font-size: 0.8rem; }

@media (max-width: 52rem) {
  .feature, .feature.flip { grid-template-columns: 1fr; gap: 1.25rem; }
  .feature.flip .feature-visual { order: 0; }
  .feature-visual { padding: 1.1rem; }
}

/* Practical-work talk title visual (site.js, heroLex). */
#hero-lex .lex-box { fill: var(--panel); stroke: var(--line); }
#hero-lex .law { font-size: 15px; fill: var(--muted); }
#hero-lex .law .phrase { fill: var(--text); }
#hero-lex .code { font-size: 11.5px; fill: var(--muted); }
#hero-lex .code .kw { fill: var(--tok-kw); font-weight: 600; }
#hero-lex .code .fn { fill: var(--tok-fn); }
#hero-lex .hl { fill: color-mix(in srgb, var(--accent) 18%, transparent); opacity: 0; transition: opacity 0.5s; }
#hero-lex .hl.on { opacity: 1; }
#hero-lex tspan { transition: fill 0.5s; }
#hero-lex .law .phrase.on, #hero-lex .code .fn.on { fill: var(--accent); }
#hero-lex .link { fill: none; stroke: var(--accent); stroke-width: 1.3; stroke-dashoffset: var(--len); opacity: 0; transition: stroke-dashoffset 0.9s ease-out, opacity 0.4s; }
#hero-lex .link.on { stroke-dashoffset: 0; opacity: 1; }
#hero-lex.still .link { stroke-dashoffset: 0; opacity: 0.45; }
#hero-lex.still .hl { opacity: 1; }
.pipeline-diagram rect.end { stroke: var(--accent); }

/* Theme toggle (site.js): system, light, dark. */
.theme-toggle { margin-left: auto; display: inline-flex; align-items: center; gap: 0.4rem; font: 0.72rem var(--mono); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.7rem; cursor: pointer; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 0.9rem; height: 0.9rem; }
.reader-bar .theme-toggle { margin-left: 0; }
body.presenting .site-nav { display: none; }

/* Wide screens: thesis and home pages grow with the window, so the text
   column is not lost in the middle (talk pages size their slide cards). */
@media (min-width: 1500px) { body:is(.thesis, .home) main { zoom: 1.08; } }
@media (min-width: 1750px) { body:is(.thesis, .home) main { zoom: 1.16; } }
@media (min-width: 2000px) { body:is(.thesis, .home) main { zoom: 1.24; } }
@media (min-width: 2400px) { body:is(.thesis, .home) main { zoom: 1.34; } }
.talk-thumb .refinement-tree { width: 100%; }
.talk-thumb.visual .refinement-tree svg { transform: none; height: auto; }
/* Original slides in full screen (F): one slide filling the screen on black. */
button.icon-button { font: inherit; cursor: pointer; }
body.reader.full { background: #000; }
body.reader.full .reader-bar, body.reader.full .deck-nav { display: none; }
body.reader.full .pages.slides { --slide-w: min(100vw, calc(100dvh * var(--ratio))); gap: 0; align-items: center; height: 100dvh; }
body.reader.full .pages.slides .sheet { transform: none; opacity: 0; transition: none; }
body.reader.full .pages.slides .sheet.cur { opacity: 1; }
body.reader.full .pages.slides .page-no { display: none; }
/* Present mode on touch screens: the controls stay visible and are big enough to tap. */
@media (hover: none) {
  body.presenting .present-bar { opacity: 0.8; bottom: max(0.75rem, env(safe-area-inset-bottom)); font-size: 0.85rem; }
  body.presenting .present-bar button { padding: 0.45rem 0.9rem; }
}
body.presenting { touch-action: pan-y pinch-zoom; }
body.reader.full .pages.slides { scroll-snap-type: none; }
body.reader.full .pages.slides .sheet.cur { animation: sheet-in 0.12s ease-out; }
@keyframes sheet-in { from { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { body.reader.full .pages.slides .sheet.cur { animation: none; } }
body.nav-hidden .site-nav:not(:focus-within) { transform: translateY(-100%); }
