/*
 * TDA technical explainers — shared presentation layer.
 * Author: Loki. Implementation: Claude (Opus 5.5, Claude Code) under Loki's direction, 2026-10-04.
 * Colours and type follow the Those Dark Arts site palette (near-black, pink, cyan,
 * and its explicit light skin). Scene grid, focus, notes-disclosure and SVG primitive
 * rules are small adaptations of the TDA field-guide presentation package
 * (style.css / presentation.css, Loki; implementation Moiré).
 * Fonts: Space Grotesk and Share Tech Mono, SIL Open Font License 1.1 (see fonts/*-OFL.txt).
 */

@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/SpaceGrotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Share Tech Mono";
  src: url("fonts/ShareTechMono.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

/* ------------------------------------------------------------------ tokens */

:root,
:root[data-theme="tda-dark"] {
  --bg: #050507;
  --bg2: #07070e;
  --panel: #101018;
  --inset: #08080e;
  --fg: #ededf4;
  --dim: #a0a0c0;
  --muted: #7878a4;
  --line: #333342;
  --line-strong: #4a4a5e;
  --grid: #1b1b29;
  --pink: #ff3d88;        /* accent fill / stroke */
  --pink-ink: #ff5c9b;    /* accent used as text */
  --cyan: #00e0ff;
  --cyan-ink: #00e0ff;
  --good: #adca93;
  --caution: #f2b45a;
  --fail: #ff6b6b;
  --neutral: #8a8aa8;
  --pink-wash: rgba(255, 61, 136, 0.14);
  --cyan-wash: rgba(0, 224, 255, 0.12);
  --good-wash: rgba(173, 202, 147, 0.14);
  --caution-wash: rgba(242, 180, 90, 0.14);
  --fail-wash: rgba(255, 107, 107, 0.14);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 32px rgba(0, 0, 0, 0.45);
  --focus: #00e0ff;
  color-scheme: dark;
}

:root[data-theme="tda-light"] {
  --bg: #ece9e1;
  --bg2: #f4f2ec;
  --panel: #f4f2ec;
  --inset: #e4e1d8;
  --fg: #14161b;
  --dim: #454850;
  --muted: #5b5d62;
  --line: #bcb9b0;
  --line-strong: #8f8c84;
  --grid: #d9d6cd;
  --pink: #d61c6d;
  --pink-ink: #a11350;
  --cyan: #1f5f5a;
  --cyan-ink: #1f5f5a;
  --good: #426326;
  --caution: #8a5a00;
  --fail: #b3261e;
  --neutral: #6a6c72;
  --pink-wash: rgba(214, 28, 109, 0.10);
  --cyan-wash: rgba(31, 95, 90, 0.10);
  --good-wash: rgba(66, 99, 38, 0.10);
  --caution-wash: rgba(138, 90, 0, 0.10);
  --fail-wash: rgba(179, 38, 30, 0.10);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 26px rgba(20, 22, 27, 0.10);
  --focus: #1f5f5a;
  color-scheme: light;
}

:root {
  --font-sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Share Tech Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --measure: 68ch;
  --radius: 6px;
  --gap: clamp(14px, 2vw, 24px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 280ms;
  font-family: var(--font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: break-word;
}
::selection { background: var(--pink-wash); color: var(--fg); }
a { color: var(--cyan-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--pink-ink); }
img, svg, canvas, video { max-width: 100%; }
button, select, input, textarea { font: inherit; color: inherit; }

:where(a, button, select, input, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 3px;
}

.tda-skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--panel); color: var(--fg); padding: 8px 12px; border: 1px solid var(--line);
}
.tda-skip:focus { top: 8px; }
.tda-visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.tda-label, .tda-mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pink-ink);
}
.tda-mono { text-transform: none; letter-spacing: 0.02em; color: var(--dim); }

/* ------------------------------------------------------------ page chrome */

