/* ═══════════ 基础 ═══════════ */
:root {
  --pink: #ff6b81;
  --pink-light: #ffe3e8;
  --pink-bg: #fff5f6;
  --text: #4a3b3e;
  --text-light: #9b8589;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(255, 107, 129, 0.12);
  --radius: 18px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--pink-bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ═══════════ 封面页 ═══════════ */
#cover {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #fff0f2 0%, #ffe0e6 45%, #ffd3dc 100%);
}

.cover-content {
  text-align: center;
  z-index: 2;
  padding: 24px;
  animation: fadeUp 1.2s ease both;
}

.cover-heart {
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  font-size: 52px;
  color: var(--pink);
  animation: heartbeat 1.6s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.15); }
  40% { transform: scale(1); }
  60% { transform: scale(1.1); }
}

.cover-title {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 4px;
  margin: 16px 0 8px;
  background: linear-gradient(135deg, #ff6b81, #ff8fa3);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.cover-subtitle {
  font-size: 15px;
  color: var(--text-light);
  letter-spacing: 2px;
}

.cover-days {
  margin: 36px auto 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#days-count {
  font-size: 64px;
  font-weight: 800;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.days-label { font-size: 14px; color: var(--text-light); letter-spacing: 3px; }

.cover-hint {
  margin-top: 48px;
  font-size: 13px;
  color: var(--text-light);
  animation: bounceHint 2s ease-in-out infinite;
}

@keyframes bounceHint {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(8px); opacity: 1; }
}

/* 漂浮爱心 */
.float-hearts {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
@keyframes floatUp {
  to { transform: translateY(-110vh) rotate(20deg); opacity: 0; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════ 章节导航 ═══════════ */
#chapter-nav {
  position: fixed;
  top: 12px;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.3s;
}
#chapter-nav::-webkit-scrollbar { display: none; }

.chapter-pill {
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-light);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(255, 107, 129, 0.15);
  transition: all 0.25s;
}
.chapter-pill.active {
  background: var(--pink);
  color: #fff;
  font-weight: 600;
}

/* 导航分组（章节 + 子导航） */
.nav-group {
  position: relative;
  flex-shrink: 0;
}

/* 子导航面板：默认折叠隐藏，fixed 定位避免被父容器 overflow 裁剪 */
.sub-nav {
  position: fixed;
  top: 52px;
  left: 12px;
  min-width: 160px;
  max-width: 70vw;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(255, 107, 129, 0.2);
  transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
  z-index: 100;
}

/* 展开状态 */
.nav-group.expanded .sub-nav {
  max-height: 320px;
  overflow-y: auto;
  opacity: 1;
  padding: 10px;
}

.sub-pill {
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  text-align: left;
  background: var(--pink-light);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
  flex-shrink: 0;
}
.sub-pill:active {
  background: var(--pink);
  color: #fff;
}

/* ═══════════ 时间线 ═══════════ */
#timeline {
  max-width: 560px;
  margin: 0 auto;
  padding: 40px 20px 60px;
  position: relative;
}

#timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 34px;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--pink-light) 5%, var(--pink-light) 95%, transparent);
}

/* 阶段 */
.phase { margin-bottom: 72px; position: relative; }

.phase-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  padding: 16px 0 12px;
  border-bottom: 2px solid var(--pink-light);
}

.phase-emoji {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), #ff8fa3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(255, 107, 129, 0.3);
}

.phase-title-wrap h2 { font-size: 24px; font-weight: 800; color: var(--pink); }
.phase-date {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 1px;
}

.phase-desc {
  font-size: 14px;
  color: var(--text-light);
  margin: 8px 0 24px;
  padding-left: 4px;
}

.chapter { margin-bottom: 40px; position: relative; }

.chapter-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  position: relative;
}

.chapter-dot {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--pink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 1;
  box-shadow: 0 0 0 4px var(--pink-light);
}

.chapter-title-wrap h2 { font-size: 22px; font-weight: 800; }
.chapter-date {
  font-size: 12px;
  color: var(--pink);
  background: var(--pink-light);
  border-radius: 999px;
  padding: 2px 10px;
  display: inline-block;
  margin-top: 2px;
}

.chapter-desc {
  margin: 0 0 16px 44px;
  font-size: 14px;
  color: var(--text-light);
}

