/* Long-form article layout: one reading column, wider figures, quiet chrome. */
:root {
  --ink: #1d2327;
  --ink-2: #3b4449;
  --muted: #6b7479;
  --faint: #d9dcd8;
  --line: #e7e8e4;
  --paper: #ffffff;
  --wash: #f7f6f2;
  --accent: #c4612f;
  --accent-wash: #fbeee6;
  --blue: #315c78;
  --col: 680px;
  --wide: 920px;
  --sans: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --serif-zh: "Noto Serif SC", "Songti SC", serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body.article-page {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16.5px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: rgba(29, 35, 39, 0.3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

/* Language switching: show only the active language. */
html[data-lang="en"] [data-lang="zh"],
html[data-lang="zh"] [data-lang="en"] { display: none !important; }

/* ---------- chrome ---------- */
.article-topbar { border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.article-topbar__inner { max-width: var(--wide); margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.article-brand { font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.article-nav { display: flex; gap: 22px; font-size: 14px; }
.article-nav a { text-decoration: none; color: var(--muted); }
.article-nav a.is-current, .article-nav a:hover { color: var(--ink); }

.article-shell { max-width: var(--wide); margin: 0 auto; padding: 28px 20px 40px; }
.article-crumbs { font-size: 13px; color: var(--muted); }
.article-crumbs a { text-decoration: none; }
.article-crumbs span { margin: 0 6px; color: var(--faint); }
.article-meta-row { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 10px; font-size: 13.5px; color: var(--muted); }
.lang-toggle { display: inline-flex; background: var(--wash); border-radius: 999px; padding: 3px; }
.lang-toggle button { border: 0; background: transparent; font: 600 12px var(--sans); color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.lang-toggle button.is-active { background: #e6eefb; color: #2456b3; }

.article-title { font-size: clamp(32px, 5vw, 46px); line-height: 1.12; letter-spacing: -0.025em; font-weight: 600; margin: 0 0 14px; max-width: 760px; }
.article-dek { font-size: 19px; line-height: 1.5; color: var(--ink-2); margin: 0 0 22px; max-width: var(--col); }
.article-byline { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; margin-bottom: 26px; }
.article-byline img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

.article-toc { display: flex; gap: 6px 22px; flex-wrap: nowrap; overflow-x: auto; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 30px; scrollbar-width: none; position: sticky; top: 53px; background: #fff; z-index: 10; }
.article-toc::-webkit-scrollbar { display: none; }
.article-toc a { white-space: nowrap; font-size: 13.5px; color: var(--muted); text-decoration: none; }
.article-toc a.is-active, .article-toc a:hover { color: var(--ink); }

/* ---------- body ---------- */
.article-body { max-width: var(--col); }
.article-body > * { max-width: var(--col); }
.article-body p { margin: 0 0 1.1em; }
html[data-lang="zh"] .article-body p, html[data-lang="zh"] .article-body li { line-height: 1.85; }
.article-body h2 { font-size: 27px; line-height: 1.25; letter-spacing: -0.015em; font-weight: 600; margin: 2.4em 0 0.7em; scroll-margin-top: 120px; }
.article-body h3 { font-size: 19px; font-weight: 600; margin: 1.8em 0 0.5em; }
.article-body ul, .article-body ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.article-body li { margin: 0.3em 0; }
.article-body code { font: 0.88em var(--mono); background: var(--wash); padding: 1px 5px; border-radius: 4px; }
.article-body strong { font-weight: 600; }
.article-body sup a { text-decoration: none; color: var(--accent); font-weight: 600; }

.callout { border-left: 3px solid var(--accent); background: var(--accent-wash); padding: 14px 18px; border-radius: 0 8px 8px 0; margin: 1.4em 0; }
.callout p:last-child { margin: 0; }
.note-draft { border: 1px dashed #d7b28f; background: #fffaf3; color: #7a5531; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 1.2em 0; }

/* Figures break out of the reading column. */
.article-body figure { margin: 2em 0 2.2em; max-width: var(--wide); width: min(var(--wide), calc(100vw - 40px)); }
.article-body figcaption { font-size: 13.5px; line-height: 1.6; color: var(--muted); margin-top: 12px; max-width: var(--col); }
.article-body figcaption b { color: var(--ink); font-weight: 600; }
.fig-frame { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 18px; }

/* ---------- film ---------- */
.film { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.film canvas { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; }
.film-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; pointer-events: none; }
.film-stage { position: relative; }
.film-controls { display: flex; align-items: center; gap: 14px; padding: 10px 16px 12px; border-top: 1px solid var(--line); }
.film-play { width: 28px; height: 28px; flex: none; border-radius: 50%; border: 1px solid var(--faint); background: #fff; cursor: pointer; position: relative; }
.film-play::before { content: ""; position: absolute; left: 10px; top: 8px; border-left: 9px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.film-play.is-playing::before { left: 9px; top: 8px; width: 3px; height: 11px; border: 0; background: var(--ink); box-shadow: 6px 0 0 var(--ink); }
.film-chapters { display: flex; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.film-chapters::-webkit-scrollbar { display: none; }
.film-tab { flex: 1 0 auto; min-width: 84px; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; font: 500 12px var(--sans); color: var(--muted); }
.film-tab__bar { display: block; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.film-tab__bar span { display: block; height: 100%; width: 0; background: var(--accent); }
.film-tab.is-active { color: var(--ink); font-weight: 600; }

/* ---------- interactive figure controls ---------- */
.fx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fx-chip { border: 1px solid var(--faint); background: #fff; border-radius: 999px; padding: 4px 11px 4px 9px; font: 500 12.5px var(--sans); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fx-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.fx-chip.is-active { border-color: var(--ink); color: var(--ink); background: var(--wash); }
.fx-grid { display: grid; grid-template-columns: 256px 1fr; gap: 24px; align-items: start; }
.fx-map { width: 256px; height: 256px; display: block; border-radius: 4px; }
.fx-line { width: 100%; height: auto; display: block; }
.fx-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.fx-row input[type=range] { flex: 1; min-width: 160px; accent-color: var(--accent); }
.fx-play { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--faint); background: #fff; cursor: pointer; position: relative; flex: none; }
.fx-play::before { content: ""; position: absolute; left: 10px; top: 8px; border-left: 9px solid var(--ink); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.fx-play.is-playing::before { left: 9px; width: 3px; height: 11px; border: 0; background: var(--ink); box-shadow: 6px 0 0 var(--ink); }
.fx-seg { display: inline-flex; border: 1px solid var(--faint); border-radius: 8px; overflow: hidden; }
.fx-seg button { border: 0; background: #fff; font: 500 12px var(--sans); color: var(--muted); padding: 5px 10px; cursor: pointer; }
.fx-seg button.is-active { background: var(--wash); color: var(--ink); }
.fx-readout { font: 12.5px var(--mono); color: var(--ink-2); margin-top: 10px; }
.fx-readout sub { font-size: 0.75em; }
.ax-grid { stroke: var(--line); }
.ax-zero { stroke: var(--faint); }
.ax-cursor { stroke: var(--ink); stroke-dasharray: 2 3; opacity: 0.5; }
.ax-tick { font: 10px var(--mono); fill: var(--muted); }
.ax-label { font: 11px var(--sans); fill: var(--muted); }
.ax-series { font: 600 11px var(--sans); }

/* scale-profile table */
.fx-profiles { display: grid; gap: 0; }
.pr-row { display: grid; grid-template-columns: 170px repeat(4, 60px) 1fr 110px; gap: 10px; align-items: center; padding: 6px 0; }
.pr-head { font: 600 11.5px var(--mono); color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.pr-head .pr-bar, .pr-head .pr-amp { font-family: var(--sans); font-weight: 500; }
.pr-group { font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 14px 0 4px; }
.pr-name b { display: block; font-size: 13.5px; font-weight: 600; }
.pr-name span { font-size: 11.5px; color: var(--muted); }
.pr-cell { text-align: center; }
.pr-cell canvas { width: 56px; height: 56px; display: block; margin: 0 auto; }
.pr-stack { display: flex; height: 22px; border-radius: 4px; overflow: hidden; }
.pr-stack span { display: flex; align-items: center; justify-content: center; }
.pr-stack em { font: normal 10.5px var(--mono); color: var(--ink); }
.pr-stack em.on-dark { color: #fff; }
.pr-amp { display: flex; align-items: center; gap: 8px; }
.pr-amp__bar { flex: 1; height: 6px; background: var(--wash); border-radius: 3px; overflow: hidden; }
.pr-amp__bar span { display: block; height: 100%; background: var(--ink-2); }
.pr-amp__val { font: 12px var(--mono); width: 34px; text-align: right; }
.pr-legend { display: flex; gap: 14px; font: 11.5px var(--mono); color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.pr-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* references / citation */
.refs { font-size: 14px; color: var(--ink-2); }
.refs li { margin: 0.5em 0; }
.cite-block { font: 12.5px/1.6 var(--mono); background: var(--wash); border-radius: 8px; padding: 14px 16px; white-space: pre; overflow-x: auto; }

.article-footer { border-top: 1px solid var(--line); margin-top: 40px; }
.article-footer__inner { max-width: var(--wide); margin: 0 auto; padding: 22px 20px; display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.article-footer a { text-decoration: none; }

@media (max-width: 760px) {
  body.article-page { font-size: 16px; }
  .article-shell { padding: 20px 16px 32px; }
  .article-body figure { width: 100%; }
  .fx-grid { grid-template-columns: 1fr; }
  .fx-map { width: 100%; height: auto; aspect-ratio: 1; max-width: 320px; }
  .fig-frame { padding: 12px; }
  .pr-row { grid-template-columns: 112px repeat(4, 36px) 1fr; gap: 6px; }
  .pr-cell canvas { width: 34px; height: 34px; }
  .pr-amp, .pr-head .pr-amp { display: none; }
  .pr-name span { display: none; }
  .article-toc { top: 49px; }
}
