/* Figures and callouts for the Berg & Purcell (1977) post, built on the metachow design
   system: its tokens (tokens.json v4), its fonts, and its component classes (bundle.css:
   Figure, Callout, Button, chart marks). The tokens are scoped to .mc-figure and
   .mc-callout, so the rest of the blog keeps its own palette and type. */

@font-face { font-family: 'Inter'; src: url('/fonts/metachow/Inter-Variable.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/metachow/Inter-Italic-Variable.woff2') format('woff2'); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/fonts/metachow/JetBrainsMono-Variable.woff2') format('woff2'); font-weight: 100 800; font-style: normal; font-display: swap; }

/* ---------- tokens ---------- */
.mc-figure,
.mc-callout {
  --paper: #f6f5f1;
  --paper-raised: #ffffff;
  --line: #d9d6cd;
  --line-strong: #7d848e;
  --ink: #18202b;
  --ink-muted: #5a6472;
  --sky: #1d5ea8;
  --sky-soft: #dfeaf7;
  --seal: #b5352a;
  --on-accent: #ffffff;
  --link: var(--sky);
  --data-1: #1d5ea8;
  --data-2: #c47c0c;
  --data-3: #0f7a67;
  --data-context: #b9bec5;
  --focus-ring: 0 0 0 2px #f6f5f1, 0 0 0 4px #1d5ea8;
  --space-1: 4px;
  --space-2: 8px;
  --space-4: 16px;
  --space-8: 32px;
  --radius-sm: 2px;
  --radius-md: 4px;
  --font-sans: 'Inter', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans', 'Noto Sans JP', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  /* Symbols in figures match the post's mathematics. The post is typeset by KaTeX
     (Computer Modern), so figures use CM too, as the system asks of LaTeX-set text. */
  --font-math: KaTeX_Math, 'Latin Modern Math', 'Times New Roman', serif;
  font-family: var(--font-sans);
  color: var(--ink);
}
:root[data-theme='dark'] .mc-figure,
:root[data-theme='dark'] .mc-callout {
  --paper: #13171d;
  --paper-raised: #1a1f27;
  --line: #2c333d;
  --line-strong: #6b7480;
  --ink: #e6e8eb;
  --ink-muted: #9aa3ae;
  --sky: #7aaee8;
  --sky-soft: #172a40;
  --seal: #e8705f;
  --on-accent: #13171d;
  --data-1: #7aaee8;
  --data-2: #e3a14a;
  --data-3: #4fb89f;
  --data-context: #4a525d;
  --focus-ring: 0 0 0 2px #13171d, 0 0 0 4px #7aaee8;
}

/* ---------- post-level pieces (blog styles) ---------- */
.post-content .bp-cite { font-family: var(--font-mono); font-size: 14px; color: var(--muted); }
.post-content h2 .num { margin-right: 10px; font-weight: 400; color: var(--faint); }
.post-content .katex { font-size: 1.08em; }
.post-content .katex-display { margin: 0 0 24px; padding: 2px 0; overflow-x: auto; overflow-y: hidden; }
.post-content .bp-refs p { margin: 0 0 8px; font-size: 14px; line-height: 22px; color: var(--muted); }

/* ---------- Callout (bundle.css) ---------- */
.post-content .mc-callout {
  display: flex;
  gap: var(--space-4);
  margin: var(--space-2) 0 var(--space-8);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--sky-soft);
  color: var(--ink);
}
.post-content .mc-callout-key { background: var(--paper-raised); border: 1px solid var(--line); }
.mc-seal { flex: none; width: 12px; height: 12px; margin-top: 7px; border-radius: var(--radius-sm); background: var(--seal); }
.mc-callout-inner { min-width: 0; }
.post-content .mc-callout p { margin: 0 0 var(--space-2); font-size: 16px; line-height: 26px; }
.post-content .mc-callout-inner > :last-child { margin-bottom: 0; }
.mc-callout-title { display: block; margin: 0 0 var(--space-1); font-weight: 600; }
.mc-callout .katex { font-size: 1.05em; }

/* ---------- Figure (bundle.css) ---------- */
.post-content .mc-figure { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-2) 0 var(--space-8); }
.mc-figure-plot {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper-raised);
}
.mc-figure-plot svg { display: block; width: 100%; height: auto; }
.post-content .mc-figure-cap,
.post-content .mc-figure-cap p { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.mc-figure-num { font-weight: 600; color: var(--ink); }
.mc-figure-cap .katex { font-size: 1.05em; }
.mc-figure :focus-visible { outline: 2px solid transparent; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.mc-figure .m { font-family: var(--font-math); font-style: italic; }

/* ---------- Button (bundle.css) ---------- */
.mc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink);
}
.mc-btn-md { height: 36px; padding: 0 var(--space-4); font-size: 15px; }
.mc-btn-sm { height: 28px; padding: 0 var(--space-2); font-size: 13px; }
.mc-btn:hover { border-color: var(--ink-muted); }
.mc-btn-primary { background: var(--sky); border-color: var(--sky); color: var(--on-accent); }
.mc-btn-primary:hover { border-color: var(--ink); }
.mc-btn[disabled] { cursor: not-allowed; opacity: 0.5; }

