/* blog-figures: shared tokens + figure chrome. Load once per site (served from the blog-assets bucket, figures/bf.css).
   Light tokens live on :root. The site toggles dark with a `.dark` class on <html> (next-themes), so dark tokens live under
   .dark. Do not rely on prefers-color-scheme alone: the reader can override the system theme with the site toggle.
   Everything below is scoped to .bf or a bf- class, so it cannot leak into the rest of the site. */
:root {
  --fig-bg: #f9f7f2;
  --fig-ink: #2b2926;
  --fig-muted: #7a766e;
  --fig-hair: #dcd7cc;
  --fig-hair-strong: #cdc7ba;
  --fig-true: #39796c;   /* green: what's actually true, ground truth, fresh */
  --fig-belief: #8b65a2; /* purple: what the agent believes or produced */
  --fig-serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --fig-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --fig-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* dark theme: .dark on <html>. Mid-tone green and purple so white chip text and coloured text both stay readable. */
.dark {
  --fig-bg: #1d1c1a;
  --fig-ink: #ece8df;
  --fig-muted: #a09b90;
  --fig-hair: #3b3834;
  --fig-hair-strong: #4c4841;
  --fig-true: #3f8f7f;
  --fig-belief: #9a73b3;
}

.bf { margin: 40px 0; }
.bf-legend { display: flex; flex-wrap: wrap; gap: 8px 24px; font-family: var(--fig-sans); font-size: 14px; color: var(--fig-muted); margin-bottom: 14px; }
.bf-legend span { display: inline-flex; align-items: center; gap: 8px; }
.bf-key { width: 22px; height: 14px; border-radius: 3px; display: inline-block; }
.bf-key.true { background: var(--fig-true); }
.bf-key.belief { background: var(--fig-belief); }
.bf-key.outline { border: 1.4px solid var(--fig-belief); }
.bf-key.dashed { border: 1.4px dashed var(--fig-muted); }

.bf-stage { display: flex; gap: 18px; align-items: flex-start; }
.bf-scene { flex: 1; min-width: 0; }
.bf-scene svg { display: block; width: 100%; height: auto; overflow: visible; }

/* SVG text roles */
.bf .label { font-family: var(--fig-mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; fill: var(--fig-muted); }
.bf .label.true { fill: var(--fig-true); }
.bf .label.belief { fill: var(--fig-belief); }
.bf .msg { font-family: var(--fig-serif); font-size: 14px; fill: var(--fig-ink); }
.bf .msg.aside { font-style: italic; fill: var(--fig-muted); }
.bf .chip-text { font-family: var(--fig-serif); font-size: 14px; }
.bf .answer { font-family: var(--fig-serif); font-size: 13px; font-style: italic; fill: var(--fig-ink); }
.bf .note { font-family: var(--fig-mono); font-size: 9px; letter-spacing: .08em; }

/* timeline controls. `all: unset` on buttons means every button rule below needs `.bf` in front to win */
.bf-timeline { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 2px; }
.bf-transport { display: flex; flex-direction: column; gap: 6px; }
.bf button { all: unset; cursor: pointer; display: grid; place-items: center; border-radius: 6px; color: var(--fig-muted); }
.bf button:hover { color: var(--fig-ink); }
.bf button:focus-visible { outline: 2px solid var(--fig-belief); outline-offset: 2px; }
.bf .bf-transport button { width: 28px; height: 28px; }
.bf-transport svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bf [data-play] .pause-icon { display: none; }
.bf[data-playing="true"] [data-play] .pause-icon { display: block; }
.bf[data-playing="true"] [data-play] .play-icon { display: none; }
.bf-segments { display: flex; flex-direction: column; gap: 6px; }
.bf .bf-segment { width: 12px; height: 46px; display: flex; justify-content: center; }
.bf-track { width: 5px; height: 100%; border-radius: 3px; background: var(--fig-hair); overflow: hidden; display: block; }
.bf-fill { display: block; width: 100%; height: 100%; background: var(--fig-true); transform-origin: top; transform: scaleY(var(--p, 0)); }
.bf .bf-segment[aria-current="step"] .bf-track { background: var(--fig-hair-strong); }
.bf-status { font-family: var(--fig-mono); font-size: 11px; letter-spacing: .06em; color: var(--fig-muted); margin: 10px 0 0; min-height: 1.4em; }
.bf figcaption { font-family: var(--fig-sans); font-size: 14px; line-height: 1.55; color: var(--fig-muted); margin-top: 18px; max-width: 70ch; }
.bf figcaption strong { color: var(--fig-ink); font-weight: 600; }

/* phone: controls go underneath. stretch, or the scene shrinks to its content width */
@media (max-width: 620px) {
  .bf-stage { flex-direction: column; align-items: stretch; }
  .bf-timeline { flex-direction: row; width: 100%; }
  .bf-transport { flex-direction: row; }
  .bf-segments { flex-direction: row; flex: 1; }
  .bf .bf-segment { flex: 1; min-width: 0; width: auto; height: 12px; align-items: center; justify-content: stretch; }
  .bf-track { width: 100%; height: 5px; }
  .bf-fill { transform-origin: left; transform: scaleX(var(--p, 0)); }
}

/* the site wraps posts in .prose, which styles figure, svg, p, button and figcaption. Win those fights explicitly. */
.prose .bf { margin: 40px 0; }
.prose .bf svg { margin: 0; max-width: none; }
.prose .bf .bf-status { margin: 10px 0 0; }
.prose .bf figcaption { margin: 18px 0 0; text-align: left; font-size: 14px; line-height: 1.55; }
.prose .bf button { margin: 0; }
