/* ============================================================
   生日祝福贺卡 · 深夜蓝 + 烫金玻璃卡片
   index.html（祝福页）与 gift.html（礼物页）共用这一份样式
   ============================================================ */

:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --ink: #fffaf3;
  --muted: #d6ccd0;
  --gold: #f4c978;
  --coral: #ed846d;
  --teal: #78c9ba;
  --night: #0d1022;
  --panel: rgba(20, 21, 43, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --card-radius: 8px;
  --pill: 999px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 14%, rgba(237, 132, 109, 0.19), transparent 25%),
    radial-gradient(circle at 88% 18%, rgba(120, 201, 186, 0.14), transparent 25%),
    radial-gradient(circle at 50% 100%, rgba(244, 201, 120, 0.12), transparent 34%),
    linear-gradient(145deg, #0b0e1c, #201b38 56%, #101e2c);
  background-attachment: fixed;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  opacity: 0.7;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.75) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(244, 201, 120, 0.7) 0 1px, transparent 1.5px);
  background-position: 8% 16%, 86% 76%;
  background-size: 210px 190px, 260px 230px;
}

body::after {
  background: linear-gradient(115deg, transparent 0 48%, rgba(244, 201, 120, 0.04) 48% 49%, transparent 49% 100%);
  mix-blend-mode: screen;
}

/* ---------- 版面骨架 ---------- */

.page {
  position: relative;
  min-height: 100dvh;
  padding: 30px 18px 104px;
  display: grid;
  place-items: center;
}

.frame {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.frame::before,
.frame::after {
  content: "";
  position: absolute;
  width: 70px;
  height: 70px;
  border: 1px solid rgba(244, 201, 120, 0.35);
}

.frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.frame::after { right: -1px; bottom: -1px; border-left: 0; border-top: 0; }

.card {
  position: relative;
  z-index: 1;
  width: min(92vw, 720px);
  padding: clamp(30px, 6vw, 58px) clamp(22px, 7vw, 72px) 42px;
  overflow: hidden;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012)), var(--panel);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.42), inset 0 1px rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(17px);
  -webkit-backdrop-filter: blur(17px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(244, 201, 120, 0.11);
  pointer-events: none;
}

/* ---------- 四角星光 ---------- */

.spark {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 22px rgba(244, 201, 120, 0.45);
  animation: shimmer 3.8s ease-in-out infinite;
}

.spark.one { top: 17%; left: 11%; }
.spark.two { top: 25%; right: 12%; background: var(--teal); animation-delay: -1.2s; }
.spark.three { bottom: 18%; left: 16%; background: var(--coral); animation-delay: -2s; }
.spark.four { bottom: 13%; right: 17%; animation-delay: -0.6s; }

/* ---------- 文字 ---------- */

.eyebrow {
  position: relative;
  margin: 0 0 18px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.rule {
  width: min(100%, 300px);
  height: 1px;
  margin: 0 auto 24px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

h1 {
  position: relative;
  margin: 0;
  font-size: clamp(38px, 8.4vw, 72px);
  line-height: 1.14;
  letter-spacing: 0.04em;
  text-shadow: 0 5px 26px rgba(237, 132, 109, 0.38);
}

.wish,
.sub {
  position: relative;
  max-width: 31rem;
  margin: 20px auto 30px;
  color: var(--muted);
  font-size: clamp(16px, 3.5vw, 20px);
  line-height: 1.9;
}

/* ---------- 印章 ---------- */

.seal {
  position: relative;
  width: 116px;
  aspect-ratio: 1;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 201, 120, 0.64);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(244, 201, 120, 0.07);
  box-shadow: 0 0 0 8px rgba(244, 201, 120, 0.035), 0 0 36px rgba(244, 201, 120, 0.13);
}

.seal::before,
.seal::after {
  content: "✦";
  position: absolute;
  color: var(--coral);
  font-size: 15px;
}

.seal::before { top: 12px; }
.seal::after { bottom: 12px; color: var(--teal); }

.seal span {
  max-width: 58px;
  font-family: serif;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0.08em;
}

/* ---------- 按钮 ---------- */

.cta,
.back {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 28px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--pill);
  color: #261728;
  background: linear-gradient(135deg, var(--gold), #ef9a70);
  box-shadow: 0 14px 30px rgba(237, 132, 109, 0.24), inset 0 1px rgba(255, 255, 255, 0.55);
  font: inherit;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.cta:hover,
.back:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 34px rgba(237, 132, 109, 0.34), inset 0 1px rgba(255, 255, 255, 0.55);
}

.cta:active,
.back:active { transform: translateY(0); }

.back {
  min-height: 48px;
  padding: 0 24px;
  font-size: 16px;
}

/* ---------- 礼物页：蛋糕 ---------- */

.cake-wrap {
  position: relative;
  width: min(66vw, 300px);
  margin: 4px auto 12px;
}

.cake {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cake:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 6px;
  border-radius: var(--card-radius);
}

.cake svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 22px 22px rgba(0, 0, 0, 0.34));
  animation: float 4.6s ease-in-out infinite;
}

