
/* figkit.css — shared look for vLLM blog figures.
   Every figure page links this file; build.py inlines it. Do not restyle these
   tokens in a page: add a role here so all figures change together.

   Design: Swiss-style grid and type (flush left, one grotesk, uppercase mono
   for meta labels), a Morandi palette in the vLLM logo hues (greyed sky blue,
   greyed amber), 1.2px hairlines, square corners, no shadows (cf. zero-to-vllm). */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  color-scheme: light;
  --font: Inter, -apple-system, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --hair: 1.2px;

  /* surfaces and text: warm greys */
  --bg: #ffffff;
  --card: #f7f5f2;          /* player panel */
  --ink: #23201e;
  --muted: #605b56;
  --faint: #8e8881;   /* still >= 3:1 on white: faint text must stay readable */
  --rule: #e6e1da;          /* hairlines, gridlines */
  --line: #8f8a84;          /* arrows, connectors */

  /* Morandi line colors in the vLLM hues; fills are tints of the same line */
  --blue-line: #4d7ba6;     /* vLLM sky blue, greyed: global KV, long-lived state */
  --gold-line: #b5873a;     /* vLLM amber, greyed: the concept the figure introduces */
  --green-line: #6a8a5e;    /* sage: third category (side stream) */
  --stone-line: #9a958f;    /* ordinary work */
  --blue-text: #3e6890;
  --gold-text: #8a6420;
  --green-text: #4f6b45;

  /* data-chart series (dataviz validator: CVD + normal-vision separation pass) */
  --series-blue: #5a87b3;
  --series-gold: #c99a45;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: 520ms;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #18181a; --card: #201f1e;
    --ink: #f1eeea; --muted: #b3ada6; --faint: #8a847d; --rule: #34312e; --line: #7d7872;
    --blue-line: #8fb2d3; --gold-line: #d6b06a; --green-line: #9cb48f; --stone-line: #7f7a74;
    --blue-text: #a3c1dd; --gold-text: #e0c084; --green-text: #a9c09d;
    --series-blue: #6b93bb; --series-gold: #b08a45;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #18181a; --card: #201f1e;
  --ink: #f1eeea; --muted: #b3ada6; --faint: #8a847d; --rule: #34312e; --line: #7d7872;
  --blue-line: #8fb2d3; --gold-line: #d6b06a; --green-line: #9cb48f; --stone-line: #7f7a74;
  --blue-text: #a3c1dd; --gold-text: #e0c084; --green-text: #a9c09d;
  --series-blue: #6b93bb; --series-gold: #b08a45;
}

/* derived tints: soft (-t) for areas, main (-m) for emphasis, stroke (-ts) half strength */
:root {
  --blue-t: color-mix(in srgb, var(--blue-line) 13%, var(--bg));
  --blue-ts: color-mix(in srgb, var(--blue-line) 50%, var(--bg));
  --blue-m: color-mix(in srgb, var(--blue-line) 30%, var(--bg));
  --blue-ms: var(--blue-line);
  --gold-t: color-mix(in srgb, var(--gold-line) 14%, var(--bg));
  --gold-ts: color-mix(in srgb, var(--gold-line) 50%, var(--bg));
  --gold-m: color-mix(in srgb, var(--gold-line) 34%, var(--bg));
  --gold-ms: var(--gold-line);
  --green-t: color-mix(in srgb, var(--green-line) 15%, var(--bg));
  --green-ts: color-mix(in srgb, var(--green-line) 55%, var(--bg));
  --green-m: color-mix(in srgb, var(--green-line) 32%, var(--bg));
  --green-ms: var(--green-line);
  --slate-t: color-mix(in srgb, var(--stone-line) 11%, var(--bg));
  --slate: color-mix(in srgb, var(--stone-line) 60%, var(--bg));
  --hatch-bg: var(--bg);
  --hatch-line: color-mix(in srgb, var(--stone-line) 30%, var(--bg));
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --blue-t: color-mix(in srgb, var(--blue-line) 16%, var(--bg));
    --gold-t: color-mix(in srgb, var(--gold-line) 16%, var(--bg));
    --gold-m: color-mix(in srgb, var(--gold-line) 36%, var(--bg));
    --hatch-line: color-mix(in srgb, var(--stone-line) 40%, var(--bg));
  }
}
:root[data-theme="dark"] {
  --blue-t: color-mix(in srgb, var(--blue-line) 16%, var(--bg));
  --gold-t: color-mix(in srgb, var(--gold-line) 16%, var(--bg));
  --gold-m: color-mix(in srgb, var(--gold-line) 36%, var(--bg));
  --hatch-line: color-mix(in srgb, var(--stone-line) 40%, var(--bg));
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 400 15px/1.5 var(--font);
  /* no global "tnum": in Inter it also widens hyphens ("V4.1-Flash"); numbers opt in via .tnum / .t-num */
  -webkit-font-smoothing: antialiased;
  padding: 4px 0 8px;
}
.fig { max-width: 760px; margin: 0 auto; }