.tda-masthead, .tda-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px clamp(16px, 4vw, 48px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.tda-masthead { border-bottom: 1px solid var(--line); }
.tda-footer { border-top: 1px solid var(--line); color: var(--dim); font-size: 14px; margin-top: 64px; }
.tda-brand { font-weight: 600; letter-spacing: -0.02em; text-decoration: none; color: var(--fg); }
.tda-brand span { font-family: var(--font-mono); font-weight: 400; color: var(--dim); font-size: 0.8rem; margin-left: 12px; letter-spacing: 0.06em; }
.tda-nav { display: flex; gap: 6px 18px; flex-wrap: wrap; font-size: 15px; }
.tda-nav a { color: var(--dim); text-decoration: none; }
.tda-nav a[aria-current="page"], .tda-nav a:hover { color: var(--fg); text-decoration: underline; }

[data-embed="1"] .tda-masthead,
[data-embed="1"] .tda-footer,
[data-embed="1"] .tda-page-only { display: none !important; }

/* ------------------------------------------------------------- buttons */

.tda-btn, .tda-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 7px 14px;
  background: var(--panel); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 14px; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: border-color 160ms, background-color 160ms, color 160ms;
}
.tda-btn:hover, .tda-theme-toggle:hover { border-color: var(--line-strong); }
.tda-btn:disabled, .tda-btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.tda-btn--primary { border-color: var(--cyan); color: var(--cyan-ink); }
.tda-btn--accent { border-color: var(--pink); color: var(--pink-ink); }
.tda-btn[aria-pressed="true"], .tda-btn[aria-current="step"] {
  border-color: var(--pink); color: var(--pink-ink); background: var(--pink-wash);
}
.tda-btn--quiet { background: transparent; border-color: transparent; color: var(--dim); }
.tda-btn--quiet:hover { color: var(--fg); border-color: var(--line); }
.tda-theme-toggle { font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em; }

/* ------------------------------------------------------------- form controls */

.tda-field { display: grid; gap: 6px; font-size: 14px; color: var(--dim); }
.tda-field__row { display: flex; align-items: center; gap: 12px; }
.tda-field output, .tda-value {
  font-family: var(--font-mono); color: var(--fg); min-width: 3.5ch; text-align: right;
}
.tda-range { width: 100%; min-width: 120px; accent-color: var(--pink); min-height: 32px; }
.tda-select {
  min-height: 40px; padding: 6px 10px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.tda-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tda-seg > button {
  min-height: 38px; padding: 6px 12px; border: 0; border-right: 1px solid var(--line);
  background: var(--panel); color: var(--dim); cursor: pointer; font-size: 14px;
}
.tda-seg > button:last-child { border-right: 0; }
.tda-seg > button[aria-pressed="true"], .tda-seg > button[aria-checked="true"] {
  background: var(--pink-wash); color: var(--pink-ink);
}
fieldset.tda-fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; }
fieldset.tda-fieldset > legend { padding: 0 6px; font-family: var(--font-mono); font-size: 12px; color: var(--dim); letter-spacing: .04em; }
.tda-check { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; }
.tda-check input { accent-color: var(--pink); width: 18px; height: 18px; }

/* ------------------------------------------------------- long-form reading */

.tda-article, .tda-companion {
  max-width: calc(var(--measure) + 2 * clamp(16px, 4vw, 48px));
  margin: 0 auto;
  padding: clamp(28px, 6vw, 72px) clamp(16px, 4vw, 48px) 32px;
}
.tda-companion { --measure: 74ch; }
.tda-article > *, .tda-companion > * { max-width: var(--measure); }
.tda-kicker { font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--pink-ink); margin: 0 0 14px; }
.tda-article h1, .tda-companion h1 {
  font-size: clamp(2.1rem, 5.2vw, 3.4rem); line-height: 1.04; letter-spacing: -0.035em;
  font-weight: 500; margin: 0 0 18px; text-wrap: balance;
}
.tda-dek { font-size: clamp(1.1rem, 2vw, 1.32rem); line-height: 1.5; color: var(--dim); margin: 0 0 22px; }
.tda-byline { font-size: 14px; color: var(--dim); border-left: 2px solid var(--pink); padding-left: 12px; margin: 0 0 40px; line-height: 1.55; }
.tda-byline p { margin: 0; }
.tda-article h2, .tda-companion h2 {
  font-size: clamp(1.45rem, 3vw, 1.9rem); line-height: 1.18; letter-spacing: -0.02em;
  font-weight: 500; margin: 2.4em 0 .7em; text-wrap: balance;
}
.tda-article h3, .tda-companion h3 { font-size: 1.2rem; font-weight: 600; margin: 1.8em 0 .5em; line-height: 1.3; }
.tda-article h4, .tda-companion h4 { font-family: var(--font-mono); font-weight: 400; font-size: .9rem; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); margin: 1.6em 0 .4em; }
.tda-article p, .tda-companion p { margin: 0 0 1.05em; }
.tda-article > p:first-of-type::first-letter {
  float: left; margin: .08em .12em 0 0; color: var(--pink);
  font-size: 4.2em; font-weight: 700; line-height: .75;
}
.tda-article ul, .tda-article ol, .tda-companion ul, .tda-companion ol { padding-left: 1.3em; margin: 0 0 1.1em; }
.tda-article li, .tda-companion li { margin: .3em 0; }
.tda-article blockquote, .tda-companion blockquote {
  margin: 1.5em 0; padding: .2em 0 .2em 1.1em; border-left: 2px solid var(--cyan); color: var(--fg); font-size: 1.05em;
}
hr.tda-rule { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--pink) 30%, var(--cyan) 70%, transparent); opacity: .5; margin: 3em 0; }

