/* ============================================================
   《开演！MUSICAL WORLD》全站样式（M1 基础 / M2 舞台 / M3 徽章 / M4 嵌图与打磨 / M6 动态舞台背景）
   主题色体系：页面级变量 --bg / --accent 写在 :root 里；
   每张剧目卡片自己的 --theme 由模板注入（style="--theme: ...")，
   这里只负责"使用"它。零外部字体、零 CDN，全部本地渲染。
   M2 新增：剧目页"剧情舞台"样式（对话框 / 打字机 / 选项按钮）。
   M3 新增：大厅卡片"已通关 ✓"徽章样式（数据来自进度库）。
   M4 新增：大厅横幅与场景插图样式、过渡动画与字号层级打磨。
   M6 新增（2026-11-22 意见修改轮）：答题界面全屏动态背景（变底色 /
   摇曳聚光灯 / 吊灯 / 人物剪影 / 音符粒子 / 幕布），舞台改半透明面板；
   幕次轨（剧情逐段解锁）与对话框面具徽记样式。
   ============================================================ */

:root {
  --bg: #14101c;      /* 剧场夜色背景 */
  --panel: #201a2e;   /* 卡片底色 */
  --accent: #c9a227;  /* 全站强调色：金箔 */
  --text: #f2ecdf;
  --muted: #9a90ad;
  /* M4 打磨：字号层级集中管理（标题用 clamp 随窗口伸缩，小屏不破版） */
  --fs-h1: clamp(30px, 5vw, 42px);
  --fs-stage-h1: clamp(26px, 4.5vw, 34px);
  --fs-dialog: 17px;   /* 剧情正文：最大一级 */
  --fs-option: 15px;   /* 选项次之 */
  --fs-meta: 13px;     /* 场景栏 / 徽章 / 页脚等辅助信息最小 */
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- 大厅头部 ---------- */
.site-header { text-align: center; padding: 48px 16px 8px; }
.eyebrow { color: var(--muted); font-size: var(--fs-meta); letter-spacing: 2px; }
.site-header h1 { font-size: var(--fs-h1); margin: 10px 0 6px; }
.site-header h1 .en { color: var(--accent); }
.tagline { color: var(--muted); }

/* ---------- 剧目卡片 ---------- */
.lobby {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* M4 大厅装饰横幅（static/img/lobby_banner.svg，纯装饰 alt 留空） */
.lobby-banner {
  display: block;
  width: 100%;
  margin-bottom: 28px;
  border-radius: 14px;
  border: 1px solid rgba(201, 162, 39, 0.28);
}

.card-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.card {
  --theme: var(--accent);  /* 模板没给主题色时的兜底 */
  position: relative;
  border-radius: 14px;
  overflow: hidden;
}

.card-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 26px 18px 18px;
  background: var(--panel);
  border-top: 4px solid var(--theme);
  text-decoration: none;
  color: inherit;
  /* M4 打磨：卡片浮起与入场动画 */
  transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
li.card { animation: riseIn 0.5s ease backwards; }
li.card:nth-child(2) { animation-delay: 0.08s; }
li.card:nth-child(3) { animation-delay: 0.16s; }
li.card:nth-child(4) { animation-delay: 0.24s; }

/* 只有"正在上演"的卡片是链接，才有 hover 反馈 */
a.card-inner:hover { background: #2a2240; transform: translateY(-4px); box-shadow: 0 12px 26px rgba(0, 0, 0, 0.4); }

/* 键盘操作也能看清焦点（可访问性） */
a.card-inner:focus-visible,
.option:focus-visible,
.back-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card h2 { font-size: 23px; }
.subtitle { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.desc { color: var(--muted); font-size: 14px; line-height: 1.6; flex: 1; }

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-playing { background: var(--accent); color: #241c07; font-weight: bold; }
.badge-soon { background: transparent; color: var(--muted); border: 1px solid var(--muted); }
/* M3 通关徽章：放在"正在上演"的左边（右上角已被它占住），
   描边金圈与主题区分开，一眼看出"这剧我通过了" */
.badge-cleared { top: 12px; right: 92px; background: transparent; color: var(--accent); border: 1px solid var(--accent); }

.cta { color: var(--theme); font-weight: bold; font-size: 14px; transition: transform 0.25s ease; }
.cta-soon { color: var(--muted); font-weight: normal; }
a.card-inner:hover .cta { transform: translateX(4px); }

/* 即将上演：整卡降饱和 + 半透明，视觉上"置灰不可点" */
.card.soon { filter: grayscale(0.7); opacity: 0.55; }

/* ---------- 剧目页 · 剧情舞台（第 8 课 M2 正式引擎 / M6 改半透明面板） ----------
   M6：node.bg 的场景底色改由引擎写到全屏背景层 #bg-tint 上（见下方
   M6 背景 section），舞台本体改为半透明面板浮在动态背景之上，
   文字永远坐在暗面板上保持可读。 */
.play-page { justify-content: center; }
.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  margin: 24px auto;
  padding: 40px 28px 28px;
  background: rgba(12, 8, 18, 0.66);
  border: 1px solid rgba(201, 162, 39, 0.22);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  min-height: calc(100vh - 48px);
}
.stage-head { text-align: center; margin-bottom: 28px; }
.stage-head h1 { font-size: var(--fs-stage-h1); margin-top: 6px; color: var(--theme); }

/* 场景栏：幕名 + 当前场景，小字居中 */
.scene {
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-meta);
  letter-spacing: 1.5px;
  margin-bottom: 14px;
}

/* 结局角标：只在结局节点显示（script.js 控制.hidden） */
.ending-tag {
  text-align: center;
  color: var(--accent);
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.ending-tag.pop { animation: tagIn 0.7s ease; }

/* M4 场景插图：剧本节点带 img 字段时出现在角标下方（static/img/） */
.scene-visual { margin: 0 0 16px; text-align: center; }
.scene-visual img {
  display: inline-block;
  width: 100%;
  max-width: 540px;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--theme);
  opacity: 0.94;
}
.scene-visual img.reveal { animation: riseIn 0.6s ease; }

/* 对话框：正文容器，点击可跳过打字（见 script.js 的 skipTyping） */
.textbox {
  background: rgba(20, 14, 30, 0.82);
  border: 1px solid var(--theme);
  border-radius: 12px;
  padding: 22px 24px;
  min-height: 150px;
  cursor: pointer;
  line-height: 1.95;
  font-size: var(--fs-dialog);
}
.dialog-text { display: inline; }
/* M4 打磨：换场时对话框整体轻浮入场（script.js 每次渲染节点时重放） */
.textbox.swap { animation: riseIn 0.45s ease; }

/* 打字机光标：跟随正文末尾闪烁 */
.cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 0.8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* 选项按钮：打完字后由 script.js 生成，纵向排列；
   M4 打磨：每次重建后依次入场（选项逐个浮现） */
.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 22px;
}
.option {
  padding: 12px 18px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--theme);
  border-radius: 10px;
  font-size: var(--fs-option);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  animation: riseIn 0.32s ease backwards;
}
.options .option:nth-child(1) { animation-delay: 0.05s; }
.options .option:nth-child(2) { animation-delay: 0.13s; }
.options .option:nth-child(3) { animation-delay: 0.21s; }
.options .option:nth-child(n+4) { animation-delay: 0.29s; }
.option:hover { background: #2a2240; transform: translateX(4px); }
.option:active { transform: translateX(4px) scale(0.99); }
/* 结局页的"再玩一次"：弱化样式，和剧情选项区分开 */
.option-again { border-style: dashed; color: var(--muted); }

/* 舞台页脚：返回大厅链接 */
.stage-foot { text-align: center; margin-top: 26px; }
.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 6px;
  transition: opacity 0.2s ease;
}
.back-link:hover { text-decoration: underline; opacity: 0.85; }

/* ---------- M4 动画关键帧与打磨 ----------
   riseIn：入场（上浮 + 淡入）—— 对话框换场 / 选项 / 卡片 / 插图共用；
   tagIn：结局角标登场（字距从宽收到正常，像"谢幕字幕"压下来）。 */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tagIn {
  from { opacity: 0; letter-spacing: 10px; }
  to   { opacity: 1; letter-spacing: 4px; }
}

/* 尊重系统"减少动态效果"设置：动画与过渡全部瞬时完成；
   M6 补充 iteration-count 收敛（避免 0.01ms × infinite 空转），
   音符粒子画布由 script.js 检测同一媒体特性后只画一帧静像。 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 页脚 ---------- */
.site-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

/* ============================================================
   M6 意见修改轮（2026-11-22）：答题界面全屏动态舞台背景
   ============================================================
   层序（都在 .backdrop 内，自底向上）：
     bg-tint      随剧情节点变色的底色（引擎写 backgroundColor，transition 渐变）
                  ::before 顶部柔光 ::after 地面阴影 —— 纯静态渐变零开销
     bg-beam×2    锥形聚光灯光束，transform-origin 顶端、两束反向缓摆
     bg-chandelier×2  内嵌 SVG 吊灯（<use> 复用画稿），绕吊点小幅摆动
     bg-figure×2  内嵌 SVG 人物剪影（魅影 / 克里斯汀），低透明度沉在背景
     bg-notes     飘浮音符粒子画布（引擎 RAF 绘制，标签页隐藏时暂停）
     bg-curtain×2 / bg-valance   幕布与檐幕（CSS 渐变褶皱，静态）
   全层 pointer-events:none 不挡答题按钮；动画只用 transform/opacity
   （合成层属性，机房集显可跑）；prefers-reduced-motion 时全部收敛。
   ============================================================ */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  animation: backdropIn 1s ease both;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

/* 变色底色层：node.bg 写在这里（JS），渐变过渡与 M2 手感一致 */
.bg-tint {
  position: absolute;
  inset: 0;
  background-color: #1c1024;      /* JS 未生效前的兜底底色 */
  transition: background-color 0.8s ease;
}
.bg-tint::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 24%, rgba(255, 244, 214, 0.07), transparent 62%);
}
.bg-tint::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22vh;
  background: linear-gradient(to top, rgba(5, 3, 9, 0.6), transparent);
}

