/* ============================================================
   画册阅读器  .hb-flipbook
   默认受 .entry（max-width:820px）限制，书会偏小；
   有画册的页面用 :has() 把文章栏放开到容器宽度。
   老浏览器不支持 :has() 时只是书窄一点，功能不受影响。
   ============================================================ */

.page-wrap:has(.hb-flipbook) .container,
.page-wrap:has(.hb-flipbook) .entry{max-width:none}

/* 放开文章栏后，正文要保持 820px 的阅读宽度，只有画册满宽。
   注意不能写 `.entry > *:not(.hb-flipbook)`：画册外面还套着一层
   .wp-block-post-content，压住外层容器会把画册一起压窄。 */
.page-wrap:has(.hb-flipbook) .entry h2,
.page-wrap:has(.hb-flipbook) .entry h3,
.page-wrap:has(.hb-flipbook) .entry ul,
.page-wrap:has(.hb-flipbook) .entry ol,
.page-wrap:has(.hb-flipbook) .entry blockquote{max-width:820px}

/* 正文段落：不管有没有加 hb-cat-lead 类都居中。
   老内容（后台直接敲的一段话）没有类名，只靠下面这条兜住。 */
.page-wrap:has(.hb-flipbook) .entry p{
  max-width:62ch;
  margin:20px auto 34px;
  text-align:center;
  font-size:16.5px;
  line-height:1.7;
  color:var(--steel);
}

/* ------------------------------------------------------------
   画册页的页头
   标题来自模板的 .page-head，引文与元信息来自正文里的
   .hb-cat-lead / .hb-cat-meta。三者居中在同一条中轴线上，
   和下面 1148px 宽的书体对称；左对齐时书是居中的、字贴着
   容器左边，看起来就是"没对齐"。
   ------------------------------------------------------------ */
.page-wrap:has(.hb-flipbook) .page-head{
  text-align:center;
  margin-bottom:0;
}

.page-wrap:has(.hb-flipbook) .page-head h1{
  font-size:clamp(34px,5vw,58px);
  letter-spacing:.005em;
}

/* 标题下那道橙色短横，代替一整条分割线，轻但有品牌感 */
.page-wrap:has(.hb-flipbook) .page-head::after{
  content:"";
  display:block;
  width:46px;
  height:2px;
  margin:22px auto 0;
  background:var(--accent);
}

.page-wrap:has(.hb-flipbook) .entry .hb-cat-lead{
  max-width:62ch;
  margin:20px auto 0;
  text-align:center;
  font-size:16.5px;
  line-height:1.7;
  color:var(--steel);
}

/* 页数 / 体积 / 语种，细竖线分隔 */
.page-wrap:has(.hb-flipbook) .entry .hb-cat-meta{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  max-width:none;
  margin:22px auto 34px;
  font-size:11.5px;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:var(--steel);
}

.page-wrap:has(.hb-flipbook) .entry .hb-cat-meta span{
  padding:0 18px;
  border-left:1px solid var(--line);
}

.page-wrap:has(.hb-flipbook) .entry .hb-cat-meta span:first-child{padding-left:0;border-left:0}
.page-wrap:has(.hb-flipbook) .entry .hb-cat-meta span:last-child{padding-right:0}

.hb-flipbook{
  width:100%;
  max-width:var(--maxw);
  margin:0 auto;
  font-family:var(--font-body);
}

/* 舞台：书放在里面 */
.hb-fb-stage{
  position:relative;
  background:var(--ink);
  border-radius:10px;
  padding:clamp(10px, 2vw, 26px);
  min-height:clamp(240px, 40vw, 520px);
  display:flex;
  align-items:center;
  justify-content:center;
}

.hb-fb-book{
  width:100%;
  filter:drop-shadow(0 14px 34px rgba(0,0,0,.45));
}

.hb-fb-page{
  background:#fff;
  overflow:hidden;
}

.hb-fb-page img{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
  -webkit-user-drag:none;
  user-select:none;
}

