/* ═══════════════════════════════════════════════════════════════════════════
   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(244, 168, 197);   /* 与封面 00 自白的强调色一致 */

  /* 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; }

/* ── cover (00) — pure black page, confession reveals paragraph by paragraph ── */
/* the column docks low: the last line should land below even the bottom of the rail */
.panel-cover { align-content: end; padding-bottom: clamp(48px, 9vh, 110px); }

.stage-cover {
  /* long-form reading column, not the brief half-width; a real column so the
     meta and the scrolling window never overlap each other. Kept shorter than
     the viewport so the window's top — where paragraphs dissolve away — sits
     well below the title's line instead of hugging the top of the page. */
  max-width: min(62ch, 72vw);
  /* 压缩正文栏高度：更大的字号在更短的窗口里滚动，文本框边界保持不动 */
  height: min(58vh, 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
/* the hero is not part of the text column at all — it owns the whole panel,
   vertically centred and flush left like a classic cover page */
.cover-hero {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: var(--pad);
  pointer-events: none;
}
.cover-meta { flex: 0 0 auto; }
.cover-meta .eyebrow { margin-bottom: clamp(12px, 1.6vh, 20px); }
.display-cover {
  font-size: clamp(2.2rem, 5vw, 5rem);
  margin-bottom: 0;
}
.cover-window {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: clamp(24px, 3.4vh, 44px);
  overflow: hidden;
  /* paragraphs dissolve at both edges — the ones that have had their moment
     fade out upward, the ones still waiting fade in from below */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 88%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 14%, #000 88%, transparent);
}
.cover-copy { padding: 2vh 0; will-change: transform; }
.cover-copy p {
  /* 固定 13px，不再随视口缩放 */
  font-size: 13px;
  line-height: 1.9;
  color: var(--fg);
  opacity: 0.88;
  margin: 0 0 2.1em;
  font-weight: 300;
}
.cover-copy p:last-child { margin-bottom: 0; }
.cover-en {
  font-family: var(--f-mono);
  font-size: 0.92em;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.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);
}
p.lead + p.lead { margin-top: 14px; }
.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; }

.outro-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: clamp(32px, 4vw, 56px);
}
.outro-actions .backtop { margin-top: 0; }

.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(244,168,197,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; }
  /* the cover stays a centered column instead of docking to the bottom */
  .panel-cover { align-content: center; padding-bottom: var(--pad); }
  .stage-cover { height: calc(82vh - 2 * var(--pad)); height: calc(82svh - 2 * var(--pad)); }
}

@media (max-width: 640px) {
  .hud { display: none; }
  .chapter { height: 200vh; }
  .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; }
}