/* 聚光灯光束：顶部锥形，两束反向缓摆（transform 合成层动画） */
.bg-beam {
  position: absolute;
  top: -6vh;
  left: 50%;
  width: 21vw;
  height: 120vh;
  margin-left: -10.5vw;
  transform-origin: 50% 0;
  background: linear-gradient(to bottom,
    rgba(240, 225, 180, 0.15),
    rgba(240, 225, 180, 0.05) 62%,
    rgba(240, 225, 180, 0) 92%);
  clip-path: polygon(41% 0, 59% 0, 100% 100%, 0 100%);
}
.beam-a { animation: beamSwayA 12s ease-in-out infinite alternate; }
.beam-b { animation: beamSwayB 15s ease-in-out infinite alternate; opacity: 0.8; }
@keyframes beamSwayA { from { transform: rotate(-16deg); } to { transform: rotate(13deg); } }
@keyframes beamSwayB { from { transform: rotate(19deg); } to { transform: rotate(-11deg); } }

/* 吊灯：同一画稿两盏，远近错相摆动 */
.bg-chandelier {
  position: absolute;
  transform-origin: 50% 0;
  opacity: 0.8;
}
.chand-a {
  top: 6vh;
  left: 13%;
  width: min(190px, 15vw);
  animation: chandSway 9s ease-in-out infinite alternate;
}
.chand-b {
  top: 8vh;
  right: 11%;
  width: min(130px, 11vw);
  opacity: 0.45;
  animation: chandSway 12s ease-in-out infinite alternate-reverse;
}
@keyframes chandSway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }

