/* Brand: cream paper, serif display, tracked mono labels, hairlines,
   contour-line glyphs with soft glows, dark pill buttons. Light only. */
:root {
  color-scheme: light;
  --bg: #F3F2EA;
  --card: #F7F6F0;
  --sunk: #ECEADF;
  --ink: #1D1D1B;
  --ink-2: #3F3F3A;
  --muted: #67655C;
  --faint: #9C998E;
  --hair: #D3D0C3;
  --hair-2: #E2DFD3;
  --threat: #C4368F;
  --threat-text: #A82A78;
  --state: #5E8A34;
  --state-text: #4A7324;
  --threat-soft: rgba(196, 54, 143, .07);
  --gap: #957D8A;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --gutter: 32px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background-color: var(--bg); color: var(--ink);
  background-image: radial-gradient(circle, rgba(29, 29, 27, .075) 1px, transparent 1.3px); background-size: 22px 22px;
  font-family: var(--serif); font-size: 18px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; }
.dim { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

/* ---------- the one-screen replay ---------- */
.screen { height: 100vh; height: 100svh; display: flex; flex-direction: column; padding: 0 var(--gutter) 12px; max-width: 1600px; margin: 0 auto; }
.screen:focus { outline: none; }
.bar { display: flex; align-items: baseline; gap: 20px; padding: 12px 0 10px; border-bottom: 1px solid var(--hair); flex: none; }
.brand { font-size: 21px; text-decoration: none; white-space: nowrap; }

.controls { display: flex; align-items: center; gap: 16px; padding: 10px 0 6px; flex: none; }
.ctl-left { display: flex; align-items: center; gap: 8px; flex: none; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 104px; background: var(--ink); color: #F6F5EE; border: 0; border-radius: 999px; padding: 9px 20px; font-size: 16px; cursor: pointer; white-space: nowrap; }
.pill:hover { background: #33332f; }
.round { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ink); background: transparent; cursor: pointer; font-size: 15px; flex: none; }
.round:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.round:disabled { opacity: .3; cursor: default; }
.clock { display: flex; flex-direction: column; min-width: 150px; line-height: 1.1; flex: none; }
.clock-t { font-size: 26px; font-variant-numeric: tabular-nums; }
.clock-p { color: var(--muted); font-size: 9px; margin-top: 2px; white-space: nowrap; }
.track { display: flex; gap: 5px; flex: 1; min-width: 0; user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.seg { min-width: 0; }
.seg-label { font-size: 8.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .08em; }
.ticks { display: flex; gap: 3px; height: 22px; align-items: stretch; border-bottom: 1px solid var(--ink); padding-bottom: 3px; }
.tick { flex: 1; min-width: 5px; border: 0; padding: 0; cursor: pointer; border-radius: 3px; background: linear-gradient(var(--faint), var(--faint)) center / 100% 6px no-repeat; }
.tick:hover { background-image: linear-gradient(var(--muted), var(--muted)); background-size: 100% 10px; }
.tick.done { background-image: linear-gradient(var(--ink-2), var(--ink-2)); }
.tick.now { background-image: linear-gradient(var(--ink), var(--ink)); background-size: 100% 16px; }
.tick { position: relative; }
.tick.run { background-image: linear-gradient(var(--hair), var(--hair)); }
.tick.run::after { content: ""; position: absolute; left: 0; top: 50%; height: 16px; margin-top: -8px; width: 100%; border-radius: 3px; background: var(--ink); transform-origin: left; animation: tickfill var(--dwell, 3s) linear both; }
@keyframes tickfill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.lens { display: inline-flex; border: 1px solid var(--hair); border-radius: 999px; padding: 3px; background: var(--card); flex: none; }
.lens button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; cursor: pointer; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.lens button[aria-pressed="true"] { background: var(--ink); color: #F6F5EE; }
.lens button:hover:not([aria-pressed="true"]) { background: var(--sunk); }

.key { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; color: var(--ink-2); font-size: 9px; letter-spacing: .08em; flex: none; }
.key li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.key svg { width: 32px; height: 12px; overflow: visible; }
.key .edge.on { opacity: 1; }
.key .dim { color: var(--muted); }
.legend-ring { fill: none; stroke: var(--threat); stroke-dasharray: 3 3; }

.stage-frame { position: relative; flex: 1; min-height: 0; display: flex; }
.stage-scroll { flex: 1; min-width: 0; min-height: 0; container-type: size; border: 1px solid var(--hair); border-radius: 3px; background: rgba(247, 246, 240, .72); overflow: hidden; }
.stage { position: relative; aspect-ratio: 1240 / 672; width: min(100cqw, 100cqh * 1240 / 672); margin: 0 auto; }
#replaySvg { display: block; width: 100%; height: 100%; overflow: hidden; }
.story-m { display: none; }

/* story, drawn inside the SVG so it scales with the map */
.story { background: rgba(247, 246, 240, .94); padding: 0 12px 4px 0; font-family: var(--serif); color: var(--ink); }
.story .meta, .story-m .meta { margin: 0; }
.story h3 { font-size: 30px; font-weight: 400; line-height: 1.1; margin: 6px 0 4px; letter-spacing: -.01em; }
.story .txt { font-size: 18px; line-height: 1.35; margin: 0; color: var(--ink-2); }
.story .note, .story-m .note { font-style: italic; font-size: 15px; line-height: 1.3; margin: 5px 0 0; color: var(--muted); }
.chip { display: inline-block; border: 1px solid currentColor; border-radius: 999px; padding: 2px 8px; font-size: 9px; letter-spacing: .1em; color: var(--ink-2); font-family: var(--mono); }
.chip.kind-scenario { color: var(--threat-text); }
.chip.kind-analysis { border-style: dashed; }

/* rows, zone */
.rail { stroke: var(--hair-2); stroke-dasharray: 1 5; }
.rowname { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; fill: var(--muted); }
.zone { opacity: 0; transition: opacity .6s; }
.zone.on { opacity: 1; }
.zone-rect { fill: var(--threat-soft); stroke: var(--threat); stroke-opacity: .5; stroke-dasharray: 4 5; }
.zone-label { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; fill: var(--threat-text); paint-order: stroke; stroke: var(--card); stroke-width: 8px; stroke-linejoin: round; }
.funnel-label { font-size: 9px; fill: var(--ink-2); }

/* glyphs */
.glyph { fill: none; stroke-width: 1; stroke-linejoin: round; stroke-linecap: round; transition: stroke .4s; }
.glyph .gfill { fill: var(--ink); stroke: none; }
.glyph .gfaint { stroke-opacity: .35; }

/* edges */
.edge { fill: none; stroke-width: 1.25; opacity: 0; transition: opacity .45s, stroke-width .3s; }
.edge.on { opacity: .13; }
.edge.on.recent { opacity: .32; }
.edge.cur { opacity: 1; stroke-width: 2; }
.edge.hover { opacity: 1; stroke-width: 2.2; }
.edge.funnel.on { stroke-width: 2.8; opacity: .55; }
.edge.funnel.cur, .lensed .edge.funnel.on.hi { stroke-width: 3.4; opacity: 1; }
.t-attack { stroke: var(--threat); }
.t-directive { stroke: #26261f; }
.t-request { stroke: #26261f; stroke-dasharray: 7 4; }
.t-information { stroke: #6f6d64; stroke-dasharray: 3 4; }
.t-resource { stroke: #26261f; stroke-dasharray: 0.1 5; stroke-linecap: round; stroke-width: 2.8; }
.t-legal { stroke: #26261f; stroke-dasharray: 9 3 2 3; }
.t-gap { stroke: var(--gap); stroke-dasharray: 3 5; }
.edge.cur.t-attack { stroke-dasharray: 6 4; animation: flow 1.1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -20; } }
.lensed .edge.on, .lensed .edge.on.recent { opacity: .06; }
.lensed .edge.on.hi { opacity: 1; stroke-width: 2; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: none; }
.edge-hit.on { pointer-events: stroke; cursor: help; }
.gap-x { opacity: 0; transition: opacity .4s; }
.gap-x.on { opacity: .75; }
.gap-x.cur { opacity: 1; }
.lensed .gap-x.on { opacity: .12; }
.gap-x circle { fill: var(--bg); stroke: var(--gap); }
.gap-x path { stroke: #7d6673; stroke-width: 1.3; stroke-linecap: round; }
.gap-x text { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; fill: #6d5663; paint-order: stroke; stroke: var(--card); stroke-width: 4px; }
.elabel { font-family: var(--mono); font-size: 9.5px; letter-spacing: .08em; fill: var(--ink-2); paint-order: stroke; stroke: rgba(247, 246, 240, .97); stroke-width: 5px; stroke-linejoin: round; pointer-events: none; }
.elabel.k-attack { fill: var(--threat-text); }
.dot { pointer-events: none; }
.dot.t-attack { fill: var(--threat); }
.dot:not(.t-attack) { fill: var(--ink); }
.dot.t-information { fill: var(--muted); }

/* nodes */
.node { cursor: pointer; opacity: .32; transition: opacity .5s; outline: none; }
.node:not(.on) .glyph, .lensed .node.on:not(.hi) .glyph { stroke: #9a978b; }
.node:not(.on) .glow { opacity: 0; }
.node.on { opacity: 1; }
.node .glow { opacity: .8; transition: opacity .4s, transform .4s; transform-box: fill-box; transform-origin: center; }
.node.cur .glow { opacity: 1; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.18); } }
.node .ring { fill: none; stroke: var(--threat); stroke-width: 1.1; stroke-dasharray: 3 3.5; opacity: 0; transition: opacity .5s; }
.node.compromised .ring { opacity: .9; }
.node-hit { fill: transparent; }
.nlabel { font-family: var(--serif); font-size: 15px; text-anchor: middle; fill: var(--ink); paint-order: stroke; stroke: rgba(247, 246, 240, .95); stroke-width: 4px; stroke-linejoin: round; }
.node.big .nlabel { font-size: 16.5px; }
.node.cur .nlabel { font-weight: 500; }
.node:hover .nlabel, .node:focus-visible .nlabel, .node.sel .nlabel { text-decoration: underline; text-underline-offset: 3px; }
.node:focus-visible .node-hit { stroke: var(--ink); stroke-dasharray: 2 2; }
.lensed .node.on { opacity: .32; }
.lensed .node.on.hi { opacity: 1; }

/* tooltip & drawer */
.tip { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; background: var(--card); border: 1px solid var(--hair); border-radius: 3px; padding: 7px 10px; max-width: min(250px, calc(100vw - 48px)); display: flex; flex-direction: column; gap: 2px; box-shadow: 0 6px 18px rgba(29, 29, 27, .08); }
.tip .mono { font-size: 8.5px; }
.tip strong { font-weight: 450; font-size: 15px; line-height: 1.25; }
.drawer { position: absolute; right: 12px; top: 12px; width: 300px; max-height: calc(100% - 24px); z-index: 6; overflow: auto; background: var(--card); border: 1px solid var(--hair); border-radius: 3px; padding: 14px 18px; box-shadow: 0 10px 30px rgba(29, 29, 27, .1); }
.drawer-bar { position: sticky; top: -14px; display: flex; justify-content: flex-end; margin: -14px -18px 0; padding: 4px 6px 0; background: var(--card); }
.drawer .close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--card); font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.drawer h4 { font-weight: 400; font-size: 24px; margin: 2px 0 4px; }
.drawer p:not(.mono) { font-size: 16px; margin: 0 0 8px; }
.layer-chip { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 9.5px; }
.layer-chip svg { overflow: visible; }
.reflist { list-style: none; padding: 0; margin: 0; }
.reflist li { font-size: 13.5px; line-height: 1.35; margin-bottom: 5px; }
.reflist a { color: var(--ink-2); text-decoration-color: var(--hair); text-underline-offset: 3px; }

h3 { font-weight: 400; font-size: 21px; margin: 4px 0 2px; }

@media (prefers-reduced-motion: reduce) {
  .edge.cur.t-attack, .node.cur .glow { animation: none; }
  .edge, .node, .zone, .gap-x, .glyph, .node .glow, .node .ring { transition: none; }
}

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .controls { flex-wrap: wrap; row-gap: 6px; }
  .track { order: 5; flex-basis: 100%; }
}
@media (max-width: 760px) {
  :root { --gutter: 14px; }
  .bar { flex-wrap: wrap; row-gap: 4px; }
  .clock { min-width: 0; }
  .clock-t { font-size: 22px; }
  .lens { margin-left: auto; }
  .lens button { padding: 6px 8px; font-size: 9px; }
  .key { gap: 2px 10px; font-size: 8px; } .key svg { width: 22px; } .key .dim { display: none; }
  .story-m { display: block; padding: 4px 0 8px; flex: none; min-height: 124px; }
  .nlabel { font-size: 19px; } .node.big .nlabel { font-size: 20px; } .elabel, .gap-x text { font-size: 13px; } .rowname { font-size: 13px; }
  .story-m h3 { font-size: 20px; margin: 3px 0 1px; font-weight: 400; }
  .story-m .txt { font-size: 14.5px; line-height: 1.3; margin: 0; color: var(--ink-2); }
  .story-m .note { font-size: 12.5px; margin-top: 2px; }
  .story-m .meta { display: none; }
  .controls { padding-top: 6px; }
  .pill { padding: 8px 16px; min-width: 88px; }
  .fo-story { display: none; }
  .stage-scroll { overflow-x: auto; container-type: normal; }
  .stage { height: 100%; width: auto; aspect-ratio: 1240 / 628; margin: 0; }
  .drawer { position: fixed; left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: 60svh; }
}
