:root {
  --paper: #f7f4ec;
  --accent: #c8a24a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  /* 天空云海背景图（web/assets/bg.jpg），主色兜底 */
  background: #0a3550 url("../assets/bg.jpg") center / cover no-repeat;
  color: #fff;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  user-select: none;
}

#app { position: relative; height: 100%; }

/* 顶部标题：悬浮居中，白色带投影 */
.topbar {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 10px);
  left: 0; right: 0;
  text-align: center;
  z-index: 30;
  pointer-events: none;
}
.title {
  font-size: 15px; font-weight: 600; letter-spacing: 2px;
  color: #fff; text-shadow: 0 1px 8px rgba(0, 25, 45, .5);
}

/* 舞台：铺满居中 */
.stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  perspective: 1800px;
  touch-action: pan-y;
}

/* 书本与书页：摊开的左右两页（--page-ratio 为摊开宽高比，由 flipbook.js 按页图设置），
 * 宽不超 94vw、高不超 86vh */
.book {
  --page-ratio: 1.7778;
  position: relative;
  width: min(94vw, calc(86vh * var(--page-ratio)), 1280px);
  aspect-ratio: var(--page-ratio);
  transform-style: preserve-3d;
  transition: width .3s ease, aspect-ratio .3s ease;
}
.page {
  position: absolute; top: 0; bottom: 0; width: 50%;
  background-color: var(--paper);
  background-size: cover; background-position: center;
  backface-visibility: hidden;
}
.page.left {
  left: 0; border-radius: 6px 0 0 6px;
  box-shadow: 0 24px 60px rgba(0, 15, 35, .55), inset -18px 0 24px -14px rgba(0, 0, 0, .28);
}
.page.right {
  right: 0; border-radius: 0 6px 6px 0;
  box-shadow: 0 24px 60px rgba(0, 15, 35, .55), inset 18px 0 24px -14px rgba(0, 0, 0, .28);
}
/* 空白页（封面/封底内侧） */
.page.blank { background-image: linear-gradient(135deg, #f4f0e4, #e8e2d2); }
/* 单页屏（封面/封底）：页占满整本书宽，另一半隐藏 */
.page.full { width: 100%; border-radius: 6px; }
.page.full.right { left: 0; }
.page.hidden { visibility: hidden; box-shadow: none; }

/* 翻动中的书页：占右半、绕书脊（左边缘）旋转 */
.page.turning {
  left: 50%; width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
  transition: transform .6s cubic-bezier(.4,.0,.2,1);
  z-index: 5;
  opacity: 0; /* 默认隐藏，翻页时由 JS 加 .active 显示 */
  border-radius: 0 6px 6px 0;
  box-shadow: 0 24px 60px rgba(0, 15, 35, .45);
}
.page.turning.active { opacity: 1; }
.page.turning .face2 {
  position: absolute; inset: 0;
  background-color: var(--paper);
  background-size: cover; background-position: center;
  backface-visibility: hidden;
  border-radius: 0 6px 6px 0;
}
.page.turning .face2.front { box-shadow: inset 18px 0 24px -14px rgba(0, 0, 0, .28); }
.page.turning .face2.back {
  transform: rotateY(180deg);
  border-radius: 6px 0 0 6px;
  box-shadow: inset -18px 0 24px -14px rgba(0, 0, 0, .28);
}
.page.turning .face2.blank { background-image: linear-gradient(135deg, #f4f0e4, #e8e2d2); }

/* 左右两侧翻页箭头 */
.edge {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 20;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff; font-size: 18px; line-height: 1; padding: 0 0 3px;
  box-shadow: 0 4px 16px rgba(0, 20, 40, .3);
  transition: opacity .25s, background .2s, transform .1s;
}
.edge:hover  { background: rgba(255, 255, 255, .38); }
.edge:active { transform: translateY(-50%) scale(.9); }
.edge.left  { left:  max(12px, env(safe-area-inset-left)); }
.edge.right { right: max(12px, env(safe-area-inset-right)); }
.edge.off   { opacity: .25; pointer-events: none; }

/* 底部：实时页码胶囊 + 自动播放按钮 */
.toolbar {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  left: 0; right: 0;
  display: flex; justify-content: center; align-items: center; gap: 10px;
  z-index: 30;
}
.pager {
  min-width: 96px; text-align: center;
  padding: 9px 20px; border-radius: 999px;
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #134a6b; font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 16px rgba(0, 20, 40, .3);
}
.mini {
  width: 40px; height: 40px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: #fff; font-size: 15px; line-height: 1;
  box-shadow: 0 4px 16px rgba(0, 20, 40, .3);
  transition: background .2s, transform .1s;
}
.mini:hover  { background: rgba(255, 255, 255, .38); }
.mini:active { transform: scale(.9); }

.hint {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom) + 66px);
  left: 0; right: 0;
  text-align: center; font-size: 12px;
  color: rgba(255, 255, 255, .85);
  text-shadow: 0 1px 6px rgba(0, 25, 45, .5);
  transition: opacity .4s; pointer-events: none;
}
.hint.gone { opacity: 0; }
