/* =============================================================================
   base.css · 舞台框体 / 影调叠加 / 通用排版 / 歌词 / 开场帘 / QA
   —— 所有场景在 1920×1080 设计空间内作画，由 #stage 整体等比缩放。
   —— 禁止：网页卡片、毛玻璃面板、常驻顶栏、彩色发光描边。
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}

body {
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-sans);
  color: var(--tx-hi);
}

body.is-idle { cursor: none; }

img { user-select: none; -webkit-user-drag: none; }
button { font: inherit; color: inherit; background: none; border: 0; }

/* ---------- 视口与舞台框体 ---------- */
#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 90% at 50% 46%, #070a10 0%, #020305 68%, #000 100%);
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  transform: translate(-50%, -50%) scale(var(--stage-scale, 1));
  transform-origin: 50% 50%;
  background: var(--ink-00);
  overflow: hidden;
  isolation: isolate;
}

#scenes,
#scenes > .scene {
  position: absolute;
  inset: 0;
}

#scenes > .scene {
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: opacity;
}

#scenes > .scene.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#scenes > .scene.is-backdrop { z-index: 1; }

#stage:has(.scene.is-active.is-blackout)::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 72;
  background: #000;
  pointer-events: none;
}

/* ---------- 电影质感叠加层 ---------- */
#grain,
#vignette,
#dust,
#lyrics,
#veil,
#flash,
#boot,
#qa,
#hint {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#grain {
  z-index: 60;
  opacity: 0.055;
  background-image: var(--tex-grain);
  background-size: 512px 512px;
  mix-blend-mode: overlay;
  animation: grain-drift 900ms steps(5) infinite;
}

#dust {
  z-index: 61;
  opacity: 0.10;
  background-image: var(--tex-dust);
  background-size: 512px 512px;
  animation: grain-drift 2600ms steps(9) infinite reverse;
  mix-blend-mode: screen;
  display: none;
}

#vignette {
  z-index: 62;
  background:
    radial-gradient(ellipse 78% 70% at 50% 47%, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0.34) 78%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.38) 0%, rgba(0, 0, 0, 0) 12%, rgba(0, 0, 0, 0) 88%, rgba(0, 0, 0, 0.42) 100%);
}

/* 学术 Slides 与静态图谱场景直接嵌入全图放映，取消全局暗角与胶片颗粒叠加 */
#stage:has(.scene-s05c.is-active, .scene-s09.is-active, .scene-s12.is-active, .scene-s13.is-active) #vignette,
#stage:has(.scene-s05c.is-active, .scene-s09.is-active, .scene-s12.is-active, .scene-s13.is-active) #grain {
  opacity: 0;
}

@keyframes grain-drift {
  0%   { background-position: 0 0; }
  20%  { background-position: -42px 17px; }
  40%  { background-position: 73px -34px; }
  60%  { background-position: -18px -61px; }
  80%  { background-position: 55px 48px; }
  100% { background-position: -92px 8px; }
}

/* ---------- 转场遮罩 ---------- */
#veil {
  z-index: 70;
  background: #000;
  opacity: 0;
  transition: opacity 260ms linear;
}
#veil.is-on { opacity: 1; }
#veil[data-color="paper"] { background: #e9dfcc; }

#flash {
  z-index: 71;
  background: #fff;
  opacity: 0;
}
#flash.is-on { opacity: 0.92; transition: opacity 80ms linear; }

/* ---------- 歌词字幕（机制 2：逐句渐显） ---------- */
#lyrics {
  z-index: 66;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 92px;
  text-align: center;
}

#lyrics .lyr-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 340px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.28) 46%, rgba(0, 0, 0, 0.62) 100%);
  opacity: 0;
  transition: opacity 900ms var(--ease-soft);
}
#lyrics.is-live .lyr-scrim { opacity: 1; }

#lyrics .lyr-rows {
  --lyr-support-size: 34px;
  --lyr-line-height: 1.18;
  position: relative;
  width: 1740px;
  padding-bottom: calc(var(--lyr-support-size) * var(--lyr-line-height) * var(--lyr-reserved-rows, 0));
}
#lyrics .lyr-row {
  display: flex;
  justify-content: center;
}
#lyrics .lyr-line {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 40px;
  line-height: var(--lyr-line-height);
  letter-spacing: 0.08em;
  color: #fff4de;
  text-shadow: 0 2px 12px #000, 0 2px 24px #000;
  white-space: nowrap;
}
#lyrics .lyr-line.is-supporting { font-size: var(--lyr-support-size); }
#lyrics .lyr-mark {
  position: relative;
  width: 46px;
  height: 1px;
  margin: 26px 0 0;
  background: linear-gradient(90deg, transparent, rgba(230, 196, 140, 0.72), transparent);
  opacity: 0;
  transition: opacity 1600ms var(--ease-soft);
}
#lyrics.is-live .lyr-mark { opacity: 0.8; }

