/* === variables.css === */
/* ============================================================
   CSS custom properties — distill-inspired design system
   ============================================================ */

:root {
  /* Typography: one system for prose and figures. Helvetica Neue (a system
     font on macOS/iOS; Helvetica, then Arial elsewhere) for text and figure
     labels (also static/rosetta/viz-theme.css --viz-font-sans); IBM Plex Mono
     for tokens, chips and code (--viz-font-mono), from Google Fonts via
     ssg/config.py WEB_FONT_URL. */
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;

  /* Layout */
  --col-width: 60px;
  --col-gap:   32px;
  --n-cols:    12;

  /* Derived widths — all from column math so grid and hero stay in sync */
  --text-width:   880px;                                                     /* was 8 cols + 7 gaps = 704px */
  --gutter-width: calc(2 * var(--col-width) + 1 * var(--col-gap));          /* 152px */
  --page-width:   calc(var(--text-width) + 2 * var(--gutter-width));        /* 1008px */

  /* Light mode colors — closely matching distill.pub */
  --text-color:       rgba(0, 0, 0, 0.8);
  --heading-color:    rgba(0, 0, 0, 0.9);
  --bg-color:         #fff;          /* = --viz-page (light) */
  --link-color:       rgb(55, 174, 151);
  --link-border:      rgba(0, 0, 0, 0.4);
  --meta-color:       rgba(0, 0, 0, 0.55);
  --border-color:     rgba(0, 0, 0, 0.1);
  --border-medium:    rgba(0, 0, 0, 0.2);
  --code-bg:          rgba(0, 0, 0, 0.04);
  --blockquote-color: rgba(0, 0, 0, 0.6);
  --hover-bg:         rgba(250, 250, 250, 0.95);
  --tooltip-bg:       #fff;
  --tooltip-shadow:   0 2px 10px rgba(0, 0, 0, 0.12);
  --selection-bg:     rgba(0, 100, 255, 0.12);
  --tag-color:        rgba(0, 0, 0, 0.6);
  --tag-border:       rgba(0, 0, 0, 0.35);

  /* Accent */
  --accent-color: #009688;
  --nav-bg:       rgb(40, 40, 40);
  --nav-border:   rgba(0, 0, 0, 0.08);
  --nav-shadow:   0 1px 6px rgba(0, 0, 0, 0.15);

  color-scheme: light;
}

/* ------------------------------------------------------------
   Dark mode. The site's single switch is <html data-theme="dark">
   (set from localStorage before first paint, flipped by the nav
   toggle; default light). The page ground equals viz-theme's dark
   --viz-page (#111111), so figures sit on the page without a panel.
   ------------------------------------------------------------ */
:root[data-theme="dark"] {
  --text-color:       rgba(255, 255, 255, 0.80);
  --heading-color:    rgba(255, 255, 255, 0.92);
  --bg-color:         #111111;       /* = --viz-page (dark) */
  --link-color:       rgb(94, 206, 182);
  --link-border:      rgba(255, 255, 255, 0.45);
  --meta-color:       rgba(255, 255, 255, 0.56);
  --border-color:     rgba(255, 255, 255, 0.12);
  --border-medium:    rgba(255, 255, 255, 0.24);
  --code-bg:          rgba(255, 255, 255, 0.06);
  --blockquote-color: rgba(255, 255, 255, 0.66);
  --hover-bg:         rgba(30, 30, 30, 0.95);
  --tooltip-bg:       #1c1c1c;       /* = --viz-card-fill (dark) */
  --tooltip-shadow:   0 2px 12px rgba(0, 0, 0, 0.6);
  --selection-bg:     rgba(86, 162, 255, 0.30);
  --tag-color:        rgba(255, 255, 255, 0.66);
  --tag-border:       rgba(255, 255, 255, 0.35);

  --accent-color: #26a69a;
  --nav-bg:       #1a1a1a;
  --nav-border:   rgba(255, 255, 255, 0.08);
  --nav-shadow:   0 1px 0 rgba(255, 255, 255, 0.04);

  color-scheme: dark;
}

/* === base.css === */
/* ============================================================
   Base: reset, body, typography, links, code, math, tables
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size:   16px;
  line-height: 1.6em;
  color:       var(--text-color);
  background:  var(--bg-color);
  margin: 0;
  padding: 0;
}

/* ---- Headings ---- */
h1, h2, h3, h4, h5, h6 {
  color:       var(--heading-color);
  line-height: 1.1em;
  font-family: var(--font-body);
  margin-top:    1.5em;
  margin-bottom: 0.5em;
}

h1 {
  font-size:   2.5rem;
  font-weight: 700;
  line-height: 1.1em;
  margin-top:  0;
}

h2 {
  font-size:     1.5rem;
  font-weight:   600;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25em;
}

h3 {
  font-size:   1.125rem;
  font-weight: 700;
}

h4 {
  font-size:      0.875rem;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

strong, b { font-weight: 700; }

/* ---- Paragraphs ---- */
p {
  margin:    1em 0;
  hyphens:   none;
  word-wrap: break-word;
}

/* ---- Links ---- */
a {
  color:           var(--link-color);
  font-weight:     500;
  text-decoration: none;
  border-bottom:   1px solid transparent;
  transition:      border-color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--link-border);
}

a:visited {
  color: var(--link-color);
}

/* ---- Lists ---- */
ul, ol {
  padding-left: 2em;
  margin: 0.75em 0;
}

li {
  margin-bottom: 0.3em;
  line-height: 1.6em;
}

/* ---- Blockquotes ---- */
blockquote {
  margin:      1.5em 0;
  padding:     0.5em 0 0.5em 1.25em;
  border-left: 3px solid var(--border-color);
  color:       var(--blockquote-color);
  font-style:  italic;
}

blockquote p { margin: 0.4em 0; }

/* ---- Code ---- */
code {
  font-family:   var(--font-mono);
  font-size:     0.85em;
  background:    var(--code-bg);
  padding:       0.15em 0.35em;
  border-radius: 2px;
}

pre {
  background:    var(--code-bg);
  border:        1px solid var(--border-color);
  border-radius: 3px;
  padding:       1em 1.25em;
  overflow-x:    auto;
  font-size:     0.85em;
  line-height:   1.5;
  margin:        1.5em 0;
}

pre code {
  background: none;
  padding:    0;
  font-size:  1em;
}

/* ---- Horizontal rule ---- */
hr {
  border:     none;
  border-top: 1px solid var(--border-color);
  margin:     2em 0 0;
}

/* ---- Tables ---- */
table {
  width:           100%;
  border-collapse: collapse;
  font-size:       0.875em;
  margin:          1.5em 0;
}

th {
  font-weight:      600;
  text-align:       left;
  padding:          0.5em 0.75em;
  border-bottom:    2px solid var(--border-medium);
  color:            var(--heading-color);
}

td {
  padding:       0.45em 0.75em;
  border-bottom: 1px solid var(--border-color);
}

/* ---- Math (KaTeX) ---- */
.katex         { font-size: 1.0em; }
.katex-display {
  padding: 0.5em 0;
  margin:  1em 0;
}

/* ---- Text selection ---- */
::selection {
  background: var(--selection-bg);
}

/* ---- Figures / images ---- */
figure {
  margin: 2em 0;
}

figcaption {
  font-size:   0.8rem;
  line-height: 1.5em;
  color:       var(--meta-color);
  margin-top:  0.5em;
}

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

/* ---- Pandoc code blocks ----
   Pandoc wraps each source line in <a class="sourceLine">; without its own
   highlighting CSS those would inherit link color and weight. */
pre a.sourceLine {
  display:        inline-block;
  color:          inherit;
  font-weight:    inherit;
  border-bottom:  none;
  pointer-events: none;
  min-height:     1.2em;
}
div.sourceCode { margin: 1.5em 0; }
div.sourceCode > pre { margin: 0; }
code span.va, code span.kw { color: var(--heading-color); font-weight: 700; }
code span.dt { color: var(--link-color); }
code span.ot, code span.st { color: var(--text-color); }