.cake:hover svg { animation-play-state: paused; }

.cake::after {
  content: "";
  position: absolute;
  inset: 9% 9% 14%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 201, 120, 0.18), transparent 68%);
  filter: blur(6px);
  pointer-events: none;
}

.cake .flames .flame {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: flicker 1.15s ease-in-out infinite;
  transition: opacity 420ms ease, transform 420ms ease;
}

.cake .flames .flame:nth-child(2) { animation-delay: -0.35s; }
.cake .flames .flame:nth-child(3) { animation-delay: -0.7s; }

.cake .halo {
  transition: opacity 420ms ease;
}

.cake .smoke,
.cake .smoke-line {
  opacity: 0;
  transition: opacity 200ms ease;
}

.cake.is-out .flames .flame {
  opacity: 0;
  animation: none;
  transform: scale(0.35) translateY(4px);
}

.cake.is-out .halo { opacity: 0; }

.cake.is-out .smoke { animation: smoke 2.4s ease-out 120ms both; }
.cake.is-out .smoke-line { animation: smoke-line 2.6s ease-out 120ms both; }

.cake-hint {
  display: block;
  margin: 2px auto 0;
  color: var(--gold);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.08em;
  animation: breathe 2.6s ease-in-out infinite;
  transition: color 400ms ease, animation 400ms ease;
}

.cake.is-out + .cake-hint,
.cake-hint.is-done {
  color: var(--muted);
  animation: none;
}

.message {
  position: relative;
  margin: 4px 0 12px;
  font-size: clamp(32px, 7.6vw, 60px);
  line-height: 1.16;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-shadow: 0 5px 24px rgba(237, 132, 109, 0.4);
}

/* ---------- 礼物页：奶茶 ---------- */

.cup {
  position: relative;
  width: min(64vw, 280px);
  margin: 4px auto 12px;
  display: grid;
  place-items: center;
}

.cup::before {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 201, 120, 0.18), transparent 68%);
  filter: blur(5px);
  pointer-events: none;
}

.cup img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 22px 22px rgba(0, 0, 0, 0.34));
  animation: float 4.6s ease-in-out infinite;
}

.sub {
  margin-bottom: 26px;
}

.message,
.sub,
.cake-hint {
  transition: opacity 320ms var(--ease), transform 320ms var(--ease), color 320ms var(--ease);
}

/* 文案切换：两段文字叠在同一格里，交叉淡入淡出，卡片高度不跳动 */
.swap { display: grid; }

.swap > span {
  grid-area: 1 / 1;
  transition: opacity 460ms var(--ease), transform 460ms var(--ease);
}

.swap > .swap-next {
  opacity: 0;
  transform: translateY(10px);
}

.swap.is-done > span {
  opacity: 0;
  transform: translateY(-10px);
}

.swap.is-done > .swap-next {
  opacity: 1;
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 生日歌开关 ---------- */

.music {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--pill);
  color: var(--ink);
  background: rgba(20, 21, 43, 0.78);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, color 180ms ease;
}

.music:hover { transform: translateY(-2px); border-color: rgba(244, 201, 120, 0.5); }
.music:active { transform: translateY(0); }
.music:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.music .note {
  color: var(--gold);
  font-size: 17px;
  line-height: 1;
}

