/* ============================================================
 *  引擎样式 —— 跟具体是哪一幕无关的部分
 *
 *  调色板、页面外壳（#app / .scene / 进场动画）、各幕共用的零件
 *  （标题、小标题、底部按钮）、固定控件（导航点、音乐按钮、
 *  二维码、大图查看）。
 *
 *  六幕各自的样式在 templates/<模板>/style.css。分开是因为会有多套模板：
 *  这个文件是共用的，那个文件是每套模板自己写一份的。
 *  改外观先想清楚改的是哪一类 —— 改错了要么每套模板都跟着变，
 *  要么只有一套变，都不是你想要的。
 * ============================================================ */

:root {
  /* ============================================================
   *  调色板 · 换肤入口
   *
   *  改主题只需要改下面这 7 组「通道值」（RGB 三个数字，不带括号）。
   *  全文所有半透明色都写成 rgba(var(--xxx-rgb), 透明度) 从它们推出来，
   *  所以改一处，描边、光晕、阴影会一起跟着变 ——
   *  不会出现"换了主色，粉色光晕还留在那儿"的情况。
   * ============================================================ */
  --ink-rgb: 10, 5, 24;
  --cream-rgb: 255, 246, 234;
  --rose-rgb: 255, 111, 156;
  --rose-soft-rgb: 255, 179, 217;
  --gold-rgb: 255, 209, 102;
  --lilac-rgb: 195, 166, 255;
  --sky-rgb: 138, 214, 255;
  --rose-mid-rgb: 255, 143, 184;

  --ink: rgb(var(--ink-rgb));
  --ink-2: #170a2e;
  --ink-3: #241041;
  --cream: rgb(var(--cream-rgb));
  --rose: rgb(var(--rose-rgb));
  --rose-soft: rgb(var(--rose-soft-rgb));
  --gold: rgb(var(--gold-rgb));
  --lilac: rgb(var(--lilac-rgb));
  --sky: rgb(var(--sky-rgb));

  --muted: rgba(var(--cream-rgb), 0.62);
  --faint: rgba(var(--cream-rgb), 0.34);
  --glass: rgba(var(--cream-rgb), 0.07);
  --hair: rgba(var(--cream-rgb), 0.16);

  /* ============================================================
   *  以下颜色跟品牌色无关，单独命名，方便整体切换明暗主题
   *  （做浅色版时把这一整段换掉即可）
   * ============================================================ */

  /* 背景 */
  --bg-glow-1: #3a1055;
  --bg-glow-2: #1d2a6b;
  --bg-glow-3: #55113d;
  --bg-deep: #12071f;

  /* 卡片 / 面板底 */
  --card-top: #2a1148;
  --card-bottom: #14082a;
  --panel: rgba(20, 10, 40, 0.86);
  --scrim: rgba(6, 2, 14, 0.94);   /* 比 --ink 更暗，不是它的透明度 */
  --card-light: rgba(255, 255, 255, 0.95);
  --card-light-ink: #1a0b2e;

  /* 阴影与高光（数字 = 透明度百分数） */
  --shade-18: rgba(0, 0, 0, 0.18);
  --shade-22: rgba(0, 0, 0, 0.22);
  --shade-35: rgba(0, 0, 0, 0.35);
  --shade-42: rgba(0, 0, 0, 0.42);
  --shade-45: rgba(0, 0, 0, 0.45);
  --shade-50: rgba(0, 0, 0, 0.50);
  --shade-55: rgba(0, 0, 0, 0.55);
  --shade-60: rgba(0, 0, 0, 0.60);
  --spec: rgba(255, 255, 255, 0.22);

  /* 封面标题的流光 / 徽章 / 爱心光晕 */
  --title-mid: #ff9fc4;
  --title-glow: rgba(255, 130, 180, 0.42);
  --badge-glow: rgba(255, 160, 190, 0.35);
  --heart-glow: rgba(255, 90, 140, 0.5);

  /* 蛋糕与蜡烛 */
  --cake-1a: #ff9ec0;  --cake-1b: #e8618f;  --cake-1c: #c9426f;
  --cake-2a: #ffd08d;  --cake-2b: #f2a95c;  --cake-2c: #d98a3c;
  --cake-3a: #cdb4ff;  --cake-3b: #a586ec;  --cake-3c: #8567d0;
  --frosting: #fff8ee;
  --rose-mid: rgb(var(--rose-mid-rgb));
  --wick: #6b5142;
  --smoke: rgba(220, 220, 235, 0.5);

  /* 火苗 / 吹蜡烛按钮 */
  --flame-core: #fffdf2;
  --flame-mid: #ffe08a;
  --flame-outer: #ffab4a;
  --flame-edge: rgba(255, 106, 61, 0.6);
  --flame-glow-1: rgba(255, 190, 90, 0.85);
  --flame-glow-2: rgba(255, 140, 70, 0.55);
  --flame-halo: rgba(255, 180, 100, 0.35);
  --wish-glow: rgba(255, 180, 120, 0.4);
  --blow-grad-a: rgba(255, 172, 74, 0.22);
  --blow-shadow: rgba(255, 140, 70, 0.2);

  /* 彩带用的点缀色（品牌色之外，让彩带更花一点）。
   * js/effects.js 会读这几个通道值。 */
  --fx-mint-rgb: 126, 240, 192;
  --fx-peach-rgb: 255, 159, 122;
  --fx-butter-rgb: 255, 242, 178;
  --fx-white-rgb: 255, 255, 255;

  --font: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;

  --ease: cubic-bezier(0.22, 0.9, 0.24, 1);
  --pad: clamp(20px, 5vw, 40px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 12% 0%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(100% 70% at 92% 12%, var(--bg-glow-2) 0%, transparent 58%),
    radial-gradient(90% 70% at 50% 108%, var(--bg-glow-3) 0%, transparent 60%),
    linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

/* 背景光晕，让深色不死板 */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background:
    radial-gradient(38% 30% at 20% 25%, rgba(var(--rose-rgb), 0.16), transparent 70%),
    radial-gradient(34% 28% at 82% 70%, rgba(var(--lilac-rgb), 0.14), transparent 70%),
    radial-gradient(30% 26% at 55% 92%, rgba(var(--gold-rgb), 0.10), transparent 70%);
  filter: blur(20px);
  animation: drift 26s ease-in-out infinite alternate;
  z-index: 0;
}

@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 2%, 0) scale(1.07); }
}

