/* ============================================================
   翻书模式（Book Mode）
   —— 落地页在桌面端呈现逐页翻阅的画册效果；手机端自动降级为纵向滚动。
   思路：不改动原有 8 个 section 的内容，由 JS 把它们分配进 .book-page，
        本样式只负责「书」的外观、翻页动画与模式切换。
   ============================================================ */

/* 默认（无 JS / 手机端）：书壳完全透明，页面就是普通纵向滚动 —— 保证降级可用 */
.book-shell { display: contents; }
.book-page { display: contents; }
.book-progress, .book-nav, .book-hint { display: none; }

/* ---------- 桌面端翻书模式（由 body.book-mode 激活） ---------- */
body.book-mode {
  overflow: hidden;                    /* 翻书时锁定整页滚动 */
  height: 100vh;
  background:
    radial-gradient(1000px 520px at 82% -8%, rgba(240, 168, 104, .12), transparent 60%),
    radial-gradient(760px 420px at 8% 108%, rgba(224, 118, 74, .07), transparent 55%),
    linear-gradient(160deg, #FBF6EF 0%, #F6EAE0 52%, #F3E2D3 100%);
}

/* 书壳：居中承载当前页 */
body.book-mode .book-shell {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 10;
  perspective: 2400px;                 /* 3D 翻转透视 */
  perspective-origin: 50% 46%;
}

/* 单页：默认堆叠隐藏，仅当前页可见 */
body.book-mode .book-page {
  display: block;
  position: absolute;
  inset: 0;
  overflow-y: auto;                    /* 单页内容超出时页内滚动 */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  transform-origin: left center;
  transform: rotateY(-14deg) scale(.96);
  transition: opacity .5s cubic-bezier(.22,.61,.36,1),
              transform .62s cubic-bezier(.22,.61,.36,1),
              visibility .5s;
  box-shadow: 0 2px 8px -2px rgba(120, 86, 60, .10), 0 40px 100px -24px rgba(120, 86, 60, .32), 0 16px 40px -12px rgba(120, 86, 60, .16);
  will-change: transform, opacity;
}

/* 当前页：正面朝向用户 */
body.book-mode .book-page.is-current {
  opacity: 1;
  visibility: visible;
  transform: none;
  z-index: 3;
}

/* 已翻过的页：向左后方退出（营造"翻过去"的层叠感） */
body.book-mode .book-page.is-flipped {
  opacity: 0;
  visibility: hidden;
  transform: rotateY(16deg) scale(.94);
  transform-origin: right center;
}

/* 页内内容容器：给单页留出呼吸空间 */
body.book-mode .book-page > section {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 0;
}
/* 导航条不参与拉伸：保持自然高度吸附在书页顶部 */
body.book-mode .book-page > header {
  min-height: auto;
  display: block;
  position: sticky;
  top: 0;
  z-index: 12;
  background: rgba(251, 246, 239, .92);
  backdrop-filter: blur(10px);
}
/* section 内的主容器在 flex 拉伸下保持满宽 */
body.book-mode .book-page > section > .container { width: 100%; }
/* 封面页：hero 原生 padding 已足够，书页层不再叠加，确保一屏放下 */
body.book-mode .book-page[data-page="0"] > .hero { padding: 12px 0 24px; }
body.book-mode .book-page[data-page="0"] { display: flex; flex-direction: column; }
body.book-mode .book-page[data-page="0"] > .hero { flex: 1; justify-content: center; }

/* ---------- 翻页控件：右下角按钮组 ---------- */
body.book-mode .book-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 40;
}
body.book-mode .book-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 46px;
  height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(140, 102, 71, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 8px 22px -6px rgba(140, 102, 71, .22);
  transition: transform .2s, box-shadow .2s, opacity .2s, background .2s;
}
body.book-mode .book-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -8px rgba(140, 102, 71, .3);
  background: #fff;
}
body.book-mode .book-btn:disabled { opacity: .34; cursor: not-allowed; }
body.book-mode .book-btn.is-primary {
  background: var(--accent, #E0764A);
  border-color: transparent;
  color: #fff;
}
body.book-mode .book-btn.is-primary:hover:not(:disabled) { background: #CE6A40; }

/* ---------- 页码 / 进度 ---------- */
body.book-mode .book-progress {
  display: flex;
  align-items: center;
  gap: 4px;
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 40;
}
body.book-mode .book-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(140, 102, 71, .26);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: width .3s cubic-bezier(.22,.61,.36,1), background .3s;
}
body.book-mode .book-dot:hover { background: rgba(140, 102, 71, .45); }
body.book-mode .book-dot.is-current {
  width: 22px;
  background: var(--accent, #E0764A);
}
body.book-mode .book-count {
  position: fixed;
  right: 30px;
  bottom: 88px;
  z-index: 40;
  margin: 0;
  font-size: 12px;
  letter-spacing: .06em;
  color: rgba(90, 72, 58, .5);
  font-variant-numeric: tabular-nums;
}

/* ---------- 首次进入的提示条 ---------- */
body.book-mode .book-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  position: fixed;
  left: 50%;
  bottom: 96px;                        /* 避开顶部导航，放在页面下方 */
  transform: translateX(-50%);
  z-index: 45;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(51, 44, 37, .86);
  backdrop-filter: blur(8px);
  color: #FBF6EF;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 10px 26px -8px rgba(0, 0, 0, .3);
  transition: opacity .45s, transform .45s;
}
body.book-mode .book-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 14px);
  pointer-events: none;
}
body.book-mode .book-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .16);
  font-family: inherit;
  font-size: 12px;
}

