/* RetenDemo — living diagram. MediaMagic design tokens (from providers/styles.css). */

:root {
  --canvas: #fffaf0;
  --surface-soft: #faf5e8;
  --surface-card: #f5f0e0;
  --surface-strong: #ebe6d6;
  --surface-dark: #0a1a1a;
  --surface-dark-elevated: #1a2a2a;

  --ink: #0a0a0a;
  --body: #3a3a3a;
  --body-strong: #1a1a1a;
  --muted: #6a6a6a;
  --muted-soft: #9a9a9a;
  --hairline: #e5e5e5;
  --hairline-soft: #f0f0f0;
  --on-dark: #ffffff;
  --on-dark-soft: #a0a0a0;

  --pink: #ff4d8b;
  --teal: #1a3a3a;
  --lavender: #b8a4ed;
  --peach: #ffb084;
  --ochre: #e8b94a;
  --mint: #a4d4c5;
  --coral: #ff6b5a;

  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;

  --content: 1400px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--body);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--pink); color: #fff; }

.display {
  font-weight: 500;
  letter-spacing: -0.045em;
  color: var(--ink);
  line-height: 1.06;
  margin: 0;
}
.d-lg { font-size: clamp(28px, 3.8vw, 48px); letter-spacing: -0.05em; }

h3 { font-size: 18px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; color: var(--body-strong); margin: 0; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: clamp(15.5px, 1.4vw, 18px);
  line-height: 1.5;
  color: var(--body-strong);
  letter-spacing: -0.012em;
  max-width: 74ch;
}

.mono { font-family: var(--mono); }

.wrap { width: 100%; max-width: var(--content); margin: 0 auto; padding: 0 28px; }

/* ── topbar ── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 250, 240, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-in {
  max-width: var(--content); margin: 0 auto; padding: 12px 28px;
  display: flex; align-items: center; gap: 18px;
}
.brand {
  font-weight: 600; font-size: 14px; letter-spacing: -0.02em; color: var(--ink);
  display: flex; align-items: center; gap: 9px; text-decoration: none;
}
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); flex: none; }
.brand-sub { color: var(--muted-soft); font-weight: 400; }
.audit-link {
  margin-left: auto; font-size: 12.5px; color: var(--muted); text-decoration: none;
  padding: 6px 8px; border-radius: var(--r-sm); white-space: nowrap;
}
.audit-link:hover { color: var(--ink); background: var(--surface-card); }
.audit-link ~ .audit-link { margin-left: 0; }
.cta-btn {
  font-size: 12.5px; font-weight: 600; color: #fff; text-decoration: none;
  background: var(--pink); border-radius: 999px; padding: 7px 14px; white-space: nowrap;
}
.cta-btn:hover { filter: brightness(1.06); }

.lang { display: inline-flex; border: 1px solid var(--hairline); border-radius: var(--r-sm); overflow: hidden; flex: none; }
.lang button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  padding: 7px 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.lang button.on { background: var(--ink); color: #fff; }

/* ── hero ── */

.demo-hero { padding: 44px 0 26px; }
.demo-hero .display { max-width: 24ch; }
.demo-hero .lede { margin-top: 16px; }

.hero-callout {
  margin-top: 18px;
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 8px 22px;
  border: 1px solid var(--hairline); background: var(--surface-card);
  border-radius: var(--r-md); padding: 12px 18px;
  font-size: 13.5px; color: var(--body-strong); letter-spacing: -0.01em;
}
.hc-title {
  font-size: 10px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.hc-item { font-weight: 500; }

/* ── body layout ── */

.demo-body {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding-bottom: 64px;
  position: relative;
}

/* ── rail ── */

.rail {
  position: sticky; top: 72px;
  display: flex; flex-direction: column; gap: 20px;
  border: 1px solid var(--hairline);
  background: var(--surface-soft);
  border-radius: var(--r-lg);
  padding: 20px;
}
.rail-block { display: flex; flex-direction: column; gap: 8px; }
.rail-title {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  margin: 0;
}
.rail-read { font-size: 12.5px; color: var(--ink); }
.rail-hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }

.presets { display: flex; flex-direction: column; gap: 7px; }
.preset {
  text-align: left; border: 1px solid var(--hairline); background: var(--canvas);
  border-radius: var(--r-md); padding: 10px 12px; cursor: pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 600; color: var(--body-strong);
  letter-spacing: -0.01em; transition: border-color 0.15s, background 0.15s;
}
.preset span { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-top: 1px; }
.preset:hover { border-color: var(--muted-soft); }
.preset.on { border-color: var(--pink); background: #fff; box-shadow: 0 0 0 1px var(--pink); }

.seg { display: flex; border: 1px solid var(--hairline); border-radius: var(--r-sm); overflow: hidden; background: var(--canvas); }
.seg button {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 12px; font-weight: 500; color: var(--muted);
  padding: 8px 4px; transition: background 0.15s, color 0.15s;
}
.seg button + button { border-left: 1px solid var(--hairline); }
.seg button.on { background: var(--ink); color: #fff; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 20px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--pink) 0%, var(--pink) var(--fill, 50%), var(--surface-strong) var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--pink); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(10, 26, 26, 0.25); margin-top: -6px;
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--surface-strong); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--pink); }
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--pink); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(10, 26, 26, 0.25);
}
input[type="range"]:focus-visible { outline: 2px solid var(--pink); outline-offset: 4px; border-radius: 4px; }