/* 人物剪影：浅色实体的"背光剪影"画法（CSS 整体压透明度），
   深浅任意剧情底色上都读得出形；随音乐极缓浮动；
   结局节点整体再退一层（引擎给 #backdrop 加 is-ending） */
.bg-figure {
  position: absolute;
  bottom: 0;
  height: 54vh;
  width: auto;
  opacity: 0.24;
  transition: opacity 1s ease;
  animation: figureFloat 9s ease-in-out infinite alternate;
}
.figure-christine { left: calc(50% - 530px); }
.figure-phantom { right: calc(50% - 550px); }
.figure-phantom { animation-duration: 11s; }
@keyframes figureFloat {
  from { transform: translateY(-5px); }
  to   { transform: translateY(4px); }
}
.backdrop.is-ending .bg-figure { opacity: 0.12; }

/* 音符粒子画布：铺满背景层，引擎控制帧循环 */
.bg-notes { position: absolute; inset: 0; width: 100%; height: 100%; }

/* 幕布：左右幕腿（竖向褶皱渐变）+ 顶部檐幕（金线 + 波形垂边） */
.bg-curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 11vw;
  min-width: 96px;
  background:
    repeating-linear-gradient(90deg,
      rgba(94, 16, 42, 0.92) 0 14px,
      rgba(58, 8, 26, 0.92) 14px 26px,
      rgba(122, 31, 61, 0.9) 26px 40px,
      rgba(46, 6, 20, 0.92) 40px 56px),
    #3a0a1c;
  box-shadow: inset 0 -40px 60px rgba(0, 0, 0, 0.5);
}
.curtain-l { left: 0; }
.curtain-r { right: 0; }