/* ---------- 画布 ---------- */
#bg-fx, #burst-fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#bg-fx { z-index: 1; opacity: 0.9; }
#burst-fx { z-index: 90; }

/* ============================================================
 *  滚动容器
 * ============================================================ */
#app {
  position: relative;
  z-index: 2;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#app::-webkit-scrollbar { width: 0; }
#app.locked { overflow: hidden; }

.scene {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 26px);
  padding: calc(var(--pad) + env(safe-area-inset-top, 0px)) var(--pad)
           calc(var(--pad) + env(safe-area-inset-bottom, 0px));
  text-align: center;
}

/* 进入视口后的浮现动画 */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--d, 0) * 110ms);
}
.scene.in [data-reveal] { opacity: 1; transform: none; }

/* ============================================================
 *  各幕共用的零件
 * ============================================================ */
.kicker {
  font-size: clamp(11px, 3vw, 13px);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--faint);
  text-transform: uppercase;
  margin: 0;
}

.section-title {
  margin: 0;
  font-size: clamp(24px, 6.4vw, 34px);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
}

.section-sub {
  margin: 0;
  font-size: clamp(13px, 3.6vw, 15px);
  color: var(--muted);
  letter-spacing: 0.08em;
}

.next-btn {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 26px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--cream);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  transition: transform 0.4s var(--ease), background 0.4s var(--ease), border-color 0.4s;
}
.next-btn:hover { background: rgba(var(--cream-rgb), 0.14); border-color: rgba(var(--cream-rgb), 0.34); }
.next-btn:active { transform: scale(0.96); }
.next-btn::after {
  content: "↓";
  animation: bob 1.9s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(-1px); opacity: 0.7; }
  50% { transform: translateY(3px); opacity: 1; }
}

