/* Control Room / Flight Recorder aesthetic.
   Semantic colors: amber = running/warning, green = pass/hardened, red = kill (momentary). */
:root {
  --bg: #101013;
  --bg2: #16161a;
  --panel: #1b1b20;
  --line: #2a2a31;
  --text: #d6d2c8;
  --dim: #8a867c;
  --faint: #55524b;
  --amber: #e8a33d;
  --amber-dim: #8a6224;
  --green: #5fbf7a;
  --green-dim: #2e5c3c;
  --red: #d95f5f;
  --serif: "Source Serif 4", "Noto Serif SC", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --maxw: 880px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--serif); line-height: 1.75;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
.mono { font-family: var(--mono); }
::selection { background: var(--amber); color: #17110a; }

/* ---------- language toggle ---------- */
.lang-toggle {
  position: fixed; top: 22px; right: 26px; z-index: 60;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 13px;
  background: rgba(27, 27, 32, 0.8); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 14px; cursor: pointer; color: var(--dim);
  transition: border-color 0.3s;
}
.lang-toggle:hover { border-color: var(--amber-dim); }
.lang-toggle .lang-opt.active { color: var(--amber); }
.lang-toggle .lang-sep { color: var(--faint); }

/* ---------- rail ---------- */
.rail { position: fixed; left: 22px; top: 50%; transform: translateY(-50%); z-index: 50; }
.rail ul { list-style: none; display: flex; flex-direction: column; gap: 13px; }
.rail li {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  cursor: pointer; transition: color 0.3s;
}
.rail li .tick { width: 16px; height: 2px; background: var(--faint); transition: all 0.3s; }
.rail li:hover { color: var(--dim); }
.rail li.active { color: var(--amber); }
.rail li.active .tick { width: 30px; background: var(--amber); }
.rail li .label { opacity: 0; transition: opacity 0.3s; white-space: nowrap; }
.rail li.active .label, .rail li:hover .label { opacity: 1; }

/* ---------- hero ---------- */
.hero { min-height: 100vh; display: flex; align-items: center; padding: 0 7vw; }
.hero-inner {
  max-width: 1180px; margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: center;
}
.kicker { font-size: 13px; letter-spacing: 0.04em; color: var(--amber); margin-bottom: 26px; }
.prompt { color: var(--amber-dim); margin-right: 4px; }
.hero-title {
  font-size: clamp(2.2rem, 5.5vw, 4rem); font-weight: 700;
  line-height: 1.15; letter-spacing: -0.01em; margin-bottom: 26px;
}
.strike { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--amber-dim); }
.em { color: var(--amber); font-style: italic; }
.hero-sub { font-size: clamp(0.8rem, 1.4vw, 0.95rem); color: var(--dim); }
.scroll-hint {
  margin-top: 56px; font-size: 11px; color: var(--faint);
  display: flex; flex-direction: column; gap: 4px;
  letter-spacing: 0.2em; text-transform: uppercase;
}
.scroll-hint .cursor { animation: bob 1.6s ease-in-out infinite; font-size: 14px; }
@keyframes bob { 50% { transform: translateY(6px); } }

