/* ==========================================================================
   西华·女娲传说 H5 — 全局基础样式（美术 token / 肌理 / 适配 / 组件）
   ========================================================================== */

/* ===== 美术 Token ===== */
:root {
  --ochre: #c8a26b;        /* 赭石土黄（主色） */
  --ochre-dark: #9c7440;
  --ochre-deep: #7a5530;
  --sand: #e8dcc4;         /* 浅砂 */
  --sand-dark: #d4c4a0;
  --celadon: #6e7b7a;      /* 青灰 */
  --celadon-light: #a7b8b5;
  --celadon-deep: #465251;
  --ink: #2c2a28;          /* 墨黑 */
  --c-red: #b8412e;        /* 五色石 · 红 */
  --c-yellow: #d9a441;     /* 五色石 · 黄 */
  --c-white: #efe6d2;      /* 五色石 · 白 */
  --c-black: #2c2a28;      /* 五色石 · 黑 */
  --c-cyan: #3e6e7a;       /* 五色石 · 青 */
  --gold: #e8c878;         /* 星点金 */
  --gold-deep: #b8893a;
  --title-font: 'ZCOOL XiaoWei', 'STLiti', 'LiSu', 'KaiTi', 'STKaiti', serif;
  --body-font: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #15120f;
  font-family: var(--body-font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; }
svg { display: block; }

/* ===== 视口适配：750×1334 等比缩放居中 ===== */
#viewport {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #0b0a08;
}
#app {
  position: relative;
  width: 750px; height: 1334px;
  transform-origin: center center;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 80px rgba(0, 0, 0, .7);
}

/* ===== 纸张 / 岩画肌理（所有页面通用叠层） ===== */
.texture {
  position: absolute; inset: 0; pointer-events: none; z-index: 60;
  mix-blend-mode: multiply; opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='240'%20height='240'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='0.85'%20numOctaves='2'%20stitchTiles='stitch'/%3E%3CfeColorMatrix%20type='saturate'%20values='0'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23n)'/%3E%3C/svg%3E");
}
.grime {
  position: absolute; inset: 0; pointer-events: none; z-index: 61; opacity: .22;
  background:
    radial-gradient(circle at 18% 28%, rgba(58, 38, 18, .55), transparent 42%),
    radial-gradient(circle at 82% 72%, rgba(58, 38, 18, .5), transparent 46%),
    radial-gradient(circle at 50% 100%, rgba(40, 28, 14, .4), transparent 55%);
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 62;
  box-shadow: inset 0 0 140px 30px rgba(20, 14, 8, .55);
}

/* ===== 页面与横向翻页转场 ===== */
.page {
  position: absolute; inset: 0;
  display: none; overflow: hidden;
  transition: transform .82s cubic-bezier(.4, 0, .2, 1), opacity .82s ease;
}
.page.page-active { display: block; }
.page > * { position: absolute; }

/* ===== 全局 UI：静音按钮（最顶层，不遮挡内容） ===== */
.mute-btn {
  position: absolute; top: 30px; right: 30px; z-index: 300;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--sand);
  background: rgba(30, 22, 14, .5);
  border: 1.5px solid rgba(232, 220, 196, .55);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35), 0 0 14px rgba(232, 200, 120, .2);
  transition: transform .3s ease, background .3s ease;
}
.mute-btn:hover { transform: scale(1.08); background: rgba(50, 36, 22, .6); }
.mute-btn.is-muted { color: rgba(232, 220, 196, .5); }
.mute-btn::after { /* 放大点击热区 */
  content: ''; position: absolute; inset: -12px;
}

/* ===== 全局 UI：返回首页按钮 ===== */
.home-btn {
  position: absolute; top: 30px; left: 30px; z-index: 200;
  display: none; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 30px;
  font-family: var(--title-font); font-size: 24px; letter-spacing: 2px;
  color: var(--sand);
  background: rgba(30, 22, 14, .5);
  border: 1.5px solid rgba(232, 220, 196, .5);
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
  transition: transform .3s ease, background .3s ease;
}
.home-btn:hover { transform: translateY(-2px); background: rgba(50, 36, 22, .65); }
.home-btn::before { content: '⌂'; font-size: 22px; }

