/* ============================================================
   首页开场动画 — 纯2D书本展开
   薄条 → M型曲边书页（展开+弯曲同时进行）
   细节优化：纸质纹理、书脊斜角、暖光氛围
   ============================================================ */

.splash-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.splash-book {
  position: relative;
  width: 720px;
  height: 480px;
  overflow: visible;
}

/* ===== 书后暖光晕 ===== */
.splash-book::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 45%;
  width: 680px;
  height: 420px;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse 50% 45% at 50% 50%,
    rgba(255,220,140,.12) 0%, rgba(200,155,92,.06) 40%, transparent 70%);
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  animation: fadeIn 1.5s ease 0.8s forwards;
}

/* ===== 左右书页 ===== */
.splash-page {
  position: absolute;
  top: -10%;
  width: 50%;
  height: 120%;
  z-index: 3;
  overflow: visible;
}

/* 左页: 纸质渐变 + 纸纹理叠层 */
.splash-page-L {
  left: 0;
  background:
    /* 微妙纸质噪点 */
    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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E"),
    linear-gradient(90deg,
      #f9f0de 0%, #f5eacc 15%, #f0ddc0 35%,
      #ead2aa 55%, #ddc090 75%, #d0b078 100%);
  animation: openLeft 1.5s cubic-bezier(.42,0,.58,1) 0.5s both;
}

@keyframes openLeft {
  0% {
    clip-path: polygon(
      84% 8%, 85.8% 8%, 87.6% 8%, 89.4% 8%, 91.2% 8%,
      93% 8%, 95% 8%, 97% 8%, 98.5% 8%, 100% 8%,
      100% 92%, 98.5% 92%, 97% 92%, 95% 92%, 93% 92%,
      91.2% 92%, 89.4% 92%, 87.6% 92%, 85.8% 92%, 84% 92%
    );
  }
  30% {
    clip-path: polygon(
      58% 8%, 63% 7%, 68% 6.2%, 74% 5.5%, 80% 5.5%,
      85% 5.8%, 90% 6.2%, 94% 6.8%, 97% 7.2%, 100% 8%,
      100% 92%, 97% 91%, 94% 90.5%, 90% 90%, 85% 89.8%,
      80% 89.5%, 74% 89.8%, 68% 90.5%, 63% 91%, 58% 92%
    );
  }
  60% {
    clip-path: polygon(
      26% 8%, 33% 5.8%, 40% 4.2%, 48% 3.2%, 56% 3%,
      64% 3.2%, 72% 4%, 80% 5.2%, 88% 6.5%, 100% 8.5%,
      100% 91.5%, 88% 89%, 80% 88%, 72% 87.5%, 64% 87.2%,
      56% 87%, 48% 87.2%, 40% 87.8%, 33% 89%, 26% 92%
    );
  }
  85% {
    clip-path: polygon(
      5% 8%, 12% 5.8%, 22% 3.5%, 33% 2.5%, 44% 2.2%,
      55% 2.5%, 66% 3.5%, 76% 5%, 86% 6.8%, 100% 8.5%,
      100% 91.5%, 86% 88.5%, 76% 87.5%, 66% 87%, 55% 86.8%,
      44% 87%, 33% 87.5%, 22% 88.5%, 12% 90%, 5% 92%
    );
  }
  100% {
    clip-path: polygon(
      0% 8%, 10% 5.5%, 22% 3.5%, 35% 2.5%, 48% 2.2%,
      60% 2.5%, 72% 3.5%, 82% 5.2%, 90% 7%, 100% 8.5%,
      100% 91.5%, 90% 89%, 82% 88%, 72% 87.3%, 60% 87%,
      48% 87%, 35% 87.3%, 22% 88%, 10% 89.5%, 0% 92%
    );
  }
}

/* 右页: 水平镜像，确保完全同步 */
.splash-page-R {
  right: 0;
  background:
    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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E"),
    linear-gradient(90deg,
      #f9f0de 0%, #f5eacc 15%, #f0ddc0 35%,
      #ead2aa 55%, #ddc090 75%, #d0b078 100%);
  animation: openLeft 1.5s cubic-bezier(.42,0,.58,1) 0.5s both;
  transform: scaleX(-1);
}

/* ===== 页内横线(笔记本风格) ===== */
.splash-page-grid {
  position: absolute;
  inset: 24px 16px 16px 16px;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px, transparent 30px,
    rgba(140,90,40,.07) 30px, rgba(140,90,40,.07) 31px
  );
  pointer-events: none;
}

/* ===== 书脊线(斜角高光 + 深凹陷) ===== */
.splash-spine {
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 100%;
  transform: translateX(-50%);
  z-index: 5;
  background: linear-gradient(180deg,
    rgba(120,75,25,.15) 5%,
    rgba(100,60,18,.5) 20%,
    rgba(80,45,10,.65) 50%,
    rgba(100,60,18,.5) 80%,
    rgba(120,75,25,.15) 95%
  );
  box-shadow:
    -2px 0 6px rgba(0,0,0,.22),
    2px 0 6px rgba(0,0,0,.22),
    0 0 12px rgba(0,0,0,.08);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.splash-spine.show { opacity: 1; }
.splash-spine.show::before,
.splash-spine.show::after { opacity: 1; }

.splash-spine::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 60px;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,0,0,.02) 10%,
    rgba(0,0,0,.08) 25%,
    rgba(0,0,0,.15) 40%,
    rgba(0,0,0,.18) 50%,
    rgba(0,0,0,.15) 60%,
    rgba(0,0,0,.08) 75%,
    rgba(0,0,0,.02) 90%,
    transparent 100%
  );
  opacity: 0;
}