/* hero fan-out svg */
.fanout { width: 100%; max-width: 460px; justify-self: end; }
.fanout .wire { fill: none; stroke: var(--line); stroke-width: 1.5; }
.fanout .wire.live { stroke: var(--amber-dim); stroke-dasharray: 5 5; animation: flow 1.4s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -10; } }
.fanout .node circle { fill: var(--bg2); stroke: var(--dim); stroke-width: 1.5; }
.fanout .node.root circle { stroke: var(--amber); fill: #1f1a10; }
.fanout .node.verdict circle { stroke: var(--green); }
.fanout .node text {
  font-family: var(--mono); font-size: 10px; fill: var(--dim); text-anchor: middle;
}

/* ---------- principles ---------- */
.principles { padding: 12vh 7vw; max-width: 1180px; margin: 0 auto; }
.pr-head {
  font-size: clamp(1.5rem, 3vw, 2.2rem); font-weight: 700;
  letter-spacing: -0.01em; margin-bottom: 44px; max-width: var(--maxw);
}
.pr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.pr-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 26px 24px; transition: border-color 0.4s, background 0.4s;
}
.pr-card.lit { border-color: var(--amber-dim); background: #1f1c15; }
.pr-card .idx { font-size: 11px; color: var(--amber-dim); font-weight: 700; }
.pr-card h3 { font-size: 1.1rem; margin: 12px 0 10px; }
.pr-card p { color: var(--dim); font-size: 0.92rem; line-height: 1.6; }

/* ---------- main line ---------- */
.mainline { position: relative; max-width: 1180px; margin: 0 auto; padding: 0 7vw; }
.mainline::before {
  content: ""; position: absolute; left: calc(7vw - 28px); top: 0; bottom: 0;
  width: 1px; background: var(--line);
}

/* ---------- stages ---------- */
.stage { padding: 11vh 0; max-width: var(--maxw); }
.stage-head { margin-bottom: 36px; }
.stage-label {
  font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber); display: block; margin-bottom: 14px;
}
.stage-head h2 {
  font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 700;
  letter-spacing: -0.01em; line-height: 1.2;
}
.principle-ref {
  font-size: 12px; color: var(--faint); margin-top: 12px;
  letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer;
  transition: color 0.3s;
}
.principle-ref:hover { color: var(--amber); }
.core { font-size: 1.06rem; color: var(--text); margin-top: 28px; max-width: 720px; }

/* field note (expandable) */
.field-note { margin-top: 22px; max-width: 720px; }
.field-note summary {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color 0.3s;
}
.field-note summary::-webkit-details-marker { display: none; }
.field-note summary::before { content: "◆"; font-size: 8px; color: var(--amber-dim); }
.field-note summary:hover { color: var(--amber); }
.field-note[open] summary { color: var(--amber); margin-bottom: 12px; }
.field-note p {
  color: var(--dim); font-size: 0.96rem;
  border-left: 2px solid var(--line); padding-left: 18px;
}

/* ---------- demo blocks ---------- */
.demo { margin: 8px 0; }