/* ===== 全局 UI：侧边记忆图鉴栏 ===== */
.codex {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  z-index: 200; display: none; flex-direction: column; align-items: center; gap: 8px;
  width: 58px; padding: 16px 0;
  border-radius: 16px;
  background: rgba(30, 22, 14, .55);
  border: 1.5px solid rgba(232, 220, 196, .45);
  backdrop-filter: blur(3px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  transition: transform .3s ease, background .3s ease;
}
.codex:hover { transform: translateY(-50%) scale(1.05); background: rgba(50, 36, 22, .65); }
.codex .codex-tab {
  writing-mode: vertical-rl; letter-spacing: 6px;
  font-family: var(--title-font); font-size: 22px; color: var(--sand);
}
.codex .codex-num {
  font-family: var(--title-font); font-size: 20px; color: var(--gold);
  background: rgba(0,0,0,.3); border-radius: 50%; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.codex .codex-orn { width: 30px; height: 2px; background: var(--gold-deep); border-radius: 2px; }

/* ===== 国风弹窗（通用） ===== */
.modal {
  position: absolute; inset: 0; z-index: 500;
  display: none; align-items: center; justify-content: center;
  background: rgba(10, 8, 6, .72);
  backdrop-filter: blur(2px);
}
.modal.modal-open { display: flex; animation: fadeIn .4s ease; }
.modal-card {
  position: relative; width: 600px; max-width: 92%;
  background: linear-gradient(160deg, #efe6d2, #e0d2b4);
  border: 2px solid var(--ochre-dark);
  border-radius: 14px;
  padding: 56px 44px 40px;
  box-shadow: 0 0 0 1px rgba(122, 85, 48, .4), 0 20px 60px rgba(0,0,0,.6);
  animation: popIn .5s cubic-bezier(.2, .9, .3, 1.3);
}
/* 国风回纹边角 */
.modal-card::before, .modal-card::after {
  content: ''; position: absolute; width: 38px; height: 38px;
  border: 2px solid var(--ochre-deep);
}
.modal-card::before { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.modal-card::after { bottom: 10px; right: 10px; border-left: none; border-top: none; }
.modal-title {
  font-family: var(--title-font); font-size: 34px; text-align: center;
  color: var(--ochre-deep); letter-spacing: 4px; margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid rgba(122, 85, 48, .4);
}
.modal-body {
  font-size: 26px; line-height: 1.9; color: var(--ink); text-align: center;
  max-height: 700px; overflow-y: auto;
}
.modal-body p { margin-bottom: 14px; }
.modal-close {
  position: absolute; top: 14px; right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--ochre-deep);
  background: rgba(122, 85, 48, .12);
  transition: background .2s;
}
.modal-close:hover { background: rgba(122, 85, 48, .28); }

/* ===== Toast 轻提示 ===== */
.toast {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9);
  z-index: 600; opacity: 0; pointer-events: none;
  padding: 16px 30px; border-radius: 30px;
  font-family: var(--title-font); font-size: 26px; letter-spacing: 2px;
  color: var(--sand);
  background: rgba(30, 22, 14, .85);
  border: 1.5px solid rgba(232, 200, 120, .6);
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  transition: opacity .35s ease, transform .35s ease;
  white-space: nowrap;
}
.toast.toast-show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ===== 图鉴弹窗卡片网格 ===== */
.codex-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.codex-card {
  border: 1.5px solid var(--ochre-dark); border-radius: 10px;
  padding: 18px 16px; text-align: center;
  background: rgba(255, 255, 255, .4);
  transition: transform .3s;
}
.codex-card.unlocked { background: linear-gradient(160deg, #f3ead5, #e3d2af); box-shadow: 0 0 16px rgba(232, 200, 120, .4); }
.codex-card.locked { filter: grayscale(.7); opacity: .55; }
.codex-card .codex-icon { font-size: 34px; color: var(--gold-deep); margin-bottom: 8px; }
.codex-card .codex-name { font-family: var(--title-font); font-size: 26px; color: var(--ochre-deep); letter-spacing: 3px; margin-bottom: 8px; }
.codex-card .codex-desc { font-size: 19px; line-height: 1.6; color: var(--celadon-deep); }
.codex-card .codex-page { margin-top: 10px; font-size: 18px; color: var(--ochre-dark); }

/* ===== 石块按钮 ===== */
.stone-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--title-font); letter-spacing: 4px;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 35% 30%, #e6d3a8, #c8a26b 55%, #9c7440 100%);
  border: 2px solid #7a5530;
  border-radius: 46% 54% 50% 50% / 55% 45% 55% 45%;
  box-shadow:
    inset 0 3px 10px rgba(255, 245, 220, .6),
    inset 0 -6px 14px rgba(80, 52, 24, .55),
    0 8px 20px rgba(0, 0, 0, .45),
    0 0 18px rgba(232, 200, 120, .25);
  transition: transform .3s ease, filter .3s ease, box-shadow .3s ease;
}
.stone-btn::after { /* 石块纹理 */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='120'%20height='60'%3E%3Cfilter%20id='n'%3E%3CfeTurbulence%20type='fractalNoise'%20baseFrequency='1.2'%20numOctaves='2'/%3E%3C/filter%3E%3Crect%20width='100%25'%20height='100%25'%20filter='url(%23n)'%20opacity='.22'/%3E%3C/svg%3E");
  mix-blend-mode: multiply; opacity: .6;
}
.stone-btn:hover { transform: translateY(-6px); filter: brightness(1.08); box-shadow: inset 0 3px 10px rgba(255,245,220,.7), inset 0 -6px 14px rgba(80,52,24,.5), 0 14px 28px rgba(0,0,0,.5), 0 0 26px rgba(232,200,120,.45); }
.stone-btn:active { transform: translateY(-2px) scale(.98); }
.stone-btn:disabled { filter: grayscale(.5) brightness(.75); cursor: not-allowed; transform: none; }

/* ===== 篇章页通用：标题区（左上岩画边框） ===== */
.chapter-title {
  left: 40px; top: 110px; width: 420px; padding: 20px 26px 22px;
  background: rgba(30, 22, 14, .55);
  border: 1.5px solid rgba(232, 220, 196, .5);
  border-left: 5px solid var(--gold);
  backdrop-filter: blur(2px);
}
.chapter-title h2 {
  font-family: var(--title-font); font-size: 46px; letter-spacing: 8px;
  color: var(--gold); text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
.chapter-title .title-sub {
  margin-top: 8px; font-size: 20px; letter-spacing: 3px; color: var(--celadon-light);
}
/* 正文段落 */
.chapter-body {
  left: 40px; right: 120px; bottom: 230px;
  font-size: 26px; line-height: 1.95; color: var(--sand);
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
}
/* 底部提示 */
.chapter-hint {
  left: 0; right: 0; bottom: 150px; text-align: center;
  font-size: 24px; letter-spacing: 2px; color: var(--gold);
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  animation: hintPulse 2.4s ease-in-out infinite;
}
/* 底部篇章进度 */
.chapter-progress {
  position: absolute; left: 0; right: 0; bottom: 56px; text-align: center;
  font-family: var(--title-font); font-size: 22px; letter-spacing: 4px;
  color: var(--celadon-light); opacity: .85;
}
/* 继续前行按钮（默认隐藏，完成后由 JS 显示） */
.continue-btn {
  left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: 96px; width: 300px; height: 88px;
  font-size: 30px; opacity: 0; pointer-events: none;
  transition: opacity .6s ease, transform .6s ease;
}
.continue-btn.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ===== 通用动画 ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes hintPulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes floatY { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes glow {
  0%,100% { box-shadow: 0 0 12px 2px rgba(232, 200, 120, .5); }
  50% { box-shadow: 0 0 28px 8px rgba(232, 200, 120, .85); }
}
@keyframes ripple {
  0% { transform: scale(.3); opacity: .9; }
  100% { transform: scale(3.2); opacity: 0; }
}
.anim-shake { animation: shake .4s ease; }
.anim-float { animation: floatY 3.5s ease-in-out infinite; }
