/* =========================================================
   小文文 NFC 专属祝福页 · 温暖治愈系样式（Mobile-First）
   零外部 CDN 依赖，加载迅速，适配 iOS / Android / 微信浏览器
   ========================================================= */

:root {
  --bg-cream: #fff9f2;
  --bg-peach: #fde9dc;
  --bg-blush: #fadcd4;
  --bg-warm: #fef3e4;

  --ink-primary: #4b332d;
  --ink-secondary: #7b5d54;
  --ink-muted: #a6887d;

  --accent-rose: #e38b7d;
  --accent-rose-deep: #d27164;
  --accent-gold: #dfb17b;
  --card-paper: #fffdfa;
  --glass-bg: rgba(255, 252, 248, 0.72);
  --glass-border: rgba(255, 255, 255, 0.85);

  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--font-sans);
  color: var(--ink-primary);
  background: linear-gradient(
    160deg,
    var(--bg-cream) 0%,
    var(--bg-warm) 36%,
    var(--bg-peach) 72%,
    var(--bg-blush) 100%
  );
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked {
  overflow: hidden;
}

/* =========================================================
   背景漂浮微粒与环境光晕
   ========================================================= */
.particle-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(56px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
  animation: glowDrift 12s ease-in-out infinite alternate;
}

.ambient-glow--top {
  top: -12vh;
  left: -14vw;
  width: 68vw;
  height: 68vw;
  max-width: 340px;
  max-height: 340px;
  background: radial-gradient(circle, rgba(255, 217, 186, 0.85) 0%, rgba(255, 217, 186, 0) 70%);
}

.ambient-glow--bottom {
  right: -16vw;
  bottom: -10vh;
  width: 76vw;
  height: 76vw;
  max-width: 380px;
  max-height: 380px;
  background: radial-gradient(circle, rgba(246, 186, 179, 0.72) 0%, rgba(246, 186, 179, 0) 72%);
  animation-delay: -5s;
}

@keyframes glowDrift {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(14px, 18px, 0) scale(1.08);
  }
}

/* =========================================================
   开屏互动遮罩（信封卡片）
   ========================================================= */
.opening-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 22px calc(24px + var(--safe-bottom));
  background: radial-gradient(
      circle at 50% 35%,
      rgba(255, 250, 244, 0.88),
      rgba(253, 232, 220, 0.94)
    );
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.75s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.opening-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  pointer-events: none;
}

.envelope-card {
  position: relative;
  width: 100%;
  max-width: 332px;
  padding: 58px 26px 28px;
  border-radius: 26px;
  background: linear-gradient(180deg, #fffefb 0%, #fff7f0 100%);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 24px 54px rgba(176, 114, 96, 0.18),
    0 6px 18px rgba(176, 114, 96, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  animation: cardFloatIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.envelope-card.is-opening {
  transform: translateY(-14px) scale(0.97);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardFloatIn {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 92px;
  pointer-events: none;
}

.envelope-flap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.wax-seal {
  position: relative;
  z-index: 2;
  width: 50px;
  height: 50px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fffaf7;
  background: linear-gradient(145deg, #ee9d8d 0%, #d87467 100%);
  box-shadow:
    0 8px 18px rgba(214, 116, 103, 0.34),
    inset 0 2px 4px rgba(255, 255, 255, 0.38);
  animation: gentlePulse 2.6s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 8px 18px rgba(214, 116, 103, 0.32),
      0 0 0 0 rgba(227, 139, 125, 0.32);
  }
  50% {
    transform: scale(1.05);
    box-shadow:
      0 10px 22px rgba(214, 116, 103, 0.36),
      0 0 0 11px rgba(227, 139, 125, 0);
  }
}

.envelope-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent-rose-deep);
  background: rgba(235, 165, 148, 0.16);
  margin-bottom: 14px;
}

.envelope-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-primary);
}

.envelope-desc {
  margin: 0 0 26px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-secondary);
}

.open-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 224px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #ffffff;
  background: linear-gradient(135deg, #eba08f 0%, #dc7b6d 100%);
  box-shadow:
    0 10px 24px rgba(220, 123, 109, 0.36),
    inset 0 1px 1px rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.open-btn:active {
  transform: scale(0.96);
  box-shadow: 0 6px 14px rgba(220, 123, 109, 0.3);
}

.open-btn__sparkle {
  font-size: 15px;
}

.envelope-tip {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

/* =========================================================
   右上角音乐控制胶囊（旋转黑胶唱片 + 歌名）
   ========================================================= */
.music-control {
  position: fixed;
  top: calc(14px + var(--safe-top));
  right: 14px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 7px 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(154, 101, 84, 0.13);
  cursor: pointer;
  color: var(--ink-primary);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.6s ease 0.2s, transform 0.6s ease 0.2s, background 0.2s ease;
}

body.is-revealed .music-control {
  opacity: 1;
  transform: translateY(0);
}

.music-control:active {
  transform: scale(0.95);
}

.music-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
}

.music-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-primary);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.music-status {
  font-size: 10px;
  color: var(--ink-muted);
}