/* 书脊斜角高光 */
.splash-spine::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(180deg,
    rgba(255,245,220,.25) 10%,
    rgba(255,235,200,.35) 30%,
    rgba(255,230,180,.4) 50%,
    rgba(255,235,200,.35) 70%,
    rgba(255,245,220,.25) 90%
  );
  opacity: 0;
}

/* ===== 金色底边（复制页面 + 下移露出底边） ===== */
.splash-page-ge {
  z-index: 1 !important;
  pointer-events: none;
}
.splash-page-ge-1 {
  margin-top: 10px;
  background: #e8d090 !important;
  z-index: 2 !important;
}
.splash-page-ge-2 {
  margin-top: 20px;
  background: #d0b060 !important;
  z-index: 1 !important;
}
.splash-page-ge-3 {
  margin-top: 30px;
  background: #b89840 !important;
  z-index: 0 !important;
}
.splash.is-closing .splash-page-ge { opacity: 0 !important; }

/* ===== 翻开边竖线（合拢时显示多层竖线，模拟书页侧面） ===== */
.splash-fore-edge {
  position: absolute;
  left: calc(50% - 40px);
  top: 0;
  width: 80px;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.splash-fore-edge.fade { opacity: 0; }
.splash.is-closing .splash-fore-edge {
  opacity: 1;
}
.splash-fore-edge .fe-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(160,120,50,.25) 5%,
    rgba(140,100,40,.35) 30%,
    rgba(140,100,40,.4) 50%,
    rgba(140,100,40,.35) 70%,
    rgba(160,120,50,.25) 95%,
    transparent 100%
  );
}

/* ===== 左页外缘阴影(3D纸张厚度感) ===== */
.splash-page-L::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 100%;
  background: linear-gradient(90deg,
    rgba(140,95,40,.3) 0%,
    rgba(160,110,50,.18) 30%,
    rgba(180,130,65,.06) 60%,
    transparent 100%
  );
  pointer-events: none;
  border-radius: 4px 0 0 4px;
  opacity: 0;
  animation: fadeIn 0.8s ease 1.2s forwards;
}

/* ===== 右页外缘阴影 ===== */
.splash-page-R::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 100%;
  background: linear-gradient(90deg,
    rgba(140,95,40,.3) 0%,
    rgba(160,110,50,.18) 30%,
    rgba(180,130,65,.06) 60%,
    transparent 100%
  );
  pointer-events: none;
  border-radius: 4px 0 0 4px;
  opacity: 0;
  animation: fadeIn 0.8s ease 1.2s forwards;
}

/* ===== 页面顶部M型高光(拱形受光) ===== */
.splash-page::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(180deg,
    rgba(255,248,230,.35) 0%,
    rgba(255,240,210,.12) 40%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  animation: fadeIn 1s ease 1.4s forwards;
}

/* ===== 中央文字(毛笔风格) ===== */
.splash-page-char {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 72px;
  font-family: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', serif;
  color: rgba(70,40,15,.35);
  z-index: 4;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 0;
  animation: fadeIn 1.2s ease 1.6s forwards;
  text-shadow: 0 2px 8px rgba(120,80,30,.1);
}
.splash-page-char-L {
  right: calc(50% + 40px);
}
.splash-page-char-R {
  left: calc(50% + 40px);
}

/* ===== 展开光效 ===== */
.splash-unfold-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255,230,170,.5) 0%, rgba(255,200,100,.15) 30%, transparent 65%);
  border-radius: 50%;
  z-index: 30;
  pointer-events: none;
  width: 0;
  height: 0;
  opacity: 0;
  animation: unfoldGlow 2.5s cubic-bezier(.22,.68,.32,1) 0.8s forwards;
}

