/* ============================================================
   迟来的礼物 · A Belated Gift — base.css
   设计系统 / 全局层：令牌、排版、光标、预加载、星图、音效、灯箱
   ============================================================ */

:root {
  --bg: #07070c;
  --bg-2: #0b0b14;
  --bg-3: #101018;
  --ink: #ece7dd;
  --ink-dim: rgba(236, 231, 221, 0.6);
  --ink-faint: rgba(236, 231, 221, 0.34);
  --gold: #d8b36a;
  --gold-hi: #f3dfae;
  --gold-deep: #8a6b3c;
  --rouge: #a4453e;
  --rouge-hi: #c4736b;
  --line: rgba(216, 179, 106, 0.22);
  --line-soft: rgba(236, 231, 221, 0.1);
  --paper: #14120d;

  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --hand: "Long Cang", "Zhi Mang Xing", "Kaiti SC", cursive;
  --sans: "Space Grotesk", "Noto Sans SC", "PingFang SC", sans-serif;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --gutter: clamp(1.25rem, 4vw, 4.5rem);
}

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.9;
  letter-spacing: 0.02em;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

::selection { background: rgba(216, 179, 106, 0.32); color: var(--gold-hi); }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(216, 179, 106, 0.28); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(216, 179, 106, 0.5); }

/* ---------- 质感层：噪点 + 暗角 ---------- */
.grain {
  position: fixed; inset: -100px; z-index: 90; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.055;
  mix-blend-mode: overlay;
  animation: grainShift 0.9s steps(4) infinite;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-32px, 18px); }
  50% { transform: translate(20px, -28px); }
  75% { transform: translate(-14px, -10px); }
  100% { transform: translate(0, 0); }
}
.vignette {
  position: fixed; inset: 0; z-index: 89; pointer-events: none;
  background: radial-gradient(ellipse 120% 90% at 50% 42%, transparent 58%, rgba(3, 3, 8, 0.55) 100%);
}