.music[data-state="off"] { color: var(--muted); }
.music[data-state="off"] .note { color: rgba(214, 204, 208, 0.55); }

.music[data-state="on"] .note,
.music[data-state="ready"] .note { animation: note-pulse 1.6s ease-in-out infinite; }

.music[data-state="ready"] { border-color: rgba(244, 201, 120, 0.42); }

.music-hint {
  position: fixed;
  right: 20px;
  bottom: 78px;
  z-index: 8;
  margin: 0;
  padding: 9px 15px;
  border: 1px solid rgba(244, 201, 120, 0.36);
  border-radius: var(--pill);
  color: var(--gold);
  background: rgba(20, 21, 43, 0.9);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  animation: breathe 2.6s ease-in-out infinite;
  transition: opacity 400ms ease, transform 400ms ease;
}

.music-hint[hidden] { display: none; }

/* ---------- 撒花 ---------- */

.confetti {
  position: fixed;
  inset: 0;
  z-index: 7;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -6vh;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  animation: fall linear forwards;
}

/* ---------- 动效 ---------- */

@keyframes shimmer {
  0%, 100% { opacity: 0.6; transform: rotate(45deg) scale(0.85); }
  50% { opacity: 1; transform: rotate(45deg) scale(1.15); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes flicker {
  0%, 100% { transform: scale(1) rotate(-1deg); opacity: 1; }
  35% { transform: scale(1.08, 0.94) rotate(1.5deg); opacity: 0.92; }
  70% { transform: scale(0.94, 1.06) rotate(-0.5deg); opacity: 1; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes note-pulse {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(-2px); opacity: 1; }
}

@keyframes smoke {
  0% { opacity: 0; transform: translateY(6px) scale(0.6); }
  25% { opacity: 0.75; }
  100% { opacity: 0; transform: translateY(-58px) scale(1.5); }
}

@keyframes smoke-line {
  0% { opacity: 0; transform: translateY(6px) scaleY(0.5); }
  30% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-62px) scaleY(1.25); }
}

@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--drift, 0px), 118vh, 0) rotate(760deg); opacity: 0; }
}

/* ---------- 响应式 ---------- */

@media (max-width: 520px) {
  .page { padding: 18px 12px 84px; }
  .frame { inset: 12px; }
  .card { padding: 28px 20px 34px; }
  .eyebrow { letter-spacing: 0.1em; }
  .seal { width: 96px; margin-bottom: 18px; }
  .seal span { font-size: 21px; }
  .cake-wrap { width: min(74vw, 260px); }
  .cup { width: min(62vw, 240px); }

  /* 手机上音乐键收成一颗圆形小按钮，避免压住卡片里的按钮 */
  .music {
    justify-content: center;
    width: 46px;
    min-height: 46px;
    padding: 0;
    right: 12px;
    bottom: 12px;
  }

  .music .label { display: none; }
  .music .note { font-size: 19px; }

  .music-hint {
    right: 66px;
    bottom: 16px;
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* 矮屏手机：整卡再收一档，尽量一屏放得下 */
@media (max-width: 520px) and (max-height: 700px) {
  .page { padding: 10px 12px 60px; }
  .card { padding: 22px 18px 26px; }
  .seal { width: 84px; margin-bottom: 14px; }
  .seal span { font-size: 19px; }
  h1 { font-size: clamp(30px, 8.4vw, 52px); }
  .message { font-size: clamp(28px, 7.4vw, 46px); }
  .wish,
  .sub { margin: 14px auto 20px; font-size: 15px; line-height: 1.8; }
  .cta,
  .back { min-height: 48px; font-size: 16px; }
  .cake-wrap { width: min(58vw, 210px); }
  .cup { width: min(54vw, 200px); }
  .cake-hint { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .spark,
  .cake svg,
  .cup img,
  .cake .flames .flame,
  .cake-hint,
  .music .note,
  .music-hint {
    animation: none !important;
  }

  .message,
  .sub,
  .cake-hint,
  .swap > span,
  .cta,
  .back,
  .music {
    transition: none;
  }
}