/* BibTeX and other citation blocks wrap instead of scrolling sideways:
   each line becomes a hanging-indented block so wrapped values stay aligned. */
pre.sourceCode.bibtex { white-space: pre-wrap; overflow-x: visible; font-size: 0.74em; padding: 0.9em 1em; }
pre.sourceCode.bibtex > code { white-space: pre-wrap; overflow-wrap: anywhere; }
pre.sourceCode.bibtex a.sourceLine { padding-left: 4ch; text-indent: -4ch; }

/* ---- Pandoc endnotes ([^name]) ---- */
a.footnote-ref { border-bottom: none; }
a.footnote-ref sup { font-size: 0.7em; line-height: 0; }
section.footnotes {
  font-size:   0.85rem;
  line-height: 1.55em;
  color:       var(--meta-color);
  margin-top:  2.5em;
  border-top:  1px solid var(--border-color);
}
section.footnotes::before {
  content:        "Footnotes";
  display:        block;
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  margin-top:     1.25em;
}
section.footnotes hr { display: none; }
section.footnotes ol { padding-left: 1.4em; margin-top: 0.5em; }
section.footnotes li p { margin: 0 0 0.4em 0; }
a.footnote-back { margin-left: 0.3em; color: var(--meta-color); border-bottom: none; }

/* Appendix headings after the closing rule (References, Citation) use the quiet label style. */
.post-body h2#references {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  margin-top:     1.25em;
  margin-bottom:  0.5em;
}
.post-body h2#references + ol { font-size: 0.9rem; margin-bottom: 1.5em; }

/* Acknowledgments and Citation: a quiet label + small grey text */
.post-body h2#acknowledgments,
.post-body h2#citation {
  font-size:      0.85rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color:          var(--text-color);
  margin-top:     2.25em;
  margin-bottom:  0.5em;
}
.post-body h2#acknowledgments + p,
.post-body h2#acknowledgments + p + p,
.post-body h2#citation + p { font-size: 0.95rem; line-height: 1.65; color: var(--blockquote-color); }

/* Margin footnotes (static/footnote-margin.js): the note shows in the empty
   right margin beside its marker; a popover under the marker where the margin
   is too narrow. */
.fn-margin {
  position:    absolute;
  z-index:     50;
  font-size:   0.8rem;
  line-height: 1.5;
  color:       var(--meta-color);
}
.fn-margin[hidden] { display: none; }
.fn-margin p { display: inline; margin: 0; }
.fn-margin-num { color: var(--text-color); font-weight: 600; margin-right: 0.35em; }
.fn-margin a { color: var(--link-color); }
.fn-margin--pop {
  background:    var(--tooltip-bg);
  border:        1px solid var(--border-color);
  border-radius: 6px;
  box-shadow:    var(--tooltip-shadow);
  padding:       0.6em 0.8em;
  color:         var(--text-color);
}

/* === controls.css === */
/* ============================================================
   Controls: site nav header + theme toggle
   ============================================================ */

/* ---- Site nav bar (distill-style) ---- */

.site-nav {
  position:         relative;
  height:           60px;
  background-color: var(--nav-bg);
  width:            100%;
  box-sizing:       border-box;
  z-index:          100;
  border-bottom:    1px solid var(--nav-border);
  box-shadow:       var(--nav-shadow);
}

.site-nav .nav-content {
  max-width:       calc(var(--page-width) + 2 * 80px);
  margin:          0 auto;
  height:          60px;
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0 80px;
}

.site-nav .nav-logo {
  display:         flex;
  align-items:     center;
  gap:             0.6em;
  font-size:       17px;
  font-weight:     300;
  color:           rgba(255, 255, 255, 0.9);
  text-decoration: none;
  border-bottom:   none;
  letter-spacing:  0.01em;
}

.site-nav .nav-logo:hover {
  color:        rgba(255, 255, 255, 1);
  border-bottom: none;
}

.site-nav .nav-logo img {
  width:         28px;
  height:        28px;
  border-radius: 4px;
  display:       block;
  filter:        invert(1);   /* the site logo is black line art; show it white on the dark bar */
}

.site-nav .nav-links {
  display:     flex;
  align-items: center;
  gap:         1.5em;
}

.site-nav .nav-links a {
  font-size:       11px;
  font-weight:     400;
  text-transform:  uppercase;
  letter-spacing:  0.08em;
  color:           rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-bottom:   none;
  transition:      color 0.15s ease;
}

.site-nav .nav-links a:hover {
  color:        rgba(255, 255, 255, 1);
  border-bottom: none;
}

/* Theme toggle lives in the nav */
.nav-theme-toggle {
  background:    none;
  border:        1px solid rgba(255, 255, 255, 0.3);
  font-size:     0.75em;
  color:         rgba(255, 255, 255, 0.7);
  cursor:        pointer;
  padding:       0.3em 0.6em;
  border-radius: 3px;
  transition:    all 0.15s ease;
  font-family:   var(--font-body);
  line-height:   1;
}

.nav-theme-toggle:hover {
  color:        rgba(255, 255, 255, 1);
  border-color: rgba(255, 255, 255, 0.6);
}

