/* ===== 基础重置 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --cream: #fdf8f3;
  --warm-white: #fffcf8;
  --blush: #f5e6d8;
  --peach: #e8c5a0;
  --terracotta: #c9845a;
  --brown: #8b6347;
  --dark: #3a2e28;
  --text: #4a3728;
  --text-light: #8b7355;
  --sakura: #f4b8c1;
  --sakura-dark: #e8909e;
  --green: #8aab7a;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Serif SC', serif;
  background: var(--cream);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  /* 消除 iOS/安卓双击缩放带来的 300ms click 延迟 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

/* ===== 入场动画 ===== */
#intro {
  position: fixed;
  inset: 0;
  background: var(--warm-white);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 1s ease;
}

#intro.fade-out {
  opacity: 0;
  pointer-events: none;
}

#petalCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#intro-name {
  position: relative;
  z-index: 10;
  text-align: center;
  opacity: 0;
  animation: nameReveal 2s ease forwards 1.5s;
}

.name-text {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.4rem, 5.5vw, 2.2rem);
  font-weight: 300;
  font-style: normal;
  color: var(--dark);
  letter-spacing: 0.12em;
  line-height: 1.8;
}

@keyframes nameReveal {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ===== 主页面 ===== */
#main {
  width: 100%;
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
}

/* ===== 全屏模块 ===== */
.full-section {
  width: 100%;
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 0 20px;
}

/* ===== 模块标题 ===== */
.section-header {
  text-align: center;
  padding-top: 48px;
  padding-bottom: 20px;
  flex-shrink: 0;
}

.section-sub {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.section-title {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  font-weight: 300;
  color: var(--dark);
  letter-spacing: 0.06em;
}

/* ===== 音乐按钮 ===== */
#musicToggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 500;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--peach);
  background: rgba(253, 248, 243, 0.85);
  backdrop-filter: blur(6px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
}

#musicToggle:active { transform: scale(0.92); }

.music-icon {
  font-size: 1rem;
  color: var(--terracotta);
  line-height: 1;
}

#musicToggle.muted .music-icon { opacity: 0.35; }

/* ===== 模块一：日本地图 ===== */
#japan {
  background: var(--warm-white);
  padding-left: 0;
  padding-right: 0;
}

#japanBgCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* 地图容器和标题需在 canvas 之上 */
#japan .section-header,
#japan-map-container {
  position: relative;
  z-index: 1;
}

#japan-map-container {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
}

#japan-map {
  width: auto;
  max-width: 100%;
  height: calc(100vh - 140px);
  max-height: calc(100vh - 140px);
  filter: drop-shadow(0 2px 8px rgba(138, 99, 71, 0.12));
  /* 确保 SVG 整体可接收触摸事件，防止穿透 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 地图路线动画 */
#route-lines {
  transition: opacity 0.6s ease;
}

#route-lines.visible { opacity: 1; }

.route-line {
  stroke-dasharray: 4 3;
  animation: dashMove 20s linear infinite;
}

@keyframes dashMove {
  to { stroke-dashoffset: -100; }
}

/* 地点标记 */
.loc-dot {
  cursor: pointer;
  opacity: 0;
  transform-origin: center;
  transition: transform 0.15s;
  /* 修复 SVG pointer-events 穿透：含透明填充区域也响应事件 */
  pointer-events: all;
  /* 消除移动端 300ms click 延迟 */
  touch-action: manipulation;
  /* 去除 iOS/安卓 tap 蓝色高亮 */
  -webkit-tap-highlight-color: transparent;
  /* 禁止长按呼出系统菜单干扰点击 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.loc-dot.visible { opacity: 1; }
.loc-dot:active { transform: scale(1.2); }

.loc-label {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 5px;
  fill: var(--brown);
  letter-spacing: 0.02em;
}

.pulse-ring {
  animation: pulse 2s ease-out infinite;
  transform-origin: center;
}

@keyframes pulse {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.8); opacity: 0; }
}

/* 点击波纹动画 */
@keyframes tapRipple {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(5); opacity: 0; }
}

/* ===== 场景展示 ===== */
#scene-display {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(58, 46, 40, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#scene-stage {
  width: 100%;
  max-width: 380px;
  height: 70vh;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background: var(--blush);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* 照片条 */
#photo-strip-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#photo-strip {
  display: flex;
  height: 100%;
  transition: transform 0.38s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.photo-slide {
  flex: none;
  /* 宽度由 JS 在弹窗显示后用 offsetWidth 写入，确保精确 */
  height: 100%;
  background-size: cover;
  background-position: center;
  opacity: 1;
}

/* 左右箭头 */
.photo-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.photo-arrow:active { background: rgba(255,255,255,0.38); }

#photo-prev { left: 10px; }
#photo-next { right: 10px; }

.photo-arrow.hidden-arrow { opacity: 0; pointer-events: none; }

/* 圆点指示器 */
#photo-dots {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

.photo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: background 0.3s, transform 0.3s;
}

