/* ============================================================
   The Underground Civilization — 视觉系统
   深黑 · 骨白 · 氧化铜 · 暗红。克制的博物馆/档案气质。
   ============================================================ */

:root {
  --ink: #08080a;
  --bone: #ece7dc;
  --bone-dim: rgba(236, 231, 220, 0.62);
  --copper: #5f9384;
  --copper-bright: #8fc0b0;
  --blood: #8e2a2a;
  --mist: #8b9096;
  --line: rgba(236, 231, 220, 0.14);
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  --font-body: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden;
}

/* ---------- 固定画布与氛围 ---------- */
#scene {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  display: block;
  touch-action: pan-y; /* 保留纵向滚动，横向交给画布 */
}

#vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
#vignette::after { /* 微弱纸纹 */
  content: ""; position: absolute; inset: 0; opacity: 0.05;
  background-image: repeating-linear-gradient(0deg,
    rgba(236, 231, 220, 0.5) 0, rgba(236, 231, 220, 0.5) 1px,
    transparent 1px, transparent 3px);
  mix-blend-mode: overlay;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 24px;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

#brand { line-height: 1.5; }
.brand-en {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.28em;
  color: var(--bone);
}
.brand-zh {
  display: block;
  font-size: 11px; letter-spacing: 0.18em;
  color: var(--bone-dim);
  margin-top: 2px;
}

#chapters {
  display: flex; flex-direction: column; gap: 10px;
  position: fixed; right: 22px; top: 50%; transform: translateY(-50%);
}
.ch-dot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  background: none; border: 0; cursor: pointer;
  color: var(--bone-dim);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
  transition: color 0.4s var(--ease-out);
}
.ch-dot i {
  font-style: normal;
  width: 22px; height: 1px; background: var(--line);
  display: inline-block; text-indent: -9999px; overflow: hidden;
  transition: background 0.4s, width 0.4s var(--ease-out);
}
.ch-dot span { opacity: 0; transform: translateX(6px); transition: opacity 0.4s, transform 0.4s var(--ease-out); }
.ch-dot:hover span, .ch-dot.active span { opacity: 1; transform: none; }
.ch-dot.active { color: var(--bone); }
.ch-dot.active i { background: var(--copper-bright); width: 34px; }

#sound-toggle {
  position: fixed; right: 24px; bottom: 20px;
  background: none; border: 1px solid var(--line);
  color: var(--bone-dim);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.2em;
  padding: 8px 12px; min-height: 44px; cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
#sound-toggle:hover { color: var(--bone); border-color: var(--bone-dim); }
body:has(#city-panel.open) #sound-toggle { opacity: 0; pointer-events: none; }
#chapters, #sound-toggle { transition: opacity 0.4s; }

#progress {
  position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 51;
  background: rgba(236, 231, 220, 0.06);
}
#progress-bar {
  display: block; height: 100%;
  background: var(--copper);
  transform-origin: 0 50%; transform: scaleX(0);
}

/* ---------- 章节与文案 ---------- */
.chapter { position: relative; z-index: 2; min-height: 190vh; pointer-events: none; }
.chapter .stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  display: flex; align-items: center;
  padding: 0 clamp(24px, 7vw, 110px);
}
#ch-threshold { min-height: 130vh; }
.chapter-mirror { min-height: 470vh; }
.chapter-mirror .stage { position: relative; height: 88vh; }

.copy { max-width: 560px; pointer-events: auto; }
.copy-center { margin: 0 auto; text-align: center; max-width: 640px; }
.copy-tl { margin-right: auto; }

[data-inview] {
  opacity: 0; transform: translateY(30px);
  transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out);
}
[data-inview].is-inview { opacity: 1; transform: none; }

.kicker {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 0.32em;
  color: var(--copper-bright);
  margin-bottom: 22px;
}
.kicker-red { color: var(--blood); }

h1.line-en {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 5.2vw, 62px);
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.line-zh {
  font-family: var(--font-display);
  font-size: clamp(17px, 2vw, 22px);
  color: var(--bone-dim);
  margin-top: 20px;
}

h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(26px, 3.6vw, 42px);
  line-height: 1.4;
  margin-bottom: 20px;
}
.body-text { color: var(--bone-dim); font-size: 15px; margin-bottom: 18px; }
.hint { font-size: 13px; color: var(--mist); margin-top: 26px; }

