/* Ser explainer. System fonts only. Light and dark via prefers-color-scheme. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --panel: #ffffff;
  --panel2: #f2f4f1;
  --ink: #1a1d21;
  --muted: #4f5761;
  --line: #d6dadf;
  --line2: #aab2bb;
  --accent: #0a62c4;
  --on-accent: #ffffff;
  --accent-soft: #e4effc;
  --bad: #b7232a;
  --bad-soft: #fbe9ea;
  --good: #146b38;
  --good-soft: #e1f4e8;
  --warn: #8a4e00;
  --warn-soft: #fdf0d8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --panel: #181c22;
    --panel2: #1f242b;
    --ink: #e9ecf0;
    --muted: #a9b2bd;
    --line: #333b45;
    --line2: #556070;
    --accent: #6fb0ff;
    --on-accent: #08121f;
    --accent-soft: #15304f;
    --bad: #ff8a90;
    --bad-soft: #3a1a1d;
    --good: #5fd18b;
    --good-soft: #15321f;
    --warn: #f2b95a;
    --warn-soft: #382a10;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0 0 .75em; }
code {
  font-family: var(--mono); font-size: .9em;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 5px; padding: .05em .35em;
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- header and intro ---------- */
.top { padding: 28px 0 8px; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 4px; }
h1 { font-size: clamp(2rem, 6vw, 2.8rem); margin-bottom: 12px; }
.lead { max-width: 46rem; color: var(--ink); }
.jump {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--accent);
  color: var(--accent); font-weight: 700; text-decoration: none; min-height: 44px;
}
.jump:hover { background: var(--accent-soft); }
.explorer { scroll-margin-top: 8px; }

.intro { padding: 16px 0 8px; }
.intro h2, .today h2 { font-size: 1.45rem; margin-bottom: 14px; }

.flow {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 8px;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; min-width: 0;
}
.card h3 { font-size: 1.05rem; margin: 8px 0 6px; display: flex; gap: 8px; align-items: center; }
.card p { margin: 0; color: var(--muted); font-size: .98rem; }
.n {
  display: inline-grid; place-items: center; width: 1.6em; height: 1.6em;
  border-radius: 50%; background: var(--accent); color: var(--on-accent);
  font-size: .85rem; font-weight: 700; flex: none;
}
.ico { display: block; width: 100%; max-width: 200px; height: 70px; margin: 0 auto; color: var(--ink); }
.join { display: grid; place-items: center; text-align: center; padding: 2px 0; }
.join-arrow { color: var(--accent); font-weight: 700; font-size: .9rem; }
.join-r::after { content: " \2193"; font-size: 1.2rem; }
.join-l::after { content: " \2191"; font-size: 1.2rem; }

