/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #4f3a1e;       /* 深褐文字 */
  --ink-soft: #7a5e34;
  --gold: #ffe2a8;
  --text: #eef1ff;
  --text-soft: #b8bedd;
  --kai: "Ma Shan Zheng", "LXGW WenKai", "KaiTi", "STKaiti", serif;
}
html, body { height: 100%; overflow: hidden; background: #000; }
body { color: var(--text); font-family: "Noto Serif SC", "EB Garamond", serif; }
.hidden { display: none !important; }

/* ===== 开场（bg.png 背景） ===== */
.start-overlay {
  position: fixed; inset: 0; z-index: 100; background: #04040a;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.start-bg-video { position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover; background: #04040a;
  opacity: 0; animation: fadeIn 1.2s ease 0.2s forwards; }
.start-overlay::after { content: ""; position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, rgba(4,4,10,.32) 0%, rgba(4,4,10,.78) 100%);
  animation: vignettePulse 9s ease-in-out infinite; }
/* 飘动的金色微光 */
.embers { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.ember { position: absolute; bottom: -12px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,226,168,.9) 0%, rgba(255,226,168,0) 70%);
  opacity: 0; animation: emberRise linear infinite; }
.start-inner { position: relative; z-index: 2; width: min(92vw, 760px); padding: 24px; }
#startName { animation: nameGlow 4.5s ease-in-out infinite; }
/* 三段依次淡入：第一行 → 第二行 → 按钮。第一行与标题同款毛笔字，字号小一点 */
.start-sub { font-family: "Ma Shan Zheng", var(--kai); color: #dfe3ff; letter-spacing: 3px; font-weight: 400; font-size: clamp(24px, 6.4vw, 40px); margin-bottom: 26px; text-shadow: 0 2px 14px rgba(0,0,0,.6); opacity: 0; transform: translateY(18px); transition: opacity 1.5s ease, transform 1.5s ease; }
.start-title { font-family: "Ma Shan Zheng", serif; font-weight: 400; font-size: clamp(44px, 12vw, 78px); margin-bottom: 0; text-shadow: 0 2px 20px rgba(0,0,0,.6); opacity: 0; transform: translateY(18px); transition: opacity 1.5s ease, transform 1.5s ease; }
#startName { color: var(--gold); text-shadow: 0 0 36px rgba(255,226,168,.6); }
.start-btn { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: clamp(92px, 22vw, 128px); height: clamp(92px, 22vw, 128px); padding: 0 0 0 clamp(4px, 1vw, 8px); border-radius: 50%;
  background: rgba(0,0,0,.28); border: 1px solid rgba(255,226,168,.6); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: clamp(38px, 9vw, 58px); line-height: 1; font-family: var(--kai); letter-spacing: 0;
  cursor: pointer; transition: all .4s ease; backdrop-filter: blur(4px);
  opacity: 0; animation: fadeIn 1.4s ease .8s forwards, glow 2.6s ease-in-out 2.4s infinite; }
.start-btn:hover { background: rgba(255,226,168,.18); transform: translate(-50%, calc(-50% - 2px)); }
.start-btn-icon { font-family: "Noto Serif SC", serif; font-size: .95em; transform: translateY(1px); }
.start-overlay.playing .start-btn {
  animation: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .8s ease;
}
.start-sub.show,
.start-title.show {
  opacity: 1;
  transform: none;
}
.intro-lines { position: absolute; left: 50%; top: calc(50% + 118px); width: min(86vw, 760px); transform: translateX(-50%); pointer-events: none; }
.intro-line { font-family: var(--kai); font-weight: 400; color: #dfe3ff; font-size: clamp(25px, 6.6vw, 44px); line-height: 1.55; letter-spacing: 2px;
  text-shadow: 0 2px 18px rgba(0,0,0,.72), 0 0 28px rgba(255,226,168,.22);
  opacity: 0; transform: translateY(18px); transition: opacity 1.5s ease, transform 1.5s ease; }
.intro-line + .intro-line { margin-top: 18px; }
.intro-line.show { opacity: 1; transform: none; }

/* ===== 舞台 / 各幕 ===== */
.stage { position: fixed; inset: 0; z-index: 1; background: #f3ecda; }
.scene { position: absolute; inset: 0; opacity: 0; visibility: hidden; background: #f3ecda;
  transition: opacity 0.8s ease, visibility 0.8s ease; }
.scene.active { opacity: 1; visibility: visible; }

/* 已合成片段（羊皮纸 + 墨晕开 + 做旧场景），整幅铺满；播放前停在第 0 帧（纸） */
.scene-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  background: #f3ecda; }

/* 纸上的文字：放到每一幕画面的空白角；带浅色光晕保证压在场景上也清晰 */
.scene-caption { position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column; padding: 11vh 8vw;
  opacity: 0; transition: opacity 0.7s ease; pointer-events: none; }
.scene-caption.show { opacity: 1; }
.scene-caption.tl { align-items: flex-start; justify-content: flex-start; text-align: left; }
.scene-caption.tr { align-items: flex-end;   justify-content: flex-start; text-align: right; }
.scene-caption.bl { align-items: flex-start; justify-content: flex-end;   text-align: left; }
.scene-caption.br { align-items: flex-end;   justify-content: flex-end;   text-align: right; }
.cap-stage { font-family: var(--kai); font-weight: 400; color: #6b4f29;
  font-size: clamp(14px, 3.6vw, 18px); letter-spacing: 2px; margin-bottom: 12px;
  text-shadow: 0 1px 10px rgba(245,236,210,.95), 0 0 2px rgba(245,236,210,.9); }
.cap-line { font-family: var(--kai); font-weight: 400; color: #36260f;
  font-size: clamp(33px, 8.1vw, 45px); margin-bottom: 10px; line-height: 1.5; letter-spacing: 2px;
  text-shadow: 0 0 4px rgba(247,238,214,.98), 0 0 12px rgba(247,238,214,.9), 0 1px 20px rgba(247,238,214,.72); }
.cap-date { font-family: "EB Garamond", var(--kai); font-weight: 600; color: #432f16;
  font-size: clamp(25px, 6.4vw, 38px); letter-spacing: 2px;
  text-shadow: 0 1px 12px rgba(245,236,210,.95), 0 0 3px rgba(245,236,210,.95); }

/* ===== 信（羊皮纸） ===== */
.paper-bg { position: absolute; inset: 0; z-index: 1;
  background: #f3ecda url("photos/paper.jpg") center center / cover no-repeat; }
.paper-bg::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 220px rgba(90,60,25,.45), inset 0 0 90px rgba(90,60,25,.22); }
.scene.letter .paper-bg { z-index: 1; }
.letter-wrap { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 3vh 3vw; }
.letter-col { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vh, 30px); max-width: 1200px; }
.letter-text { font-family: var(--kai); font-size: clamp(24px, 4.8vw, 34px); line-height: 1.75; color: #4a3518; white-space: pre-wrap; font-weight: 400; text-align: left; }
/* 照片像晕染进羊皮纸：不规则羽化边缘（turbulence 扰动）+ 正片叠底融色 + 做旧暖调，无边框，随手贴的微斜 */
.letter-photo { width: clamp(250px, 46vw, 420px); height: auto; display: block;
  filter: sepia(.42) saturate(.82) contrast(1.0) brightness(1.06);
  mix-blend-mode: multiply;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300' preserveAspectRatio='none'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='47%25' r='62%25'%3E%3Cstop offset='0%25' stop-color='white'/%3E%3Cstop offset='44%25' stop-color='white'/%3E%3Cstop offset='70%25' stop-color='white' stop-opacity='0.45'/%3E%3Cstop offset='100%25' stop-color='white' stop-opacity='0'/%3E%3C/radialGradient%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.013' numOctaves='2' seed='11' result='n'/%3E%3CfeDisplacementMap in='SourceGraphic' in2='n' scale='62'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='400' height='300' fill='url(%23g)' filter='url(%23r)'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 300' preserveAspectRatio='none'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='47%25' r='62%25'%3E%3Cstop offset='0%25' stop-color='white'/%3E%3Cstop offset='44%25' stop-color='white'/%3E%3Cstop offset='70%25' stop-color='white' stop-opacity='0.45'/%3E%3Cstop offset='100%25' stop-color='white' stop-opacity='0'/%3E%3C/radialGradient%3E%3Cfilter id='r'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.013' numOctaves='2' seed='11' result='n'/%3E%3CfeDisplacementMap in='SourceGraphic' in2='n' scale='62'/%3E%3C/filter%3E%3C/defs%3E%3Crect width='400' height='300' fill='url(%23g)' filter='url(%23r)'/%3E%3C/svg%3E");
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  mask-mode: alpha; -webkit-mask-mode: alpha;
  transform: rotate(-2.6deg);
  opacity: 0; transition: opacity 1.6s ease; }
.letter-photo.in { opacity: 1; }
.lt-line { opacity: 0; transition: opacity 1.3s ease; }
.lt-line.in { opacity: 1; }
.lt-line.lt-blank { height: 0.7em; }
.letter-caret { display: none; }

/* ===== 结尾（黑场） ===== */
.scene.ending { background: #04040a; }
.ending-wrap { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.end-en { font-family: "EB Garamond", serif; font-style: italic; font-size: clamp(18px, 5vw, 30px); color: #e8e2d2; line-height: 1.6; margin-bottom: 26px; opacity: 0; animation: fadeUp 2.6s ease .3s forwards; }
.end-zh { font-family: "Ma Shan Zheng", serif; font-size: clamp(24px, 6.5vw, 40px); color: var(--gold); line-height: 1.5; text-shadow: 0 0 34px rgba(255,226,168,.45); opacity: 0; animation: fadeUp 2.6s ease 1.1s forwards; }
.end-sign { margin-top: 40px; color: var(--text-soft); font-size: clamp(14px, 3.6vw, 17px); font-weight: 300; opacity: 0; animation: fadeUp 2.4s ease 2s forwards; }

/* ===== 进度条 / 重看 ===== */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: rgba(120,90,40,.18); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #b8995a, var(--gold)); transition: width .8s ease; }
.replay-btn { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 70;
  background: rgba(10,10,18,.6); border: 1px solid rgba(255,226,168,.4); color: var(--gold);
  padding: 10px 22px; border-radius: 999px; font-family: inherit; font-size: 14px; letter-spacing: 1px;
  cursor: pointer; backdrop-filter: blur(6px); animation: fadeUp 1.2s ease both; }

/* ===== 动画 ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes kenburns { from { transform: scale(1.0); } to { transform: scale(1.14) translateY(-1.5%); } }
@keyframes vignettePulse { 0%,100% { opacity: .92; } 50% { opacity: 1; } }
@keyframes emberRise { 0% { transform: translateY(0) translateX(0); opacity: 0; }
  12% { opacity: .85; } 88% { opacity: .45; }
  100% { transform: translateY(-108vh) translateX(24px); opacity: 0; } }
@keyframes nameGlow { 0%,100% { text-shadow: 0 0 24px rgba(255,226,168,.45); }
  50% { text-shadow: 0 0 40px rgba(255,226,168,.8), 0 0 14px rgba(255,226,168,.6); } }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 0 rgba(255,226,168,0); } 50% { box-shadow: 0 0 26px 2px rgba(255,226,168,.3); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }
@media (orientation: landscape) and (max-height: 520px) {
  .start-inner { width: min(88vw, 680px); padding: 12px; }
  .start-btn {
    top: 44%;
    width: clamp(64px, 12vw, 84px);
    height: clamp(64px, 12vw, 84px);
    font-size: clamp(26px, 5.8vw, 38px);
  }
  .start-sub {
    font-size: clamp(15px, 3.5vw, 22px);
    margin-bottom: 9px;
    letter-spacing: 2px;
  }
  .start-title {
    font-size: clamp(27px, 6.2vw, 44px);
  }
  .intro-lines {
    top: calc(50% + 58px);
    width: min(76vw, 560px);
  }
  .intro-line {
    font-size: clamp(15px, 3.5vw, 22px);
    line-height: 1.34;
    letter-spacing: 1px;
  }
  .scene-caption {
    padding: 4vh 5vw;
  }
  .cap-stage {
    font-size: clamp(10px, 2.1vw, 12px);
    margin-bottom: 3px;
    letter-spacing: 1px;
  }
  .cap-line {
    font-size: clamp(15px, 3.7vw, 23px);
    line-height: 1.28;
    letter-spacing: 1px;
    max-width: min(44vw, 360px);
  }
  .cap-date {
    font-size: clamp(12px, 2.9vw, 19px);
    letter-spacing: 1px;
  }
  .letter-wrap {
    padding: 2vh 5vw;
    align-items: flex-start;
    overflow: hidden;
  }
  .letter-col {
    max-width: 88vw;
    gap: 6px;
  }
  .letter-text {
    font-size: clamp(13px, 2.8vw, 18px);
    line-height: 1.38;
  }
  .letter-photo {
    width: clamp(120px, 20vw, 180px);
  }
  .replay-btn {
    bottom: 12px;
    padding: 8px 18px;
  }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