/* ---------- 自定义光标 ---------- */
.cursor { position: fixed; top: 0; left: 0; z-index: 200; pointer-events: none; }
.cursor-dot, .cursor-ring { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.cursor-dot { width: 6px; height: 6px; background: var(--gold-hi); }
.cursor-ring {
  width: 34px; height: 34px; border: 1px solid rgba(216, 179, 106, 0.65);
  transition: width 0.35s var(--ease-out), height 0.35s var(--ease-out),
    border-color 0.35s, background-color 0.35s, opacity 0.3s;
}
.cursor-label {
  position: absolute; left: 26px; top: 10px; font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.28em; color: var(--gold-hi); white-space: nowrap; opacity: 0;
  transform: translateY(4px); transition: opacity 0.3s, transform 0.3s;
}
.cursor.is-hover .cursor-ring { width: 58px; height: 58px; background: rgba(216, 179, 106, 0.08); }
.cursor.is-press .cursor-ring { width: 22px; height: 22px; }
.cursor.is-label .cursor-ring { width: 78px; height: 78px; border-color: rgba(216, 179, 106, 0.9); }
.cursor.is-label .cursor-label { opacity: 1; transform: translateY(0); }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- 预加载 · 送花开场 ---------- */
.preloader {
  position: fixed; inset: 0; z-index: 150; background: #040408;
  display: flex; align-items: center; justify-content: center;
}
.preloader canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pre-center { position: relative; text-align: center; z-index: 2; padding: 0 1.5rem; }
.pre-line {
  font-size: clamp(1.05rem, 2.6vw, 1.5rem); font-weight: 400;
  letter-spacing: 0.42em; text-indent: 0.42em; color: var(--ink);
  opacity: 0;
}
.pre-line + .pre-line { margin-top: 0.9em; color: var(--gold-hi); }
.pre-meta {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: clamp(1.5rem, 4vh, 3rem);
  display: flex; justify-content: space-between; align-items: baseline; z-index: 2;
  font-family: var(--sans); font-size: 11px; letter-spacing: 0.32em; color: var(--ink-faint);
}
.pre-count { font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; }
.preloader.is-done { transition: opacity 0.7s var(--ease-in-out); }

/* ---------- 章节星图 ---------- */
.starmap {
  position: fixed; right: clamp(0.9rem, 2.4vw, 2rem); top: 50%; transform: translateY(-50%);
  z-index: 80; display: flex; align-items: center; gap: 0.9rem;
}
.starmap-rail { width: 1px; height: 180px; background: var(--line-soft); position: relative; }
.starmap-progress {
  position: absolute; top: 0; left: -1px; width: 3px; height: 0;
  background: linear-gradient(to bottom, transparent, var(--gold));
  box-shadow: 0 0 8px rgba(216, 179, 106, 0.7);
}
.starmap-list { display: flex; flex-direction: column; gap: 1.15rem; }
.starmap-list a { display: flex; align-items: center; gap: 0.65rem; flex-direction: row-reverse; }
.starmap-list i {
  font-style: normal; font-family: var(--serif); font-size: 12px; color: var(--ink-faint);
  width: 1.4em; text-align: center; transition: color 0.4s, text-shadow 0.4s;
}
.starmap-list span {
  font-size: 12px; letter-spacing: 0.3em; color: var(--ink-faint);
  opacity: 0; transform: translateX(6px); transition: opacity 0.4s, transform 0.4s, color 0.4s;
}
.starmap-list a:hover span, .starmap-list a.is-active span { opacity: 1; transform: translateX(0); }
.starmap-list a:hover i, .starmap-list a.is-active i { color: var(--gold-hi); text-shadow: 0 0 12px rgba(243, 223, 174, 0.8); }
.starmap-list a.is-active span { color: var(--gold); }

/* ---------- 环境音开关 ---------- */
.sound-toggle {
  position: fixed; left: var(--gutter); bottom: clamp(1.2rem, 3vh, 2.2rem); z-index: 80;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.95rem;
  border: 1px solid var(--line); border-radius: 99px; background: rgba(7, 7, 12, 0.55);
  backdrop-filter: blur(8px); font-family: var(--sans); font-size: 11px;
  letter-spacing: 0.3em; color: var(--ink-dim); transition: border-color 0.4s, color 0.4s;
}
.sound-toggle:hover { border-color: rgba(216, 179, 106, 0.55); color: var(--gold-hi); }
.st-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.st-bars i { width: 2px; height: 3px; background: var(--gold); transition: height 0.3s; }
.sound-toggle.is-playing .st-bars i { animation: stBounce 1s ease-in-out infinite; }
.sound-toggle.is-playing .st-bars i:nth-child(2) { animation-delay: 0.18s; }
.sound-toggle.is-playing .st-bars i:nth-child(3) { animation-delay: 0.36s; }
.sound-toggle.is-playing .st-bars i:nth-child(4) { animation-delay: 0.54s; }
@keyframes stBounce { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* ---------- 通用幕结构 ---------- */
.act { position: relative; padding: clamp(6rem, 14vh, 11rem) var(--gutter); }
.act-head {
  display: flex; align-items: flex-start; gap: clamp(1rem, 3vw, 2.4rem);
  max-width: 1200px; margin: 0 auto clamp(3rem, 7vh, 5.5rem);
  border-left: 1px solid var(--line); padding-left: clamp(1.2rem, 3vw, 2.4rem);
}
.act-numeral {
  font-size: clamp(3.2rem, 7vw, 5.2rem); line-height: 1; font-weight: 600;
  background: linear-gradient(160deg, var(--gold-hi) 5%, var(--gold) 45%, var(--gold-deep) 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.act-titles h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.3rem); font-weight: 600; letter-spacing: 0.3em;
  line-height: 1.4;
}
.act-intro { color: var(--ink-dim); font-size: clamp(0.85rem, 1.6vw, 1rem); letter-spacing: 0.12em; margin-top: 0.4rem; }

.dim { color: var(--ink-dim); }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 160; display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 9, 0.9); backdrop-filter: blur(14px);
  opacity: 0; pointer-events: none; transition: opacity 0.5s var(--ease-out);
  padding: var(--gutter);
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox-figure { max-width: 980px; width: 100%; display: grid; gap: 1.4rem; }
.lightbox-imgwrap { overflow: hidden; border: 1px solid var(--line); box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7); }
.lightbox-imgwrap img { width: 100%; max-height: 72vh; object-fit: cover; }
.lightbox-figure figcaption { display: grid; gap: 0.5rem; }
.lightbox-figure strong { font-size: 1.3rem; font-weight: 600; letter-spacing: 0.24em; color: var(--gold-hi); }
.lightbox-figure span { color: var(--ink-dim); max-width: 560px; }
.lightbox-close {
  position: absolute; top: clamp(1rem, 3vh, 2rem); right: var(--gutter);
  width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%;
  transition: transform 0.4s var(--ease-out), border-color 0.3s;
}
.lightbox-close::before, .lightbox-close::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 1px; background: var(--gold);
}
.lightbox-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.lightbox-close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.lightbox-close:hover { transform: rotate(90deg); border-color: var(--gold); }

/* ---------- 页脚 ---------- */
.footer {
  padding: clamp(4rem, 10vh, 7rem) var(--gutter) clamp(3rem, 7vh, 5rem);
  text-align: center; border-top: 1px solid var(--line-soft);
}
.footer-mark { font-size: 0.95rem; letter-spacing: 0.4em; color: var(--ink-dim); }
.footer-credits { font-size: 11px; font-family: var(--sans); letter-spacing: 0.14em; color: var(--ink-faint); margin-top: 1rem; }
.footer-year { font-family: var(--sans); font-size: 11px; letter-spacing: 0.5em; color: var(--gold-deep); margin-top: 0.6rem; }

/* ---------- JS 渐进隐藏（无 JS 时全部可见） ----------
   仅保留由 class/inline 控制的容器；GSAP 动画元素的初始态
   一律由各模块 gsap.set() 负责，避免 from() 把隐藏态当作自然态 */
html.js .season-slide,
html.js .memory { opacity: 0; }

/* ---------- 降级：减少动态 ---------- */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .sound-toggle.is-playing .st-bars i { animation: none; height: 8px; }
  html.js .season-slide, html.js .memory { opacity: 1; }
}