/* ---------- 翻书模式下页内锚点偏移与导航适配 ---------- */
body.book-mode .book-page > * { scroll-margin-top: 0; }

/* ---------- 翻页动画：进入方向 ---------- */
body.book-mode .book-page.is-current.from-next { animation: bookInNext .62s cubic-bezier(.22,.61,.36,1) both; }
body.book-mode .book-page.is-current.from-prev { animation: bookInPrev .62s cubic-bezier(.22,.61,.36,1) both; }
@keyframes bookInNext {
  from { opacity: 0; transform: rotateY(-13deg) scale(.965) translateX(3%); }
  to   { opacity: 1; transform: none; }
}
@keyframes bookInPrev {
  from { opacity: 0; transform: rotateY(13deg) scale(.965) translateX(-3%); }
  to   { opacity: 1; transform: none; }
}

/* 书脊阴影：增强"这是一本书"的暗示 */
body.book-mode .book-shell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 74px;
  pointer-events: none;
  z-index: 6;
  background: linear-gradient(90deg, rgba(120, 86, 60, .13), rgba(120, 86, 60, 0));
}

/* ---------- 关闭翻书（小屏或用户偏好） ---------- */
body.book-mode .book-shell.book-off { display: contents; }
body.book-mode .book-shell.book-off .book-page { display: contents; }

/* 尊重系统「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
  body.book-mode .book-page,
  body.book-mode .book-page.is-current { animation: none !important; transition: opacity .18s, visibility .18s; transform: none !important; }
}

/* ============================================================
   目录页（总目录 + 附属目录）
   —— 封面之后的展示页：左侧总目录（本页 8 个板块，点击直达），
      右侧附属目录（独立子页面，已上线可点、规划中标注"筹备中"）。
   ============================================================ */

.toc-wrap {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 40px;
  align-items: start;
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}

/* 目录页顶部标题区 */
.toc-head { margin-bottom: 26px; }
.toc-head .eyebrow { margin-bottom: 10px; }
.toc-head h2 { font-size: 32px; line-height: 1.25; margin-bottom: 10px; }
.toc-head p { color: var(--muted, #8A8073); font-size: 15px; max-width: 46em; }

/* ---------- 左：总目录 ---------- */
.toc-col-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(140, 102, 71, .16);
}
.toc-col-title b { font-size: 15px; letter-spacing: .02em; }
.toc-col-title span { font-size: 12px; color: var(--muted, #8A8073); letter-spacing: .04em; }

.toc-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s;
  width: 100%;
  text-align: left;
  background: none;
  font: inherit;
}
.toc-item:hover {
  background: #fff;
  border-color: rgba(140, 102, 71, .16);
  transform: translateX(3px);
}
.toc-item .toc-num {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent, #E0764A);
  letter-spacing: .06em;
}
.toc-item .toc-body { min-width: 0; }
.toc-item .toc-name { font-size: 15px; font-weight: 500; display: block; }
.toc-item .toc-desc {
  font-size: 12.5px;
  color: var(--muted, #8A8073);
  display: block;
  margin-top: 1px;
  line-height: 1.45;
}
.toc-item .toc-arrow {
  font-size: 15px;
  color: rgba(140, 102, 71, .35);
  transition: color .2s, transform .2s;
}
.toc-item:hover .toc-arrow { color: var(--accent, #E0764A); transform: translateX(2px); }

/* ---------- 右：附属目录（独立页面） ---------- */
.toc-sublist { display: flex; flex-direction: column; gap: 10px; }
.toc-sub {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(140, 102, 71, .13);
  text-decoration: none;
  color: var(--ink);
  transition: transform .2s, box-shadow .2s, border-color .2s, background .2s;
}
.toc-sub.is-live:hover {
  transform: translateY(-2px);
  background: #fff;
  border-color: rgba(224, 118, 74, .4);
  box-shadow: 0 14px 30px -12px rgba(140, 102, 71, .3);
}
.toc-sub.is-soon { opacity: .68; cursor: default; }
.toc-sub-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, #FBE7D8, #F6D8C2);
  font-size: 16px;
}
.toc-sub-body { min-width: 0; flex: 1; }
.toc-sub-body b { font-size: 14.5px; display: block; }
.toc-sub-body small {
  font-size: 12.5px;
  color: var(--muted, #8A8073);
  display: block;
  margin-top: 2px;
  line-height: 1.45;
}
.toc-badge {
  flex-shrink: 0;
  align-self: center;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.toc-badge.live { background: rgba(224, 118, 74, .12); color: #C15F35; font-weight: 600; }
.toc-badge.soon { background: rgba(140, 102, 71, .1); color: var(--muted, #8A8073); }

/* 附属目录分组小标题 */
.toc-group { margin-top: 4px; }
.toc-group + .toc-group { margin-top: 12px; }
.toc-group-head {
  font-size: 11.5px;
  letter-spacing: .1em;
  color: rgba(140, 102, 71, .55);
  margin: 6px 0 8px 2px;
  text-transform: uppercase;
}

/* 目录页底部提示 */
.toc-foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px dashed rgba(140, 102, 71, .18);
  font-size: 12.5px;
  color: var(--muted, #8A8073);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toc-foot kbd {
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(140, 102, 71, .1);
  font-family: inherit;
  font-size: 11.5px;
}

/* ---------- 窄屏 / 滚动模式下的目录页 ---------- */
@media (max-width: 1024px) {
  .toc-wrap { grid-template-columns: 1fr; gap: 32px; }
  .toc-head h2 { font-size: 26px; }
}
