/* The moving parts: the hero terminal and its background, the famous-failure player, the code
   map, the checklist and "Try it". style.css holds the page's base look; this builds on its
   variables. Everything animated stands still under prefers-reduced-motion. */

:root {
  --map-line: rgba(90, 110, 130, .22);
  --stage-bg: #0d1520;
  --stage-surface: #142030;
  --stage-border: #22324a;
  --stage-text: #e6edf3;
  --stage-muted: #93a1b1;
  --hot: #ff6b5e;
}
@media (prefers-color-scheme: dark) {
  :root { --map-line: rgba(150, 170, 190, .16); --stage-bg: #0e1724; --stage-border: #26384f; }
}

/* sections fade in as they arrive (hero.js); without JavaScript nothing is hidden */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.js .reveal.in { opacity: 1; transform: none; }
.section-lede { color: var(--muted); max-width: 48em; margin: -4px 0 20px; }
button.button { font: inherit; font-weight: 600; cursor: pointer; }
.cards > *, .steps > * { min-width: 0; }   /* long code lines scroll inside, not widen the page */
.button[disabled] { opacity: .6; cursor: progress; }

/* -- hero ------------------------------------------------------------------------------- */
.hero-wrap { position: relative; overflow: hidden; }
.hero-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 70% 80% at 65% 45%, #000 35%, transparent 80%);
  mask-image: radial-gradient(ellipse 70% 80% at 65% 45%, #000 35%, transparent 80%);
}
.hero { position: relative; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); }
.hero h1 { font-size: clamp(2rem, 4.2vw, 2.85rem); }
.terminal-window {
  min-width: 0; border-radius: var(--radius); background: var(--code-bg); overflow: hidden;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
}
.terminal-bar {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px; color: #7d8b9c;
  font: .75rem var(--mono); background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.terminal-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; flex: none; }