/* 加载遮罩 */
.hb-fb-veil{
  position:absolute;
  inset:0;
  z-index:9;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--ink);
  border-radius:10px;
  color:var(--steel-2);
  font-size:12px;
  letter-spacing:.18em;
  text-transform:uppercase;
  transition:opacity .35s ease;
}
.hb-fb-veil.is-done{opacity:0;pointer-events:none}

/* 控制条 */
.hb-fb-bar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:10px;
  margin-top:16px;
}

.hb-fb-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  height:40px;
  min-width:40px;
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--card);
  color:var(--ink);
  font-family:var(--font-body);
  font-size:13px;
  font-weight:500;
  letter-spacing:.04em;
  text-decoration:none;
  cursor:pointer;
  transition:background .18s, border-color .18s, color .18s, transform .12s;
}

/* .entry a 会把链接刷成橙色带下划线，按钮要盖回来 */
.entry .hb-flipbook .hb-fb-btn{color:var(--ink);text-decoration:none}
.entry .hb-flipbook .hb-fb-btn:hover:not(:disabled){color:#fff}

.hb-fb-btn:hover:not(:disabled){
  background:var(--accent);
  border-color:var(--accent);
  color:#fff;
}

.hb-fb-btn:active:not(:disabled){transform:scale(.96)}

.hb-fb-btn:disabled{opacity:.35;cursor:default}

.hb-fb-btn svg{
  width:16px;
  height:16px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}

/* 页码输入 */
.hb-fb-num{
  display:inline-flex;
  align-items:center;
  gap:6px;
  height:40px;
  padding:0 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:var(--card);
  color:var(--steel);
  font-size:13px;
  font-variant-numeric:tabular-nums;
}

.hb-fb-num input{
  width:38px;
  border:0;
  background:transparent;
  color:var(--ink);
  font-family:var(--font-body);
  font-size:13px;
  font-variant-numeric:tabular-nums;
  text-align:right;
  padding:0;
  -moz-appearance:textfield;
}

.hb-fb-num input::-webkit-outer-spin-button,
.hb-fb-num input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}

.hb-fb-num input:focus{outline:0;color:var(--accent)}

.hb-fb-spacer{flex:1 1 auto}

.hb-fb-hint{
  flex-basis:100%;
  color:var(--steel);
  font-size:12px;
  letter-spacing:.02em;
}

/* 全屏时铺满，书居中。
   .is-fs 是 JS 在 fullscreenchange 时同步加的类，和 :fullscreen 一起用，
   某些嵌入环境（预览面板、iframe）里 :fullscreen 不生效时还有兜底。 */
.hb-flipbook:fullscreen,
.hb-flipbook.is-fs{
  position:fixed;
  inset:0;
  z-index:9999;
  width:100%;
  max-width:none;
  height:100%;
  margin:0;
  transform:none;
  background:var(--ink);
  padding:16px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}
.hb-flipbook:fullscreen .hb-fb-stage,
.hb-flipbook.is-fs .hb-fb-stage{
  background:transparent;
  padding:0;
  flex:1 1 auto;
  min-height:0;
}
.hb-flipbook:fullscreen .hb-fb-bar,
.hb-flipbook.is-fs .hb-fb-bar{
  flex:0 0 auto;
  margin-top:12px;
  justify-content:center;
}
.hb-flipbook:fullscreen .hb-fb-hint,
.hb-flipbook.is-fs .hb-fb-hint{display:none}

@media (max-width:640px){
  .hb-fb-bar{gap:8px;justify-content:center}
  .hb-fb-btn{height:36px;min-width:36px;padding:0 12px;font-size:12px}
  .hb-fb-num{height:36px;padding:0 12px;font-size:12px}
  .hb-fb-spacer{display:none}
  .hb-fb-hint{display:none}

  .page-wrap:has(.hb-flipbook) .page-head::after{margin-top:16px;width:36px}
  .page-wrap:has(.hb-flipbook) .entry .hb-cat-lead{margin-top:16px;font-size:15px;line-height:1.65;max-width:34ch}
  .page-wrap:has(.hb-flipbook) .entry .hb-cat-meta{margin:16px auto 22px;font-size:10.5px;letter-spacing:.12em}
  .page-wrap:has(.hb-flipbook) .entry .hb-cat-meta span{padding:0 11px}
}
