/* ===== 《天天和乐乐的恐龙岛》绘本样式 - M5 Final ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans SC', sans-serif;
}

/* ===== 加载画面 ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #4a3f35;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-emoji {
  font-size: 56px;
  animation: loading-bounce 1.2s ease-in-out infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 15px;
  color: rgba(201, 168, 76, 0.7);
  letter-spacing: 2px;
}

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

/* ===== 纸质纹理背景 ===== */
body {
  background-color: #4a3f35;
  background-image:
    /* 细微噪点纹理 */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* ===== 绘本容器 ===== */
.book-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* StPageFlip 容器 */
#book-container {
  position: relative;
  margin: 0 auto;
  box-shadow:
    0 15px 50px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.15),
    inset 0 0 60px rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}

/* ===== 每一页的基础样式 ===== */
.page {
  background-color: #faf6ee;
  overflow: hidden;
  position: relative;
  /* 米色纸张纹理 */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23p)' opacity='0.025'/%3E%3C/svg%3E");
}

/* 场景图 */
.page .page-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

/* ===== 文字卡片 ===== */
.page-text-card {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px 20px;
  background: linear-gradient(
    to bottom,
    rgba(253, 249, 240, 0) 0%,
    rgba(253, 249, 240, 0.85) 15%,
    rgba(253, 249, 240, 0.95) 100%
  );
  z-index: 2;
  animation: text-fade-up 0.6s ease both;
  animation-delay: 0.2s;
}

@keyframes text-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-text-card p {
  font-family: 'Noto Sans SC', sans-serif;
  font-size: clamp(13px, 2.8vw, 17px);
  color: #3d2e1e;
  line-height: 1.9;
  margin-bottom: 2px;
  text-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.5);
}

.page-text-card p.text-gap {
  margin-top: 10px;
}

/* 恐龙名字高亮 */
.dino-name {
  color: #b8860b;
  font-weight: 700;
}

/* ===== 封面样式 ===== */
.page.page-cover {
  background: linear-gradient(145deg, #4a7c3f 0%, #2d5a26 50%, #1e4420 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* 封面金色边框 */
.cover-border {
  width: 100%;
  height: 100%;
  border: 3px solid #c9a84c;
  border-radius: 8px;
  padding: 4px;
  position: relative;
}

.cover-border::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 5px;
  pointer-events: none;
}

/* 封面四角装饰 */
.cover-border::after {
  content: '✦';
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  color: #c9a84c;
  font-size: 14px;
}

.cover-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.cover-title {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(26px, 6vw, 44px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  margin-bottom: 16px;
  line-height: 1.4;
  letter-spacing: 2px;
}

.cover-subtitle {
  font-size: clamp(13px, 2.5vw, 17px);
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 32px;
  letter-spacing: 1px;
}

.cover-author {
  font-size: clamp(12px, 2vw, 15px);
  color: #c9a84c;
  margin-top: auto;
  letter-spacing: 1px;
}

.cover-hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 16px;
  animation: pulse 2.5s ease-in-out infinite;
}

/* ===== 尾页样式 ===== */
.page.page-end {
  background: linear-gradient(160deg, #fdf9f0 0%, #f5edd8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.end-inner {
  text-align: center;
}

.end-heart {
  font-size: clamp(32px, 6vw, 48px);
  margin-bottom: 28px;
}

.end-text {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(14px, 3vw, 20px);
  color: #5c4a32;
  line-height: 2.2;
}

.end-date {
  font-size: 0.85em;
  color: #9a8568;
}

/* ===== 翻页按钮（书签风格） ===== */
.nav-btn {
  position: fixed;
  bottom: 32px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(201, 168, 76, 0.5);
  background: rgba(253, 249, 240, 0.9);
  color: #6b5538;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: all 0.25s ease;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.nav-btn:hover {
  background: #fff;
  border-color: #c9a84c;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-btn svg {
  width: 16px;
  height: 16px;
}

.nav-btn.prev {
  left: calc(50% - 60px);
}

.nav-btn.next {
  right: calc(50% - 60px);
}

/* ===== 页码指示器 ===== */
.page-indicator {
  position: fixed;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(201, 168, 76, 0.6);
  z-index: 100;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
}

/* ===== TTS 朗读按钮 ===== */
.tts-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(201, 168, 76, 0.4);
  background: rgba(253, 249, 240, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 8;
  transition: all 0.25s;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tts-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: #c9a84c;
  transform: scale(1.1);
}

.tts-btn:active {
  transform: scale(0.9);
}

.tts-icon {
  width: 18px;
  height: 18px;
  color: #6b5538;
}

/* 朗读中 - 脉冲动画 */
.tts-btn.speaking {
  border-color: #c9a84c;
  background: rgba(201, 168, 76, 0.15);
  animation: tts-pulse 1.2s ease-in-out infinite;
}

.tts-btn.speaking .tts-icon {
  color: #b8860b;
}

.tts-btn.speaking .tts-wave {
  animation: tts-wave-anim 1s ease-in-out infinite;
}

.tts-btn.speaking .tts-wave-2 {
  animation-delay: 0.2s;
}

@keyframes tts-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201, 168, 76, 0.3); }
  50% { box-shadow: 0 0 0 6px rgba(201, 168, 76, 0); }
}

@keyframes tts-wave-anim {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ===== 视频覆盖层 ===== */
.video-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}

.video-overlay.active {
  display: flex;
}

.video-overlay.fade-out {
  animation: video-fade-out 0.5s ease forwards;
}