/* Figures, including embedded scene previews and diagrams. */
.tda-figure { margin: 2em 0; max-width: none !important; }
.tda-figure > :first-child { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tda-figure figcaption { font-size: 14px; color: var(--dim); margin-top: 10px; max-width: var(--measure); line-height: 1.55; }
.tda-figure figcaption strong { color: var(--fg); font-weight: 600; }

/* Code, equations, technical blocks. */
code, kbd, samp { font-family: var(--font-mono); font-size: .92em; }
:not(pre) > code { background: var(--inset); border: 1px solid var(--line); border-radius: 4px; padding: .05em .35em; }
pre {
  font-family: var(--font-mono); font-size: 14px; line-height: 1.55;
  background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; overflow-x: auto; margin: 1.4em 0; tab-size: 2;
}
pre code { background: none; border: 0; padding: 0; }
.tda-equation {
  display: block; margin: 1.4em 0; padding: 14px 18px; overflow-x: auto;
  background: var(--inset); border-left: 2px solid var(--cyan); border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-mono); font-size: 15px; line-height: 1.7; white-space: pre-wrap;
}
.tda-equation .tda-eq-num { float: right; color: var(--dim); }
.tda-def { margin: 1.2em 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tda-def > :first-child { margin-top: 0; }
.tda-def > :last-child { margin-bottom: 0; }
.tda-def dt { font-weight: 600; }
.tda-def dd { margin: 0 0 .6em; color: var(--dim); }

/* A qualification stated once, where it matters. */
.tda-note {
  margin: 1.5em 0; padding: 12px 16px; border-radius: var(--radius);
  background: var(--cyan-wash); border-left: 3px solid var(--cyan); font-size: .95em;
}
.tda-note--limit { background: var(--caution-wash); border-left-color: var(--caution); }
.tda-note > :last-child { margin-bottom: 0; }

/* Tables. */
.tda-table-wrap { overflow-x: auto; margin: 1.5em 0; max-width: none !important; }
table.tda-table { border-collapse: collapse; width: 100%; font-size: 15px; line-height: 1.45; }
.tda-table caption { text-align: left; color: var(--dim); font-size: 14px; padding-bottom: 8px; caption-side: top; }
.tda-table th, .tda-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.tda-table thead th { font-family: var(--font-mono); font-weight: 400; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); border-bottom-color: var(--line-strong); }
.tda-table td.num, .tda-table th.num { text-align: right; font-family: var(--font-mono); }

/* Citations and footnotes. */
sup.tda-cite, .tda-cite { font-size: .72em; line-height: 0; vertical-align: super; }
sup.tda-cite a, .tda-cite a { text-decoration: none; font-family: var(--font-mono); padding: 0 .1em; }
.tda-refs { font-size: 14.5px; line-height: 1.55; color: var(--dim); border-top: 1px solid var(--line); margin-top: 3em; padding-top: 1.2em; }
.tda-refs h2 { font-size: 1.1rem !important; margin-top: 0 !important; color: var(--fg); }
.tda-refs ol { padding-left: 1.6em; }
.tda-refs li { margin: .5em 0; }
.tda-refs li:target { background: var(--pink-wash); outline: 1px solid var(--pink); outline-offset: 4px; }
.tda-backref { font-family: var(--font-mono); text-decoration: none; margin-left: .3em; }