.nav-theme-toggle:focus-visible {
  outline:        2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.site-nav .nav-right {
  display:     flex;
  align-items: center;
  gap:         1.25em;
}

.nav-theme-toggle {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  width:           30px;
  height:          26px;
  padding:         0;
  font-size:       12px;
}

/* Inline SVG theme icons (ssg/templates.py ICON_MOON / ICON_SUN): the moon
   offers dark mode on a light page, the sun offers light mode on a dark one. */
.nav-theme-toggle .icon       { display: block; }
.nav-theme-toggle .icon-sun   { display: none; }
:root[data-theme="dark"] .nav-theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .nav-theme-toggle .icon-sun  { display: block; }
.back-to-top a .icon          { display: inline-block; vertical-align: -0.125em; }

@media (max-width: 680px) {
  .site-nav,
  .site-nav .nav-content {
    height: 52px;
  }

  .site-nav .nav-logo {
    font-size: 15px;
  }

  .site-nav .nav-links {
    gap: 1em;
  }
}

/* === layout.css === */
/* ============================================================
   Layout: distill-style CSS grid for post pages + homepage
   ============================================================ */

/* ---- Post page grid ---- */

.post-grid {
  display:               grid;
  grid-template-columns: [screen-start] minmax(40px, 1fr)
                         [page-start kicker-start]   160px
                         [kicker-end text-start]      var(--text-width)
                         [text-end gutter-start]      160px
                         [gutter-end page-end]
                         minmax(40px, 1fr) [screen-end];
  row-gap:       0;
  overflow-x:    clip;  /* clip, not hidden — hidden creates a scroll container that breaks position: sticky inside */
}

/* All direct children default to the text column */
.post-grid > * {
  grid-column: text;
}

/* Figure layout utility classes — usable inside post body */
.l-body        { grid-column: text; }
.l-body-outset { grid-column: text / gutter-end; }
.l-page        { grid-column: page; }
.l-screen      { grid-column: screen; }
.l-gutter      { grid-column: gutter; }

/* ---- Sidenotes ([^a] style) ---- */
aside.sidenote {
  float:        right;
  clear:        right;
  width:        240px;
  margin-right: -260px;
  margin-left:  1em;
  margin-top:   0.2em;
  font-size:    0.78rem;
  line-height:  1.5em;
  color:        var(--meta-color);
}

aside.sidenote p {
  margin: 0;
}

/* On narrow screens, collapse sidenotes into indented block */
@media (max-width: 1100px) {
  aside.sidenote {
    float:         none;
    width:         auto;
    margin-right:  0;
    margin-left:   0;
    margin-top:    0.5em;
    margin-bottom: 0.5em;
    padding:       0.4em 0.6em;
    border-left:   2px solid var(--border-color);
    font-size:     0.8rem;
  }
}

/* ---- Math equation tooltips ---- */
span.eq-tip {
  position:      relative;
  cursor:        help;
}

span.eq-tip.eq-tip--display {
  display:       block;
  border-bottom: none;
  cursor:        help;
}

.eq-tip-tooltip {
  display:               none;
  position:              absolute;
  left:                  50%;
  bottom:                calc(100% + 8px);
  transform:             translateX(-50%);
  grid-template-columns: max-content 1fr;
  column-gap:            1em;
  row-gap:               0.25em;
  min-width:             200px;
  max-width:             480px;
  width:                 max-content;
  background:            var(--tooltip-bg);
  border:                1px solid var(--border-color);
  border-radius:         4px;
  padding:               0.55em 0.8em;
  font-size:             0.8rem;
  line-height:           1.7em;
  color:                 var(--text-color);
  box-shadow:            var(--tooltip-shadow);
  white-space:           normal;
  z-index:               200;
  pointer-events:        none;
}

span.eq-tip:hover .eq-tip-tooltip,
span.eq-tip:focus .eq-tip-tooltip,
span.eq-tip.eq-tip--open .eq-tip-tooltip {
  display: grid;
}

.eq-tip-entry {
  display: contents;
}
.eq-tip-math {
  justify-self: start;
}
.eq-tip-desc {
  color:        var(--meta-color);
  justify-self: start;
}

/* ---- Hover footnotes ([^1] style) ---- */
span.fn {
  position:    relative;
  cursor:      pointer;
  white-space: nowrap;
}

span.fn sup {
  color:       var(--link-color);
  font-size:   0.7em;
  font-weight: 500;
}

span.fn-tooltip {
  display:       none;
  position:      absolute;
  left:          50%;
  bottom:        calc(100% + 6px);
  transform:     translateX(-50%);
  width:         560px;
  background:    var(--tooltip-bg);
  border:        1px solid var(--border-color);
  border-radius: 4px;
  padding:       0.6em 0.8em;
  font-size:     0.78rem;
  line-height:   1.5em;
  color:         var(--text-color);
  box-shadow:    var(--tooltip-shadow);
  white-space:   normal;
  z-index:       100;
}

span.fn:hover span.fn-tooltip,
span.fn:focus span.fn-tooltip,
span.fn.fn--open span.fn-tooltip {
  display: block;
}

span.fn sup a {
  color:           var(--link-color);
  text-decoration: none;
}

/* ---- Footnotes section at end of post ---- */
.footnotes-section {
  margin-top: 2.5em;
  font-size:  0.88rem;
  color:      var(--text-color);
}

.footnotes-section hr {
  border:     none;
  border-top: 1px solid var(--border-color);
  margin-bottom: 1em;
}

.footnotes-section h2 {
  font-size:     1.1rem;
  font-weight:   600;
  margin-top:    0;
  margin-bottom: 0.6em;
  border-bottom: none;
}

.footnotes-list {
  padding-left: 1.4em;
  line-height:  1.6em;
}

.footnotes-list li {
  margin-bottom: 0.5em;
}

.footnotes-list li p {
  display: inline;
}

.fn-backref {
  text-decoration: none;
  margin-left:     0.2em;
  color:           var(--meta-color);
}

/* Post article element fills the grid */
.post-grid > article,
.post-grid > .comments-section,
.post-grid > .sequence-toc-container {
  grid-column: text;
}

/* ---- Post header (title block) ---- */

.post-header {
  grid-column:  text;
  margin-bottom: 2em;
  padding-top:   0.5em;
}

.post-header--standalone {
  padding-top: 1.5em;
}

.post-header h1 {
  font-size:   calc(1.75 * var(--hb));
  font-weight: 600;
  line-height: 1.2em;
  margin:      0 0 0.5em 0;
  color:       var(--heading-color);
}

/* ---- Byline ---- */

.byline {
  display:        flex;
  flex-wrap:      wrap;
  gap:            0.5em 3em;
  font-size:      0.8rem;
  line-height:    1.8em;
  color:          var(--meta-color);
  border-top:     1px solid var(--border-color);
  border-bottom:  1px solid var(--border-color);
  padding:        0.75em 0;
  margin-bottom:  2em;
}

.byline-section {
  display:        flex;
  flex-direction: column;
  flex:           1 1 0;
  min-width:      100px;
}

.byline-label {
  font-size:      0.625rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  line-height:    1.4em;
}

.byline-value {
  font-size:   0.8rem;
  line-height: 1.4em;
  color:       var(--text-color);
}

.byline-value a {
  color:        var(--text-color);
  border-bottom: none;
}

.byline-value a:hover {
  border-bottom: 1px solid var(--link-border);
}

/* Plain one-line byline (front matter `byline:`), used instead of the boxed byline */
.byline-plain {
  font-size:     1rem;
  line-height:   1.4em;
  color:         var(--meta-color);
  margin:        0 0 2em 0;
}

/* Paper / Project Page / Code links under the byline (front matter paper_url etc.).
   Plain underlined text links in a row, in the style of goodfire.com research posts. */
.byline-plain:has(+ .post-links) { margin-bottom: 0.6em; }

/* Optional second byline line (front matter `byline_note:`), e.g. paper co-authors */
.byline-plain:has(+ .byline-note) { margin-bottom: 0.25em; }
.byline-note {
  font-size:   0.9rem;
  line-height: 1.45em;
  color:       var(--meta-color);
  margin:      0 0 2em 0;
}
.byline-note:has(+ .post-links) { margin-bottom: 0.6em; }
.byline-note a {
  color:           inherit;
  text-decoration: none;
  border-bottom:   1px solid var(--link-border);
}
.byline-note a:hover { color: var(--text-color); }

.post-links {
  display:     flex;
  flex-wrap:   wrap;
  gap:         0.5em 1.4em;
  margin:      0 0 2em 0;
  font-size:   0.9rem;
  line-height: 1.5;
}

.post-links a,
.post-links a:visited {
  color:                     var(--text-color);
  font-weight:               400;
  border-bottom:             none;
  text-decoration:           underline;
  text-decoration-thickness: 1px;
  text-underline-offset:     0.2em;
  transition:                color 0.15s ease;
}

.post-links a:hover {
  color:         var(--link-color);
  border-bottom: none;
}

/* ---- Sequence nav (above title for sequence posts) ---- */

.sequence-nav-bar {
  grid-column:   text;
  font-size:     0.8rem;
  color:         var(--meta-color);
  margin-bottom: 0.4em;
  padding-top:   3em;
}

.sequence-nav-bar a {
  color:        var(--meta-color);
  border-bottom: none;
  white-space:  nowrap;
}

.sequence-nav-bar a:hover {
  color:        var(--link-color);
  border-bottom: 1px solid var(--link-border);
}

/* Sequence name header (first post only) */
.sequence-name-header {
  grid-column:  text;
  text-align:   center;
  padding-top:  3em;
  margin-bottom: 0;
}

.sequence-name-header h1 {
  font-size:   2rem;
  font-weight: 700;
  color:       var(--meta-color);
  margin:      0;
}

/* ---- Article body ---- */

.post-body--wide {
  grid-column:   screen;
  width:         min(880px, 100vw / var(--page-zoom, 1) - 4em);
  justify-self:  center;
  padding-top:   2em;
}

.post-body {
  grid-column: text;
  font-size:   1.0625rem; /* 17px */
  line-height: 1.7em;
  color:       var(--text-color);
}

.post-body > * + * {
  margin-top: 0;
}

.post-body p {
  margin: 0 0 1em 0;
}

.post-body h2 {
  font-size:      calc(1.9 * var(--hb));
  font-weight:    700;
  margin-top:     1.8em;
  margin-bottom:  0.6em;
  border-bottom:  none;
  padding-bottom: 0;
}

.post-body h3 {
  font-size:     calc(1.75 * var(--hb));
  font-weight:   700;
  margin-top:    1.5em;
  margin-bottom: 0.5em;
  border-bottom: none;
}

.post-body h4 {
  font-size:      calc(1.2 * var(--hb));
  font-weight:    600;
  text-transform: none;
  letter-spacing: normal;
  margin-top:     1.3em;
  margin-bottom:  0.35em;
  color:          var(--heading-color);
}

/* ---- Figure layout within post body ---- */

.post-body figure {
  margin: 2em 0;
}

/* These classes on a figure inside .post-body push it into wider columns */
.post-body .l-body-outset {
  margin-left:  0;
  margin-right: calc(-160px - var(--col-gap));
}

.post-body .l-page {
  margin-left:  calc(-160px - var(--col-gap));
  margin-right: calc(-160px - var(--col-gap));
}

/* ---- Appendix (citation block) ---- */

.post-appendix {
  grid-column:    text;
  border-top:     1px solid var(--border-color);
  margin-top:     3em;
  padding-top:    1.5em;
  font-size:      0.85em;
  line-height:    1.7em;
  color:          var(--meta-color);
}

.post-appendix h2 {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  border-bottom:  none;
  margin-top:     0;
  margin-bottom:  0.75em;
}

.post-appendix pre {
  font-size:  0.85em;
  background: var(--code-bg);
  border:     1px solid var(--border-color);
}


/* ---- Homepage layout ---- */

.site-page {
  max-width: calc(var(--page-width) + 2 * 80px);
  margin:    0 auto;
  padding:   0 80px;
}

.site-header {
  padding:       3em 0 2em;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2.5em;
}

.site-header h1 {
  font-size:     2.5rem;
  font-weight:   700;
  margin:        0 0 0.2em 0;
  color:         var(--heading-color);
}

.site-subtitle {
  font-size:  1rem;
  color:      var(--meta-color);
  margin:     0 0 1.5em 0;
  font-style: italic;
}

.site-description {
  font-size:   1rem;
  line-height: 1.7em;
  color:       var(--text-color);
}

.site-description p { margin: 0.5em 0; }

/* ---- TOC sidebar (sequence end-of-post) ---- */

.sequence-toc-container {
  grid-column:   text;
  border-top:    1px solid var(--border-color);
  margin-top:    3em;
  padding-top:   1.5em;
}

/* ---- Sticky footer: push footer to bottom on short pages ---- */

body {
  display:        flex;
  flex-direction: column;
  min-height:     calc(100vh / var(--page-zoom, 1));
}

body > * { flex-shrink: 0; }

footer.site-footer {
  margin-top: auto;
}

/* ---- Footer ---- */

footer.site-footer {
  border-top: 1px solid var(--border-color);
  padding:    1.5em 80px 2em;
  font-size:  0.8rem;
  color:      var(--meta-color);
}

.site-footer-inner {
  max-width: calc(var(--text-width) + 2 * 80px);
  margin:    0 auto;
  display:   flex;
  flex-direction: column;
  align-items: center;
  gap:       1em;
}

/* Inline subscribe row */
.footer-subscribe-row {
  display:     flex;
  align-items: center;
  gap:         0.5em;
  flex-wrap:   wrap;
}

.footer-subscribe-label {
  color:      var(--meta-color);
  font-size:  0.8rem;
  white-space: nowrap;
}

.footer-links {
  display:         flex;
  gap:             1.25em;
  flex-wrap:       wrap;
  justify-content: center;
}

.footer-links a {
  color:         var(--meta-color);
  border-bottom: none;
}

.footer-links a:hover {
  color:         var(--link-color);
  border-bottom: 1px solid var(--link-border);
}

.footer-subscribe-success {
  color:     var(--meta-color);
  font-size: 0.8rem;
  margin:    0;
}

@media (max-width: 700px) {
  footer.site-footer {
    padding: 1.5em 1.5em 2em;
  }
}

/* ---- Floating TOC sidebar ---- */

/* Invisible kicker-column placeholder; one per header row above the article.
   Occupies a grid cell so that nav.post-toc auto-places into the article row. */
.toc-spacer {
  grid-column: screen-start / kicker-end;
}

nav.post-toc {
  grid-column:   screen-start / kicker-end;
  grid-row:      auto / span 100;  /* auto-placed after spacers; spans through article + comments */
  align-self:    start;
  position:      sticky;
  top:           5em;
  max-height:    calc(100vh / var(--page-zoom, 1) - 6em);
  overflow-y:    auto;
  font-size:     0.82rem;
  line-height:   1.6em;
  color:         var(--meta-color);
  padding-left:  1.5em;
  padding-right: 1.5em;
}

nav.post-toc h3 {
  font-size:      0.6rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  margin:         0 0 0.6em 0;
  border:         none;
  padding:        0;
}

nav.post-toc a {
  display:         block;
  color:           var(--meta-color);
  opacity:         0.7;
  text-decoration: none;
  border-bottom:   none;
  padding:         0.15em 0;
  transition:      color 0.15s ease, opacity 0.15s ease;
}

nav.post-toc a:hover {
  color:   var(--link-color);
  opacity: 1;
}

nav.post-toc a.toc-active {
  color:       var(--link-color);
  font-weight: 500;
  opacity:     1;
}

nav.post-toc .toc-h2 {
  margin-top: 0.3em;
}

nav.post-toc .toc-h3 {
  padding-left: 0.75em;
  font-size:    0.78rem;
}

nav.post-toc .toc-h4 {
  padding-left: 1.5em;
  font-size:    0.75rem;
}

/* ---- Section numbers (front matter `number_sections: true`) ---- */

.post-body .section-number {
  color:        var(--meta-color);
  font-weight:  400;
  margin-right: 0.35em;
  font-variant-numeric: tabular-nums;
}

nav.post-toc a:has(> .toc-number) {
  display:      flex;          /* wrapped titles hang-indent past the number */
}

nav.post-toc .toc-number {
  flex:         none;
  min-width:    1.6em;
  font-variant-numeric: tabular-nums;
}

nav.post-toc .toc-h3 .toc-number {
  min-width:    2em;
}

/* ---- Sequence landing page ---- */

.seq-landing {
  max-width:  var(--text-width);
  margin:     4em auto 0;
}

.seq-landing-title {
  font-size:   2.25rem;
  font-weight: 700;
  margin:      0 0 0.3em 0;
  color:       var(--heading-color);
}

.seq-landing-date {
  margin-bottom: 0.5em;
}

.seq-landing-posts {
  display:        flex;
  flex-direction: column;
  margin-top:     0.75em;
}

.seq-landing-posts .post-link {
  padding:     0.75em 0;
  border-top:  1px solid var(--border-color);
}

.seq-landing-posts .post-link-title {
  font-size:   1.1rem;
  font-weight: 600;
  color:       var(--heading-color);
  line-height: 1.3em;
}

.seq-landing-posts .post-link:hover .post-link-title {
  color: var(--link-color);
}

.seq-landing-posts .post-link-author {
  font-size:  0.75rem;
  color:      var(--meta-color);
  margin-top: 0.05em;
}

.seq-landing-posts .post-link-author a,
.seq-landing-posts .post-link-author a:visited {
  color:              var(--meta-color);
  border-bottom:      none;
}

.seq-landing-posts .post-link-author a:hover {
  color:              var(--meta-color);
  border-bottom:      none;
  border-bottom-color: transparent;
}

/* An author with no listed affiliation keeps an empty, row-height cell so the
   name and affiliation columns stay aligned (no placeholder dash). */
.byline-value--empty { min-height: 1.4em; }
@media (max-width: 1023px) {
  .byline-value--empty { display: none; }
}

/* Roadmap box at the end of an introduction (posts/*: <div class="post-roadmap">) */
.post-body .post-roadmap {
  margin: 1.5em 0 2em;
  padding: 1em 1.4em 1em 1.2em;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.post-body .post-roadmap ul { margin: 0; padding-left: 1.2em; }
.post-body .post-roadmap li { margin: 0 0 0.55em; }
.post-body .post-roadmap li:last-child { margin-bottom: 0; }
.post-body .post-roadmap li p { margin: 0; }
.post-body .post-roadmap .post-roadmap-title {
  margin: 0 0 0.6em;
  text-align: center;
  font-size: 1.25em;
  font-weight: 700;
  color: var(--heading-color);
}
.post-body .post-roadmap .roadmap-num {
  margin-right: 0.45em;
  font-weight: 600;   /* part of the link: same colour, so it reads as clickable */
}

/* TL;DR box at the top of a section (posts/*: <div class="post-tldr">) */
.post-body .post-tldr {
  margin: 1.2em 0 1.8em;
  padding: 0.95em 1.35em 1.05em;
  background: color-mix(in srgb, var(--accent-color) 5%, var(--bg-color));
  border: 1px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
  border-radius: 12px;
}
.post-body .post-tldr p { margin: 0; font-style: italic; }
.post-body .post-tldr .post-tldr-label { font-style: normal; }
.post-body .post-tldr .post-tldr-label {
  margin: 0 0 0.4em;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-color);
}

/* A key question set apart in the prose (posts/*: <p class="post-question">) */
.post-body p.post-question {
  margin: 1.4em 0 1.5em;
  text-align: center;
  font-size: 1.2em;
  font-weight: 400;
  font-style: italic;
  color: var(--heading-color);
}

/* === components.css === */
/* ============================================================
   Components: sequence cards, post links, homepage entries,
   comments section
   ============================================================ */

/* ---- Homepage announcement banner ---- */

.announcement {
  text-align:  center;
  font-size:   1.0625rem;
  padding:     2em 0 1em;
  color:       var(--text-color);
}

.announcement-rule {
  border:      none;
  border-top:  1px solid var(--border-color);
  margin:      0;
}

/* ---- Distill-style post list (homepage) ---- */

.post-list {
  margin-top: 1.5em;
}

/* Each row is a 3-col flex: meta | body | thumbnail */
.post-preview {
  display:         flex;
  align-items:     flex-start;
  gap:             0;
  padding:         24px 0;
  border-bottom:   1px solid var(--border-color);
  cursor:          pointer;
  overflow:        hidden;
}


.post-preview:last-child {
  border-bottom: none;
}

.post-preview:hover .post-title a,
.post-preview:focus .post-title a {
  color:         var(--link-color);
  border-bottom: none;
}

/* Cancel the highlight when hovering anywhere in the sub-posts region */
.post-preview:has(.post-subposts:hover) .post-title a {
  color: var(--heading-color);
}

.post-preview .post-title a {
  color:           var(--heading-color);
  text-decoration: none;
  border-bottom:   none;
}

/* Left column: date + tag */
.post-meta {
  flex:       0 0 130px;
  min-width:  130px;
  padding-right: 1.5em;
  padding-top: 4px;
}

.post-date {
  font-size:   0.75rem;
  color:       var(--meta-color);
  line-height: 1.4em;
  margin-bottom: 0.4em;
  white-space: nowrap;
}

.post-tag {
  display:        inline-block;
  font-size:      0.65rem;
  font-weight:    500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color:          var(--tag-color);
  border:         1px solid var(--tag-border);
  border-radius:  2px;
  padding:        0.2em 0.45em;
  white-space:    nowrap;
}

/* Center column: title, authors, description, sub-posts */
.post-body-col {
  flex:       1 1 auto;
  min-width:  0;
  padding-right: 2em;
}

h2.post-title {
  font-size:   1.375rem;
  font-weight: 700;
  line-height: 1.2em;
  margin:      0 0 0.4em 0;
  border:      none;
  padding:     0;
  color:       var(--heading-color);
  transition:  color 0.15s ease;
}

.post-authors {
  font-size:    0.875rem;
  color:        var(--meta-color);
  margin:       0 0 0.6em 0;
  line-height:  1.4em;
}

.post-authors a {
  color:        inherit;
  border-bottom: none;
}

.post-authors a:hover {
  border-bottom: 1px solid var(--link-border);
}

.post-description {
  font-size:   0.9375rem;
  line-height: 1.5em;
  color:       var(--text-color);
  margin:      0 0 0.75em 0;
}

.post-description.post-coming-soon {
  color: var(--meta-color);
}

.post-preview--coming-soon {
  cursor: default;
}

.post-preview--coming-soon .post-title {
  font-weight: 500;
  color:       var(--meta-color);
}

/* Sub-posts list for sequences */
.post-subposts {
  display:        flex;
  flex-direction: column;
  gap:            0.1em;
  margin-top:     0.5em;
  padding-top:    0.5em;
  border-top:     1px solid var(--border-color);
}

.post-link {
  display:         flex;
  flex-direction:  column;
  text-decoration: none;
  border-bottom:   none;
  padding:         0.3em 0;
  transition:      color 0.15s ease;
}

.post-link-title {
  font-size:   0.9375rem;
  font-weight: 400;
  color:       var(--meta-color);
  line-height: 1.3em;
}

.post-link-author {
  font-size:   0.75rem;
  color:       var(--meta-color);
  line-height: 1.4em;
  margin-top:  0.1em;
}

.post-link-author a,
.post-link-author a:visited {
  color:         var(--meta-color);
  border-bottom: none;
}

.post-link-author a:hover {
  color:         var(--meta-color);
  border-bottom: none;
}

.post-link:hover .post-link-title {
  color: var(--link-color);
}

/* Right column: thumbnail */
.post-thumbnail {
  flex:       0 0 35%;
  max-width:  35%;
  align-self: flex-start;
  margin-top: 4px;
}

.post-thumbnail img,
.post-thumbnail video {
  display:    block;
  max-height: 100%;
  width:      auto;
  max-width:  100%;
  margin-left: auto;
}

.post-thumbnail video {
  max-width: 65%;
  margin:    0 auto;
}

.post-thumbnail--placeholder {
  /* no image — column collapses */
  display: none;
}

/* ---- Comments section ---- */

.comments-section {
  margin-top:  3em;
  padding-top: 2em;
  border-top:  1px solid var(--border-color);
}

.comments-section h2 {
  font-size:      0.7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:          var(--meta-color);
  border-bottom:  none;
  margin-top:     0;
  margin-bottom:  1.5em;
}

/* ---- Metadata (post byline area) ---- */

.metadata {
  font-size:  0.8rem;
  color:      var(--meta-color);
  font-style: italic;
}

/* ---- Figure caption ---- */

.figure-caption {
  font-size:   0.8rem;
  line-height: 1.5em;
  color:       var(--meta-color);
  margin-top:  0.5em;
}

.full-width-figure {
  text-align: center;
  margin:     2em 0;
}

.full-width-figure img {
  margin: 0 auto;
}

.full-width-figure img {
  max-width: 100%;
}

/* ---- People section (about page) ---- */

/* Stacked layout: Editors row, then Team row below */
hr + .people-section {
  margin-top: 0;
}

.people-section {
  display:        flex;
  flex-direction: column;
  gap:            0;
  margin-top:     0;
}

.people-group {
  padding-top: 0;
}

.people-group + .people-group {
  border-top: 1px solid var(--border-color);
  margin-top: 2em;
}

.people-group-label {
  font-size:      0.75rem;
  font-weight:    400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color:          var(--meta-color);
  padding-bottom: 0;
  margin:         0 0 0.75em 0;
}

/* Grid of person cards */
.people {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap:                   0.8em 1.5em;
  margin:                0;
}

/* Single person card */
.person {
  display:     flex;
  align-items: flex-start;
  gap:         0.75em;
}

.person .mug {
  flex-shrink:   0;
  width:         48px;
  height:        48px;
  border-radius: 50%;
  overflow:      hidden;
  border:        1px solid var(--border-color);
  display:       block;
}

.person .mug img {
  width:   100%;
  height:  100%;
  display: block;
  object-fit: cover;
}

.person-info {
  display:        flex;
  flex-direction: column;
  padding-top:    0.15em;
}

.person .name,
.person .name:visited {
  font-size:       0.9rem;
  font-weight:     600;
  color:           var(--text-color);
  text-decoration: none;
  border-bottom:   none;
  line-height:     1.3em;
  align-self:      flex-start;
}

.person .name:hover {
  border-bottom: 1px solid var(--link-border);
}

.person .affiliation {
  font-size:   0.78rem;
  color:       var(--meta-color);
  line-height: 1.3em;
  margin-top:  0.15em;
}

/* About page footer note */
/* ---- Collapsible breakout sections ---- */

summary.collapsible-h4 {
  font-size:   1.05em;
  font-weight: 600;
  cursor:      pointer;
}

hr.about-footer-rule {
  margin-top: 2em;
}

p.about-footer {
  font-size:  0.78rem;
  color:      var(--meta-color);
  margin-top: 0.5em;
}


/* Post figures and callouts (site-wide; previously defined inline per post) */
.post-figure { margin: 1.5em 0; text-align: center; }
.post-figure img, .post-figure video { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.post-figure figcaption { font-size: 0.85rem; line-height: 1.5em; opacity: 0.7; margin-top: 0.6em; font-style: italic; text-align: center; }
.callout-box { margin: 1.5em auto; padding: 1em 1.5em; border: 1px solid rgba(127, 127, 127, 0.35); border-radius: 8px; background-color: rgba(127, 127, 127, 0.08); }
.callout-box > :first-child { margin-top: 0; }
.callout-box > :last-child { margin-bottom: 0; }
.post-thumbnail img { border-radius: 3px; }
[data-theme="dark"] .post-thumbnail img { box-shadow: 0 0 0 1px var(--border-color); }

/* === questions.css === */
/* ============================================================
   Open questions, sequence TOC, back-to-top
   ============================================================ */

/* ---- Question title link ---- */

a.oq-title-link,
a.oq-title-link:visited {
  color:           inherit;
  font-weight:     inherit;
  text-decoration: none;
  border-bottom:   none;
}

a.oq-title-link:hover {
  border-bottom: 1px solid var(--link-border);
}

/* ---- Question text block on discussion page ---- */

blockquote.oq-question-text {
  border-left:  3px solid var(--meta-color);
  padding:      0.6em 0 0.6em 1.25em;
  margin:       0 0 1.5em 0;
  font-style:   normal;
  font-size:    1.05rem;
  color:        inherit;
}

blockquote.oq-question-text p { margin: 0; }

/* ---- Question boxes ---- */

.question-box {
  border:        1px solid var(--border-medium);
  border-left:   3px solid var(--meta-color);
  border-radius: 3px;
  padding:       1em 1.25em;
  margin:        1.5em 0 0.5em 0;
  background:    var(--code-bg);
  font-size:     0.95em;
  line-height:   1.6em;
}

.question-box p { margin: 0.4em 0; }
.question-box p:first-child { margin-top: 0; }
.question-box p:last-child  { margin-bottom: 0; }

/* oq-group: question section on the open-questions page */
.oq-group {
  margin-bottom: 3em;
}

.oq-group-title {
  font-size:     1.1rem;
  font-weight:   600;
  color:         var(--meta-color);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4em;
  margin-bottom:  1em;
  margin-top:     2em;
}

/* ---- Question navigation links ---- */

.oq-links {
  display:         flex;
  justify-content: space-between;
  align-items:     center;
  font-size:       0.8rem;
  color:           var(--meta-color);
  margin-top:      0.25em;
  margin-bottom:   1.5em;
}

.oq-see-all,
.oq-discussion {
  line-height: 1.4em;
}

.oq-see-all    { text-align: left; }
.oq-discussion { text-align: right; }

.oq-see-all a,
.oq-discussion a {
  color:        var(--meta-color);
  border-bottom: none;
}

.oq-see-all a:hover,
.oq-discussion a:hover {
  color:        var(--link-color);
  border-bottom: 1px solid var(--link-border);
}

.oq-source          { font-size: 0.85em; color: var(--meta-color); }
.oq-source a        { color: inherit; border-bottom: none; }
.oq-source a:hover  { border-bottom: 1px solid var(--link-border); }

/* ---- Sequence TOC (end of post) ---- */

.sequence-toc {
  margin:        2em 0;
  padding:       1.25em 1.5em;
  background:    var(--code-bg);
  border:        1px solid var(--border-color);
  border-radius: 4px;
  font-size:     0.9rem;
}

.sequence-toc h3 {
  font-size:     0.7rem;
  font-weight:   700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color:         var(--meta-color);
  border-bottom: none;
  margin-top:    0;
  margin-bottom: 0.75em;
  padding:       0;
}

.sequence-toc ol,
.sequence-toc ul {
  margin:      0;
  padding-left: 0;
  list-style:  none;
}

.sequence-toc li {
  padding:       0.2em 0;
  border-bottom: 1px solid var(--border-color);
}

.sequence-toc li:last-child { border-bottom: none; }

.sequence-toc a {
  color:        var(--text-color);
  border-bottom: none;
}

.sequence-toc a:hover {
  color:        var(--link-color);
  border-bottom: 1px solid var(--link-border);
}

.sequence-toc .toc-current {
  font-weight: 600;
  color:       var(--heading-color);
}

/* ---- Back to top ---- */

.back-to-top       { text-align: center; margin-top: 1.5em; }
.back-to-top a     { font-size: 1.25em; color: var(--meta-color); border-bottom: none; }
.back-to-top a:hover { color: var(--link-color); }

/* === widgets.css === */
@font-face {
  font-family: "DSEG7Classic";
  src: url("/static/assets/DSEG7Classic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   Widget color palette
   ============================================================ */
:root {
  /* Knob */
  --widget-knob-rim: #1b1611;
  --widget-knob-rim-shadow: rgba(70,50,25,0.22);
  --widget-knob-ridge: #655e51;
  --widget-knob-face-border: #2d2b29;
  --widget-knob-indicator-hi: #ffffff;
  --widget-knob-indicator-lo: #d1ccc1;
  --widget-knob-lo: #6b685e;
  --widget-knob-hi: #57534d;

  /* Slider */
  --widget-groove: #a49d93;
  --widget-groove-shadow: #383530;
  --widget-thumb-hi: #a29d92;
  --widget-thumb-lo: #30220b;
  --widget-thumb-ridge: #393530;
  --widget-readout: #dee7e1;

  /* Dashboard */
  --widget-dash-face: #fdfeff;
  --widget-dash-border: #cacccd;

  /* Labels */
  --widget-label-color: #7b8595;

  /* Transport buttons */
  --widget-btn-face-top: #dee7e13f;
  --widget-btn-face-bot: #dee7e1;
  --widget-btn-face-top-dn: #dee7e155;
  --widget-btn-border: #80787070;
  --widget-btn-shadow: rgba(0,0,0,0.38);
  --widget-btn-hi: rgba(255,255,255,0.5);
  --widget-btn-icon: #545b61;

  /* LED progress bar */
  --widget-led-lit: #f7fbff;
  --widget-led-unlit: #3f3f3f41;
  --widget-led-glow: rgb(51, 180, 255);
  --widget-led-track: #86827c00;

  /* Window */
  --widget-window-bg: #fdfeff;
  --widget-window-border: #cbccd754;

  /* Card */
  --widget-card-bg: transparent;
  --widget-card-border: #d0d1db;
}

/* ============================================================
   Widget containers and controls
   ============================================================ */

/* Base widget container — centered in the text column */
.widget {
  margin: 1.5em 0;
  padding: 1em 0;
}

.widget-svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

/* Slider row: label — track — readout */
.widget-slider {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin: 0.5em 0;
  font-size: 0.9rem;
  color: var(--text-color);
}

.widget-slider-label {
  flex: 0 0 auto;
  font-weight: 500;
  white-space: nowrap;
}

.widget-slider input[type="range"] {
  flex: 1 1 auto;
  min-width: 100px;
  accent-color: var(--accent-color);
}

.widget-slider-value {
  flex: 0 0 3em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--meta-color);
}

/* Controls wrapper (for groups of sliders / buttons) */
.widget-controls {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  margin-bottom: 0.75em;
}

/* ============================================================
   Widget Card — outer grouping container
   ============================================================ */

.widget-card {
  margin: 1.5em 0;
  padding: 1em 0.75em 0.25em;
  border: 1px solid var(--widget-card-border);
  border-radius: 12px;
  background: var(--widget-card-bg);
}

.widget-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 0.3em 0;
  color: var(--text-color);
}

.widget-card-desc {
  font-size: 0.85rem;
  color: var(--meta-color);
  margin: 0 0 0.75em 0;
  line-height: 1.5;
}

/* ============================================================
   Widget Window — scroll-reactive viewport with depth cue
   ============================================================ */

.widget-window {
  position: relative;
  overflow: hidden;
  margin: 0;
  border-radius: 10px;
}

.widget-window-clipper {
  position: absolute;
  overflow: hidden;
  border-radius: 10px;
  background: var(--widget-window-bg);
  /* box-shadow set dynamically by window.js (scroll-reactive depth cue) */
}

.widget-window-content {
  position: absolute;
}

.widget-window-border {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--widget-window-border);
  pointer-events: none;
}

.widget-card .widget-dashboard-wrapper {
  margin-bottom: 0;
}

/* ============================================
   Widget Dashboard
   ============================================ */

.widget-dashboard-wrapper {
  width: 100%;
  margin: 8px 0 1.5em 0;
}
.widget-dashboard-face {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5em;
  padding: 0.65em 1em;
  border-radius: 5px;
  background: var(--widget-dash-face);
  border: 1px solid var(--widget-dash-border);
}

/* Transport bar: [reset] [play/pause] [====progress====] */
.widget-transport {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Skeuomorphic transport button */
.widget-transport-btn {
  width: 26px;
  height: 20px;
  border-radius: 4px;
  border: 1.4px solid var(--widget-btn-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--widget-btn-face-top) 0%, var(--widget-btn-face-bot) 100%);
  color: var(--widget-btn-icon);
  box-shadow: 0 0 0 var(--widget-btn-shadow),
              inset 0 1px 0 var(--widget-btn-hi);
  transform: translateY(0);
  transition: box-shadow 55ms ease, transform 55ms ease, background 55ms ease;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
  outline: none;
}
.widget-transport-btn svg { width: 14px; height: 14px; display: block; }

/* Momentary press (mousedown held) */
.widget-transport-btn--pressed {
  background: linear-gradient(180deg, var(--widget-btn-face-top-dn) 0%, var(--widget-btn-face-bot) 100%);
  box-shadow: 0 0 0 var(--widget-btn-shadow),
              inset 0 2px 4px rgba(0,0,0,0.28);
}

/* Latched active state (play/pause stays down when playing) */
.widget-transport-btn--active {
  background: linear-gradient(180deg, var(--widget-btn-face-top-dn) 0%, var(--widget-btn-face-bot) 100%);
  box-shadow: 0 0 0 var(--widget-btn-shadow),
              inset 0 2px 5px rgba(0,0,0,0.32);
}

/* LED progress track */
.widget-transport-track {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 15px;
  box-sizing: border-box;
  padding: 4px 4px;
  background: var(--widget-led-track);
  border-radius: 5px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.6);
}