.switch {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--hairline); background: var(--canvas);
  border-radius: 999px; padding: 5px 14px 5px 5px; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--muted);
  transition: border-color 0.2s;
}
.switch-knob {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--muted-soft); transition: background 0.2s;
  display: inline-block; flex: none;
}
.switch.on { color: var(--body-strong); border-color: rgba(34, 197, 94, 0.4); }
.switch.on .switch-knob { background: var(--success); }

.how summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted);
  text-decoration: underline; text-decoration-color: var(--muted-soft);
}
.how summary:hover { color: var(--ink); }
.how-body { margin-top: 10px; font-size: 11px; line-height: 1.7; color: var(--muted); white-space: pre-line; }

/* ── graph ── */

.stage-wrap { min-width: 0; }

.graph-card {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  background: var(--surface-soft);
  overflow: hidden;
}
#graph { display: block; width: 100%; height: auto; }

/* svg node/edge classes */
.edge { fill: none; stroke: #c9c2b0; stroke-width: 1.4; transition: opacity 0.5s, stroke 0.5s, stroke-width 0.5s; }
.edge.loom { opacity: 0.16; stroke-width: 1.1; }
.edge.loom.lit { opacity: 0.55; stroke-width: 1.8; }
.edge.dim { opacity: 0.12; }
.edge.dashed { stroke-dasharray: 5 4; }
.edge.pink { stroke: var(--pink); }
.edge.soft { opacity: 0.45; }
.edge.sd { opacity: 0.28; }
.edge.off { opacity: 0.07; }

.node-box { fill: var(--canvas); stroke: var(--hairline); transition: stroke 0.4s, fill 0.4s, opacity 0.4s; rx: 12px; }
.node-dark .node-box { fill: var(--teal); stroke: var(--teal); }
.node-pinkline .node-box { stroke: var(--pink); }

.n-title { font-family: var(--font); font-size: 14px; font-weight: 600; fill: var(--ink); }
.n-sub { font-family: var(--font); font-size: 11.5px; fill: var(--muted); }
.n-mono { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.n-count { font-family: var(--mono); font-size: 11px; fill: var(--ink); }
.node-dark .n-title { fill: #fff; }
.node-dark .n-sub, .node-dark .n-mono { fill: rgba(255,255,255,0.72); }
.node-dark .n-count { fill: #fff; }

.prov { cursor: pointer; }
.prov .node-box:hover { stroke: var(--muted-soft); }
.prov.flash .node-box { stroke: var(--pink); stroke-width: 2; }

.p-name { font-family: var(--font); font-size: 13px; font-weight: 600; fill: var(--ink); }
.p-badge-bg { rx: 8px; transition: fill 0.4s; }
.p-badge { font-family: var(--mono); font-size: 10.5px; }
.chan-line { font-family: var(--mono); font-size: 9.5px; fill: var(--muted); }
.chan-line.chan-s2s { fill: #c2366b; }
.stage-lbl {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; fill: var(--muted);
}
.ev-off { opacity: 0.55; }
.fillbar-bg { fill: var(--surface-strong); rx: 2.5px; }
.fillbar { rx: 2.5px; transition: width 0.8s ease; }

.bucket-bg { fill: rgba(255,255,255,0.12); rx: 4px; }
.bucket-fill { rx: 4px; transition: width 0.6s ease, fill 0.6s; }
.b-label { font-family: var(--font); font-size: 11px; fill: rgba(255,255,255,0.88); }
.b-state { font-family: var(--mono); font-size: 10px; fill: rgba(255,255,255,0.72); }

/* GTM container layers */
.layer-box { fill: rgba(255, 255, 255, 0.55); stroke: var(--hairline); rx: 8px; transition: opacity 0.4s; }
.layer-box.ours { stroke: var(--pink); }
.layer-title { font-family: var(--font); font-size: 11.5px; font-weight: 600; fill: var(--ink); }
.layer-tag { font-family: var(--mono); font-size: 9px; fill: var(--muted); }

/* Storage per-network packages */
.d-divider { stroke: rgba(255,255,255,0.18); }
.d-label { font-family: var(--mono); font-size: 10px; fill: var(--ochre); transition: opacity 0.4s; }
.d-chip { font-family: var(--mono); font-size: 9px; fill: rgba(255,255,255,0.8); }
.dchips { transition: opacity 0.4s; }
.dchips.dim, .d-label.dim { opacity: 0.3; }

.camp .n-title { font-size: 12.5px; }
.camp.dead .node-box { opacity: 0.45; }
.camp.dead text { opacity: 0.45; }
.fdot { opacity: 0.9; }

.eco-num { font-family: var(--mono); font-size: 15px; font-weight: 500; fill: #fff; }
.eco-label { font-family: var(--font); font-size: 10.5px; fill: rgba(255,255,255,0.65); }
.eco-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em; fill: var(--ochre); }
.eco-warn { font-family: var(--mono); font-size: 9.5px; fill: var(--ochre); }

.particle { pointer-events: none; }

/* focus mode during guided beats: inline styles set by setFocus() */
#graph .fadeable { transition: opacity 0.5s; }

/* ── caption bar ── */

.caption-bar {
  margin-top: 10px;
  display: flex; align-items: center; gap: 12px;
  background: rgba(10, 26, 26, 0.94);
  color: #fff; border-radius: var(--r-md);
  padding: 12px 16px;
  font-size: 14px; line-height: 1.45; letter-spacing: -0.01em;
  box-shadow: 0 8px 28px rgba(10, 26, 26, 0.25);
}
.caption-step { flex: none; font-size: 10.5px; color: var(--ochre); letter-spacing: 0.1em; }
.caption-text { flex: 1; min-width: 0; }
.caption-next, .caption-close {
  flex: none; border: 1px solid rgba(255,255,255,0.25); background: transparent;
  color: #fff; border-radius: var(--r-sm); padding: 5px 10px;
  font-family: var(--font); font-size: 12px; cursor: pointer;
}
.caption-next:hover, .caption-close:hover { background: rgba(255,255,255,0.12); }
.caption-close { padding: 5px 9px; }

.play-overlay {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 22px;
  width: 230px; height: 58px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--hairline); border-radius: 999px;
  background: rgba(255, 250, 240, 0.95); color: var(--ink);
  font-family: var(--font); font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 8px 28px rgba(10, 26, 26, 0.12);
}
.play-ic { color: var(--pink); }

.estimate-note { margin-top: 12px; font-size: 12px; color: var(--muted); }

.view-switch {
  margin-top: 16px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  font-size: 11px; color: var(--muted);
}
.vs-pill {
  font-size: 12px; color: var(--ink); text-decoration: none;
  border: 1px solid var(--hairline); border-radius: 999px;
  padding: 8px 14px; background: var(--canvas);
  transition: border-color 0.15s;
}
.vs-pill:hover { border-color: var(--pink); }

/* ── type legend ── */

.type-legend {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; gap: 6px 26px;
  font-size: 11px; color: var(--muted); line-height: 1.5;
}
.type-legend b { color: var(--ink); font-weight: 500; }

/* ── integration examples ── */

.examples { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.ex-card {
  min-width: 0;
  border: 1px solid var(--hairline); background: var(--surface-soft);
  border-radius: var(--r-lg); padding: 18px;
}
.ex-head { display: flex; align-items: baseline; gap: 10px; }
.ex-head h3 { font-size: 15px; margin-right: auto; }
.ex-chip {
  flex: none; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase;
  color: #92400e; background: rgba(245, 158, 11, 0.14);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.gtm-hier { margin-top: 12px; font-size: 10.5px; color: var(--muted); line-height: 1.7; }
.gh-row:first-child { color: var(--ink); }
.ex-code {
  margin: 12px 0 0; padding: 14px;
  background: var(--surface-dark); color: rgba(255, 255, 255, 0.85);
  font-size: 11px; line-height: 1.65;
  border-radius: var(--r-md); overflow-x: auto; white-space: pre;
}
.ex-tags { margin-top: 10px; display: flex; flex-direction: column; }
.tag-row {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 0; border-top: 1px solid var(--hairline-soft); font-size: 12.5px;
}
.tag-row.ours { border-top: 0; }
.tag-row.ours .tag-name { font-weight: 600; }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tag-dot-hollow { background: transparent; border: 1.5px solid var(--pink); }
.tag-name { font-weight: 500; color: var(--body-strong); margin-right: auto; }
.tag-kind { font-size: 10px; color: var(--muted); text-align: right; flex: none; }
.ex-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ptab {
  font-family: var(--mono); font-size: 10.5px; padding: 5px 10px;
  border-radius: 999px; border: 1px solid var(--hairline);
  background: var(--canvas); color: var(--muted); cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ptab:hover { border-color: var(--muted-soft); color: var(--ink); }
.ptab.on { border-color: var(--pink); color: var(--ink); background: #fff; box-shadow: 0 0 0 1px var(--pink); }
.ex-note { margin-top: 10px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.ex-note + .ex-note { margin-top: 4px; }

/* ── dossier ── */

.dossier {
  position: fixed; right: 24px; top: 84px; z-index: 50;
  width: min(400px, calc(100vw - 40px));
  background: var(--canvas); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: 22px;
  box-shadow: 0 16px 48px rgba(10, 26, 26, 0.16);
  max-height: calc(100vh - 108px); overflow-y: auto;
}
.dossier-head { display: flex; align-items: center; gap: 10px; }
.dossier-head h3 { font-size: 19px; margin-right: auto; }
.dossier-close {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 4px 6px; border-radius: var(--r-xs);
}
.dossier-close:hover { background: var(--surface-card); color: var(--ink); }
.dossier-domain { font-size: 11px; color: var(--muted); margin: 2px 0 0; }
.dossier dl { display: grid; grid-template-columns: 92px 1fr; gap: 10px 14px; margin: 16px 0 0; }
.dossier dt {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted); padding-top: 2px;
}
.dossier dd { margin: 0; font-size: 13px; line-height: 1.5; }
.dossier dd.mono { font-size: 11.5px; }
.dossier-link {
  display: inline-block; margin-top: 16px; font-size: 12.5px; color: var(--ink);
  text-decoration-color: var(--muted-soft);
}

.verdict {
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.v-open { background: rgba(34, 197, 94, 0.14); color: #15803d; }
.v-license { background: rgba(245, 158, 11, 0.16); color: #92400e; }
.v-part { background: rgba(239, 68, 68, 0.14); color: #b91c1c; }

.fchip {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 7px; border-radius: var(--r-xs);
  background: var(--surface-card); border: 1px solid var(--hairline); color: var(--body-strong);
  display: inline-block; margin: 2px 3px 2px 0; white-space: nowrap;
}
.fchip.off { color: var(--muted-soft); border-style: dashed; background: transparent; text-decoration: line-through; }

/* ── mobile stages ── */

.stages { display: none; }

.stage-card {
  border: 1px solid var(--hairline); border-radius: var(--r-lg);
  background: var(--surface-soft); padding: 18px; margin-bottom: 12px;
  scroll-margin-top: 76px;
}
.stage-card.dark { background: var(--teal); border-color: var(--teal); color: rgba(255,255,255,0.8); }
.stage-card.dark h3, .stage-card.dark .st-num { color: #fff; }
.stage-num { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted-soft); text-transform: uppercase; display: block; margin-bottom: 8px; }
.stage-card.dark .stage-num { color: rgba(255,255,255,0.55); }
.stage-card h3 { font-size: 16px; margin-bottom: 6px; }
.stage-card p { font-size: 13px; color: var(--muted); }
.stage-card.dark p { color: rgba(255,255,255,0.72); }
.stage-card .st-sub {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ochre); margin: 12px 0 2px;
}
.stage-card .st-chan { font-size: 10.5px; color: var(--muted); margin: 10px 0 0; }
.st-num { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.st-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--hairline-soft); font-size: 13px;
}
button.st-row {
  width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.stage-card.dark .st-row { border-top-color: rgba(255,255,255,0.14); }
.stage-card.dark .st-name { color: #fff; }
.stage-card.dark .st-row .mono { color: rgba(255,255,255,0.8); }
.st-row .verdict { font-size: 9px; }
.st-name { font-weight: 600; color: var(--body-strong); }
.st-arrow { text-align: center; color: var(--muted-soft); font-size: 16px; margin: -4px 0 8px; }

/* ── footer ── */

footer { border-top: 1px solid var(--hairline); padding: 32px 0 48px; }
.foot-in {
  display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: baseline;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.foot-in a { color: var(--muted); }

/* ── responsive ── */

@media (max-width: 1060px) {
  .demo-body { grid-template-columns: 1fr; }
  .rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .rail-block { flex: 1 1 200px; }
  .rail-block:first-child { flex-basis: 100%; }
  .presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}

/* below ~1000px the full SVG scales too small to read — switch to step cards */
@media (max-width: 1000px) {
  .graph-card { display: none; }
  .stages { display: block; }
}

@media (max-width: 760px) {
  .examples { grid-template-columns: 1fr; }
  .demo-hero { padding: 32px 0 18px; }
  .wrap { padding: 0 18px; }
  .topbar-in { padding: 12px 16px; gap: 10px; }
  .audit-link { display: none; } /* both links live in the footer too */
  .lang { margin-left: auto; }
  .dossier { right: 12px; left: 12px; width: auto; top: 70px; }
  .caption-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; margin-top: 0; }
  body.playing { padding-bottom: 96px; }
  .cta-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