.btn-primary {
  margin-top: 38px;
  background: none;
  border: 1px solid var(--copper);
  color: var(--bone);
  font-family: var(--font-display);
  font-size: 17px; letter-spacing: 0.3em;
  padding: 16px 34px;
  cursor: pointer;
  transition: background 0.5s var(--ease-out), letter-spacing 0.5s var(--ease-out);
}
.btn-primary span {
  display: block;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.24em;
  color: var(--bone-dim); margin-top: 6px;
}
.btn-primary:hover { background: rgba(95, 147, 132, 0.14); letter-spacing: 0.36em; }

.btn-ghost {
  margin-top: 34px;
  background: none; border: 1px solid var(--line);
  color: var(--bone-dim);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.24em;
  padding: 12px 26px; cursor: pointer;
  transition: color 0.4s, border-color 0.4s;
}
.btn-ghost:hover { color: var(--bone); border-color: var(--bone-dim); }

/* ---------- 档案索引 / 芯片按钮 ---------- */
.index-list { list-style: none; margin-top: 14px; }
.index-list button {
  background: none; border: 0; border-bottom: 1px solid var(--line);
  width: 100%; text-align: left;
  color: var(--bone-dim);
  font-family: var(--font-display); font-size: 16px;
  padding: 10px 2px; min-height: 44px; cursor: pointer;
  transition: color 0.3s, padding-left 0.3s var(--ease-out);
}
.index-list button i {
  font-style: normal; font-family: var(--font-mono);
  font-size: 10px; color: var(--copper-bright); margin-right: 10px;
}
.index-list button span {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--mist); margin-left: 8px;
}
.index-list button:hover, .index-list button.active { color: var(--bone); padding-left: 10px; }

.controls { margin-top: 24px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.chip {
  background: none;
  border: 1px solid var(--line);
  color: var(--bone-dim);
  font-family: var(--font-body); font-size: 13px;
  padding: 9px 16px; min-height: 44px; cursor: pointer;
  transition: all 0.35s var(--ease-out);
}
.chip span { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.14em; color: var(--mist); margin-left: 6px; }
.chip:hover { border-color: var(--bone-dim); color: var(--bone); }
.chip.active { border-color: var(--copper-bright); color: var(--bone); background: rgba(95, 147, 132, 0.12); }

.btn-evidence { margin-top: 20px; }

.lens-note {
  margin-top: 18px;
  font-family: var(--font-display);
  font-size: 16px; color: var(--copper-bright);
  min-height: 1.6em;
}

/* ---------- ATTRACTION 控件 ---------- */
.slider-row {
  display: flex; align-items: center; gap: 16px;
  font-size: 12px; letter-spacing: 0.12em; color: var(--bone-dim);
  margin-bottom: 18px;
}
.slider-row input[type="range"] {
  flex: 1; max-width: 240px;
  -webkit-appearance: none; appearance: none;
  height: 1px; background: var(--line); outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bone); cursor: pointer;
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 1px var(--bone-dim);
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bone); cursor: pointer; border: 0;
}
.slider-row b { font-family: var(--font-mono); font-weight: 400; color: var(--bone); min-width: 2em; }

.stage-caption {
  margin-top: 26px;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.2vw, 24px);
  color: var(--bone);
  min-height: 1.8em;
  transition: opacity 0.5s;
}
.disclaimer {
  margin-top: 26px;
  font-size: 12px; line-height: 1.8;
  color: var(--mist);
  border-left: 1px solid var(--blood);
  padding-left: 14px;
}

/* ---------- CONVERGENCE 对照表 ---------- */
.mapping {
  margin-top: 26px;
  border-collapse: collapse;
  font-size: 14px;
  max-width: 460px;
}
.mapping caption {
  text-align: left;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.24em;
  color: var(--mist); padding-bottom: 10px;
}
.mapping th, .mapping td {
  border-top: 1px solid var(--line);
  padding: 9px 14px 9px 0;
  text-align: left; font-weight: 400;
}
.mapping th { font-family: var(--font-display); color: var(--bone); white-space: nowrap; }
.mapping th span { font-family: var(--font-mono); font-size: 9px; color: var(--mist); letter-spacing: 0.12em; margin-left: 8px; }
.mapping td { color: var(--copper-bright); font-family: var(--font-display); }
.mapping td.arrow { color: var(--mist); padding: 9px 18px 9px 0; }