.bg-valance {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 9vh;
  min-height: 64px;
  background:
    repeating-linear-gradient(90deg,
      rgba(94, 16, 42, 0.95) 0 18px,
      rgba(122, 31, 61, 0.92) 18px 36px,
      rgba(58, 8, 26, 0.95) 36px 54px),
    #3a0a1c;
  border-bottom: 2px solid rgba(201, 162, 39, 0.35);
}
/* 檐幕下垂的波浪边（radial-gradient 平铺半圆） */
.bg-valance::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -13px;
  height: 13px;
  background: radial-gradient(18px 13px at 18px 0px, rgba(94, 16, 42, 0.95) 15px, transparent 16px);
  background-size: 36px 13px;
  background-repeat: repeat-x;
}

/* ---------- M6 幕次轨（剧情逐段解锁） ----------
   每答过一处抉择 / 走过一段剧情点亮一枚；当前段带光晕，
   下一枚空心呼吸待解锁——未走的剧情不提前出现。 */
.beat-rail {
  list-style: none;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: -10px 0 20px;
  min-height: 11px;
}
.beat {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(201, 162, 39, 0.55);
}
.beat.done { background: rgba(201, 162, 39, 0.72); border-color: rgba(201, 162, 39, 0.72); }
.beat.now { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18); }
.beat.next { animation: beatPulse 1.6s ease-in-out infinite; }
@keyframes beatPulse { 50% { opacity: 0.3; } }

/* ---------- M6 对话框面具徽记 ---------- */
.textbox { position: relative; }
.box-mask {
  position: absolute;
  top: -14px;
  left: 20px;
  width: 42px;
  height: 27px;
  opacity: 0.92;
}

/* 窄屏：剪影退到两侧边缘并再淡一层，避免和面板抢文字对比度 */
@media (max-width: 900px) {
  .figure-christine { left: 0; }
  .figure-phantom { right: 0; }
  .bg-figure { height: 42vh; opacity: 0.16; }
  .backdrop.is-ending .bg-figure { opacity: 0.1; }
}