.widget-transport-led {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: var(--widget-led-unlit);
  transition: background 55ms ease;
}

.widget-transport-led--lit {
  background: var(--widget-led-lit);
  box-shadow: 0 0 3px var(--widget-led-glow), 0 0 7px var(--widget-led-glow);
}

/* Controls row (knobs, sliders) below the transport bar */
.widget-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2em;
  flex-wrap: wrap;
}

/* Rotary knob component */
.widget-knob-group { display: flex; flex-direction: column; align-items: center; gap: 0.3em; user-select: none; }
.widget-knob-row { display: flex; align-items: center; gap: 0.5em; }
.widget-knob-wrapper { width: 40px; height: 40px; flex-shrink: 0; }
.widget-knob-canvas { width: 100%; height: 100%; touch-action: none; cursor: grab; }
.widget-knob-canvas:active { cursor: grabbing; }
.widget-knob-readout {
    width: 48px;
    height: 24px;
    background: var(--widget-readout);
    border-radius: 3px;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: right;
    padding: 0.15em 0.4em;
    font-family: "DSEG7Classic", monospace;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: #333;
    font-variant-numeric: tabular-nums; }
.widget-knob-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--widget-label-color); font-weight: 600; }

/* Horizontal slider component */
.widget-slider-group { display: flex; flex-direction: row; align-items: center; gap: 0.4em; user-select: none; }
.widget-slider-lock { width: 14px; height: 14px; flex-shrink: 0; color: var(--widget-label-color); display: flex; align-items: center; justify-content: center; }
.widget-slider-lock svg { width: 100%; height: 100%; display: block; }
.widget-slider-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--widget-label-color); font-weight: 600; text-align: right; white-space: nowrap; }
.widget-slider-row { display: flex; align-items: center; gap: 0.5em; }
.widget-slider-wrapper { width: 160px; height: 36px; flex-shrink: 0; }
.widget-slider-canvas { width: 100%; height: 100%; touch-action: none; cursor: grab; }
.widget-slider-canvas:active { cursor: grabbing; }