/* header: an uppercase mono kicker (optional), a sentence-case title, a muted subtitle */
.fig-kicker { font: 500 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.fig-title { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; margin: 0; }
.fig-sub { font-size: 14px; color: var(--muted); margin: 4px 0 0; }
.fig-head { margin-bottom: 16px; }
.fig-head-row { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }

/* the drawing; SVG text uses these classes, never inline font sizes */
.fig-stage { width: 100%; display: block; overflow: visible; }
.fig-stage text { font-family: var(--font); fill: var(--ink); }
.t-lab { font-size: 13px; fill: var(--ink); }
.t-lab-b { font-size: 13px; font-weight: 600; fill: var(--ink); }
.t-head { font-family: var(--mono) !important; font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; fill: var(--muted) !important; }
.t-mut { font-size: 13px; fill: var(--muted); }
.t-faint { font-size: 13px; fill: var(--faint); }
.t-blue { font-size: 13px; fill: var(--blue-text); font-weight: 500; }
.t-gold { font-size: 13px; fill: var(--gold-text); font-weight: 600; }
.t-mono { font-family: var(--mono) !important; font-size: 12px; font-weight: 500; }
/* ellipses: draw them with FK.dots (filled circles); a text "…" / "⋮" glyph is too thin to see */
.fk-dots { fill: var(--muted); stroke: none; }
.t-num { font-size: 13px; font-weight: 600; fill: var(--ink); }
.t-num, .tnum, /* grouped steps: a mono group label over its segments; step labels move to the explanation */
.fig-pills.grouped { gap: 12px; }
.fig-pgroup { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fig-pglabel { font: 500 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-pgroup.on .fig-pglabel { color: var(--ink); }
.fig-pgpills { display: flex; gap: 4px; }
.fig-pills.grouped .fig-pill { height: 10px; }
.fig-pills.grouped .fig-pill .lbl { display: none; }
.fig-count { font-variant-numeric: tabular-nums; }

/* marks by role (fill + hairline stroke). Square corners everywhere. */
.fig-stage rect { rx: 0; ry: 0; }
.fig-stage rect, .fig-stage path, .fig-stage line, .fig-stage polyline { stroke-width: var(--hair); }
.m-global     { fill: var(--blue-t);  stroke: var(--blue-ts); }
.m-global-new { fill: var(--blue-m);  stroke: var(--blue-ms); }
.m-window     { fill: var(--gold-t);  stroke: var(--gold-ts); }
.m-accent     { fill: var(--gold-m);  stroke: var(--gold-ms); }
.m-green      { fill: var(--green-t); stroke: var(--green-ts); }
.m-green-strong { fill: var(--green-m); stroke: var(--green-ms); }
.m-computed   { fill: var(--slate-t); stroke: var(--slate); }
.m-skipped    { fill: url(#fk-hatch); stroke: var(--rule); }
.m-empty      { fill: var(--bg); stroke: var(--slate); stroke-dasharray: 3 2; }
.m-ghost      { fill: none; stroke: var(--faint); stroke-dasharray: 4 3; }
.m-focus      { fill: none; stroke: var(--gold-ms); stroke-width: 2 !important; }
.m-rule       { stroke: var(--rule); fill: none; }
.m-line       { stroke: var(--line); fill: none; }
.fig-stage rect, .fig-stage path, .fig-stage line, .fig-stage text, .fig-stage g {
  transition: opacity var(--dur) var(--ease), fill var(--dur) var(--ease), stroke var(--dur) var(--ease);
}
.fade-out { opacity: 0; }
.dim { opacity: .28; }

/* legend: square swatches, sentence case */
.fig-legend { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.fig-legend span, .fig-legend button { display: inline-flex; align-items: center; gap: 8px; }
.fig-legend i { width: 14px; height: 10px; border: var(--hair) solid; display: inline-block; }
.fig-legend i.m-global     { background: var(--blue-t);  border-color: var(--blue-ts); }
.fig-legend i.m-global-new { background: var(--blue-m);  border-color: var(--blue-ms); }
.fig-legend i.m-window     { background: var(--gold-t);  border-color: var(--gold-ts); }
.fig-legend i.m-accent     { background: var(--gold-m);  border-color: var(--gold-ms); }
.fig-legend i.m-green      { background: var(--green-t); border-color: var(--green-ts); }
.fig-legend i.m-green-strong { background: var(--green-m); border-color: var(--green-ms); }
.fig-legend i.m-computed   { background: var(--slate-t); border-color: var(--slate); }
.fig-legend i.m-empty      { background: var(--bg); border: var(--hair) dashed var(--slate); }
.fig-legend i.m-ghost      { background: none; border: var(--hair) dashed var(--faint); }
.fig-legend i.m-skipped    { border-color: var(--rule);
  background: repeating-linear-gradient(-45deg, var(--hatch-bg) 0 3px, var(--hatch-line) 3px 4.5px); }
.fig-legend i.s-blue { background: var(--series-blue); border-color: transparent; }
.fig-legend i.s-gold { background: var(--series-gold); border-color: transparent; }
.fig-legend i.ref-line { width: 18px; height: 0; border: 0; border-top: var(--hair) dashed var(--line); }

/* step player: hairline panel, square controls, segmented progress */
.fig-player { background: var(--card); border: var(--hair) solid var(--rule); padding: 14px 16px 16px; margin-top: 14px; }
.fig-controls { display: flex; align-items: center; gap: 6px; }
.fig-btn {
  font: 500 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  background: var(--bg); border: var(--hair) solid var(--rule); border-radius: 0;
  height: 28px; min-width: 28px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer;
}
.fig-btn:hover { border-color: var(--line); }
.fig-btn:focus-visible, .fig-pill:focus-visible, .fig-seg button:focus-visible { outline: 2px solid var(--blue-line); outline-offset: 2px; }
.fig-btn svg { width: 10px; height: 10px; fill: currentColor; }
.fig-btn.play { min-width: 84px; }
.fig-pills { display: flex; gap: 4px; flex: 1; min-width: 0; margin-left: 8px; }
.fig-pill {
  flex: 1; min-width: 0; position: relative; height: 28px; border: 0; padding: 0; background: none; cursor: pointer;
  font: 500 12.5px/1 var(--font); color: var(--muted); text-align: left;
}
.fig-pill::before {  /* progress segment */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--rule);
}
.fig-pill .fill { position: absolute; left: 0; top: 0; height: 2px; width: 0; background: var(--gold-line); }
.fig-pill.done .fill { width: 100%; }
.fig-pill .lbl { position: absolute; left: 0; right: 2px; top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-pill.on .lbl { color: var(--ink); font-weight: 600; }
.fig-count { font: 500 11.5px/1 var(--mono); letter-spacing: .06em; color: var(--muted); min-width: 44px; text-align: right; }
.fig-explain { margin-top: 14px; min-height: 66px; }
.fig-explain h3 { font-size: 15px; font-weight: 600; margin: 0 0 3px; letter-spacing: -0.005em; }
.fig-explain p { font-size: 14px; color: var(--muted); margin: 0; max-width: 64ch; }
.fig-explain b, .fig-explain strong { color: var(--ink); font-weight: 600; }
.fig-explain .gold { color: var(--gold-text); font-weight: 600; }
.fig-explain code, .fig-sub code { font-family: var(--mono); font-size: 12.5px; }

/* segmented toggle */
.fig-seg { display: inline-flex; border: var(--hair) solid var(--rule); }
.fig-seg button {
  font: 500 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: var(--bg); border: 0; border-radius: 0; height: 28px; padding: 0 12px; cursor: pointer;
}
.fig-seg button + button { border-left: var(--hair) solid var(--rule); }
.fig-seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* text button (e.g. "Show table") */
.fig-link { font: 500 11.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  background: none; border: var(--hair) solid var(--rule); border-radius: 0; height: 28px; padding: 0 10px; cursor: pointer; }

/* tooltip */
.fig-tip {
  position: fixed; pointer-events: none; z-index: 10; background: var(--bg); color: var(--ink);
  border: var(--hair) solid var(--line); padding: 8px 10px; font-size: 12.5px; line-height: 1.45;
  opacity: 0; transition: opacity 120ms;
}
.fig-tip.show { opacity: 1; }

@media (max-width: 560px) {
  .fig-pill .lbl { display: none; }
  .fig-pill { height: 12px; }
  .fig-explain { min-height: 88px; }
  .fig-btn.play { min-width: 28px; }
  .fig-btn.play .t { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
}

/* ---- motion.js (zero-to-vllm) support ---------------------------------- */
/* tone classes that motion.js creates (merge/split/ripple/glow/flow), mapped to our roles */
.tone-gold, .tone-oat  { fill: var(--gold-m);  stroke: var(--gold-ms); }
.tone-mist, .tone-blue { fill: var(--blue-t);  stroke: var(--blue-ts); }
.tone-sage, .tone-green { fill: var(--green-t); stroke: var(--green-ts); }
.tone-stone { fill: var(--slate-t); stroke: var(--slate); }
.line-gold, .line-oat { stroke: var(--gold-ms); fill: none; }
.line-mist, .line-blue { stroke: var(--blue-ms); fill: none; }
.line-sage, .line-green { stroke: var(--green-ms); fill: none; }
.line-rose { stroke: var(--gold-ms); fill: none; }
.fill-gold { fill: var(--gold-ms); } .fill-mist, .fill-blue { fill: var(--blue-ms); } .fill-sage { fill: var(--green-ms); }
/* highlight(): hovering a [data-link] mark lights its group and dims the rest */
[data-link] { cursor: pointer; transition: opacity 320ms cubic-bezier(.16, 1, .3, 1); }
[data-link]:focus { outline: none; }
.mo-dim { opacity: .2; }
.mo-flow, .mo-flow-guide, .mo-ripple { pointer-events: none; }

/* ---- canvas frame: L-shaped corner marks around the drawing (cf. zero-to-vllm) ---- */
.fig-frame { position: relative; padding: 14px 12px 10px; }
.fig-frame::before, .fig-frame::after, .fig-frame > .fig-corners::before, .fig-frame > .fig-corners::after {
  content: ""; position: absolute; width: 9px; height: 9px; border: 0 solid var(--line); pointer-events: none;
}
.fig-frame::before { left: 0; top: 0; border-left-width: var(--hair); border-top-width: var(--hair); }
.fig-frame::after { right: 0; top: 0; border-right-width: var(--hair); border-top-width: var(--hair); }
.fig-frame > .fig-corners::before { left: 0; bottom: 0; border-left-width: var(--hair); border-bottom-width: var(--hair); }
.fig-frame > .fig-corners::after { right: 0; bottom: 0; border-right-width: var(--hair); border-bottom-width: var(--hair); }
.fig-note { font: 400 12px/1.45 var(--mono); color: var(--muted); margin: 8px 0 0; }   /* footnote inside the frame */