/* ===== 底部阴影(M型双拱投影) ===== */
.splash-book::after {
  content: '';
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: -24px;
  height: 40px;
  background:
    /* 左拱投影 */
    radial-gradient(ellipse 28% 100% at 18% 0%, rgba(0,0,0,.25) 0%, transparent 75%),
    /* 右拱投影 */
    radial-gradient(ellipse 28% 100% at 82% 0%, rgba(0,0,0,.25) 0%, transparent 75%),
    /* 书脊浅影 */
    radial-gradient(ellipse 18% 100% at 50% 0%, rgba(0,0,0,.06) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  animation: fadeIn 1s ease 1.4s forwards;
}

/* ===== 通用动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes unfoldGlow {
  0%   { width: 0; height: 0; opacity: 0; }
  40%  { width: 500px; height: 400px; opacity: .8; }
  70%  { width: 900px; height: 700px; opacity: .4; }
  100% { width: 1200px; height: 1000px; opacity: 0; }
}

/* ===== 合拢标题 ===== */
.splash-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  opacity: 1;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.splash-title-fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.splash-title-text {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: 'Noto Serif SC', 'Source Han Serif SC', 'STSong', 'SimSun', serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 12px;
  color: #c03020;
  text-shadow:
    0 0 12px rgba(255,230,160,.9),
    0 0 24px rgba(255,210,120,.5),
    2px 2px 0 rgba(255,240,200,.6),
    -1px -1px 0 rgba(255,240,200,.6);
  padding: 8px 12px;
  white-space: nowrap;
}

/* ===== 关闭动画：书本合拢 → 淡出 ===== */
/* 第1阶段（0~0.5s）：内页装饰淡出 */
.splash.is-closing .splash-page-grid {
  animation: fadeOut 0.4s ease forwards;
}
.splash.is-closing .splash-page-char {
  animation: fadeOut 0.5s ease forwards;
}
.splash.is-closing .splash-page-L::after,
.splash.is-closing .splash-page-R::after {
  animation: fadeOut 0.4s ease forwards;
}
.splash.is-closing .splash-page::before {
  animation: fadeOut 0.4s ease forwards;
}
.splash.is-closing .splash-book::before,
.splash.is-closing .splash-book::after {
  animation: fadeOut 0.5s ease forwards;
}
.splash.is-closing .splash-quote {
  animation: fadeOut 0.5s ease forwards;
}
.splash.is-closing .splash-symbols {
  animation: fadeOut 0.5s ease forwards;
}
.splash.is-closing .splash-ring {
  animation: none;
  opacity: 0;
}
.splash.is-closing .splash-unfold-glow {
  animation: fadeOut 0.4s ease forwards;
}
/* 第2阶段（0.3s起）：书页平滑合拢，过渡1.4s */
.splash.is-closing .splash-page-L,
.splash.is-closing .splash-page-R {
  animation: openLeft 1.4s cubic-bezier(.42,0,.58,1) 0.3s reverse both;
}
/* 书脊在书页合拢过程中淡入 */
.splash.is-closing .splash-spine {
  opacity: 0 !important;
  animation: spineIn 0.6s ease 1.0s forwards !important;
  visibility: visible !important;
}
.splash.is-closing .splash-spine::before,
.splash.is-closing .splash-spine::after {
  opacity: 0 !important;
  animation: spineIn 0.6s ease 1.0s forwards !important;
}
@keyframes spineIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* 金色底边在合拢时显示 */
.splash.is-closing .splash-page-ge {
  animation: fadeOut 0.3s ease forwards;
}
/* 合拢时标题重新出现（书页开始合拢即显示，持续到整体移除） */
.splash.is-closing .splash-title {
  opacity: 1 !important;
  transition: opacity 0.4s ease 0.1s;
  animation: none !important;
}
.splash.is-closing .splash-title-fade {
  opacity: 1 !important;
  transition: opacity 0.4s ease 0.1s;
  animation: none !important;
}
/* 最终淡出时标题不单独淡出，随splash整体移除 */
.splash.is-hide .splash-title {
  opacity: 1 !important;
}
/* 最终淡出整个遮罩 */
.splash.is-hide {
  animation: fadeOut 0.5s ease forwards;
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  .splash-book { width: 620px; height: 420px; }
  .splash-book::before { width: 580px; height: 380px; }
  .splash-spine::before { width: 48px; }
}
@media (max-width: 800px) {
  .splash-book { width: 480px; height: 330px; }
  .splash-book::before { width: 440px; height: 290px; }
  .splash-spine::before { width: 42px; }
  .splash-title-text { font-size: 40px; letter-spacing: 10px; }
}
@media (max-width: 480px) {
  .splash-book { width: 390px; height: 270px; }
  .splash-book::before { width: 350px; height: 230px; }
  .splash-spine::before { width: 38px; }
  .splash-title-text { font-size: 32px; letter-spacing: 8px; }
}
