/* ============================================================
   Moon & Cove · 双子座流星雨婚礼邀请
   全局背景：moonriver 星空（原样照搬 Cove 栖月湾）
   ============================================================ */

/* ---------- 字体 ---------- */
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-500.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('../fonts/cormorant-garamond-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cove Serif SC';
  src: url('../fonts/jinghua.woff2') format('woff2');
  font-weight: 400 700; font-style: normal; font-display: swap;
}
/* 京華老宋体补充字（缰 U+7F30 所在分片） */
@font-face {
  font-family: 'Cove Serif SC';
  src: url('../fonts/jinghua-sup-7e44.woff2') format('woff2');
  font-weight: 400 700; font-style: normal; font-display: swap;
  unicode-range: U+7E44-7FFF;
}
@font-face {
  font-family: 'Bonheur Royale';
  src: url('../fonts/bonheur-royale.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'PingFang Changan';
  src: url('../fonts/pingfang-changan.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --gold: #c9a05a;
  --gold-soft: #d8b879;
  --gold-bright: #ecd9a8;
  --ink: #e9e2d2;
  --ink-dim: rgba(233, 226, 210, .62);
  --serif-en: 'Cormorant Garamond', 'Cove Serif SC', 'Palatino Linotype', 'Palatino', serif;
  --serif-cn: 'Cove Serif SC', 'Palatino Linotype', 'Songti SC', 'STSong', serif;
  /* 数字规范：数字走 Cormorant oldstyle，中文回退京华老宋体 */
  --serif-num: 'Cormorant Garamond', 'Cove Serif SC', 'Palatino Linotype', 'Palatino', 'Songti SC', 'STSong', serif;
}

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

html, body { height: 100%; overflow: hidden; }

body {
  background: #020409;
  color: var(--ink);
  font-family: var(--serif-cn);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  background: none; border: none; color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus { outline: none; }

/* ============================================================
   全局背景 · moonriver 星空（moon-river.css 原样照搬）
   ============================================================ */
#bg { position: fixed; inset: 0; z-index: 0; }

.mr-universe{position:absolute;inset:0;z-index:-1;overflow:hidden;pointer-events:none;background:radial-gradient(ellipse at 12% 60%,#22304a22,transparent 54%),radial-gradient(ellipse at 85% 36%,#2c244722,transparent 56%),linear-gradient(145deg,#04070f,#020409 55%,#05070f)}
.mr-universe::before{content:'';position:absolute;inset:-25%;background:radial-gradient(ellipse at 22% 58%,#50648a0e,transparent 40%),radial-gradient(ellipse at 74% 42%,#7a60380c,transparent 38%);filter:blur(28px);animation:mr-nebula 36s ease-in-out infinite alternate}
.mr-universe::after{content:'';position:absolute;inset:0;background:radial-gradient(ellipse at 50% 58%,#080e1b55,transparent 65%)}
.mr-universe canvas{position:absolute;inset:0;width:100%;height:100%}
@keyframes mr-nebula{from{transform:translate(-2%,2%) rotate(-5deg)}to{transform:translate(3%,-2%) rotate(5deg)}}
@media(prefers-reduced-motion:reduce){.mr-universe::before{animation:none}}

/* ============================================================
   屏幕切换：全部 fixed 铺满，淡入淡出，无滚动
   ============================================================ */
.stage {
  position: fixed; inset: 0; z-index: 1;
  opacity: 0; pointer-events: none;
  transition: opacity 1.4s ease;
}
.stage.on { opacity: 1; pointer-events: auto; }

/* ============================================================
   第一屏 · 双子座手势连线
   ============================================================ */
#star-field {
  appearance: none;
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: crosshair;
}

#gemini { display: block; width: 100%; height: 100%; pointer-events: none; }

.sky-hint {
  position: absolute; left: 0; right: 0;
  top: 74%;
  text-align: center;
  font-size: 12.5px;
  letter-spacing: .34em; text-indent: .34em;
  color: var(--gold-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s ease;
}
#screen-sky.ready .sky-hint { animation: hintPulse 3.2s ease-in-out infinite; }
.sky-hint.gone { opacity: 0 !important; animation: none; }
@keyframes hintPulse { 0%, 100% { opacity: .35; } 50% { opacity: .75; } }

.sky-meta {
  position: absolute; left: 0; right: 0;
  bottom: calc(28px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--serif-en);
  font-variant-numeric: oldstyle-nums;
  color: var(--ink-dim);
  opacity: 0;
  transition: opacity 2s ease .4s;
  pointer-events: none;
}
#screen-sky.ready .sky-meta { opacity: 1; }
.sky-date { font-size: 15px; letter-spacing: .22em; font-weight: 500; }
.sky-coord { font-size: 11.5px; letter-spacing: .18em; margin-top: 7px; opacity: .75; }

#btn-accept {
  position: absolute; left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  padding: 14px 10px;
  font-family: var(--serif-num);
  font-size: 15.5px;
  letter-spacing: .18em;
  white-space: nowrap;
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(216, 184, 121, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s ease, transform 1.6s ease;
}
#btn-accept::after {
  content: '';
  position: absolute; left: 18%; right: 18%; bottom: 6px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216,184,121,.65), transparent);
}
#screen-sky.lines-done #btn-accept { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ============================================================
   音乐按钮（故事屏起常驻右上角，事件视界接管后淡出）
   ============================================================ */
.invite-music {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  right: 18px;
  display: flex; flex-direction: column; align-items: center;
  z-index: 5;
  opacity: 0; pointer-events: none;
  transition: opacity 1.8s ease;
}
.invite-music.on { opacity: 1; pointer-events: auto; }
.invite-music.gone { opacity: 0 !important; pointer-events: none !important; transition: opacity 3.2s ease; }
#btn-music {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
}
#btn-music img { width: 42px; height: auto; display: block; }
/* The crescent stays sharp. A pre-painted halo breathes on a separate opacity layer. */
#btn-music { position: relative; }
#btn-music img { position: relative; }
.crescent-halo {
  position: absolute; inset: -16px; pointer-events: none;
  opacity: 0; transition: opacity .8s ease-in-out;
}
#btn-music.playing .crescent-halo { opacity: 1; }
.crescent-halo::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse closest-side,rgba(254,224,163,.19),transparent 82%),
              url('../img/moon-crescent.webp') center / 42px auto no-repeat;
  filter: blur(3px) drop-shadow(0 0 8px rgba(255,224,158,.52));
  opacity: .14; will-change: opacity;
  animation: crescentBreath 5.8s ease-in-out infinite paused;
}
.invite-music.on:not(.gone) .crescent-halo::before { animation-play-state: running; }
@keyframes crescentBreath {
  0%,100% { opacity: .14; }
  50% { opacity: .44; }
}
.music-hint {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--gold-soft);
  opacity: .85;
  transition: opacity 2.4s ease;
  white-space: nowrap;
  pointer-events: none;
}
.music-hint.gone { opacity: 0; }

/* ============================================================
   第二屏 · 邀请卡（第二部分开屏）
   ============================================================ */
#screen-invite {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10vh 20px 5vh;
}

.invite-frame {
  position: relative;
  width: min(92vw, 450px, 51vh);
  aspect-ratio: 1400 / 1650;
  text-align: center;
}

.invite-frame::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: url('../img/frame-gold.webp') no-repeat center / contain;
  -webkit-mask: url('../img/ink-screen.png?v=1') repeat center / 118px 118px;
  mask: url('../img/ink-screen.png?v=1') repeat center / 118px 118px;
}

