/* ============================================================
   AI 绘本 · 书本翻页弹层
   ============================================================ */

/* ---------- 遮罩层 ---------- */
.book-overlay {
  position: fixed; inset: 0; z-index: 1200;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
}
.book-overlay.open { display: flex; }
.book-backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 6, 20, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0; transition: opacity .4s;
}
.book-overlay.open .book-backdrop { opacity: 1; }
body.book-open { overflow: hidden; }

/* ---------- 书本舞台 ---------- */
.book-stage {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  opacity: 0; transform: translateY(40px) scale(.9);
  transition: opacity .5s cubic-bezier(.2,.8,.3,1), transform .5s cubic-bezier(.18,.9,.32,1.15);
}
.book-overlay.open .book-stage {
  opacity: 1; transform: none;
}

/* ---------- 书本主体（双页） ---------- */
.book-shell {
  position: relative;
  border-radius: 10px;
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, .75),
    0 0 60px -10px rgba(122, 162, 247, .18);
  background: #0a0f26;
}
.book-body {
  position: relative;
  width: min(1180px, 92vw);
  aspect-ratio: 1400 / 912; /* 由 JS 按图片原始比例动态覆盖 */
  perspective: 2200px;
  border-radius: 10px;
  overflow: hidden;
  background: #070b1d;
}
.book-body .page {
  position: absolute; top: 0; height: 100%;
  overflow: hidden;
  background: #fff;
}
.book-body .page img {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.page-left  { left: 0;  width: 50%; border-radius: 10px 0 0 10px; }
.page-right { left: 50%; width: 50%; border-radius: 0 10px 10px 0; }

/* 空白封底页 */
.page .page-blank {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f5efe2, #e8dfcc);
  color: #8a7f68; font-size: 14px; letter-spacing: .3em;
}

/* ---------- 翻页纸片 ---------- */
.book-leaf {
  position: absolute; top: 0; height: 100%; width: 50%;
  transform-style: preserve-3d;
  z-index: 5;
  will-change: transform;
}
.book-leaf.leaf-right { left: 50%; transform-origin: left center; }
.book-leaf.leaf-left  { left: 0;   transform-origin: right center; }
.book-leaf.leaf-right { animation: leaf-fwd .75s cubic-bezier(.35,.1,.25,1) forwards; }
.book-leaf.leaf-left  { animation: leaf-back .75s cubic-bezier(.35,.1,.25,1) forwards; }
@keyframes leaf-fwd {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(-180deg); }
}
@keyframes leaf-back {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(180deg); }
}
.leaf-face {
  position: absolute; inset: 0;
  overflow: hidden; border-radius: 6px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: #fff;
}
.leaf-face img {
  width: 100%; height: 100%;
  object-fit: contain; background: #fff;
  pointer-events: none; user-select: none;
}
.leaf-face.leaf-back { transform: rotateY(180deg); }

/* 纸片翻动时的光影 */
.leaf-face::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.18), rgba(0,0,0,0) 40%);
  opacity: 0; transition: opacity .3s;
  pointer-events: none;
}
.book-leaf.flipping .leaf-face::after { opacity: 1; }

/* ---------- 关闭按钮 ---------- */
.book-close {
  position: absolute; top: -52px; right: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(12, 22, 52, .7);
  color: #e8ecff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: transform .25s, background .25s, border-color .25s;
}
.book-close:hover {
  transform: rotate(90deg);
  background: rgba(255, 209, 102, .18);
  border-color: var(--gold);
  color: var(--gold);
}

/* ---------- 底部控制条 ---------- */
.book-controls {
  display: flex; align-items: center; gap: 18px;
}
.book-nav {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(12, 22, 52, .7);
  color: #e8ecff; font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s, background .25s, border-color .25s, color .25s;
}
.book-nav:hover:not(:disabled) {
  transform: translateY(-2px);
  background: rgba(255, 209, 102, .16);
  border-color: var(--gold);
  color: var(--gold);
}
.book-nav:disabled { opacity: .3; cursor: default; }
.book-pageinfo {
  min-width: 84px; text-align: center;
  color: var(--ink-soft); font-size: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}
.book-hint {
  color: rgba(199, 210, 254, .55); font-size: 12px;
  margin: 0; letter-spacing: .05em;
}

/* ---------- 卡片上的「翻阅」提示 ---------- */
.cover-read-tag {
  position: absolute; left: 12px; top: 12px; z-index: 5;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 209, 102, .92);
  color: #2a2107; font-size: 12px; font-weight: 700;
  box-shadow: 0 4px 14px -4px rgba(255, 209, 102, .6);
  transition: transform .3s;
}
.project-card:hover .cover-read-tag { transform: translateY(-2px); }

/* ---------- 移动端：单页模式 ---------- */
@media (max-width: 760px) {
  .book-body { width: min(560px, 92vw); }
  .page-left { display: none; }
  .page-right { left: 0; width: 100%; border-radius: 10px; }
  .book-leaf { width: 100%; left: 0; transform-origin: left center; }
  .book-leaf.leaf-left { transform-origin: right center; }
  .book-hint { display: none; }
  .book-close { top: -50px; }
  .book-stage { gap: 10px; }
}