.cast-h { font-size: 1.05rem; margin: 22px 0 10px; }
.cast { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cast li {
  display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  font-size: .93rem; line-height: 1.4;
}
.cast svg { width: 44px; height: 60px; color: var(--ink); }

@media (min-width: 760px) {
  .ico { height: 96px; }
  .flow { grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 10px; }
  .join { align-content: center; }
  .join-r::after { content: " \2192"; }
  .join-l::after { content: ""; }
  .join-l::before { content: "\2190  "; font-size: 1.2rem; }
  .join-arrow { max-width: 6rem; }
  .cast { grid-template-columns: repeat(4, 1fr); }
  .cast li { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .cast svg { width: 52px; height: 72px; }
}

/* ---------- explorer ---------- */
.explorer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 22px 0 8px; }

.tabs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tab {
  width: 100%; min-height: 56px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line2); border-radius: 10px;
  font: inherit; font-size: .8rem; line-height: 1.15; cursor: pointer;
}
.tab .tab-n { font-weight: 800; font-size: 1.05rem; }
.tab .tab-title { display: none; }
.tab[aria-current="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.tab:hover:not([aria-current="true"]) { background: var(--accent-soft); }

@media (min-width: 1100px) {
  .explorer { grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
  .tabs { grid-template-columns: 1fr; position: sticky; top: 12px; gap: 6px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 10px; padding: 8px 12px; text-align: left; font-size: .95rem; min-height: 48px; }
  .tab .tab-short { display: none; }
  .tab .tab-title { display: inline; }
  .tab .tab-n {
    display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; flex: none;
    border-radius: 50%; border: 1.5px solid currentColor; font-size: .85rem;
  }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-width: 0; }
.sc-title { font-size: 1.4rem; margin-bottom: 4px; }
.sc-question { color: var(--muted); margin-bottom: 12px; }

.rule {
  margin: 0 0 14px; padding: 12px 14px;
  border-left: 5px solid var(--accent); background: var(--accent-soft);
  border-radius: 6px; font-weight: 650; font-size: 1.1rem; line-height: 1.4;
}

.bar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 10px; }
.toggle { display: inline-flex; border: 1px solid var(--line2); border-radius: 12px; overflow: hidden; max-width: 100%; }
.seg {
  min-height: 44px; padding: 6px 14px; border: 0; background: var(--panel); color: var(--ink);
  font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.seg + .seg { border-left: 1px solid var(--line2); }
.seg[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.seg:focus-visible { outline-offset: -3px; }

.verdict {
  margin: 0; padding: 6px 12px; border-radius: 999px; font-weight: 800; letter-spacing: .03em; font-size: .95rem;
  border: 2px solid currentColor;
}
.verdict.bad { color: var(--bad); background: var(--bad-soft); }
.verdict.good { color: var(--good); background: var(--good-soft); }
.verdict.warn { color: var(--warn); background: var(--warn-soft); }

.banner { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; font-size: .95rem; border: 1px solid currentColor; }
.banner.warn { color: var(--warn); background: var(--warn-soft); }
.banner.bad { color: var(--bad); background: var(--bad-soft); }
.banner.good { color: var(--good); background: var(--good-soft); }

.stage { position: relative; margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.stage svg { display: block; width: 100%; max-width: 760px; height: auto; margin: 0 auto; color: var(--ink); }

.caption { margin: 12px 0 0; min-height: 5.1em; font-size: 1.1rem; line-height: 1.5; }
.bullets { margin: 0 0 4px; padding-left: 1.3em; }
.bullets li { margin: 2px 0; }
.bullets[hidden], .end[hidden], .rule[hidden], .banner[hidden] { display: none; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.btn {
  min-height: 44px; padding: 6px 16px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.counter { margin: 0 0 0 auto; color: var(--muted); font-size: .95rem; font-weight: 600; }

.dots { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; }
.dots li { width: 28px; height: 6px; border-radius: 3px; background: var(--line); }
.dots li.done { background: var(--accent); opacity: .55; }
.dots li.now { background: var(--accent); opacity: 1; }
.tip { margin: 8px 0 0; color: var(--muted); font-size: .85rem; }

.end { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line2); border-radius: 12px; background: var(--panel2); }
.end-title { margin: 0 0 4px; font-weight: 800; }
.end.bad { border-color: var(--bad); }
.end.bad .end-title { color: var(--bad); }
.end.good .end-title { color: var(--good); }
.end.warn .end-title { color: var(--warn); }
.end-text { margin-bottom: 10px; }

/* ---------- data snippets (HTML copy of the cards) ---------- */
.snippet { display: grid; gap: 6px; }
.stage:not(.narrow) .snippet {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.stage.narrow .snippet { margin: 6px 2px 2px; min-height: var(--snip-min, 0); align-content: start; }
.snip { border-left: 5px solid var(--accent); background: var(--panel2); border-radius: 6px; padding: 6px 10px 8px; min-width: 0; }
.snip.tone-bad { border-left-color: var(--bad); }
.snip.tone-good { border-left-color: var(--good); }
.snip.tone-warn { border-left-color: var(--warn); }
.snip-t { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.snip pre {
  margin: 0; font-family: var(--mono); font-size: .82rem; line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink);
}
.snip.tone-bad pre { color: var(--bad); }
.snip .em { font-weight: 800; }
.snip .em-good { color: var(--good); }
.snip .em-bad { color: var(--bad); }
.snip .em-dim { color: var(--muted); font-weight: 400; }
.datanote { margin: 6px 4px 2px; color: var(--muted); font-size: .8rem; text-align: center; }
.datanote[hidden] { display: none; }

/* ---------- status footer ---------- */
.today { padding: 26px 0 8px; }
.status { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.status li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.chip {
  display: inline-block; margin-right: 8px; padding: 1px 10px; border-radius: 999px;
  font-size: .85rem; font-weight: 800; border: 1.5px solid currentColor; white-space: nowrap;
}
.chip.ok { color: var(--good); background: var(--good-soft); }
.chip.todo { color: var(--warn); background: var(--warn-soft); }
.chip.off { color: var(--bad); background: var(--bad-soft); }
.small { color: var(--muted); font-size: .92rem; max-width: 48rem; }

.words { margin: 14px 0 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.words summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.words dl { margin: 0 0 8px; display: grid; gap: 6px 0; }
.words dt { font-weight: 700; margin-top: 6px; }
.words dd { margin: 0; color: var(--muted); }

.foot { padding: 22px 0 36px; color: var(--muted); font-size: .85rem; }
.noscript { text-align: center; padding: 16px; font-weight: 700; }

/* ---------- SVG stage ---------- */
#stage text { font-family: var(--font); fill: var(--ink); }
#stage .name { font-size: 24px; font-weight: 700; text-anchor: middle; }
#stage .sub { font-size: 17px; fill: var(--muted); text-anchor: middle; }
#stage .lbl { font-size: 20px; font-weight: 700; }
#stage .lbl2 { font-size: 17px; fill: var(--muted); }
#stage .mono { font-family: var(--mono); font-size: 19px; }
#stage .fig { color: var(--ink); }

#stage .box { fill: var(--panel); stroke: var(--ink); stroke-width: 3; }
#stage .part { fill: var(--bg); stroke: var(--line2); stroke-width: 2.5; }
#stage .part.hot, #stage .box.hot { stroke: var(--accent); stroke-width: 4; }
#stage .part.hot { fill: var(--accent-soft); }
#stage .thin { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#stage .glyph { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#stage .book { fill: var(--panel2); stroke: var(--line2); stroke-width: 2; }

#stage .trail { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 3 8; stroke-linecap: round; opacity: .45; }

#stage .msg-line { fill: none; stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; }
#stage .msg.tone-accent { color: var(--accent); }
#stage .msg.tone-bad { color: var(--bad); }
#stage .msg.tone-good { color: var(--good); }
#stage .msg-line { stroke: currentColor; }
#stage .msg-head { fill: currentColor; }
#stage .env-body { fill: var(--panel); stroke: currentColor; stroke-width: 3; }
#stage .env-flap { fill: none; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; }

#stage .pill rect { fill: var(--panel); stroke: currentColor; stroke-width: 2.5; }
#stage .pill .ph { fill: currentColor; font-weight: 700; font-size: 19px; text-anchor: middle; }
#stage .pill.mark .ph { font-size: 17px; }
#stage .pill .pc { font-family: var(--mono); font-size: 12px; font-weight: 600; text-anchor: start; fill: var(--ink); }
#stage .pill.tone-bad .pc { fill: var(--bad); }
#stage .pill .prule { stroke: currentColor; stroke-width: 1.5; opacity: .45; }
#stage .pc .em { font-weight: 800; fill: currentColor; }
#stage .pc .em-good { fill: var(--good); }
#stage .pc .em-bad { fill: var(--bad); }
#stage .pc .em-dim { fill: var(--muted); font-weight: 500; }
#stage .pill.tone-accent, #stage .pill.tone-info { color: var(--accent); }
#stage .pill.tone-bad { color: var(--bad); }
#stage .pill.tone-good { color: var(--good); }
#stage .pill.tone-warn { color: var(--warn); }
#stage .pill.tone-info rect { stroke-dasharray: 6 4; }

#stage .bookrow { font-family: var(--mono); font-size: 19px; font-weight: 700; }
#stage .bookrow.bad { fill: var(--bad); }

@keyframes flash-fig { 0%, 100% { color: var(--ink); } 40% { color: var(--accent); } }
@keyframes flash-box { 0%, 100% { stroke-width: 3; } 40% { stroke: var(--accent); stroke-width: 6; } }
#stage .actor.pulse .fig { animation: flash-fig .8s ease; }
#stage .pulse-shape { animation: flash-box .8s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 420px) {
  .panel { padding: 10px; }
  .stage { padding: 2px; }
  .sc-title { font-size: 1.25rem; }
  .caption { font-size: 1.05rem; }
  .counter { margin-left: 0; width: 100%; }
}