/* ---------- Slider (bundle.css) ---------- */
.mc-figure .controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.mc-slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 var(--space-2); }
.mc-slider-label { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.mc-slider-value { font-family: var(--font-mono); font-size: 13px; line-height: 20px; color: var(--ink); text-align: right; }
.mc-slider .mc-range { grid-column: 1 / -1; margin-top: var(--space-1); }
.mc-range { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer; --p: 50%; --d: -10%; }
.mc-range:focus-visible { box-shadow: none; }
.mc-range::-webkit-slider-runnable-track { height: 2px;
  background: linear-gradient(90deg, transparent calc(var(--d) - 1px), var(--ink-muted) calc(var(--d) - 1px), var(--ink-muted) calc(var(--d) + 1px), transparent calc(var(--d) + 1px)),
              linear-gradient(90deg, var(--sky) var(--p), var(--line) var(--p)); }
.mc-range::-webkit-slider-thumb { -webkit-appearance: none; box-sizing: border-box; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--paper-raised); border: 2px solid var(--sky); }
.mc-range:hover::-webkit-slider-thumb { background: var(--sky); }
.mc-range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); }
.mc-range::-moz-range-track { height: 2px; background: var(--line); }
.mc-range::-moz-range-progress { height: 2px; background: var(--sky); }
.mc-range::-moz-range-thumb { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-raised); border: 2px solid var(--sky); }
.mc-range:hover::-moz-range-thumb { background: var(--sky); }
.mc-range:focus-visible::-moz-range-thumb { box-shadow: var(--focus-ring); }
.mc-range[disabled] { cursor: not-allowed; opacity: 0.5; }

/* ---------- other controls inside a figure (tokens only) ---------- */
.post-content .mc-figure .panel-title { margin: var(--space-8) 0 var(--space-2); font-size: 13px; line-height: 20px; color: var(--ink); }
.post-content .mc-figure .panel-title:first-child { margin-top: 0; }
.mc-figure #sp-cv { touch-action: pan-y; cursor: grab; }
.mc-figure #sp-cv:active { cursor: grabbing; }
.mc-figure .sc-path { fill: none; stroke: var(--ink-muted); stroke-width: 1.2; stroke-linejoin: round; }
.mc-figure .sc-dot { fill: var(--ink); }
.mc-figure .cn-overlap { fill: var(--data-context); opacity: 0.6; }
.mc-figure .rt-band { fill: var(--line); opacity: 0.7; }
.mc-figure .readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: var(--space-2); margin-top: var(--space-4); }
.mc-figure .ro { padding: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.mc-figure .ro.wide { grid-column: 1 / -1; }
.mc-figure .ro .k { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.mc-figure .ro .v { font-family: var(--font-mono); font-size: 13px; line-height: 20px; font-weight: 600; color: var(--ink); }
.mc-figure .ro .t { font-family: var(--font-mono); font-size: 13px; line-height: 20px; color: var(--ink-muted); }

.mc-figure .btns { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }

.mc-figure canvas { display: block; width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mc-figure .cv-label { margin-top: var(--space-1); font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.mc-figure .status { min-height: 20px; margin-top: var(--space-2); font-family: var(--font-mono); font-size: 13px; line-height: 20px; color: var(--ink); }
.post-content .mc-figure .note { margin: 0; font-size: 13px; line-height: 20px; color: var(--ink-muted); }

.mc-figure .formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.mc-figure .field label { display: block; font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.mc-figure .field input,
.mc-figure .field select {
  width: 100%;
  height: 32px;
  padding: 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.mc-figure .seg { display: inline-flex; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.mc-figure .seg button { height: 30px; padding: 0 var(--space-4); font: inherit; font-size: 13px; color: var(--ink-muted); background: var(--paper); border: 0; cursor: pointer; }
.mc-figure .seg button[aria-pressed='true'] { color: var(--on-accent); background: var(--sky); }

/* ---------- chart marks (bundle.css names; widths per the system) ---------- */
.mc-figure .plot-bg { fill: var(--paper-raised); }
.mc-plot-axis { stroke: var(--ink); stroke-width: 1; fill: none; }
.mc-plot-tick { font-family: var(--font-mono); font-size: 11px; fill: var(--ink); }
.mc-plot-label { font-family: var(--font-sans); font-size: 12px; fill: var(--ink); }
.mc-plot-label .m { font-size: 14px; }
.mc-plot-note { font-family: var(--font-sans); font-size: 12px; }
.mc-plot-guide { stroke: var(--ink-muted); stroke-width: 1; fill: none; stroke-dasharray: 3 3; }
.mc-s1 { stroke: var(--sky); fill: none; stroke-width: 2; }
.mc-s1-mark { fill: var(--sky); }
.mc-s2 { stroke: var(--ink); fill: none; stroke-width: 1.5; stroke-dasharray: 1 3; stroke-linecap: round; }
.mc-s2-mark { fill: var(--paper-raised); stroke: var(--ink); stroke-width: 1.5; }
.mc-d1, .mc-d2, .mc-d3 { fill: none; stroke-width: 1.75; }
.mc-d1 { stroke: var(--data-1); } .mc-d1-mark { fill: var(--data-1); }
.mc-d2 { stroke: var(--data-2); } .mc-d2-mark { fill: var(--data-2); }
.mc-d3 { stroke: var(--data-3); } .mc-d3-mark { fill: var(--data-3); }
.mc-dash { stroke-dasharray: 6 4; }
.mc-figure .t-d1 { fill: var(--data-1); }
.mc-figure .t-d2 { fill: var(--data-2); }
.mc-figure .t-ink { fill: var(--ink); }
.mc-figure .t-muted { fill: var(--ink-muted); }

@media (max-width: 640px) {
  .mc-figure-plot { padding: var(--space-2); }
}