/* 瞬间卡片 */
.moment {
  margin-left: 44px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.moment.revealed { opacity: 1; transform: translateY(0); }

.moment-date {
  font-size: 12px;
  color: var(--pink);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.moment-text { font-size: 15px; margin-bottom: 12px; white-space: pre-line; }

/* 照片网格 */
.photo-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
}
.photo-grid.single { grid-template-columns: 1fr; }
.photo-grid.triple { grid-template-columns: repeat(3, 1fr); }
.photo-grid.grid-2x2 { grid-template-columns: repeat(2, 1fr); }
.photo-grid.quad { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.photo-grid.hex { grid-template-columns: repeat(6, 1fr); gap: 5px; }
.photo-grid.nine { grid-template-columns: repeat(9, 1fr); gap: 4px; }
.photo-grid.deca { grid-template-columns: repeat(10, 1fr); gap: 3px; }

.photo-item {
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  background: linear-gradient(135deg, var(--pink-light), #fff);
}
.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}
.photo-item:active img { transform: scale(1.05); }

/* 照片占位卡片 */
.photo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--pink);
  font-size: 12px;
  text-align: center;
  padding: 10px;
  border: 2px dashed rgba(255, 107, 129, 0.4);
  border-radius: 12px;
}
.photo-placeholder::before { content: "📷"; font-size: 22px; }

/* ═══════════ 结尾页 ═══════════ */
#ending {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #ffd3dc 0%, #ffe0e6 55%, #fff0f2 100%);
  padding: 32px 24px;
}

.ending-content {
  text-align: center;
  animation: fadeUp 1s ease both;
}

.heart { font-size: 72px; animation: heartbeat 1.8s ease-in-out infinite; }

.ending-title {
  font-size: 30px;
  font-weight: 800;
  margin: 16px 0 20px;
  color: var(--pink);
}

.ending-text {
  font-size: 15px;
  color: var(--text);
  white-space: pre-line;
  max-width: 90vw;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .ending-text {
    white-space: pre;
  }
}

.replay-btn {
  margin-top: 36px;
  border: none;
  border-radius: 999px;
  padding: 13px 30px;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, #ff6b81, #ff8fa3);
  box-shadow: 0 6px 18px rgba(255, 107, 129, 0.4);
}
.replay-btn:active { transform: scale(0.96); }

/* ═══════════ 大图查看器 ═══════════ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-mask { position: absolute; inset: 0; background: rgba(20, 12, 14, 0.92); }

.lightbox-figure {
  position: relative;
  z-index: 2;
  max-width: 92vw;
  max-height: 80vh;
  text-align: center;
}

#lightbox-img {
  max-width: 92vw;
  max-height: 72vh;
  border-radius: 10px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  animation: fadeUp 0.3s ease both;
  touch-action: pan-y;
}

#lightbox-caption {
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
}

.lightbox-counter {
  position: absolute;
  top: 18px;
  left: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  z-index: 3;
}

.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 3;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
}

.lightbox-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}
.lightbox-prev { left: 10px; }
.lightbox-next { right: 10px; }

/* ═══════════ 音乐按钮 ═══════════ */
#bgm-toggle {
  position: fixed;
  right: 16px;
  bottom: 24px;
  z-index: 60;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 18px;
}
#bgm-toggle.playing { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════ 彩蛋：爱心雨 ═══════════ */
.heart-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.heart-rain-drop {
  position: absolute;
  top: -40px;
  animation: heartFall linear forwards;
}

@keyframes heartFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0.3; }
}

.easter-egg-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 20px 32px;
  border-radius: 20px;
  font-size: 18px;
  color: var(--pink);
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(255, 107, 129, 0.3);
  z-index: 10000;
  animation: toastIn 0.4s ease;
  text-align: center;
  max-width: 80vw;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ═══════════ 彩蛋：烟花 ═══════════ */
.fireworks-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
}

/* ═══════════ 彩蛋：打字机光标 ═══════════ */
#ending-text {
  min-height: 120px;
}

/* ═══════════ 彩蛋：生日蛋糕动画 ═══════════ */
.birthday-cake {
  font-size: 64px;
  animation: cakeBounce 1.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(255, 180, 0, 0.4));
  margin-bottom: 8px;
}

.birthday-cake.hidden { display: none; }

@keyframes cakeBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-14px) scale(1.08); }
  50% { transform: translateY(0) scale(1); }
  65% { transform: translateY(-6px) scale(1.03); }
  80% { transform: translateY(0) scale(1); }
}