/* === theme.css === */
/* Dark mode overrides — disabled for now */

/* === media.css === */
/* ============================================================
   Responsive breakpoints — mobile-first, matching distill.pub approach
   ============================================================ */

/* ---- Mobile default (< 768px) ---- */
/* Grid: all named zones share the same lines, 8px edge padding.
   Nothing can overflow because there are no fixed-px columns. */

/* Text scale: the root size drives body text, captions, TOC, notes. Headings
   (post title, section h1-h4) are sized off --hb instead, the previous root
   size, so raising the text size leaves them exactly as they were. */
:root { --hb: 14px; }
html { font-size: 16px; }   /* was 14px */

.post-grid {
  grid-template-columns: [screen-start page-start kicker-start text-start gutter-start]
                         1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr
                         [text-end page-end gutter-end kicker-end screen-end];
  padding: 0 20px;
}

.post-grid > * { grid-column: 1 / -1; }

nav.post-toc       { display: none; }
.post-body .l-body-outset,
.post-body .l-page { margin-left: 0; margin-right: 0; }

.site-page         { padding: 0 1.25em; }
.site-footer       { padding: 1.5em 1.25em; }

.site-nav          { height: auto; }
.site-nav .nav-content {
  max-width:   100%;
  height:      auto;
  padding:     0.6em 1.25em;
  flex-wrap:   wrap;
  gap:         0.4em 1em;
}
.site-nav .nav-logo { white-space: nowrap; }
.site-nav .nav-links { flex-wrap: wrap; gap: 0.4em 1em; }
.site-nav .nav-links a { white-space: nowrap; }