/* 文案落在边框的天然留白区：中部空白、绶带、底部圆环 */
.invite-title {
  position: absolute; left: 0; right: 0; top: 42.8%;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.95;
  letter-spacing: .13em;
  color: #f2e8cd;
  text-shadow: 0 0 18px rgba(216, 184, 121, .28);
}
.invite-sub {
  position: absolute; left: 0; right: 0; top: 57.5%;
  font-family: var(--serif-en);
  font-size: 8.8px;
  letter-spacing: .32em;
  color: var(--gold-soft);
}

/* 绶带专用的两个京华老宋字形，随页加载。 */
@font-face {
  font-family: 'Cove Ribbon OldSong';
  src: url('../fonts/jinghua-ribbon.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: block;
  unicode-range: U+51FA, U+53D1;
}
.invite-line {
  position: absolute; left: 0; right: 0; top: 69.4%;
  font-family: 'Cove Ribbon OldSong', var(--serif-cn);
  font-size: 11.5px;
  letter-spacing: .18em;
  color: #3d2c17;
}

/* 两条点状分隔线之间：仪式名 */
.invite-ceremony {
  position: absolute; left: 0; right: 0; top: 37.4%;
  font-size: 10px; letter-spacing: .32em; text-indent: .32em;
  color: var(--ink);
  white-space: nowrap;
}

/* 底部圆环内：英文小字 + 日期时间地点 */
.invite-ceremony-en {
  position: absolute; left: 0; right: 0; top: 76.9%;
  font-family: var(--serif-en);
  font-size: 6.4px;
  letter-spacing: .18em;
  color: var(--gold-soft);
  white-space: nowrap;
}
.invite-when {
  position: absolute; left: 0; right: 0; top: 79.3%;
  font-family: var(--serif-num);
  font-variant-numeric: oldstyle-nums;
  font-size: 10px;
  letter-spacing: .14em;
  white-space: nowrap;
  color: var(--ink);
}

/* 边框之外的观测信息 */
.invite-obs {
  margin-top: 5.5vh;
  text-align: center;
  font-family: var(--serif-num);
  font-variant-numeric: oldstyle-nums;
  font-size: 10.5px;
  line-height: 1.85;
  letter-spacing: .1em;
  color: rgba(233, 226, 210, .42);
}
.invite-obs p { font-variant-numeric: oldstyle-nums; }

.tap-hint {
  position: absolute; left: 0; right: 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 11.5px;
  letter-spacing: .3em; text-indent: .3em;
  color: var(--gold-soft);
  animation: hintPulse 3.2s ease-in-out infinite;
  pointer-events: none;
}

/* ============================================================
   第三屏 · 法厄同的碎片（原地中央，逐段自动淡入淡出）
   ============================================================ */
.pha-story { position: absolute; inset: 0; }

.pha-block {
  position: absolute;
  left: 50%; top: 51%;
  transform: translate(-50%, -50%);
  width: min(88vw, 560px);
  text-align: center;
  font-family: var(--serif-num);
  font-variant-numeric: oldstyle-nums;
  font-size: 15.5px;
  line-height: 2.6;
  letter-spacing: .18em;
  color: var(--ink);
  opacity: 0;
  transition: opacity 1.8s ease;
  pointer-events: none;
}
.pha-block.on { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .pha-block {
    transform: translate(-50%, -50%) translateY(18px);
    transition: opacity 1.8s ease, transform 1.8s ease;
    /* 进场后持续呼吸，直到文字完全透明。 */
    animation: storyFloat 5.8s ease-in-out 1.8s infinite paused;
  }
  .pha-block.drifting {
    transform: translate(-50%, -50%);
    animation-play-state: running;
  }
}
@keyframes storyFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -11px; }
}
.pha-block em.gold {
  font-style: normal;
  color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(216, 184, 121, .4);
}