.photo-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* ── 地图导览角色 ── */
#map-guide {
  position: fixed;
  bottom: 24px;
  right: 16px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 4px;
  z-index: 210;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#map-guide.guide-hidden {
  opacity: 0;
  pointer-events: none;
}

#guide-char {
  width: 200px;
  height: auto;
  animation: guideFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

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

#guide-bubble {
  background: #fff;
  border: 1.5px solid var(--peach);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 14px;
  max-width: 220px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  opacity: 0;
  transform: scale(0.85) translateY(6px);
  transform-origin: bottom left;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#guide-bubble.visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

#guide-bubble-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text);
  font-weight: 300;
}

/* ── 照片气泡对话 ── */
#photo-bubble {
  position: absolute;
  top: 54px;
  left: 16px;
  right: 16px;
  z-index: 12;
  background: rgba(255,255,255,0.92);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

#photo-bubble.visible {
  opacity: 1;
  transform: translateY(0);
}

#photo-bubble-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text);
  font-weight: 300;
}

/* ── 场景底部地点+日期 ── */
#scene-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(58,46,40,0.75));
  padding: 20px 16px 16px;
  color: #fff;
}

#caption-location {
  display: block;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  opacity: 0.85;
  margin-bottom: 2px;
}

#caption-date {
  display: block;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  opacity: 0.7;
}

#scene-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(253,248,243,0.2);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

/* ===== 模块二：小花园 ===== */
#garden {
  background: linear-gradient(180deg, #f0f5ea 0%, #e8f0e0 100%);
}

#gardenBgCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

#garden .section-header,
#garden-grid,
.garden-hint {
  position: relative;
  z-index: 1;
}

#garden-grid {
  flex: 1;
  width: 100%;
  max-width: 380px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 16px 16px;
}

.flower-card {
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  aspect-ratio: 1;
  transition: transform 0.2s, box-shadow 0.2s;
}

.flower-card:active { transform: scale(0.96); }

.flower-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.flower-info-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(44, 32, 24, 0.82));
  padding: 20px 10px 10px;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.flower-card.info-open img { transform: scale(1.06); }

.flower-card.info-open .flower-info-overlay {
  transform: translateY(0);
}

.flower-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.78rem;
  font-weight: 400;
  color: #fff;
  letter-spacing: 0.12em;
}

.flower-language {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.65rem;
  font-weight: 300;
  color: rgba(255,255,255,0.82);
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.5;
}

.garden-hint {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.7rem;
  color: var(--text-light);
  letter-spacing: 0.1em;
  padding-bottom: 20px;
  flex-shrink: 0;
}

/* ===== 模块三：温柔的瞬间 ===== */
#stories {
  background: var(--cream);
}

#story-list {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 16px;
}

.story-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border: 1.5px solid var(--blush);
  cursor: zoom-in;
}

.story-img {
  width: 40%;
  flex-shrink: 0;
  overflow: hidden;
}

.story-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.story-content {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.story-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 0.72rem;
  line-height: 1.8;
  color: var(--text);
  font-weight: 300;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  line-clamp: 8;
  -webkit-box-orient: vertical;
}

/* ===== 模块四：给她的话 ===== */
#letter {
  background: linear-gradient(160deg, #fdf5ee 0%, #f7eadf 100%);
  justify-content: center;
}

#letterCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#letter-content {
  text-align: center;
  padding: 0 28px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  position: relative;
  z-index: 2;
}

#letter-content.visible {
  opacity: 1;
  transform: translateY(0);
}

#letter-mom {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  z-index: 3;
  transition: transform 1s cubic-bezier(0.34, 1.4, 0.64, 1);
  transition-delay: 0.6s;
}

#letter-mom.visible {
  transform: translateX(-50%) translateY(0);
}

#mom-char {
  width: 180px;
  height: auto;
  filter: drop-shadow(0 -4px 16px rgba(232, 144, 158, 0.3));
  animation: momFloat 3.5s ease-in-out infinite;
}

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

.letter-deco {
  font-size: 1.6rem;
  color: var(--sakura-dark);
  margin-bottom: 28px;
  opacity: 0.7;
}

.letter-line-1 {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(0.9rem, 3.5vw, 1.05rem);
  line-height: 2;
  color: var(--text);
  font-weight: 300;
  letter-spacing: 0.04em;
}

.letter-divider {
  width: 40px;
  height: 1px;
  background: var(--peach);
  margin: 28px auto;
}

.letter-line-2 {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  color: var(--terracotta);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.letter-footer {
  margin-top: 36px;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 0.68rem;
  color: var(--text-light);
  letter-spacing: 0.16em;
}

/* ===== 故事图片 lightbox ===== */
#story-lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.25s ease;
}

#story-lightbox.hidden {
  display: none !important;
}

#lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 16, 0.88);
  backdrop-filter: blur(6px);
}

#lightbox-img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
  animation: lightboxZoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lightboxZoom {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

#lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

#lightbox-close:active { background: rgba(255,255,255,0.3); }

/* ===== 滚动进入动画辅助 ===== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