/* ---------- 开场帘（技术幕，不是 Landing Page） ---------- */
#boot {
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 70% 58% at 50% 46%, #0a0f16 0%, #030507 72%, #000 100%);
  pointer-events: auto;
  transition: opacity 900ms var(--ease-soft), visibility 900ms;
}
#boot.is-off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#boot .boot-inner {
  position: relative;
  text-align: center;
  transform: translateY(-10px);
}
#boot .boot-kicker {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 15px;
  letter-spacing: 0.72em;
  color: rgba(230, 214, 186, 0.5);
  text-indent: 0.72em;
  margin-bottom: 34px;
  animation: boot-fade 1400ms 120ms var(--ease-soft) both;
}
#boot .boot-title {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: 140px;
  line-height: 1;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: #efe7d8;
  text-shadow: 0 0 60px rgba(226, 196, 148, 0.18);
  animation: boot-fade 1600ms 260ms var(--ease-soft) both, boot-breath 7s 1.4s ease-in-out infinite;
}
#boot .boot-sub {
  margin-top: 36px;
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 28px;
  letter-spacing: 0.28em;
  color: rgba(230, 214, 186, 0.65);
  animation: boot-fade 1600ms 460ms var(--ease-soft) both;
}
#boot .boot-rule {
  width: 420px;
  height: 1px;
  margin: 44px auto 0;
  background: linear-gradient(90deg, transparent, rgba(226, 196, 148, 0.26), transparent);
  animation: boot-rule 1800ms 620ms var(--ease-soft) both;
}
#boot .boot-enter {
  margin-top: 42px;
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: 13px;
  letter-spacing: 0.52em;
  color: rgba(230, 214, 186, 0.34);
  animation: boot-fade 1600ms 900ms var(--ease-soft) both, boot-pulse 2.6s 2s ease-in-out infinite;
}
#boot .boot-enter em { font-style: normal; color: rgba(230, 214, 186, 0.62); }

@keyframes boot-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes boot-rule {
  from { opacity: 0; transform: scaleX(0.3); }
  to { opacity: 1; transform: scaleX(1); }
}
@keyframes boot-breath {
  0%, 100% { text-shadow: 0 0 60px rgba(226, 196, 148, 0.16); }
  50% { text-shadow: 0 0 86px rgba(226, 196, 148, 0.26); }
}
@keyframes boot-pulse {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

/* ---------- QA / 排演提示（仅 ?qa=1 或 H 键） ---------- */
#qa {
  z-index: 90;
  display: none;
  inset: 14px auto auto 16px;
  width: auto;
  height: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: 0.02em;
  color: #cfe8f0;
  background: rgba(4, 8, 12, 0.74);
  border: 1px solid rgba(140, 190, 205, 0.18);
  border-radius: 3px;
  padding: 9px 13px;
  white-space: pre;
  pointer-events: none;
}
#qa.is-on { display: block; }
#qa .qa-dim { color: rgba(160, 190, 200, 0.5); }

#hint {
  z-index: 91;
  display: none;
  inset: auto 18px 16px auto;
  width: auto;
  height: auto;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.22em;
  color: rgba(220, 205, 180, 0.34);
  pointer-events: none;
}
#hint.is-on { display: block; }

/* ---------- 通用排版 ---------- */
.u-serif { font-family: var(--font-serif); }
.u-sans { font-family: var(--font-sans); }
.u-mono { font-family: var(--font-mono); }
.u-tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.u-kicker {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: var(--fs-kicker);
  letter-spacing: 0.42em;
  color: var(--tx-low);
  text-indent: 0.42em;
}
.u-label {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: var(--fs-small);
  letter-spacing: 0.28em;
  color: var(--tx-mid);
}
.u-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: var(--fs-title);
  line-height: 1.14;
  letter-spacing: 0.02em;
  color: var(--tx-hi);
}
.u-h2 {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: var(--fs-h2);
  line-height: 1.28;
  letter-spacing: 0.04em;
  color: var(--tx-hi);
}
.u-lead {
  font-family: var(--font-serif);
  font-weight: 300;
  font-size: var(--fs-lead);
  line-height: 1.9;
  letter-spacing: 0.05em;
  color: var(--tx-mid);
}
.u-body {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: var(--fs-body);
  line-height: 1.95;
  letter-spacing: 0.05em;
  color: var(--tx-mid);
}
.u-small {
  font-family: var(--font-sans);
  font-weight: 300;
  font-size: var(--fs-small);
  line-height: 1.8;
  letter-spacing: 0.08em;
  color: var(--tx-low);
}
.u-em {
  font-style: normal;
  color: var(--amber);
}
.u-num {
  font-family: var(--font-serif);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0.01em;
}

.u-rule {
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(244, 238, 226, 0.34), transparent);
}
.u-vrule {
  display: block;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(244, 238, 226, 0.3), transparent);
}

.u-glow-warm { text-shadow: 0 0 42px rgba(227, 169, 78, 0.34), 0 2px 26px rgba(0, 0, 0, 0.6); }
.u-glow-cold { text-shadow: 0 0 44px rgba(124, 201, 216, 0.32), 0 2px 26px rgba(0, 0, 0, 0.66); }
.u-glow-red { text-shadow: 0 0 46px rgba(217, 71, 59, 0.42), 0 2px 26px rgba(0, 0, 0, 0.7); }

/* 入场动画工具类：通过 style="--d: 240ms" 控制延迟 */
.u-in { animation: u-fade 900ms var(--ease-cine) both; animation-delay: var(--d, 0ms); }
.u-in-rise { animation: u-rise 1100ms var(--ease-cine) both; animation-delay: var(--d, 0ms); }
.u-in-blur { animation: u-blur 1300ms var(--ease-cine) both; animation-delay: var(--d, 0ms); }
.u-in-track { animation: u-track 1500ms var(--ease-cine) both; animation-delay: var(--d, 0ms); }

@keyframes u-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes u-rise {
  from { opacity: 0; transform: translate3d(0, 30px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes u-blur {
  from { opacity: 0; filter: blur(14px); }
  to { opacity: 1; filter: blur(0); }
}
@keyframes u-track {
  from { opacity: 0; letter-spacing: 0.32em; }
  to { opacity: 1; letter-spacing: 0.08em; }
}

/* 场景根节点默认清空样式 */

/* 安全区辅助（右侧 25% 为主讲人站位，任何场景不得放关键信息） */
.u-safe-right { position: absolute; right: 0; top: 0; width: 25%; height: 100%; pointer-events: none; }

/* 降低动效偏好 */
@media (prefers-reduced-motion: reduce) {
  #grain, #dust { animation: none !important; }
}