.decode-cell { position: relative; display: inline-block; }
.decode-cell > span { transition: opacity 1.2s ease-in-out; }
.decode-original { opacity: 0; }
.decode-cell.is-readable > .decode-original { opacity: 1; }
.decode-cell.is-readable > .decode-symbol { opacity: 0; }
.decode-symbol { position: absolute; inset: 0; text-align: center; overflow: hidden; }
.decode-tape, .decode-tape > span { display: block; height: 100%; }
.decode-tape {
  --travel: -300%;
  animation: decodeCycle 120ms steps(3,end) infinite;
}
.decode-tape.latin {
  --travel: -800%;
  animation-duration: 320ms;
  animation-timing-function: steps(8,end);
}
@keyframes decodeCycle { to { transform: translateY(var(--travel)); } }

#story-finale {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ============================================================
   第四屏 · 感谢 + 隐藏曲目
   ============================================================ */
#screen-thanks {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8vh 24px 10vh;
  overflow: hidden;
}

/* 触地的第一帧就能看见溅射，文字仍按各自的节奏显现。 */
#screen-thanks.on { transition-duration: 0s; }

#thanks-morph {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.thanks-moon {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  visibility: hidden;
  z-index: 2;
}
.thanks-moon.on { visibility: visible; }
#btn-moon { width: min(108px, 17vh); height: min(108px, 17vh); display: flex; align-items: center; justify-content: center; }
#btn-moon img { width: min(100px, 15.5vh); height: min(100px, 15.5vh); display: block; }
#btn-moon canvas {
  display: none; position: absolute; inset: 0; margin: auto;
  width: min(100px, 15.5vh); height: min(100px, 15.5vh); pointer-events: none;
}
#btn-moon.live-moon canvas { display: block; }
#btn-moon.live-moon img { visibility: hidden; }
/* 礼物的漫射光与月缘分层，月纹保持清晰。 */
#btn-moon { position: relative; isolation: isolate; }
.fullmoon-halo {
  position: absolute; inset: -28%; z-index: -1;
  pointer-events: none; opacity: 0; visibility: visible;
  transition: opacity 4.2s ease-in-out;
}
#btn-moon.playing .fullmoon-halo { opacity: 1; }
.fullmoon-halo::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle,rgba(255,220,161,.34),rgba(244,204,139,.21) 38%,rgba(232,188,116,.08) 55%,transparent 73%);
  filter: blur(8px);
  animation: giftMoonBreath 4.6s ease-in-out infinite;
}
@keyframes giftMoonBreath {
  0%,100% { opacity: .48; transform: scale(.92); }
  50% { opacity: .95; transform: scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .crescent-halo { transition: none; }
  .crescent-halo::before { animation: none; opacity: .27; }
  .fullmoon-halo::before { animation: none; opacity: .7; }
}
.moon-hint {
  margin-top: 4px;
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--gold-soft);
  opacity: .85;
  transition: opacity 2.4s ease;
  white-space: nowrap;
  pointer-events: none;
}
.thanks-moon.on .moon-hint.gone {
  opacity: 0;
  transition: opacity 5s ease-in-out 2s;
}