/* 汇聚章 · 组织档案影像 */
.org-plate {
  position: relative;
  margin-top: 20px;
  max-width: 420px;
  border: 1px solid var(--line);
  padding: 7px;
  background: rgba(236, 231, 220, 0.03);
}
.org-plate img {
  display: block; width: 100%; height: auto; max-height: 24vh; object-fit: cover;
  filter: grayscale(0.85) sepia(0.32) brightness(0.66) contrast(1.12);
  mix-blend-mode: luminosity;
}
.org-plate::after {
  content: ""; position: absolute; inset: 7px;
  background: linear-gradient(160deg, rgba(95, 147, 132, 0.16), rgba(142, 42, 42, 0.08) 90%);
  mix-blend-mode: overlay;
  pointer-events: none;
}
.org-plate figcaption {
  padding: 9px 2px 1px;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em;
  color: var(--mist);
}

/* ---------- MIRROR ---------- */
.subject-id {
  font-family: var(--font-mono);
  font-size: 13px; letter-spacing: 0.3em;
  color: var(--blood);
  border: 1px solid var(--blood);
  display: inline-block;
  padding: 10px 22px;
  margin-bottom: 26px;
}
/* 镜厅记录：给数据一层“档案纸”，与背后的轨迹图分离 */
.copy-record {
  background: rgba(8, 8, 10, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  padding: 34px 36px;
  max-height: 82vh; overflow-y: auto;
}
.record-caption {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.26em;
  color: var(--blood);
  margin-bottom: 4px;
}
.stats {
  margin: 18px auto 0;
  max-width: 520px;
  text-align: left;
  font-size: 13.5px;
}
.stats dt {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.22em;
  color: var(--mist);
  margin-top: 12px;
}
.stats dd {
  color: var(--bone);
  border-bottom: 1px solid var(--line);
  padding: 4px 0 8px;
}
.final-q { margin-top: 34px; }
.mirror-line {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.2vw, 36px);
  line-height: 1.6;
}
.mirror-en { color: var(--bone); }
.mirror-en + .mirror-en { margin-top: 12px; color: var(--copper-bright); }
.final-q {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 40px);
  line-height: 1.5;
}
.final-q-zh {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 26px);
  color: var(--bone-dim);
  margin-top: 16px;
}

/* ---------- 城市档案：贴在空间中的展签 ---------- */
#city-panel {
  position: fixed; z-index: 40;
  left: clamp(16px, 3vw, 40px); bottom: clamp(16px, 4vh, 40px);
  width: min(410px, 92vw);
  max-height: 78vh;
  overflow-y: auto;
  background: rgba(8, 8, 10, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-top: 1px solid var(--copper);
  padding: 26px 26px 24px;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
#city-panel.open { opacity: 1; transform: none; pointer-events: auto; }
#cp-close {
  position: absolute; top: 10px; right: 10px;
  background: none; border: 1px solid var(--line);
  color: var(--bone-dim); font-size: 18px;
  width: 44px; height: 44px; cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}
#cp-close:hover { color: var(--bone); border-color: var(--bone-dim); }
.cp-file { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.3em; color: var(--copper-bright); }
#cp-name { font-family: var(--font-display); font-weight: 400; font-size: 30px; margin-top: 8px; }
.cp-region { font-size: 12px; color: var(--mist); margin-bottom: 18px; letter-spacing: 0.1em; }

