/* =========================================================================
 * 趣味学堂 · 书肆立架（方案 A，对齐 _preview_classroom.html?variant=A）
 * 接在 ink.css 之后。第一屏六本等大立书；点书后暗色书主页弹层。
 * 不改 style.css / theme.css / ink.css 原规则。
 * ========================================================================= */

/* 旧第一屏：介绍、子午、规模、金句 —— 钩子 id 仍留在 DOM 给 JS 写数 */
.learn-shelf > .bs-head,
.learn-shelf > .bs-band,
.learn-shelf > .bs-quote {
  display: none !important;
}

.tabpanel.learn,
.learn-shelf,
#bs-books {
  max-width: 100%;
}

.learn-shelf {
  max-width: none;
}

#bs-books.cls-stage,
#bs-books.bs-section {
  margin-top: 0;
  margin-bottom: 12px;
  overflow: visible;
}

#bs-books .bs-sec-head {
  margin: 0 0 10px;
}

#bs-books .bs-sec-sub {
  display: none;
}

.cls-eyebrow {
  margin: 0 0 8px;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 12px;
  letter-spacing: .28em;
  color: #d4a04a;
}

.cls-kicker {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cls-kicker h2 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 600;
  letter-spacing: .18em;
  color: #d6cbb2;
  line-height: 1.25;
}

/* 立架：等宽等高立书，与验收稿 .tome 172×260 一致。
   2026-09-22 修复：线上已 15 本（人纪六部 + 天纪三书 + 评论/跟诊/医案…），
   原 nowrap + flex:0 1 → 1112px 容器里被压成每本 62px，chips 撑破书封外溢。
   改为 wrap + 不收缩：一行放得下 6 本（172×6+12×5=1092），第 7 本起自动换行，
   行内居中，末行（15=6+6+3）也居中，正好是「人纪六部一排」的意象。 */