.thanks-lines {
  margin-top: 4.5vh;
  text-align: center;
  font-family: 'PingFang Changan', var(--serif-cn);
  font-size: min(16.5px, 2.25vh);
  line-height: 2.6;
  letter-spacing: .14em;
  color: #ece2c8;
}
.thanks-lines p {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 2.4s ease, transform 2.4s ease;
}
.thanks-lines p.on { opacity: 1; transform: translateY(0); }
.thanks-lines .thanks-gap { margin-top: 1.6em; }

.thanks-sign {
  margin-top: 5vh;
  text-align: center;
  opacity: 0;
  transition: opacity 2.4s ease;
}
.thanks-sign.on { opacity: 1; }
.sign-names {
  font-family: 'Bonheur Royale', cursive;
  font-size: min(34px, 4.8vh);
  color: var(--gold-bright);
  text-shadow: 0 0 16px rgba(216, 184, 121, .3);
}
.sign-date {
  margin-top: 10px;
  font-family: var(--serif-en);
  font-variant-numeric: oldstyle-nums;
  font-size: 13px;
  letter-spacing: .3em;
  color: var(--ink-dim);
}
.sign-credit {
  margin-top: 26px;
  font-family: var(--serif-num);
  font-size: 10.5px;
  letter-spacing: .18em;
  color: rgba(233, 226, 210, .4);
}

.sign-credit a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.sign-credit a::after { content: ''; position: absolute; inset: -16px -6px; }
.sign-credit a img { width: 13px; height: 13px; object-fit: contain; opacity: .65; }
.sign-credit a:focus { outline: none; }
.sign-credit a:focus-visible, .sign-credit a:active { color: var(--gold-soft); }
#screen-thanks:not(.on) .sign-credit a, .thanks-sign:not(.on) .sign-credit a { visibility: hidden; }

/* ============================================================
   桌面端微调
   ============================================================ */
@media (min-width: 760px) {
  .pha-block { font-size: 17px; }
  .invite-title { font-size: 15.5px; }
  .thanks-lines { font-size: min(18px, 2.5vh); }
}