.page-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* P16 播放按钮 */
.video-play-btn {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 2px solid rgba(201, 168, 76, 0.6);
  border-radius: 24px;
  background: rgba(253, 249, 240, 0.9);
  color: #5c4a32;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s;
  z-index: 11;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.video-play-btn:hover {
  background: #fff;
  border-color: #c9a84c;
  transform: translateX(-50%) scale(1.05);
}

.video-play-btn:active {
  transform: translateX(-50%) scale(0.95);
}

.play-icon {
  font-size: 16px;
  color: #c9a84c;
}

.play-text {
  font-weight: 500;
}

@keyframes video-fade-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== 动画 ===== */
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.9; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

@keyframes egg-bounce {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes glow-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

@keyframes hatch-burst {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ===== 互动区域通用 ===== */
.interaction-area {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* ===== P7: 命名互动 ===== */
.interaction-name {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(253, 249, 240, 0.92);
  padding: 20px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(201, 168, 76, 0.3);
  min-width: 220px;
  max-width: 80%;
}

.name-prompt {
  font-family: 'Noto Serif SC', serif;
  font-size: clamp(13px, 2.5vw, 16px);
  color: #5c4a32;
  text-align: center;
  margin-bottom: 12px;
}

.name-input-group {
  display: flex;
  gap: 8px;
  width: 100%;
}

.name-input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e0d5c3;
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Noto Sans SC', sans-serif;
  background: #fff;
  color: #3d2e1e;
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: #c9a84c;
}

.name-input.shake {
  animation: shake 0.4s ease;
}

.name-submit {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #c9a84c, #b8960f);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}

.name-submit:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(201, 168, 76, 0.4);
}

.name-submit:active {
  transform: scale(0.95);
}

/* 命名确认状态 */
.name-confirmed {
  text-align: center;
  font-size: clamp(14px, 2.5vw, 17px);
  color: #5c4a32;
  padding: 4px;
}

.name-confirmed strong {
  color: #b8860b;
}

.name-confirmed-icon {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

/* ===== P9: 点击破壳 ===== */
.interaction-egg {
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.egg-tap-area {
  position: relative;
  width: 100px;
  height: 120px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.egg-body {
  font-size: 72px;
  text-align: center;
  line-height: 120px;
  transition: transform 0.15s;
}

.egg-tap-area.egg-bounce .egg-body {
  animation: egg-bounce 0.2s ease;
}

.egg-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.3) 0%, transparent 70%);
  animation: glow-pulse 2s ease-in-out infinite;
  pointer-events: none;
}

/* 裂纹 */
.egg-crack {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, transparent, #8b6914, transparent);
  border-radius: 1px;
  pointer-events: none;
}

/* 进度条 */
.egg-progress {
  width: 120px;
  height: 6px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.egg-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c9a84c, #ffd700);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.egg-hint {
  font-size: 12px;
  color: #8b7355;
  text-align: center;
  margin-top: 4px;
}

.egg-counter {
  font-weight: 700;
  color: #b8860b;
  margin-left: 4px;
}

/* 破壳完成 */
.egg-tap-area.egg-hatched .egg-body {
  animation: hatch-burst 0.5s ease forwards;
}

.hatch-complete .egg-glow {
  animation: none;
  opacity: 0;
}

.hatch-complete .egg-hint {
  color: #5c8a4d;
  font-weight: 700;
  font-size: 13px;
}

/* ===== P11: 食物选择 ===== */
.interaction-food {
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(253, 249, 240, 0.92);
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(201, 168, 76, 0.3);
}

.food-prompt {
  font-size: clamp(12px, 2.2vw, 15px);
  color: #5c4a32;
  text-align: center;
  margin-bottom: 12px;
}

.food-choices {
  display: flex;
  gap: 12px;
}

.food-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border: 2px solid #e0d5c3;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.food-btn:hover {
  border-color: #c9a84c;
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(201, 168, 76, 0.25);
}

.food-btn:active {
  transform: translateY(0) scale(0.95);
}

.food-icon {
  font-size: 28px;
}

.food-label {
  font-size: 12px;
  color: #6b5538;
  font-weight: 500;
}

/* 选择确认状态 */
.food-confirmed {
  text-align: center;
  font-size: clamp(13px, 2.5vw, 16px);
  color: #5c4a32;
  padding: 8px;
}

/* ===== 响应式 ===== */

/* 手机 */
@media (max-width: 767px) {
  .nav-btn {
    width: 36px;
    height: 36px;
    bottom: 16px;
  }

  .nav-btn.prev {
    left: calc(50% - 48px);
  }

  .nav-btn.next {
    right: calc(50% - 48px);
  }

  .page-indicator {
    bottom: 24px;
    font-size: 11px;
  }

  .page-text-card {
    padding: 12px 14px 14px;
  }

  .page-text-card p {
    font-size: clamp(12px, 3.5vw, 15px);
    line-height: 1.8;
  }

  .tts-btn {
    width: 30px;
    height: 30px;
    top: 8px;
    right: 8px;
  }

  .tts-icon {
    width: 14px;
    height: 14px;
  }

  .interaction-name {
    padding: 14px 16px;
    min-width: 180px;
  }

  .egg-tap-area {
    width: 80px;
    height: 96px;
  }

  .egg-body {
    font-size: 56px;
    line-height: 96px;
  }

  .food-btn {
    padding: 10px 12px;
  }

  .food-icon {
    font-size: 24px;
  }

  .video-play-btn {
    bottom: 60px;
    font-size: 12px;
    padding: 8px 16px;
  }
}

/* 平板 */
@media (min-width: 768px) and (max-width: 1023px) {
  .nav-btn.prev {
    left: calc(50% - 55px);
  }

  .nav-btn.next {
    right: calc(50% - 55px);
  }
}

/* 桌面 */
@media (min-width: 1024px) {
  .nav-btn {
    bottom: 36px;
  }

  .nav-btn.prev {
    left: calc(50% - 70px);
  }

  .nav-btn.next {
    right: calc(50% - 70px);
  }
}