.terminal-bar i:nth-child(2) { background: #febc2e; }
.terminal-bar i:nth-child(3) { background: #28c840; }
.terminal-bar span { flex: 1; margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.terminal-replay {
  background: none; border: 1px solid rgba(255, 255, 255, .14); color: #9fb0c2; cursor: pointer;
  border-radius: 999px; padding: 1px 10px; font: inherit;
}
.terminal-replay:hover { color: #fff; border-color: rgba(255, 255, 255, .35); }
.terminal-window .terminal {
  border-radius: 0; height: 410px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: .7rem; line-height: 1.55; scrollbar-width: thin;
}
.t-prompt { color: #4ac27a; }
.t-head { color: #e6edf3; font-weight: 700; }
.t-review { color: #f0b44c; }
.t-ok { color: #4ac27a; }
.t-score { color: #f2a93b; }
.t-del { color: #ff9d94; }
.t-cursor {
  display: inline-block; width: .55em; height: 1.05em; vertical-align: text-bottom;
  background: #dce4ee; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* -- the famous-failure player --------------------------------------------------------- */
.story-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.story-tab {
  flex: 0 0 auto; display: grid; gap: 1px; min-width: 150px; text-align: left; cursor: pointer;
  padding: 9px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .2s, transform .2s;
}
.story-tab:hover { transform: translateY(-1px); }
.story-tab.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tab-year { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.tab-name { font-weight: 700; font-size: .95rem; }
.tab-status { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }

.story-stage {
  /* the stage is always dark, like a screen: chip colours tuned for it */
  --block: #ff6b5e; --review: #f0b44c; --ok: #4ac27a; --wait: #93a1b1; --accent: #f2a93b;
  --map-bg: #070c12; --map-text: #c9d4df; --map-dot: #5d6d80; --map-edge: #52637a;
  position: relative; margin-top: 10px; min-height: 480px; overflow: hidden;
  background: radial-gradient(120% 90% at 85% 0%, #17263a 0%, var(--stage-bg) 55%);
  color: var(--stage-text); border: 1px solid var(--stage-border); border-radius: 16px;
  box-shadow: 0 30px 70px -35px rgba(0, 0, 0, .6);
}
.story-stage code { color: #ffd28a; font-size: .9em; }
.scene {
  position: absolute; inset: 0; padding: 28px 32px; overflow: auto;
  opacity: 0; transform: translateX(28px); visibility: hidden; pointer-events: none;
  transition: opacity .5s ease, transform .5s ease, visibility 0s .5s;
}
.scene.active {
  position: relative; opacity: 1; transform: none; visibility: visible; pointer-events: auto;
  transition: opacity .5s ease, transform .5s ease;
}
.scene-lede { font-size: 1.05rem; margin: 0 0 14px; max-width: 60em; }
.scene-lede em { font-style: normal; color: var(--accent); }
.scene-foot { color: #6f8094; font-size: .78rem; margin: 12px 0 0; }

/* 1. what happened */
.scene-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 32px; align-items: start; }
.story-date { margin: 0 0 6px; color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.story-title { font-size: clamp(1.25rem, 2.4vw, 1.7rem); margin: 0 0 12px; }
.story-text { color: var(--stage-muted); line-height: 1.65; margin: 0; }
.damage { display: grid; gap: 10px; }
.damage-head { margin: 0; color: var(--stage-muted); font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.stat-tile { background: rgba(20, 32, 48, .85); border: 1px solid var(--stage-border); border-radius: 12px; padding: 12px 16px; }
.stat-num {
  font-size: clamp(1.9rem, 4.2vw, 2.8rem); font-weight: 800; line-height: 1.05; letter-spacing: -.02em;
  color: var(--hot); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 28px rgba(255, 107, 94, .35);
}
.stat-label { color: var(--stage-muted); font-size: .88rem; margin-top: 4px; }
.damage-note { margin: 0; color: var(--stage-muted); font-size: .84rem; }
.story-sources { margin: 18px 0 0; color: #6f8094; font-size: .75rem; }

/* 2. the change, and code panels everywhere in the player */
.code-panels { display: grid; gap: 14px; }
.code-panels.n2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.code-panel { margin: 0; min-width: 0; background: #070c12; border: 1px solid var(--stage-border); border-radius: 12px; overflow: hidden; }
.code-panel figcaption {
  display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px;
  font: .76rem var(--mono); color: #c9d4df; background: rgba(255, 255, 255, .03);
  border-bottom: 1px solid var(--stage-border);
}
.file-state { font-family: var(--font); color: var(--stage-muted); white-space: nowrap; }
.code-panel.untouched .file-state { color: var(--review); font-weight: 700; }
.code-lines { margin: 0; padding: 8px 0; max-height: 300px; overflow: auto; color: #dce4ee; font-size: .76rem; line-height: 1.6; scrollbar-width: thin; }
.ln { display: block; padding-right: 12px; white-space: pre; transition: opacity .35s, transform .35s, background .35s; }
.ln .no { display: inline-block; width: 3.2em; padding-right: .8em; text-align: right; color: #4d5d70; font-style: normal; user-select: none; }
.ln .op { display: inline-block; width: 1.2em; font-weight: 700; }
.ln.add { background: rgba(46, 160, 67, .17); }
.ln.add .op { color: #4ac27a; }
.ln.del { background: rgba(248, 81, 73, .13); color: #ff9d94; text-decoration: line-through; text-decoration-color: rgba(255, 120, 110, .45); }
.ln.del .op { color: var(--hot); }
.ln.pending { opacity: 0; transform: translateX(-10px); }
.ln.hit { background: rgba(255, 107, 94, .2); box-shadow: inset 3px 0 0 var(--hot); }
.ln.hit.flash { animation: hitflash 1.1s ease 2; }
@keyframes hitflash { 50% { background: rgba(255, 107, 94, .45); } }

/* 3. what it reaches */
.reach-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; align-items: center; }
.story-stage .map-box { background: var(--map-bg); border: 1px solid var(--stage-border); border-radius: 12px; padding: 6px; }
.reach-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.reach-list li { display: flex; gap: 10px; align-items: center; }
.reach-list .score {
  min-width: 3.3em; padding: 3px 6px; border-radius: 6px; text-align: center; color: #fff;
  font: 700 .82rem var(--mono); background: rgba(255, 107, 94, var(--heat));
}
.reach-list small { display: block; color: var(--stage-muted); font-size: .75rem; }

/* 4. the issue */
.issue-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.issue-card {
  background: var(--stage-surface); border: 1px solid var(--stage-border); border-radius: 12px;
  padding: 18px; opacity: 0; transform: translateY(12px); transition: opacity .5s, transform .5s;
}
.issue-card.in { opacity: 1; transform: none; }
.issue-card.found { border-color: rgba(255, 107, 94, .6); box-shadow: 0 0 40px -12px rgba(255, 107, 94, .45); }
.issue-head { margin: 0 0 6px; font-weight: 700; }
.issue-where { margin: 0 0 10px; color: var(--stage-muted); font: .8rem var(--mono); }
.issue-text { margin: 0 0 8px; font-size: 1.02rem; }
.issue-detail { margin: 0; color: var(--stage-muted); font-size: .88rem; }
.sev {
  display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor;
  font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--wait);
}
.sev.critical, .sev.high { color: var(--block); }
.sev.medium { color: var(--review); }

/* 5. caught? */
.story-stage .verdict-stage { color: var(--stage-text); text-align: center; max-width: 760px; margin: 0 auto; padding-top: 6px; }
.verdict-stage h3 { font-size: 1.35rem; margin-bottom: .5em; }
.verdict-stage p { color: var(--stage-muted); }
.stamp {
  display: inline-block; margin: 4px 0 18px; padding: 8px 24px; border: 5px solid currentColor;
  border-radius: 14px; font: 900 clamp(2.2rem, 6vw, 3.4rem)/1 var(--font); letter-spacing: .06em;
  text-transform: uppercase; opacity: 0; transform: rotate(-6deg) scale(2.2);
  transition: transform .45s cubic-bezier(.2, 1.6, .4, 1), opacity .2s;
}
.stamp.in { opacity: 1; transform: rotate(-6deg) scale(1); }
.stamp.block, .stamp.missed { color: var(--hot); text-shadow: 0 0 30px rgba(255, 107, 94, .5); }
.stamp.review { color: var(--review); text-shadow: 0 0 30px rgba(240, 180, 76, .45); }
.stamp.waiting { color: var(--stage-muted); font-size: clamp(1.3rem, 3.6vw, 2rem); }
.stamp.quiet { color: var(--ok); }
.verdict-stage .fix {
  display: inline-block; text-align: left; color: var(--stage-text); padding: 10px 14px;
  background: rgba(74, 194, 122, .1); border: 1px solid rgba(74, 194, 122, .35); border-radius: 10px;
}
.versus { font-size: 1rem; }
.versus span { font-weight: 800; color: var(--hot); }
.versus span:last-of-type { color: var(--ok); }
.versus em { font-style: normal; margin: 0 6px; }
.out-of-reach { text-align: left; font-size: .84rem; border-top: 1px solid var(--stage-border); padding-top: 12px; margin-top: 18px; }

/* the controls */
.story-bar { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.story-ctls { display: flex; gap: 6px; }
.ctl {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.3rem; line-height: 1;
}
.ctl:hover { border-color: var(--accent); }
.ctl.play::before { content: ""; width: 11px; height: 13px; border-left: 4px solid currentColor; border-right: 4px solid currentColor; box-sizing: border-box; }
.ctl.play.paused::before { width: 0; height: 0; border: solid transparent; border-width: 7px 0 7px 12px; border-left-color: currentColor; margin-left: 3px; }
.story-steps { flex: 1; min-width: 260px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; list-style: none; padding: 0; margin: 0; }
.story-steps button {
  position: relative; width: 100%; overflow: hidden; text-align: left; cursor: pointer;
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: 600 .8rem var(--font); white-space: nowrap; text-overflow: ellipsis;
}
.story-steps button .fill { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; background: var(--accent); transition: width .1s linear; }
.story-steps button.active { color: var(--text); border-color: var(--accent); }
.story-steps button.done { color: var(--text); }
.step-n {
  display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 3px; border-radius: 50%;
  background: var(--border); color: var(--text); font-size: .68rem;
}
.story-steps button.active .step-n, .story-steps button.done .step-n { background: var(--accent); color: #111; }
.all-results { margin: 20px 0 8px; }
.all-results > summary { cursor: pointer; font-weight: 600; color: var(--muted); }

/* -- the checklist ------------------------------------------------------------------- */
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.rule-card { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.rule-card h3 { margin: 8px 0 6px; font-size: 1rem; }
.rule-card p { margin: 0; }
.rule-card.waiting { color: var(--text); background: transparent; border-style: dashed; box-shadow: none; }
.rule-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
  padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.tag.block { border-color: currentColor; }

/* -- try it ---------------------------------------------------------------------------- */
.tryit { padding: 18px; }
.tryit-examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.example-tab {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; text-align: left;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font: 600 .92rem var(--font);
}
.example-tab:hover { border-color: var(--accent); }
.example-tab.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.example-n {
  display: inline-grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--border); font-size: .75rem;
}
.example-tab.active .example-n { background: var(--accent); color: #111; }

/* the task: what to change, and a shortcut */
.tryit-task {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 14px 0 12px; padding: 12px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.tryit-task p { margin: 0; }
.task-label { color: var(--accent); font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.task-hint { margin: 2px 0 6px !important; }
.task-diff { font: .82rem var(--mono); overflow-wrap: anywhere; }
.task-diff del { color: var(--block); text-decoration-color: currentColor; }
.task-diff ins { color: var(--ok); text-decoration: none; font-weight: 700; }
.task-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.task-actions .button { padding: 7px 14px; font-size: .88rem; }

.tryit-files { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.file-tab {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px; cursor: pointer;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: .8rem var(--mono);
}
.file-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.file-tab .edited { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.file-tab .here { color: var(--accent); font-weight: 800; }

/* the editor: line numbers, an arrow at the line to change, and a band behind that line */
.editor-wrap {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr);
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.editor-wrap:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.editor-wrap .gutter, .editor-wrap textarea { font: 13px/20px var(--mono); padding-top: 12px; padding-bottom: 12px; }
.editor-wrap .gutter {
  margin: 0; padding-left: 12px; padding-right: 10px; overflow: hidden; text-align: right;
  color: #4d5d70; user-select: none; position: relative; z-index: 1;
}
.editor-wrap .gutter b { color: #f2a93b; }
.editor-wrap textarea {
  width: 100%; min-height: 140px; resize: vertical; padding-left: 4px; padding-right: 12px; tab-size: 4;
  color: var(--code-text); background: transparent; border: 0; outline: none; position: relative; z-index: 1;
}
.editor-wrap .band {
  position: absolute; left: 0; right: 0; z-index: 0; pointer-events: none;
  background: rgba(242, 169, 59, .14); box-shadow: inset 3px 0 0 #f2a93b; transition: background .3s;
}
.editor-wrap .band.done { background: rgba(74, 194, 122, .14); box-shadow: inset 3px 0 0 #4ac27a; }
.editor-wrap .band:not(.done) { animation: beckon 2.2s ease-in-out infinite; }
@keyframes beckon { 50% { background: rgba(242, 169, 59, .26); } }
.tryit-blurb { margin: 10px 0 0; }
.tryit-status { margin: 4px 0 0; }
.tryit-waiting {
  margin: 14px 0 0; padding: 14px 16px; border: 1px dashed var(--border); border-radius: 10px; color: var(--muted);
}
.tryit-result { margin-top: 14px; transition: opacity .3s; }
.tryit-result.busy { opacity: .45; }
.result-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 0 6px; border-top: 1px solid var(--border); }
.verdict-big {
  padding: 3px 16px; border: 3px solid currentColor; border-radius: 10px; font-size: 1.3rem;
  font-weight: 900; text-transform: uppercase; letter-spacing: .06em; animation: pop .45s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: scale(1.7); opacity: 0; } }
.result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: start; }
.result-grid h4 { margin: 10px 0 8px; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.findings, .changes { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.findings li { padding-left: 10px; border-left: 3px solid var(--border); }
.findings p { margin: 4px 0; }
.finding-link {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0; cursor: pointer;
  background: none; border: 0; color: var(--text); font: inherit; text-align: left;
}
.finding-link:hover .where { text-decoration: underline; }
.where { color: var(--muted); font: .8rem var(--mono); }
.fix b { color: var(--ok); }
.changes li { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: .88rem; }
.kind { padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); font: 700 .66rem var(--mono); text-transform: uppercase; }
.kind.removed { color: var(--block); }
.kind.signature, .kind.renamed, .kind.value { color: var(--review); }
.kind.added { color: var(--ok); }
.result-map .map-box, .report-view .map-box { padding: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; }
.below-tryit { margin-top: 16px; }

/* -- small screens ----------------------------------------------------------------------- */
@media (max-width: 960px) {
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .scene-grid, .reach-grid, .issue-grid, .code-panels.n2, .result-grid { grid-template-columns: minmax(0, 1fr); }
  .tryit-examples { grid-template-columns: minmax(0, 1fr); }
  .scene { padding: 20px 18px; }
  .story-stage { min-height: 0; }
  .terminal-window .terminal { height: 340px; }
}
@media (max-width: 560px) {
  .steps { grid-template-columns: minmax(0, 1fr); }
  .story-steps button .t { display: none; }
  .story-steps button.active .t { display: inline; }
  .story-steps { grid-template-columns: repeat(5, auto); }
  .story-tab { min-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .scene, .stamp, .issue-card, .ln { transition: none; }
  .ln.hit.flash, .t-cursor, .verdict-big, .editor-wrap .band { animation: none; }
}