/* terminal */
.terminal {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; max-width: 680px;
}
.term-bar {
  font-size: 11px; color: var(--faint); padding: 10px 16px;
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px;
}
.term-bar [class^="dot-"] { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-r { background: #3d2626; } .dot-a { background: #3d3426; } .dot-g { background: #263d2c; }
.term-body { padding: 18px 20px; font-size: 12.5px; line-height: 2; min-height: 170px; }
.term-body .q { color: var(--amber); display: block; }
.term-body .ans { color: var(--dim); display: block; padding-left: 18px; }
.term-body .done { color: var(--green); display: block; margin-top: 8px; }
.term-body .warn { color: var(--amber); display: block; }
.term-body .ok { color: var(--green); display: block; }
.term-body .dim { color: var(--faint); display: block; }
.term-body .caret {
  display: inline-block; width: 8px; height: 1.1em; background: var(--amber);
  vertical-align: text-bottom; margin-left: 2px; animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* tdd chain */
.tdd { display: flex; flex-direction: column; gap: 12px; max-width: 680px; }
.tdd-unit {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 13px 18px;
}
.tdd-unit .t { font-size: 12px; padding: 4px 12px; border-radius: 5px; border: 1px solid var(--line); color: var(--dim); }
.tdd-unit .t.fail { border-color: var(--red); color: var(--red); }
.tdd-unit .t.pass { border-color: var(--green); color: var(--green); }
.tdd-unit .t.commit { border-color: var(--green-dim); color: var(--green); background: rgba(95,191,122,0.06); }
.tdd-unit .a { color: var(--faint); font-size: 12px; }

/* verdict loop */
.verdict-loop { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; max-width: 720px; }
.vcard {
  font-size: 12.5px; border-radius: 8px; padding: 14px 18px;
  border: 1px solid var(--line); background: var(--panel);
}
.vcard .vdim { color: var(--faint); display: block; margin-top: 4px; }
.vcard.fail { border-color: var(--red); color: var(--red); }
.vcard.pass { border-color: var(--green); color: var(--green); }
.vmid { display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--faint); font-size: 12px; }
.diffbar { width: 110px; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.diffbar span { display: block; height: 100%; width: 100%; background: var(--amber); border-radius: 3px; }

/* adversarial kill board */
.kill {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 20px 24px; font-size: 12.5px; max-width: 720px;
}
.k-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap;
}
.k-row:last-child { border-bottom: none; }
.k-desc { color: var(--text); flex: 1; min-width: 240px; }
.k-votes { display: flex; gap: 6px; }
.k-votes .vote {
  font-style: normal; font-size: 10px; padding: 2px 8px; border-radius: 4px;
  border: 1px solid var(--red); color: var(--red); opacity: 0;
}
.k-votes .vote.keep { border-color: var(--green-dim); color: var(--green); }
.k-verdict { font-size: 11px; letter-spacing: 0.08em; opacity: 0; }
.k-verdict.dead-v { color: var(--red); }
.k-verdict.live-v { color: var(--green); }
.k-row.dead .k-desc { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--red); }
.k-row.alive .k-desc { color: var(--green); }

/* ---------- incidents ---------- */
.incident {
  max-width: var(--maxw); margin: 4vh 0; position: relative;
  border-left: 3px solid var(--amber);
  background: linear-gradient(90deg, rgba(232, 163, 61, 0.07), transparent 65%);
  padding: 26px 30px; border-radius: 0 8px 8px 0;
}
.inc-tag {
  font-size: 11px; color: var(--amber); letter-spacing: 0.12em;
  text-transform: uppercase; display: block; margin-bottom: 12px;
}
.inc-tag::before { content: "⚠ "; }
.incident p { color: var(--dim); font-size: 0.98rem; max-width: 660px; }
.incident .rule {
  margin-top: 16px; font-size: 12px; color: var(--green);
  border: 1px solid var(--green-dim); border-radius: 6px;
  display: inline-block; padding: 8px 14px; background: rgba(95, 191, 122, 0.05);
}
.incident .rule::before { content: "◆ rule: "; color: var(--green-dim); }

/* ---------- infra panels ---------- */
.infra {
  max-width: var(--maxw); margin: 4vh 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 28px 30px; transition: border-color 0.5s;
}
.infra.lit { border-color: var(--amber-dim); }
.inf-tag {
  font-size: 11px; color: var(--amber); letter-spacing: 0.12em;
  text-transform: uppercase; display: block; margin-bottom: 14px;
}
.infra h3 { font-size: 1.25rem; margin-bottom: 12px; letter-spacing: -0.01em; }
.infra p { color: var(--dim); font-size: 0.96rem; }
.infra-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; max-width: var(--maxw); }
.infra-pair .infra { margin: 4vh 0 0; }

/* token ledger */
.ledger {
  margin-top: 18px; font-size: 12px; border-top: 1px dashed var(--line); padding-top: 12px;
}
.ledger div { display: flex; justify-content: space-between; padding: 4px 0; color: var(--faint); }
.ledger b { font-weight: 500; color: var(--text); }
.ledger b.ok { color: var(--green); }
.ledger b.warn { color: var(--amber); }

/* ---------- closing ---------- */
.closing {
  min-height: 85vh; display: flex; flex-direction: column; justify-content: center;
  align-items: flex-start; padding: 12vh 7vw; max-width: 1180px; margin: 0 auto;
}
.closing h2 {
  font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 700;
  letter-spacing: -0.01em; margin: 18px 0 26px; line-height: 1.15;
}
.out-body { max-width: 660px; color: var(--dim); font-size: 1.08rem; }
.back-top {
  margin-top: 46px; font-size: 13px; color: var(--amber); text-decoration: none;
  border: 1px solid var(--amber-dim); padding: 12px 22px; border-radius: 6px;
  transition: all 0.3s;
}
.back-top:hover { background: var(--amber); color: #17110a; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .fanout { justify-self: start; max-width: 380px; }
  .infra-pair { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .rail { display: none; }
  .mainline::before { display: none; }
  .lang-toggle { top: 14px; right: 14px; padding: 6px 11px; font-size: 12px; }
  .verdict-loop { flex-direction: column; align-items: flex-start; }
}

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