.vinyl-disc {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 30% 30%, #4b4340 0%, #241f1e 55%, #161211 100%);
  box-shadow:
    0 3px 8px rgba(45, 28, 22, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: vinylSpin 7.5s linear infinite;
  animation-play-state: paused;
}

.music-control.is-playing .vinyl-disc {
  animation-play-state: running;
}

.vinyl-grooves {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.04),
    inset 0 0 0 6px rgba(255, 255, 255, 0.07);
}

.vinyl-label {
  position: relative;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f3b19f 0%, #d87467 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl-spindle {
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: #fff8f2;
}

@keyframes vinylSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   主展示舞台（竖屏居中排版）
   ========================================================= */
.main-stage {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(74px + var(--safe-top)) 22px calc(30px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
}

/* 渐次入场动画 */
.reveal-item {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

body.is-revealed .reveal-item {
  opacity: 1;
  transform: translateY(0);
}

body.is-revealed .reveal-delay-1 {
  transition-delay: 0.08s;
}

body.is-revealed .reveal-delay-2 {
  transition-delay: 0.24s;
}

body.is-revealed .reveal-delay-3 {
  transition-delay: 0.42s;
}

/* 祝福标题区 */
.blessing-header {
  text-align: center;
  width: 100%;
  margin-top: 4px;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.85);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--accent-rose-deep);
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(185, 129, 108, 0.08);
}

.badge-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-rose);
}

.main-title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: clamp(27px, 7.2vw, 34px);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.08em;
  color: var(--ink-primary);
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.8);
}

.sub-title {
  margin: 0 auto;
  max-width: 340px;
  font-size: 14px;
  line-height: 1.85;
  color: var(--ink-secondary);
  letter-spacing: 0.04em;
}

/* =========================================================
   拍立得照片展示卡片
   ========================================================= */
.photo-section {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 2px 0;
}

.polaroid-card {
  position: relative;
  margin: 0;
  width: min(82vw, 304px);
  padding: 13px 13px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, var(--card-paper) 100%);
  border: 1px solid rgba(255, 255, 255, 0.96);
  box-shadow:
    0 22px 44px rgba(164, 106, 86, 0.18),
    0 6px 14px rgba(164, 106, 86, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transform: rotate(-1.3deg);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.45s ease;
  cursor: pointer;
  user-select: none;
}

.polaroid-card:hover,
.polaroid-card:active {
  transform: rotate(0deg) translateY(-3px) scale(1.01);
  box-shadow:
    0 26px 52px rgba(164, 106, 86, 0.22),
    0 8px 18px rgba(164, 106, 86, 0.1);
}

/* 顶部半透明和纸胶带 */
.washi-tape {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%) rotate(1.8deg);
  width: 86px;
  height: 22px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgba(246, 198, 179, 0.62) 0%,
    rgba(252, 223, 207, 0.72) 50%,
    rgba(246, 198, 179, 0.62) 100%
  );
  box-shadow: 0 2px 6px rgba(166, 114, 96, 0.12);
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 3;
}

.polaroid-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 11px;
  overflow: hidden;
  background: #f9ede4;
  box-shadow: inset 0 0 0 1px rgba(145, 98, 82, 0.08);
}

.polaroid-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

body.is-revealed .polaroid-photo {
  animation: photoZoomSettle 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes photoZoomSettle {
  from {
    transform: scale(1.06);
  }
  to {
    transform: scale(1);
  }
}

.photo-sheen {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.24) 0%,
    rgba(255, 255, 255, 0) 42%,
    rgba(255, 232, 214, 0.1) 100%
  );
  pointer-events: none;
}

.polaroid-caption {
  margin-top: 15px;
  padding: 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink-secondary);
}

.caption-heart {
  color: var(--accent-rose);
  font-size: 14px;
}

/* =========================================================
   底部落款
   ========================================================= */
.blessing-footer {
  text-align: center;
  padding-bottom: 4px;
}

.footer-note {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

/* =========================================================
   点击照片飘出的小爱心微互动
   ========================================================= */
.tap-spark {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  font-size: 16px;
  color: #e48375;
  text-shadow: 0 2px 8px rgba(228, 131, 117, 0.35);
  animation: sparkFloatUp 1.05s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sparkFloatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -14px) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--drift-x, 0px)), -68px) scale(0.85);
  }
}

/* =========================================================
   轻提示 Toast
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(56px + var(--safe-bottom));
  transform: translateX(-50%) translateY(16px);
  z-index: 120;
  max-width: calc(100vw - 36px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(75, 51, 45, 0.86);
  color: #fffaf5;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 10px 24px rgba(75, 51, 45, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   小屏手机与减弱动态偏好适配
   ========================================================= */
@media (max-height: 680px) {
  .main-stage {
    padding-top: calc(64px + var(--safe-top));
    gap: 14px;
  }

  .polaroid-card {
    width: min(74vw, 266px);
    padding: 11px 11px 16px;
  }

  .polaroid-caption {
    margin-top: 12px;
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-glow,
  .wax-seal,
  .vinyl-disc {
    animation: none;
  }

  .reveal-item,
  .opening-overlay,
  .polaroid-card {
    transition-duration: 0.01ms;
  }
}