.sequence-nav-bar  { padding-top: 1em; }
.post-header       { margin-bottom: 1em; }
.post-header--standalone { padding-top: 2em; }
.byline            { margin-bottom: 0; }
.post-header h1    { font-size: calc(1.75 * var(--hb)); }
h1                 { font-size: calc(1.75 * var(--hb)); }
h2                 { font-size: calc(1.25 * var(--hb)); }
h3                 { font-size: calc(1.05 * var(--hb)); }
.post-body h2      { font-size: calc(1.4 * var(--hb)); }
.post-body h3      { font-size: calc(1.2 * var(--hb)); }
.post-body h4      { font-size: calc(1 * var(--hb)); }

.byline            { flex-direction: column; gap: 0.75em; }

/* Stack post list vertically */
.post-preview      { flex-wrap: wrap; }
.post-meta         { flex: 0 0 100%; padding-right: 0; margin-bottom: 0.5em; }
.post-body-col     { padding-right: 0; }
.post-thumbnail    { flex: 0 0 100%; max-width: 100%; margin-top: 1em; }

/* Footnote tooltip: constrain to viewport */
span.fn-tooltip    { width: calc(100vw - 2.5em); left: 0; transform: none; }

/* Sequence landing */
.seq-landing       { margin-top: 2em; }
.seq-landing-title { font-size: 1.75rem; }

