/* VK-ZFA10M explanatory articles — shared layout on top of the app's colour tokens (../css/app.css).
   One file per article in articles/, both languages in the same file (div.lang-en / div.lang-ja). */

body.article { display: block; font-size: 16px; line-height: 1.7; }
body.article.ja { line-height: 1.85; }
.article a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.article a:hover { color: var(--primary-hover); }

/* top bar */
.art-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.art-bar .back { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--brand); text-decoration: none; min-width: 0; }
.art-bar .back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.art-bar .back span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.art-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.art-tools button { border: 1px solid var(--border-strong); background: var(--surface-3); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.art-tools button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.art-tools .theme { padding: 6px 9px; }
.art-tools .theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

/* read aloud */
.art-tools .listen { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 9px; }
.art-tools .listen svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.art-tools .listen svg .f, .tts-bar svg .f { fill: currentColor; stroke: none; }
.tts-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; width: min(760px, calc(100% - 32px));
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); }
.tts-bar[hidden] { display: none; }
.tts-bar button { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text); cursor: pointer; display: grid; place-items: center; padding: 0; }
.tts-bar button.main { width: 42px; height: 42px; background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.tts-bar button:hover { border-color: var(--primary); }
.tts-bar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tts-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.tts-now { font-size: 13.5px; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tts-hint { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tts-sel { flex: none; display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 1px; }
.tts-sel select { font: inherit; font-size: 13px; color: var(--text); background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 7px; padding: 3px 4px; max-width: 120px; }
.tts-sel[hidden] { display: none; }
.reading { background: color-mix(in srgb, var(--primary) 13%, transparent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--primary) 13%, transparent); border-radius: 4px; transition: background .2s; }
tr.reading td { background: color-mix(in srgb, var(--primary) 13%, transparent); }
tr.reading { box-shadow: none; }
body.tts-on .art-main { padding-bottom: 90px; }
body.tts-on .art-main :is(p, li, h2, h3, figcaption, .note, .spd, tr) { cursor: pointer; }

/* page */
.art-wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 36px; }
.art-toc { position: sticky; top: 72px; align-self: start; font-size: 13.5px; line-height: 1.45; max-height: calc(100vh - 90px); overflow: auto; }
.art-toc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.art-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.art-toc li { margin: 0; }
.art-toc a { display: block; padding: 5px 10px; border-left: 2px solid var(--border); color: var(--muted); text-decoration: none; }
.art-toc a:hover { color: var(--text); border-left-color: var(--border-strong); }
.art-toc a.on { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.art-main { min-width: 0; }

.art-head { margin-bottom: 28px; }
.art-kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.art-head h1 { font-size: 32px; line-height: 1.25; margin: 0 0 10px; color: var(--navy); letter-spacing: -.01em; }
.art-head .sub { font-size: 18px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.art-meta { font-size: 13px; color: var(--faint); display: flex; flex-wrap: wrap; gap: 6px 16px; }

.art-main h2 { font-size: 23px; line-height: 1.3; color: var(--navy); margin: 44px 0 12px; padding-top: 6px; scroll-margin-top: 70px; }
.art-main h3 { font-size: 18px; color: var(--text); margin: 28px 0 8px; scroll-margin-top: 70px; }
.art-main p, .art-main li { max-width: 74ch; }
.art-main ul, .art-main ol { padding-left: 1.3em; }
.art-main li { margin: 4px 0; }
.art-main sub, .art-main sup { line-height: 0; }

/* boxes */
.keybox { background: var(--primary-soft); border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: 10px; padding: 14px 20px; margin: 20px 0; }
.keybox h2, .keybox h3 { margin: 0 0 6px; font-size: 16px; padding: 0; color: var(--navy); }
.keybox ul { margin: 6px 0 0; }
.note { background: var(--warn-soft); border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 10px; padding: 12px 18px; margin: 18px 0; font-size: 15px; }
.note b:first-child { color: var(--warn); }
.spd { background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 18px; margin: 18px 0; font-size: 15px; }

/* equations */
.eq { margin: 14px 0; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-family: "Cambria Math", "Times New Roman", serif; font-size: 18px;
  overflow-x: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.eq > span:first-child { white-space: nowrap; }   /* a long equation scrolls as a whole on a phone instead of breaking */
.eq .no { font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; color: var(--faint); flex: none; }
.eq i, .m { font-family: "Cambria Math", "Times New Roman", serif; }
.m { font-style: italic; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 3px; }
.frac > span:last-child { padding: 0 3px; }

/* tables */
.tbl { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tbl table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: 14px; line-height: 1.45; }   /* narrow screens scroll the table instead of squeezing it */
.tbl th, .tbl td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.tbl th { background: var(--surface-3); color: var(--navy); font-weight: 700; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl caption { caption-side: bottom; text-align: left; padding: 8px 12px; font-size: 13px; color: var(--muted); }

/* figures */
figure.fig { margin: 22px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 10px; }
figure.fig .fig-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
figure.fig .plot-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 2px 4px; }
figure.fig figcaption { font-size: 14px; color: var(--muted); line-height: 1.55; margin-top: 8px; }
figure.fig figcaption b { color: var(--text); }
/* animation figure (canvas + buttons + live readout) */
figure.anim canvas { display: block; width: 100%; max-width: 540px; height: auto; aspect-ratio: 540 / 300; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }
figure.anim .anim-ctl { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 12px 0 8px; }
figure.anim .anim-stat { text-align: center; font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; min-height: 1.5em; }
figure.fig .sim { display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--demo); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; margin-left: 4px; vertical-align: 1px; }
.circuit { width: 100%; max-width: 760px; margin: 0 auto; color: var(--text); }
.circuit .w { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.circuit .ion { stroke: var(--c2); }
.circuit .trap { stroke: var(--c3); }
.circuit .el { stroke: var(--c1); }
.circuit .lab { fill: currentColor; font: 600 17px "Segoe UI", system-ui, sans-serif; }
.circuit .lab.sm { font-weight: 400; font-size: 15px; fill: var(--muted); }
.circuit .dot { fill: currentColor; }

/* references */
.refs { font-size: 14px; line-height: 1.55; padding-left: 2.2em !important; }
.refs li { margin: 7px 0; max-width: none !important; }
.refs li:target { background: var(--primary-soft); border-radius: 6px; }
.cite { font-size: .78em; vertical-align: super; line-height: 0; text-decoration: none !important; font-weight: 600; }
.cite + .cite { margin-left: 1px; }

.art-foot { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.cta { display: inline-flex; align-items: center; gap: 8px; margin: 6px 0; padding: 9px 16px; border-radius: 9px; background: var(--primary); color: var(--primary-ink) !important; text-decoration: none !important; font-weight: 600; font-size: 14.5px; }
.cta:hover { background: var(--primary-hover); }

@media (max-width: 900px) {
  .art-wrap { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 20px 16px 48px; }
  .art-toc { position: static; max-height: none; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); }
  .art-head h1 { font-size: 25px; }
  .art-head .sub { font-size: 16px; }
  .art-main h2 { font-size: 20px; }
  .eq { font-size: 16px; }
  body.article { font-size: 15.5px; }
  .art-bar { padding: 8px 16px; }
  .art-tools .listen span { display: none; }
  .art-tools .listen { padding: 6px 9px; }
  .tts-bar { bottom: 10px; flex-wrap: wrap; gap: 6px 8px; }
  .tts-info { order: 10; flex-basis: 100%; }
  .tts-voice { display: none; }
}
@media print {
  .art-bar, .art-toc, .tts-bar { display: none; }
  .art-wrap { display: block; max-width: none; padding: 0; }
  figure.fig, .tbl, .eq { break-inside: avoid; }
}