/* ============================================================
 *  固定控件
 * ============================================================ */
#navDots {
  position: fixed;
  right: clamp(10px, 2.4vw, 22px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 40;
}
.navdot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px;
  border: 0;
  background: none;
  opacity: 0.42;
  transition: opacity 0.4s;
}
.navdot i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cream);
  transition: all 0.4s var(--ease);
}
.navdot span {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--muted);
  opacity: 0;
  transform: translateX(6px);
  transition: all 0.4s var(--ease);
  white-space: nowrap;
  order: -1;
}
.navdot.on { opacity: 1; }
.navdot.on i { background: linear-gradient(135deg, var(--rose), var(--gold)); transform: scale(1.5); }
@media (min-width: 900px) {
  .navdot:hover span, .navdot.on span { opacity: 1; transform: none; }
}

#musicBtn {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--hair);
  background: rgba(var(--ink-rgb), 0.45);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 17px;
  z-index: 50;
  transition: all 0.35s var(--ease);
}
#musicBtn:hover { color: var(--cream); border-color: rgba(var(--cream-rgb), 0.34); }
#musicBtn .bars { display: flex; align-items: flex-end; gap: 3px; height: 15px; }
#musicBtn .bars i {
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: currentColor;
  transition: height 0.3s;
}
#musicBtn.on { color: var(--gold); border-color: rgba(var(--gold-rgb), 0.5); }
#musicBtn.on .bars i { animation: eq 0.9s ease-in-out infinite; }
#musicBtn.on .bars i:nth-child(1) { animation-delay: 0s; }
#musicBtn.on .bars i:nth-child(2) { animation-delay: 0.18s; }
#musicBtn.on .bars i:nth-child(3) { animation-delay: 0.36s; }
@keyframes eq {
  0%, 100% { height: 4px; }
  50% { height: 15px; }
}

#hint {
  position: fixed;
  left: 50%;
  transform: translate(-50%, -140%);
  top: calc(12px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(var(--gold-rgb), 0.3);
  background: var(--panel);
  backdrop-filter: blur(12px);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: rgba(var(--cream-rgb), 0.88);
  z-index: 55;
  transition: transform 0.7s var(--ease);
  max-width: calc(100vw - 28px);
}
#hint.on { transform: translate(-50%, 0); }
#hint button {
  border: 0;
  background: rgba(var(--cream-rgb), 0.1);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 1;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
#hint code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  background: rgba(var(--cream-rgb), 0.1);
  padding: 2px 5px;
  border-radius: 4px;
}

#qrCard {
  position: fixed;
  left: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  background: var(--card-light);
  color: var(--card-light-ink);
  box-shadow: 0 18px 44px var(--shade-45);
  z-index: 45;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
#qrCard.on { opacity: 1; transform: none; pointer-events: auto; }
#qrCard img { width: 132px; height: 132px; }
#qrCard p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
 *  大图查看
 * ============================================================ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 20px;
  background: var(--scrim);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease);
  grid-template-rows: 1fr auto;
}
#lightbox.on { opacity: 1; pointer-events: auto; }
#lbImg {
  max-width: min(92vw, 900px);
  max-height: 74vh;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: 0 30px 70px var(--shade-60);
  align-self: center;
}
#lbCap {
  margin: 0;
  text-align: center;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--muted);
  min-height: 1.4em;
}
#lbClose, #lbPrev, #lbNext {
  position: fixed;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--hair);
  background: rgba(var(--cream-rgb), 0.08);
  font-size: 18px;
  color: var(--cream);
  transition: background 0.3s;
}
#lbClose:hover, #lbPrev:hover, #lbNext:hover { background: rgba(var(--cream-rgb), 0.18); }
#lbClose { top: calc(16px + env(safe-area-inset-top, 0px)); right: 16px; }
#lbClose::before { content: "✕"; }
#lbPrev { left: 12px; top: 50%; transform: translateY(-50%); }
#lbNext { right: 12px; top: 50%; transform: translateY(-50%); }

/* ============================================================
 *  降级
 * ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
  }
  body::before { animation: none; }
}