/* Links between the reader materials for one subject. */
.tda-related { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 2.5em 0; max-width: none !important; }
.tda-related a {
  display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); text-decoration: none; color: var(--fg);
}
.tda-related a:hover { border-color: var(--cyan); }
.tda-related a span { display: block; font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--cyan-ink); margin-bottom: 4px; }

/* -------------------------------------------------------- interactive scene */
/*
 * Layout: route bar across the top; mechanism beside controls + explanation;
 * notes below. At narrow widths the scene recomposes into a single column in
 * reading order: mechanism, controls, explanation, notes.
 */

.tda-scene-page { max-width: 1240px; margin: 0 auto; padding: 20px clamp(12px, 3vw, 32px) 32px; }
[data-embed="1"] .tda-scene-page { padding: 10px 14px 16px; }
.tda-scene-intro { max-width: 72ch; margin: 8px 0 18px; }
.tda-scene-intro h1 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); font-weight: 500; letter-spacing: -.025em; line-height: 1.1; margin: 0 0 8px; }
.tda-scene-intro p { color: var(--dim); margin: 0; }

.tda-scene {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  grid-template-areas:
    "route route"
    "stage side"
    "notes notes";
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg2);
  overflow: hidden;
}
.tda-scene__route { grid-area: route; }
.tda-scene__stage { grid-area: stage; }
.tda-scene__side { grid-area: side; }
.tda-scene__notes { grid-area: notes; }

/* Guided / explore bar. */
.tda-scene__route {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.tda-mode { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.tda-mode::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); }
[data-mode="guided"] .tda-mode::before { background: var(--cyan); }
[data-mode="explore"] .tda-mode::before { background: var(--pink); }
.tda-steps { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.tda-steps button {
  min-height: 36px; padding: 5px 10px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--dim); font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.tda-steps button span { font-family: var(--font-mono); color: var(--muted); }
.tda-steps button:hover { color: var(--fg); border-color: var(--line); }
.tda-steps button[aria-current="step"] { color: var(--fg); border-color: var(--cyan); background: var(--cyan-wash); }
.tda-steps button[aria-current="step"] span { color: var(--cyan-ink); }
.tda-route-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }

/* Mechanism. */
.tda-scene__stage {
  position: relative; min-width: 0; padding: 16px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.tda-stage-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 12px; color: var(--dim); letter-spacing: .04em; }
.tda-stage-canvas { flex: 1; display: grid; place-items: center; min-height: 280px; }
.tda-stage-canvas > svg, .tda-stage-canvas > canvas { display: block; width: 100%; height: auto; max-height: 460px; }
.tda-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--dim); margin: 0; padding: 0; list-style: none; }
.tda-legend li { display: inline-flex; align-items: center; gap: 6px; }
.tda-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--neutral); border: 1px solid var(--line-strong); }
.tda-legend i.is-pink { background: var(--pink); }
.tda-legend i.is-cyan { background: var(--cyan); }
.tda-legend i.is-good { background: var(--good); }
.tda-legend i.is-caution { background: var(--caution); }
.tda-legend i.is-fail { background: var(--fail); }

/* Controls + explanation column. */
.tda-scene__side { min-width: 0; display: flex; flex-direction: column; }
.tda-scene__controls { display: grid; gap: 14px; padding: 16px; border-bottom: 1px solid var(--line); }
.tda-scene__explain { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.tda-step-pos { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; color: var(--cyan-ink); margin: 0; }
.tda-scene__explain h2 { font-size: clamp(1.2rem, 2vw, 1.5rem); font-weight: 500; line-height: 1.2; letter-spacing: -.015em; margin: 0; }
.tda-scene__explain p { font-size: 15px; line-height: 1.6; margin: 0; }

/* The consequence of the current inputs, stated in words (aria-live polite). */
.tda-outcome {
  font-size: 15px; line-height: 1.55; padding: 10px 12px;
  border-left: 3px solid var(--pink); background: var(--pink-wash); border-radius: 0 var(--radius) var(--radius) 0;
}
.tda-outcome strong { font-weight: 600; }
.tda-outcome .tda-num { font-family: var(--font-mono); }
.tda-readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 0; }
.tda-readout div { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: var(--inset); }
.tda-readout dt { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); }
.tda-readout dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 18px; color: var(--fg); }

