/* ═══════════════════════════════════════════════════════════════════════════
   EVENT HORIZON
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #f4f1ee;
  --dim: rgba(244, 241, 238, 0.56);
  --dimmer: rgba(244, 241, 238, 0.34);
  --hair: rgba(244, 241, 238, 0.14);
  --accent: rgb(255, 122, 47);
  --accent-dim: rgba(255, 122, 47, 0.55);

  /* Geist Mono carries every latin glyph and numeral. It has no CJK coverage,
     so the chinese display title falls through to the system CJK faces below —
     that fallback is intentional, not a gap. */
  --f-display: "Geist Mono", "PingFang SC", "Noto Sans SC", ui-monospace, monospace;
  --f-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, "PingFang SC", "Noto Sans SC", monospace;

  --pad: clamp(20px, 4.4vw, 64px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  background: var(--bg);
  /* 平滑滚动交给 JS：ScrollTrigger 刷新时要先把页面归零再量元素位置，
     CSS 的 smooth 会把那次归零变成一段动画，于是所有 start/end 都被量偏
     一整个滚动距离（缩放窗口后回到顶部，首屏就整块不见了）。 */
  scrollbar-width: none;
  -webkit-text-size-adjust: 100%;
}
html::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-display);
  font-weight: 400;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-booting { overflow: hidden; height: 100vh; }

::selection { background: var(--accent); color: #000; }

a { color: inherit; text-decoration: none; }
h1, h2, p, dl, dd, dt, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }

/* ── stage ───────────────────────────────────────────────────────────────── */

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.4s var(--ease);
}
body.is-live #stage { opacity: 1; }

/* readability scrim: dark on the left where the type lives, plus top/bottom */
.fx-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(100deg, rgba(0,0,0,0.80) 0%, rgba(0,0,0,0.42) 30%, rgba(0,0,0,0) 62%),
    linear-gradient(to bottom, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0) 22%),
    linear-gradient(to top, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 26%);
}

/* hairline frame — the whole page reads as an instrument panel */
.fx-grain {
  position: fixed;
  inset: clamp(10px, 1.5vw, 20px);
  z-index: 6;
  pointer-events: none;
  border: 1px solid rgba(244, 241, 238, 0.07);
  mix-blend-mode: screen;
}

/* ── chrome ──────────────────────────────────────────────────────────────── */

.chrome {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(22px, 3.2vw, 40px) var(--pad);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  mix-blend-mode: difference;
}

.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 14px 1px var(--accent);
  transition: box-shadow 0.7s var(--ease);
}
.brand-name { letter-spacing: 0.22em; }

.chrome-meta { display: inline-flex; align-items: center; gap: 10px; color: var(--dim); }
.chrome-meta .sep { color: var(--dimmer); }
.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ── rail ────────────────────────────────────────────────────────────────── */

