/* ============================================================
   PLASTAR 翻页电子书 — 基于 StPageFlip
   - 舞台背景：工厂实景 + 模糊 + 暗角
   - 书本容器：aspect-ratio 控制比例
   - 翻页：库接管，CSS 负责容器与 UI
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f1620;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- 舞台与背景 ---------- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.stage-bg {
  position: absolute;
  inset: 0;
  background: url('assets/bg_factory.webp') center/cover no-repeat;
  filter: blur(2px) brightness(1.0);
  transform: scale(1.05);
  z-index: 0;
}
.stage-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0.00) 0%, rgba(0,0,0,0.38) 100%),
    linear-gradient(180deg, rgba(8,12,22,0.10) 0%, rgba(8,12,22,0.0) 30%, rgba(8,12,22,0.0) 70%, rgba(8,12,22,0.18) 100%);
  z-index: 1;
  pointer-events: none;
}

/* ---------- 品牌 LOGO ---------- */
.brand-logo {
  position: absolute;
  top: 24px;
  left: 36px;
  height: 45px;
  z-index: 20;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  pointer-events: none;
}

/* ---------- 书本容器 ---------- */
.book-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  /* 横向 2 页 A4：宽 = 高 × 2 × (595/842) = 高 × 1.4144 */
  width: min(92vw, calc(82vh * 1.4144), 1200px);
  aspect-ratio: 1.4144 / 1;
  /* 暗角 + 阴影（模拟书的体积感） */
  filter: drop-shadow(0 18px 48px rgba(0, 0, 0, 0.45));
}
#book {
  width: 100%;
  height: 100%;
  position: relative;
}

/* ---------- StPageFlip 页样式（DOM 模式：空白半页透明，舞台背景透出） ---------- */
.page {
  position: relative;
  background: transparent;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
/* StPageFlip 注入的容器也透明，避免色块 */
.stf__parent, .stf__wrapper, .stf__block {
  background: transparent !important;
}
.stf__item {
  background: transparent !important;
  overflow: hidden;
}
.stf__item img {
  background: #fff;        /* 图片区域本身保持白底，模拟纸质 */
}

/* ---------- 硬封（封面/封底）专属：保留原色，仅做边缘嵌入感 ----------
   用户要求"封面不需要调整色差，就用原来的封面颜色"，
   所以硬封图本身保持 filter: none，仅用 ::before 物理感 inset 阴影
   让硬壳纸板的"厚度"在亮背景里也能被感知。 */
.page-hard::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.10),
    inset 0 0 40px rgba(8, 12, 22, 0.22),
    inset 0 -2px 14px rgba(0, 0, 0, 0.18),
    inset 0 2px 12px rgba(0, 0, 0, 0.14);
  z-index: 3;
}
/* 移动端：单页 portrait 模式 */
@media (max-width: 720px) {
  .book-wrap {
    width: min(92vw, calc(82vh * 0.7072));
    aspect-ratio: 0.7072 / 1;
  }
  .brand-logo { height: 36px; top: 18px; left: 20px; }
}

/* ---------- 翻页提示角标（封面时显示） ---------- */
.flip-hint {
  position: absolute;
  right: max(2vw, 18px);
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(20, 26, 40, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 15;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
}
.flip-hint svg { width: 26px; height: 26px; }
.flip-hint.visible {
  opacity: 1;
  pointer-events: auto;
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50%      { transform: translateY(-50%) translateX(-6px); }
}

/* ---------- 侧边热区 ---------- */
.hotzone {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 72px;
  height: 140px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms ease;
}
.hotzone .arrow {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(20, 26, 40, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  font-size: 28px;
  line-height: 46px;
  text-align: center;
  user-select: none;
}
.hotzone-left  { left: 0; }
.hotzone-right { right: 0; }
.hotzone:hover { opacity: 1; }
.stage:hover .hotzone { opacity: 0.65; }

/* ---------- 底部 HUD ---------- */
.hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(20, 26, 40, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
.ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 180ms ease, transform 120ms ease, opacity 180ms ease;
}
.ctrl-btn svg { width: 18px; height: 18px; }
.ctrl-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
  transform: scale(1.06);
}
.ctrl-btn:active:not(:disabled) { transform: scale(0.94); }
.ctrl-btn:disabled { opacity: 0.30; cursor: not-allowed; }
.indicator {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.92);
  min-width: 96px;
  text-align: center;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 加载遮罩 ---------- */
.loading-mask {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: linear-gradient(180deg, #1c2333 0%, #0f1620 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity 480ms ease, visibility 480ms;
}
.loading-mask.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #4a7fbf;
  animation: spin 0.9s linear infinite;
}
.loading-text { color: rgba(255,255,255,0.75); font-size: 14px; letter-spacing: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 防止 iOS 橡皮筋 ---------- */
body { overscroll-behavior: none; touch-action: none; }