/* 来源与切面说明 */
.cp-sources { margin-bottom: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.cp-sources summary {
  cursor: pointer; min-height: 44px;
  display: flex; align-items: center;
  font-size: 12px; letter-spacing: 0.14em; color: var(--copper-bright);
  list-style: none;
}
.cp-sources summary::-webkit-details-marker { display: none; }
.cp-sources summary::before { content: "+"; margin-right: 10px; font-family: var(--font-mono); }
.cp-sources[open] summary::before { content: "−"; }
.cp-sources summary span { font-family: var(--font-mono); font-size: 9px; color: var(--mist); margin-left: 8px; }
.cp-sources p { font-size: 12px; color: var(--bone-dim); margin-top: 8px; }
.cp-scope { color: var(--copper-bright) !important; letter-spacing: 0.08em; }
/* 档案图版：统一双色调处理，融入深夜展墙 */
.cp-plate {
  position: relative;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  padding: 8px;
  background: rgba(236, 231, 220, 0.03);
}
.cp-plate img {
  display: block; width: 100%; height: auto;
  filter: grayscale(0.85) sepia(0.32) brightness(0.66) contrast(1.12);
  mix-blend-mode: luminosity;
}
.cp-plate::after { /* 氧化铜罩染 */
  content: ""; position: absolute; inset: 8px;
  background: linear-gradient(160deg, rgba(95, 147, 132, 0.16), rgba(142, 42, 42, 0.08) 90%);
  mix-blend-mode: overlay;
  pointer-events: none;
}
.cp-plate figcaption {
  padding: 10px 2px 2px;
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--mist);
}
.cp-block { margin-bottom: 24px; }
.cp-block h4 {
  font-family: var(--font-display); font-weight: 400; font-size: 16px;
  color: var(--bone); margin-bottom: 8px;
}
.cp-block h4 span { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.2em; color: var(--copper-bright); margin-left: 8px; }
.cp-block p { font-size: 13.5px; color: var(--bone-dim); }
.cp-note { font-size: 11px; color: var(--mist); border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }

/* ---------- 入场 ---------- */
body:not(.ready) .copy { opacity: 0; }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  #hud { padding: 14px 16px; }
  #brand { max-width: 52vw; }
  .brand-en { font-size: 9px; letter-spacing: 0.2em; }
  .brand-zh { font-size: 9px; }
  #sound-toggle { right: 12px; bottom: 14px; left: auto; }
  .ch-dot span { display: none; }
  #chapters { right: 12px; gap: 14px; }
  .chapter .stage { padding: 0 22px; align-items: flex-end; padding-bottom: 9vh; }
  #ch-threshold .stage, .chapter-mirror .stage { align-items: center; padding-bottom: 0; }
  .copy { max-width: 100%; }
  .body-text br { display: none; }
  h2 br { display: none; }
  .mapping { max-width: 100%; font-size: 12px; }
  .mapping th, .mapping td { padding: 5px 8px 5px 0; }
  .org-plate { max-width: 100%; margin-top: 14px; }
  .org-plate img { max-height: 12vh; }
  .org-plate figcaption { display: none; }
  .chip { padding: 7px 12px; font-size: 12px; }
  #ch-convergence .stage { align-items: flex-start; padding-top: 9vh; padding-bottom: 0; }
  #ch-convergence .disclaimer { margin-top: 14px; margin-bottom: 48px; }
  /* 城市档案：底部抽屉 */
  #city-panel {
    left: 0; right: 0; bottom: 0; width: 100vw;
    max-height: 72vh;
    border-top: 1px solid var(--copper);
    padding: 22px 20px 28px;
    transform: translateY(102%);
    opacity: 1;
  }
  #city-panel.open { transform: none; }
  .copy-record { padding: 24px 18px; max-height: 80vh; }
  /* 底部文案区加暗色渐层，保证文字压过图谱可读 */
  #vignette::before {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(to top,
      rgba(8, 8, 10, 0.94) 26%, rgba(8, 8, 10, 0.6) 52%, transparent 74%);
  }
}

/* ---------- 高对比模式 ---------- */
@media (prefers-contrast: more) {
  :root {
    --bone-dim: rgba(236, 231, 220, 0.88);
    --mist: #b6bcc2;
    --line: rgba(236, 231, 220, 0.38);
  }
  #vignette { display: none; }
  .chip, .btn-ghost, .index-list button, #sound-toggle { border-color: var(--line); }
}

/* ---------- 减少动态效果 ---------- */
@media (max-height: 880px) {
  .mapping th, .mapping td { padding: 6px 10px 6px 0; }
  .mapping td.arrow { padding: 6px 14px 6px 0; }
  .org-plate { margin-top: 14px; }
  .org-plate img { max-height: 19vh; }
  .disclaimer { margin-top: 16px; margin-bottom: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
  [data-inview] { opacity: 1; transform: none; }
}