#bs-grid.cls-shelf,
.cls-shelf {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px 12px;
  max-width: none;
  margin: 0;
  padding: 8px 4px 0;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

.cls-tome {
  box-sizing: border-box;
  width: 172px;
  height: 260px;
  flex: 0 0 172px;   /* 2026-09-22：0 1 → 0 0，禁止被压扁（原 15 本压到 62px） */
  min-width: 0;
  max-width: 172px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  padding: 18px 14px 14px;
  margin: 0;
  text-align: left;
  cursor: pointer;
  color: #f6efe2;
  font-family: inherit;
  border-radius: 3px 10px 8px 3px;
  border: 1px solid rgba(232, 185, 104, .28);
  background: linear-gradient(165deg, #1b1c22 0%, #14161b 78%);
  box-shadow:
    inset 8px 0 0 rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(243, 217, 160, .18),
    10px 18px 28px -12px rgba(0, 0, 0, .55);
  transform-origin: 50% 100%;
  transition: transform .28s cubic-bezier(.16, 1, .3, 1), box-shadow .28s cubic-bezier(.16, 1, .3, 1);
}

.cls-tome[data-group="zhenjiu"] { background: linear-gradient(165deg, #3f1612 0%, #14161b 78%); }
.cls-tome[data-group="shanghan"] { background: linear-gradient(165deg, #3a2714 0%, #14161b 78%); }
.cls-tome[data-group="jingui"]   { background: linear-gradient(165deg, #1c2e3c 0%, #14161b 78%); }
.cls-tome[data-group="hantang"]  { background: linear-gradient(165deg, #2c2114 0%, #14161b 78%); }
.cls-tome[data-group="huangdi"]  { background: linear-gradient(165deg, #2e2614 0%, #14161b 78%); }
.cls-tome[data-group="shennong"] { background: linear-gradient(165deg, #1a2c1c 0%, #14161b 78%); }

.cls-tome:hover,
.cls-tome:focus-visible {
  transform: translateY(-14px) rotate(-1.2deg);
  box-shadow:
    inset 8px 0 0 rgba(0, 0, 0, .35),
    inset 0 1px 0 rgba(243, 217, 160, .28),
    12px 28px 40px -10px rgba(0, 0, 0, .65);
  outline: none;
  border-color: rgba(232, 185, 104, .55);
}

.cls-mark {
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  color: #e8b968;
  text-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}

.cls-name {
  writing-mode: vertical-rl;
  white-space: nowrap;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .18em;
  line-height: 1;
  margin: 12px auto 0;
  flex: none;
  color: #f6efe2;
  max-height: 9em;
  overflow: hidden;
}

.cls-meta {
  margin-top: auto;
  min-width: 0;
}

.cls-meta small {
  display: block;
  color: #f3d9a0;
  font-size: 11.5px;
  letter-spacing: .12em;
}

.cls-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.cls-chip {
  font-size: 10.5px;
  letter-spacing: .04em;
  color: #d6cbb2;
  border: 1px solid rgba(232, 185, 104, .22);
  padding: 2px 6px;
  border-radius: 999px;
}

.cls-rec {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  letter-spacing: .12em;
  color: #241a08;
  background: #e8b968;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.cls-plank {
  height: 18px;
  margin: 0 4px 28px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(232, 185, 104, .28), rgba(80, 60, 30, .15) 40%, #14161b);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  position: relative;
}

.cls-plank::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -10px;
  height: 10px;
  background: radial-gradient(ellipse at 50% 0, rgba(0, 0, 0, .5), transparent 70%);
}

.cls-path {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  color: #a99e86;
  font-size: 13px;
  letter-spacing: .08em;
  padding: 4px 4px 0;
  margin: 0;
  line-height: 1.7;
}

.cls-path b {
  font-family: "Noto Serif SC", "Songti SC", serif;
  color: #d6cbb2;
  font-weight: 600;
}

.cls-path i {
  font-style: normal;
  color: #d4a04a;
  opacity: .7;
}

/* ===== 书主页弹层（对齐验收稿 .mask / .bh）===== */
.book-home {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 11, .72);
  padding: 24px;
  overflow: auto;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.book-home[hidden] {
  display: none;
}
/* theme.css ≥768：body>*:not([hidden]):not(.hd){position:relative;z-index:1}
 * 会把 body 直接子元素从 fixed 拽成 relative，弹层掉到页尾，点书像没反应。
 * 与 .chapmap-ov / .game-modal / .nh-redeem 同一条兜底。 */
body > .book-home:not([hidden]):not(.hd) {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1100 !important;
  display: grid !important;
  place-items: center !important;
  align-content: center !important;
}
.bh-card {
  width: min(560px, 100%);
  max-width: 560px;
  height: auto !important;
  max-height: min(80vh, 420px);
  overflow: auto;
  margin: 0;
  align-self: center !important;
  justify-self: center !important;
  background: #14161b;
  border: 1px solid rgba(232, 185, 104, .28);
  border-radius: 14px;
  padding: 22px 22px 20px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .55);
  position: relative;
}
.bh-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: none;
  color: #a99e86;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.bh-close:hover {
  color: #f6efe2;
  border-color: transparent;
}
.bh-back {
  display: none !important;
}
.bh-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding-right: 28px;
}
.bh-cover {
  width: 52px;
  height: 64px;
  flex: none;
  border-radius: 4px 8px 8px 4px;
  display: grid;
  place-items: center;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
  color: #e8b968;
  background: linear-gradient(160deg, #1b1c22, #101116);
  border: 1px solid rgba(232, 185, 104, .3);
}
.bh-cover-icon {
  font-size: 22px;
  font-weight: 700;
  color: #e8b968;
  font-family: "Noto Serif SC", "Songti SC", serif;
  line-height: 1;
}
.bh-eyebrow {
  display: none;
}
.bh-htxt {
  min-width: 0;
}
.bh-title {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #f6efe2;
  line-height: 1.25;
}
.bh-sub {
  margin: 2px 0 0;
  color: #d4a04a;
  font-size: 13px;
}
.bh-desc {
  margin: 8px 0 16px;
  color: #a99e86;
  font-size: 13.5px;
  line-height: 1.75;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
}
.bh-entries {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
  grid-auto-rows: min-content;
}
.bh-entry {
  display: block !important;
  height: auto !important;
  min-height: 0 !important;
  justify-content: flex-start !important;
  text-align: left;
  padding: 14px 14px 12px !important;
  border-radius: 10px;
  border: 1px solid rgba(232, 185, 104, .22);
  background: #101116;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .2s cubic-bezier(.16, 1, .3, 1);
  box-shadow: none;
  transform: none;
}
.bh-entry::before {
  display: none;
}
.bh-entry:hover,
.bh-entry:focus-visible {
  transform: none;
  box-shadow: none;
  border-color: rgba(232, 185, 104, .55);
  outline: none;
}
.bh-entry-ico,
.bh-entry em {
  display: none;
}
.bh-entry strong {
  display: block;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 16px;
  font-weight: 700;
  color: #f6efe2;
  margin-bottom: 4px;
}
.bh-entry small {
  display: block;
  color: #a99e86;
  font-size: 12px;
  line-height: 1.5;
  font-weight: 400;
}
.bh-entry.disabled {
  opacity: .4;
  cursor: not-allowed;
  background: #101116;
}
.bh-entry.disabled:hover,
.bh-entry.disabled:focus-visible {
  transform: none;
  box-shadow: none;
  border-color: rgba(232, 185, 104, .22);
}

@media (max-width: 900px) {
  #bs-grid.cls-shelf,
  .cls-shelf {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-items: stretch;
    align-items: stretch;
    min-height: 0;
    gap: 10px;
    padding-top: 10px;
  }
  .cls-tome {
    width: 100%;
    max-width: none;
    flex: none;
    height: 210px;
  }
  .cls-mark { font-size: 34px; }
  .bh-entries { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  #bs-grid.cls-shelf,
  .cls-shelf {
    grid-template-columns: repeat(3, minmax(0, 1fr));   /* 2026-09-22：2 列 → 3 列，首屏能完整看到 6 本 */
    gap: 10px 8px;
    padding: 8px 0 0;
  }
  .cls-tome {
    width: 100%;
    max-width: none;
    flex: none;
    height: 152px;
    padding: 12px 8px 10px;
  }
  .cls-mark { font-size: 26px; }
  .cls-name { font-size: 14px; letter-spacing: .1em; max-height: 6em; }
  .cls-chips { display: none; }              /* 3 列太窄，chip 一律不出，只留「N 讲」 */
  .cls-kicker h2 { letter-spacing: .06em; }
  .cls-path { font-size: 12px; letter-spacing: .04em; }
  .cls-tome:hover,
  .cls-tome:focus-visible { transform: translateY(-8px) rotate(-0.6deg); }
  .book-home { padding: 16px 12px; }
  .bh-card { padding: 18px 16px 16px; }
}

/* 本章地图：SVG <g> 本身没有点击面积，命中落到 rect/text 上 */
.cm-node,
.cm-node rect,
.cm-node text,
.cm-leaf,
.cm-dot {
  pointer-events: all;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .cls-tome { transition: none; }
  .cls-tome:hover,
  .cls-tome:focus-visible { transform: none; }
}