/* Technical notes disclosure: persists across step changes. */
.tda-scene__notes { border-top: 1px solid var(--line); background: var(--bg2); }
details.tda-notes > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .05em; color: var(--dim);
}
details.tda-notes > summary::-webkit-details-marker { display: none; }
details.tda-notes > summary::before { content: "+"; color: var(--cyan-ink); width: 1ch; }
details.tda-notes[open] > summary::before { content: "−"; }
details.tda-notes > summary:hover { color: var(--fg); }
.tda-notes__body { padding: 0 18px 18px; font-size: 15px; line-height: 1.62; max-width: 92ch; }
.tda-notes__body h3 { font-size: 1rem; font-weight: 600; margin: 1.1em 0 .4em; }
.tda-notes__step { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 12px; }

/* Animation controls are labelled as animation; these are just layout. */
.tda-anim { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* --------------------------------------------------------- SVG primitives */

svg.tda-svg text, .tda-svg text { font-family: var(--font-sans); fill: var(--fg); font-size: 14px; }
.tda-svg .t-small { font-size: 12px; fill: var(--dim); }
.tda-svg .t-mono { font-family: var(--font-mono); font-size: 11.5px; fill: var(--dim); }
.tda-svg .t-big { font-size: 20px; }
.tda-svg .bg { fill: var(--panel); }
.tda-svg .grid { stroke: var(--grid); stroke-width: 1; }
.tda-svg .box { fill: var(--inset); stroke: var(--line-strong); stroke-width: 1.2; }
.tda-svg .box.is-pink { stroke: var(--pink); fill: var(--pink-wash); }
.tda-svg .box.is-cyan { stroke: var(--cyan); fill: var(--cyan-wash); }
.tda-svg .box.is-good { stroke: var(--good); fill: var(--good-wash); }
.tda-svg .box.is-caution { stroke: var(--caution); fill: var(--caution-wash); }
.tda-svg .box.is-fail { stroke: var(--fail); fill: var(--fail-wash); }
.tda-svg .box.is-muted { opacity: .45; }
.tda-svg .wire { fill: none; stroke: var(--line-strong); stroke-width: 1.8; }
.tda-svg .wire.is-pink { stroke: var(--pink); }
.tda-svg .wire.is-cyan { stroke: var(--cyan); }
.tda-svg .wire.is-dashed { stroke-dasharray: 5 5; }
.tda-svg .fill-pink { fill: var(--pink); }
.tda-svg .fill-cyan { fill: var(--cyan); }
.tda-svg .fill-good { fill: var(--good); }
.tda-svg .fill-caution { fill: var(--caution); }
.tda-svg .fill-fail { fill: var(--fail); }
.tda-svg .fill-dim { fill: var(--dim); }
.tda-svg .fill-line { fill: var(--line); }
.tda-svg .stroke-fg { stroke: var(--fg); }
.tda-svg * { transition: fill var(--dur) var(--ease), stroke var(--dur) var(--ease), opacity var(--dur) var(--ease); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .tda-scene {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "route" "stage" "side" "notes";
  }
  .tda-scene__stage { border-right: 0; border-bottom: 1px solid var(--line); }
  .tda-route-actions { margin-left: 0; }
}

/* Phone (390px class): stacked mechanism / controls / explanation, with
   larger touch targets and a scrollable step strip instead of wrapping. */
@media (max-width: 560px) {
  body { font-size: 16px; }
  .tda-scene-page, [data-embed="1"] .tda-scene-page { padding: 8px 8px 20px; }
  .tda-scene { border-radius: 0; border-left: 0; border-right: 0; }
  .tda-scene__route { padding: 8px 10px; gap: 8px; }
  .tda-steps { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: thin; }
  .tda-steps button { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
  .tda-route-actions { width: 100%; }
  .tda-route-actions .tda-btn { flex: 1 1 auto; min-height: 44px; }
  .tda-scene__stage { padding: 10px; }
  .tda-stage-canvas { min-height: 220px; }
  .tda-scene__controls { padding: 12px; }
  .tda-scene__explain { padding: 12px 12px 16px; }
  .tda-btn { min-height: 44px; }
  .tda-masthead, .tda-footer { padding: 14px 16px; }
  .tda-article > p:first-of-type::first-letter { font-size: 3.4em; }
}

/* --------------------------------------------------------- reduced motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; scroll-behavior: auto !important;
}

@media print {
  .tda-masthead, .tda-footer, .tda-theme-toggle, .tda-scene__route { display: none; }
  body { background: #fff; color: #000; }
}