/* ---- Tablet (>= 768px) ---- */

@media (min-width: 768px) {
  :root { --hb: 16px; }
  html { font-size: 18px; }   /* was 16px */

  .post-grid {
    grid-template-columns: [screen-start] 1fr
                           [page-start kicker-start text-start gutter-start]
                           repeat(8, 45px)
                           [text-end gutter-end kicker-end page-end]
                           1fr [screen-end];
    grid-column-gap: 16px;
    padding: 0;
  }

  .post-grid > * { grid-column: page; }

  .site-page       { padding: 0 2em; }
  .site-nav .nav-content { padding: 0 2em; }
  .site-footer     { padding: 1.5em 2em; }
}

/* ---- Page scale on wide screens ----
   On screens >= 1280px the whole page renders at 75%, the same as browser zoom
   at 75%. Applied only at >= 1280px so every breakpoint below is already in its
   widest state, and the layout matches real browser zoom. vw-based lengths are
   divided by --page-zoom, because 100vw inside a zoomed page is only 75% of the
   window. */
@media (min-width: 1280px) {
  html  { zoom: 0.75; }
  :root { --page-zoom: 0.75; }
}

/* ---- Desktop (>= 1024px): full multi-column grid ---- */

@media (min-width: 1024px) {
  /* Figure outsets. --vw-in is the viewport without a classic scrollbar
     (templates/post.html sets --sbw; 0 without JS). --outset is how far
     l-body-outset / l-page reach past the text column: the 160px gutter plus
     the column gap, shrunk so a figure always keeps 16px from the window edge
     (the grid below is 1104px wide at its widest fixed tracks, so without the
     clamp figures were clipped on the right below ~1100px). */
  :root {
    --vw-in:  calc((100vw - var(--sbw, 0px)) / var(--page-zoom, 1));
    --outset: min(calc(96px + var(--col-gap)),
                  calc((var(--vw-in) - var(--text-width)) / 2 - 16px));
  }

  /* Text column stays --text-width (800px) and centred; kicker/gutter shrink from 160px and
     the outer margins from any size down to 16px, so the grid never exceeds
     the viewport (percentages resolve against the grid's own width). */
  .post-grid {
    grid-template-columns: [screen-start] max(16px, calc((100% - var(--text-width)) / 2 - 160px))
                           [page-start kicker-start]  min(160px, calc((100% - var(--text-width)) / 2 - 16px))
                           [kicker-end text-start]     var(--text-width)
                           [text-end gutter-start]     min(160px, calc((100% - var(--text-width)) / 2 - 16px))
                           [gutter-end page-end]
                           max(16px, calc((100% - var(--text-width)) / 2 - 160px)) [screen-end];
    grid-column-gap: 0;
    padding: 0;
  }

  .post-grid > *         { grid-column: text; }
  /* The sticky TOC needs ~200px of left margin to be legible; below 1100px
     there is not enough, so it stays hidden (as on tablets and phones).
     With the 800px text column that point is 1200px (see the TOC block below). */
  nav.post-toc           { display: none; }
  /* centred on the text column: jut out half the outset on each side */
  .post-body .l-body-outset { margin-left: calc(-0.5 * var(--outset)); margin-right: calc(-0.5 * var(--outset)); }
  .post-body .l-page     { margin-left: calc(-1 * var(--outset)); margin-right: calc(-1 * var(--outset)); }

  .site-page       { padding: 0 80px; }
  .site-footer     { padding: 1.5em 80px; }

  .site-nav          { height: 60px; }
  .site-nav .nav-content {
    max-width:  calc(var(--page-width) + 2 * 80px);
    height:     60px;
    padding:    0 80px;
    flex-wrap:  nowrap;
    gap:        0;
  }
  .site-nav .nav-links { flex-wrap: nowrap; gap: 1.5em; }
  .site-nav .nav-links a { white-space: nowrap; }

  .sequence-nav-bar { padding-top: 3em; }
  .post-header h1  { font-size: calc(2.75 * var(--hb)); }
  h1               { font-size: calc(2.5 * var(--hb)); }
  h2               { font-size: calc(1.5 * var(--hb)); }
  h3               { font-size: calc(1.125 * var(--hb)); }
  .post-body h2    { font-size: calc(1.9 * var(--hb)); }
  .post-body h3    { font-size: calc(1.75 * var(--hb)); }
  .post-body h4    { font-size: calc(1.2 * var(--hb)); }

  .byline          { flex-direction: row; gap: 0.5em 3em; }

  .post-preview    { flex-wrap: nowrap; }
  .post-meta       { flex: 0 0 130px; padding-right: 1.5em; margin-bottom: 0; }
  .post-body-col   { padding-right: 2em; }
  .post-thumbnail  { flex: 0 0 35%; max-width: 35%; margin-top: 4px; }

  span.fn-tooltip  { width: 560px; left: 50%; transform: translateX(-50%); }

  .seq-landing     { margin-top: 4em; }
  .seq-landing-title { font-size: 2.25rem; }
}