.rail {
  position: fixed;
  right: var(--pad);
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 15px;
  padding-right: 22px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.rail-item {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  color: var(--dimmer);
  transition: color 0.5s var(--ease);
}
.rail-item b {
  font-weight: 400;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
.rail-item i { font-style: normal; font-variant-numeric: tabular-nums; }
.rail-item:hover { color: var(--dim); }
.rail-item:hover b { opacity: 0.7; transform: none; }
.rail-item.is-on { color: var(--accent); }
.rail-item.is-on b { opacity: 1; transform: none; }

.rail-line {
  position: absolute;
  right: 0; top: 2px; bottom: 2px;
  width: 1px;
  background: rgba(244, 241, 238, 0.16);
  overflow: hidden;
}
.rail-fill {
  position: absolute;
  inset: 0 0 auto 0;
  height: 100%;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
}

/* ── hud ─────────────────────────────────────────────────────────────────── */

.hud {
  position: fixed;
  left: var(--pad);
  bottom: clamp(22px, 3.2vw, 40px);
  z-index: 8;
  display: grid;
  gap: 3px;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmer);
}
.hud-row { display: grid; grid-template-columns: 52px auto; }
.hud-row i { font-style: normal; }
.hud-row b {
  font-weight: 400;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* ── chapters ────────────────────────────────────────────────────────────── */

main { position: relative; z-index: 4; }

.chapter { position: relative; height: 240vh; }
#sc0 { height: 300vh; }

.panel {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  align-content: center;
  padding: 0 var(--pad);
  padding-right: clamp(var(--pad), 14vw, 200px);
}

.stage {
  grid-area: 1 / 1;
  max-width: min(52ch, 46vw);
  will-change: transform, opacity;
}

/* ── type ────────────────────────────────────────────────────────────────── */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: clamp(20px, 2.4vw, 34px);
}
.eyebrow .idx {
  font-style: normal;
  color: var(--accent);
  padding-right: 3px;
  transition: color 0.7s var(--ease);
}

.display {
  /* 四个汉字必须整体成行：窄视口下一旦折行，0.86 的行高会让上下两行叠在一起。
     字号按视口收敛，保证任何宽度下四个字都放得下。 */
  font-size: clamp(2.6rem, 6vw, 6rem);
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
  font-weight: 200;
  margin: 0 0 clamp(26px, 3vw, 46px);
}
.ln { display: block; overflow: hidden; padding-bottom: 0.06em; }
.ln > span { display: block; }

.title {
  /* 与首屏标题同一路数：更小更细。行高必须 > 1，中文多行标题在 0.98 下会上下相碰 */
  font-size: clamp(1.7rem, 3.6vw, 3.4rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 200;
  margin-bottom: clamp(22px, 2.6vw, 38px);
}

.lead {
  font-size: clamp(14.5px, 1.02vw, 17.5px);
  line-height: 1.66;
  color: var(--dim);
  max-width: 44ch;
  font-weight: 400;
}
.lead.dim { color: var(--dimmer); margin-top: 14px; }
.hero-lead { max-width: 38ch; }

.specs {
  margin-top: clamp(30px, 3.6vw, 52px);
  display: grid;
  gap: 0;
  border-top: 1px solid var(--hair);
  max-width: 40ch;
}
.specs > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.specs dt { color: var(--dimmer); }
.specs dd { color: var(--fg); opacity: 0.82; }
.specs sub { font-size: 0.8em; }

.cue {
  margin-top: clamp(34px, 4vw, 60px);
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--dim);
}
.cue-line {
  width: 48px; height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  position: relative;
  overflow: hidden;
}
.cue-line::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  animation: sweep 2.4s var(--ease) infinite;
}
@keyframes sweep {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

/* ── outro ───────────────────────────────────────────────────────────────── */

.outro {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(80px, 11vh, 130px) var(--pad) 0;
}
.outro::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.72) 26%, rgba(0,0,0,0.88) 100%);
  pointer-events: none;
}
.outro-inner, .foot { position: relative; }
.outro-inner { max-width: 94ch; }
.outro-title { font-size: clamp(1.7rem, 3.6vw, 3.4rem); }  /* 与章节标题同一尺度 */
.outro-lead { max-width: 52ch; }

.ledger {
  margin-top: clamp(30px, 4vw, 56px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-top: 1px solid var(--hair);
}
.ledger li {
  display: grid;
  gap: 7px;
  align-content: start;
  padding: 15px 18px 17px 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.ledger i { font-style: normal; color: var(--dimmer); }
.ledger b { font-weight: 400; color: var(--fg); opacity: 0.85; }

.backtop {
  margin-top: clamp(32px, 4vw, 56px);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 14px 22px;
  border: 1px solid var(--hair);
  border-radius: 100px;
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease), gap 0.4s var(--ease);
}
.backtop svg {
  width: 13px; height: 13px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.backtop:hover { color: var(--accent); border-color: var(--accent); gap: 18px; }

.foot {
  margin-top: auto;
  padding: 24px 0 clamp(26px, 3.4vw, 40px);
  border-top: 1px solid var(--hair);
  display: flex;
  flex-wrap: wrap;
  gap: 16px 40px;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dimmer);
}

/* ── boot ────────────────────────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #000;
  display: grid;
  place-items: center;
}
.boot-inner { display: grid; justify-items: center; gap: 22px; }
.boot-mark {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 1.5px var(--accent), 0 0 26px 2px var(--accent);
  animation: breathe 2.2s var(--ease) infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.68); opacity: 0.55; }
}
.boot-label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--dim);
}
.boot-bar { width: 168px; height: 1px; background: rgba(244,241,238,0.16); overflow: hidden; }
.boot-fill {
  display: block; height: 100%; width: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease);
}
.boot.is-gone { opacity: 0; pointer-events: none; transition: opacity 0.9s var(--ease); }

/* ── no gpu ──────────────────────────────────────────────────────────────── */

.nogpu {
  position: fixed;
  inset: 0;
  z-index: 22;
  background:
    radial-gradient(120% 90% at 70% 10%, rgba(255,122,47,0.10), transparent 60%),
    #000;
  display: grid;
  align-content: center;
  padding: 0 var(--pad);
}
.nogpu[hidden] { display: none; }
.nogpu-inner { max-width: 54ch; }

/* ── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .stage { max-width: none; }
  .panel { padding-right: var(--pad); }
  .rail { gap: 13px; }
  .rail-item b { display: none; }
  .fx-scrim {
    background:
      linear-gradient(to top, rgba(0,0,0,0.86) 0%, rgba(0,0,0,0.30) 46%, rgba(0,0,0,0.55) 100%);
  }
  .panel { align-content: end; padding-bottom: 16vh; }
  .stage-hero { align-content: end; }
}

@media (max-width: 640px) {
  .hud { display: none; }
  .chapter { height: 200vh; }
  #sc0 { height: 260vh; }
  .specs > div { grid-template-columns: 1fr; gap: 4px; }
  /* the rail would sit on top of full-bleed copy — keep only the progress line */
  .rail { padding-right: 0; gap: 0; }
  .rail-item { display: none; }
  .rail-line { top: -22vh; bottom: -22vh; }
  .outro { justify-content: flex-start; }
  .foot { margin-top: clamp(56px, 10vh, 96px); }
}

