/* =============================================================
 * 基础布局：1194x834 基准舞台、场景双模式层、字幕、占位框
 * ============================================================= */

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

html, body {
  width: 100%; height: 100%;
  background: var(--c-bg);
  font-family: var(--font-family);
  color: var(--c-ink);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}

/* ---- 视口：把 1194x834 舞台等比缩放居中 ---- */
#viewport {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

#stage {
  position: relative;
  width: 1194px; height: 834px;
  background: var(--c-bg);
  overflow: hidden;
  transform-origin: center center;
}

/* ---- 场景层（双模式，design_tokens.scene） ---- */
#scene-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  transition: opacity 400ms ease;
}

/* 任务模式磨砂幕布：白74% + 9pt虚化 + 去饱和25%，静态颗粒 */
#scene-curtain {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(12px) saturate(0.75);
  -webkit-backdrop-filter: blur(12px) saturate(0.75);
  opacity: 0;
  transition: opacity 400ms ease;
  pointer-events: none;
}
#scene-curtain.on { opacity: 1; }

/* 细噪点颗粒（feTurbulence 灰度，恒定不动） */
#grain {
  position: absolute; inset: 0;
  opacity: 0.04;
  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'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- 内容区：顶栏之下的舞台 ---- */
#content {
  position: absolute;
  left: 0; right: 0;
  top: 104px;           /* 顶栏64 + 悬浮间距 */
  bottom: 0;
  padding: 0 37px 28px;
}

/* 视觉层叠放区（show/enter 的素材进这里）。
 * 底部让出字幕带（--caption-band），素材与字幕永不重叠。 */
#visual {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--caption-band, 110px);
  display: flex; align-items: center; justify-content: center;
}
/* 每层铺满素材区（确定尺寸），内部 flex 居中；
 * img 的 max-% 以层为基准解析，保证永不溢出素材区/字幕带 */
.layer {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
/* 内容图卡片化：白底素材以"展示卡"形式立在场景上（圆角+发丝线+投影），
 * 而不是生硬的白方块压在背景图上 */
.layer img {
  max-width: 86%; max-height: 92%;
  object-fit: contain;
  border-radius: 24px;
  border: 1px solid var(--c-hairline);
  box-shadow: var(--sh-raised);
  background: var(--c-surface);
}

/* 吉祥物常驻层（enter 进场后跨页存在）。
 * 位置：左侧中部偏下；multiply 让白底图融入浅色背景不显突兀 */
.layer.mascot {
  position: absolute;
  inset: auto;
  left: 64px; top: 44%;
  width: 230px; height: 260px;
  display: flex; align-items: center; justify-content: center;
  z-index: 30;
  pointer-events: none;
  /* 动态停靠：翻页时平滑移到新位置（"有生命力"，并给交互区让路，2026-06-13反馈#5） */
  transition: left .7s cubic-bezier(.34,1.2,.4,1), right .7s cubic-bezier(.34,1.2,.4,1),
              top .7s cubic-bezier(.34,1.2,.4,1), bottom .7s cubic-bezier(.34,1.2,.4,1),
              width .7s ease, height .7s ease;
}
/* 停靠位（引擎按页面类型设置，YAML page.mascot.pos 可覆盖） */
.layer.mascot.pos-left-mid   { left: 64px; right: auto; top: 44%; bottom: auto; width: 230px; height: 260px; }
.layer.mascot.pos-corner     { left: 28px; right: auto; top: auto; bottom: 122px; width: 148px; height: 168px; }
.layer.mascot.pos-right-low  { left: auto; right: 44px; top: auto; bottom: 150px; width: 188px; height: 212px; }
.layer.mascot.pos-left-low   { left: 24px; right: auto; top: auto; bottom: 36px; width: 204px; height: 230px; }
.layer.mascot img {
  max-width: 100%; max-height: 100%;
  border: none; border-radius: 0;
  box-shadow: none; background: transparent;   /* 透明底立绘，不套展示卡样式 */
}

/* ---- 屏上大字（on_screen_text 独立步骤） ---- */
.headline {
  position: absolute;
  top: 12px; left: 0; right: 0;
  text-align: center;
  font-size: var(--fs-subtitle);
  font-weight: 900;
  color: var(--c-ink);
  z-index: 20;
}

/* ---- 字幕带（视频式逐句字幕，固定在专用底部区域） ----
 * 规则见 CLAUDE.md 第15节：每次只显示当前讲到的一句；
 * 语音结束后最后一句保留，直到下一句/翻页才消失。 */
:root { --caption-band: 110px; }

#subtitle {
  position: absolute;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  max-width: 1000px;
  height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-frosted);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--c-hairline);
  border-radius: 32px;
  box-shadow: var(--sh-card);
  padding: 0 36px;
  z-index: 60;
  opacity: 0;
  transition: opacity var(--t-base) ease;
  pointer-events: none;
  white-space: nowrap;
}
#subtitle.show { opacity: 1; }
#subtitle .line {
  font-size: 20pt;
  font-weight: 700;
  line-height: 1.4;
  color: var(--c-ink);
  text-align: center;
}
#subtitle .mock-badge {
  position: absolute; top: -10px; right: 16px;
  font-size: 11px; font-weight: 700;
  color: var(--c-retry);
  background: var(--c-retry-bg);
  border-radius: 8px;
  padding: 1px 8px;
}

/* ---- 素材占位框（文件未找到时，不报错中断） ---- */
.placeholder-box {
  min-width: 300px; min-height: 200px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  border: 2px dashed var(--c-sky-light);
  border-radius: var(--r-card);
  background: var(--c-frosted);
  color: var(--c-ink-soft);
  font-size: 16pt; font-weight: 700;
}
.placeholder-box small { font-size: 12pt; font-weight: 500; }

/* ---- 动画 ---- */
@keyframes kf-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes kf-drop-in   { from { opacity: 0; transform: translateY(-180px); }
                          to   { opacity: 1; transform: translateY(0); } }
@keyframes kf-slide-left{ from { opacity: 0; transform: translateX(-160px); }
                          to   { opacity: 1; transform: translateX(0); } }
@keyframes kf-zoom-in   { from { opacity: 0; transform: scale(0.6); }
                          to   { opacity: 1; transform: scale(1); } }
@keyframes kf-pop-in    { 0% { opacity: 0; transform: scale(0.4); }
                          70% { transform: scale(1.08); }
                          100% { opacity: 1; transform: scale(1); } }
@keyframes kf-pan-in    { from { opacity: 0; transform: translateX(120px); }
                          to   { opacity: 1; transform: translateX(0); } }
@keyframes kf-breathe   { 0%, 100% { transform: scale(1); opacity: 0.55; }
                          50% { transform: scale(1.18); opacity: 0.2; } }

.anim-fade_in       { animation: kf-fade-in var(--t-stage) var(--ease) both; }
.anim-crossfade     { animation: kf-fade-in 500ms ease both; }
.anim-drop_in       { animation: kf-drop-in 600ms var(--ease) both; }
.anim-slide_in_left { animation: kf-slide-left var(--t-stage) var(--ease) both; }
.anim-zoom_to_right { animation: kf-zoom-in 560ms var(--ease) both; }
.anim-pop_in_seq    { animation: kf-pop-in 420ms var(--ease) both; }
.anim-pan_in        { animation: kf-pan-in var(--t-stage) var(--ease) both; }

.fade-out { opacity: 0 !important; transition: opacity 420ms ease; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