/* ---- Sticky TOC (>= 1200px; was 1100px with the 704px text column) ----
   The TOC sits in the left margin in a box at most --toc-w wide. An l-page
   figure reaches left of the text column, so the two must never share
   columns (the sticky TOC would print over or be cut by the figure):
   - the l-page figure's left edge is clamped to start right of the TOC box,
     so just above 1200px it is flush with the text column (like
     l-body-outset) and from ~1600px up it gets its full symmetric outset;
   - on wide screens the TOC moves in from the window edge to sit just left of
     where an l-page figure begins, instead of far from the text.
   --text-start is the text column's left edge (the grid keeps it centred). */

@media (min-width: 1280px) {
  /* The TOC needs the left margin, so instead of clamping figures against it,
     the text column slides right (--shift) just far enough that every figure
     can jut out equally on both sides of the text. --L0 is where the column
     would start if centred; --outset shrinks so the shifted layout still fits. */
  :root {
    --toc-w:      248px;
    --L0:         calc((var(--vw-in) - var(--text-width)) / 2);
    --outset:     max(0px, min(calc(96px + var(--col-gap)),
                    calc((var(--vw-in) - var(--text-width) - var(--toc-w) - 24px) / 2)));
    --shift:      max(0px, calc(var(--toc-w) + 8px + var(--outset) - var(--L0)));
    --text-start: calc(var(--L0) + var(--shift));
  }
  .post-grid > :not(.post-toc) { position: relative; left: var(--shift); }
  nav.post-toc {
    display:      block;
    justify-self: end;
    --toc-mr:     clamp(0px, calc(var(--L0) - var(--toc-w)), calc(var(--outset) + 8px - var(--shift)));
    margin-right: var(--toc-mr);
    /* less inner padding (more room for the titles, so fewer wrap); where the margin has space to spare,
       the box also grows leftward by up to 80px, never past its grid area, and its right edge stays put */
    padding-left:  0.6em;
    padding-right: 0.9em;
    width:        min(calc(100% - var(--toc-mr)), calc(var(--toc-w) + 80px));
  }
}

/* ---- Tables: horizontal scroll on narrow screens ---- */

@media (max-width: 860px) {
  .post-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---- Print ---- */

@media print {
  body { font-size: 12pt; color: black; background: white; }
  .site-nav, .comments-section, .back-to-top, nav { display: none; }
  a { color: black; text-decoration: underline; border-bottom: none; }
  .post-grid { display: block; }
}