@media (prefers-reduced-motion: reduce) {
  .dot, .boot-mark, .cue-line::after { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ── map section（全景状态图）────────────────────────────────────────────── */

.map { position: relative; padding: clamp(80px, 11vh, 130px) var(--pad) 0; }
.map::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0.72));
}
.map-head { position: relative; max-width: 1120px; margin: 0 auto 40px; }
.map-title { font-size: clamp(1.7rem, 3.6vw, 3.4rem); font-weight: 200; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 18px; }
.map-head .lead { max-width: 56ch; }

.map-frame {
  position: relative; max-width: 1160px; margin: 0 auto;
  border: 1px solid var(--hair); border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  padding: 24px 20px;
}
.map-canvas { position: relative; max-width: 1120px; height: 1300px; margin: 0 auto; }

.node {
  position: absolute; padding: 13px 15px;
  border: 1px solid var(--hair); border-radius: 3px;
  background: rgba(0, 0, 0, 0.62);
}
.node .eb {
  display: flex; gap: 8px; align-items: baseline;
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--dimmer); margin-bottom: 7px;
}
.node .eb .idx { color: var(--accent); }
.node .t { display: block; font-weight: 500; font-size: 14.5px; letter-spacing: 0.02em; margin-bottom: 5px; }
.node .s { display: block; color: var(--dim); font-size: 11px; line-height: 1.75; letter-spacing: 0.02em; }
.node.n-pill { border-radius: 100px; text-align: center; padding: 0; display: flex; align-items: center; justify-content: center; }
.node.n-pill .t { margin: 0; }
.node.n-done { border-color: var(--accent-dim); }
.node.n-done .t { color: var(--accent); font-weight: 500; }
.node.n-gate { border-color: var(--accent-dim); background: rgba(255, 122, 47, 0.06); }
.node.n-review { border-color: rgba(244, 241, 238, 0.30); }
.node.n-human { border-style: dashed; background: rgba(0,0,0,0.4); }
.node .chip {
  display: inline-block; margin-top: 7px; padding: 3px 10px;
  border: 1px solid var(--accent-dim); border-radius: 100px;
  color: var(--accent); font-family: var(--f-mono); font-size: 9.5px; letter-spacing: 0.14em;
}

svg.wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lbl { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.10em; }
.lbl-bg { fill: #000; }

@keyframes march { to { stroke-dashoffset: -13; } }
.flow-live { animation: march 1.1s linear infinite; }

.map-legend {
  position: relative; max-width: 1160px; margin: 22px auto 0;
  display: flex; flex-wrap: wrap; gap: 12px 30px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--dim);
}
.map-legend span { display: inline-flex; align-items: center; gap: 9px; }
.ml-ln { width: 26px; height: 0; border-top: 1.5px solid var(--dimmer); display: inline-block; }
.ml-ln.acc { border-color: var(--accent); }
.ml-ln.dash { border-top-style: dashed; border-color: var(--accent); }
.ml-bx { width: 12px; height: 12px; border: 1px solid var(--hair); border-radius: 3px; display: inline-block; }
.ml-bx.acc { border-color: var(--accent-dim); background: rgba(255,122,47,0.06); }

@media (max-width: 640px) {
  .map-canvas { transform: scale(0.62); transform-origin: top left; height: 806px; }
}

@media (prefers-reduced-motion: reduce) {
  .flow-live { animation: none; }
}
