/* =============================================
   H5 基础样式 - 移动端适配 & 翻页动画
   ============================================= */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #1a1208;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

img {
  display: block;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  outline: none;
}

/* ---- 翻页容器 ---- */
.pages-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow-y: scroll;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pages-container::-webkit-scrollbar {
  display: none;
}

/* ---- 单页 ---- */
.page {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #1a1208;
}

/* 翻页过渡动画 */
.page .page-stage {
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: scale(0.92) translateY(30px);
  opacity: 0;
}

.page.active .page-stage {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.page .layer {
  transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateY(24px);
}

.page.active .layer {
  transform: translateY(0);
}

/* 图层依次入场 */
.page.active .layer:nth-child(1) { transition-delay: 0.05s; }
.page.active .layer:nth-child(2) { transition-delay: 0.12s; }
.page.active .layer:nth-child(3) { transition-delay: 0.19s; }
.page.active .layer:nth-child(4) { transition-delay: 0.26s; }
.page.active .layer:nth-child(5) { transition-delay: 0.33s; }
.page.active .layer:nth-child(6) { transition-delay: 0.40s; }
.page.active .layer:nth-child(7) { transition-delay: 0.47s; }

/* ---- 画布舞台（按 PSD 640x1030 比例缩放） ---- */
.page-stage {
  position: relative;
  width: 100%;
  max-width: 100vw;
  aspect-ratio: 640 / 1030;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

/* 宽屏手机：以高度为基准 */
@media (min-aspect-ratio: 640/1030) {
  .page-stage {
    width: auto;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
  }
}

/* ---- 图层通用定位 ---- */
.layer {
  position: absolute;
  pointer-events: none;
  will-change: transform, opacity;
}

.layer img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* ---- 上滑提示 ---- */
.swipe-hint {
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  letter-spacing: 2px;
  z-index: 100;
  animation: hintBounce 2s ease-in-out infinite;
  pointer-events: none;
}

.page:last-child .swipe-hint {
  display: none;
}

.swipe-arrow {
  width: 18px;
  height: 18px;
  border-right: 2px solid rgba(255, 255, 255, 0.6);
  border-bottom: 2px solid rgba(255, 255, 255, 0.6);
  transform: rotate(-135deg);
}

@keyframes hintBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.6; }
  50% { transform: translateX(-50%) translateY(-8px); opacity: 1; }
}

/* ---- 音频控制按钮 ---- */
.audio-btn {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  z-index: 1000;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.audio-btn:active {
  background: rgba(0, 0, 0, 0.55);
}

.audio-btn svg {
  width: 20px;
  height: 20px;
}

.audio-btn .icon-muted {
  display: none;
}

.audio-btn.paused .icon-music {
  display: none;
}

.audio-btn.paused .icon-muted {
  display: block;
}

.audio-btn.playing {
  animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 200, 100, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(255, 200, 100, 0); }
}

/* ---- 页码指示器 ---- */
.page-dots {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.page-dots .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: all 0.4s ease;
  cursor: pointer;
}

.page-dots .dot.active {
  background: rgba(255, 220, 150, 0.95);
  height: 18px;
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(255, 200, 100, 0.5);
}

/* ---- 首屏引导遮罩 ---- */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(20, 14, 6, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s;
}

.start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-content {
  text-align: center;
  color: #f5e6c8;
  padding: 0 32px;
}

.start-title {
  font-size: 28px;
  font-weight: 300;
  letter-spacing: 6px;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(255, 180, 80, 0.3);
}

.start-sub {
  font-size: 14px;
  color: rgba(245, 230, 200, 0.6);
  letter-spacing: 3px;
  margin-bottom: 40px;
}

.start-btn {
  padding: 14px 48px;
  border-radius: 30px;
  background: linear-gradient(135deg, #d4a056, #b8833a);
  color: #fff;
  font-size: 16px;
  letter-spacing: 4px;
  box-shadow: 0 4px 20px rgba(212, 160, 86, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 2px 10px rgba(212, 160, 86, 0.3);
}
