/* =====================================================================
   导文 daowen · 图书频道页  book2.css（仅图书频道页使用）
   依赖 index2.css 的色彩令牌与书卡/页脚等基础样式，需在其后引入
   ===================================================================== */

/* ---------- 面包屑 ----------ddddd */
.breadcrumb { display: flex; align-items: center; font-size: 13px; color: var(--text-faint); padding: 20px 0 4px; }
.breadcrumb > * + * { margin-left: 8px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border-strong); }

/* ---------- 频道布局 ---------- */
.channel { display: grid; grid-template-columns: 240px 1fr; gap: 32px; padding: 16px 0 32px; align-items: start; }
/* 允许网格子项收缩，避免内容把列撑破导致右侧留白 / 横向滚动 */
.channel > * { min-width: 0; }
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px; margin-bottom: 18px; }
.side-card h4 { font-size: 14px; font-weight: 700; letter-spacing: 1px; margin-bottom: 12px; color: var(--text-sub); }

/* 分类筛选 */
.cat-filter li { border-radius: var(--radius-sm); transition: background .18s var(--ease); }
.cat-filter li a { display: flex; align-items: center; padding: 7px 20px; font-size: 16px; color: var(--text); }
.cat-filter li a .dot { margin-right: 10px; }
.cat-filter li:hover { background: var(--surface-2); }
.cat-filter li.on { background: var(--primary-soft); }
.cat-filter li.on a { color: var(--primary-hover); font-weight: 600; }
.cat-filter .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.cat-filter .cnt { margin-left: auto; font-size: 12px; color: var(--text-faint); }

/* 我的书架（侧栏） */
.fav-side-list li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.fav-side-list li:last-child { border-bottom: none; }
.fav-side-list a { display: block; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fav-side-list a:hover { color: var(--primary); }
.fav-side-empty { font-size: 13px; color: var(--text-faint); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar > * + * { margin-left: 14px; }
.toolbar .result-count { color: var(--text-sub); font-size: 14px; margin-right: auto; }

/* ---------- 子分类胶囊（分类页） ---------- */
.cate-chips { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.cate-chips .chip {
  margin-right: 10px; padding: 6px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 14px; color: var(--text-sub);
  transition: all .18s var(--ease);
}
.cate-chips .chip:hover { border-color: var(--primary); color: var(--primary); }
.cate-chips .chip.on { background: var(--primary); border-color: var(--primary); color: #fdfaf3; font-weight: 600; }

/* ---------- 电子书主页 ---------- */
/* 侧栏书籍信息 */
.book-side-info { text-align: center; }
.book-side-info .cover-wrap { width: 120px; height: 160px; margin: 0 auto 12px; }
.book-side-info .cover-wrap::before { display: none; }
.book-side-info h1 { font-family: var(--font-display); font-size: 17px; line-height: 1.5; margin-bottom: 6px; }
.book-side-info .side-author { font-size: 13px; color: var(--text-sub); }
/* 侧栏目录（内部滚动） */
.toc-list { max-height: 56vh; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.toc-list li a {
  display: block; padding: 7px 10px; font-size: 13px; color: var(--text);
  border-radius: var(--radius-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc-list li a:hover { background: var(--surface-2); color: var(--primary); }
.toc-list .toc-num { color: var(--text-faint); font-size: 12px; margin-right: 6px; }

/* 简介区 */
.intro-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px 28px; margin-bottom: 24px; }
.intro-card h1 { font-family: var(--font-display); font-size: 22px; margin-bottom: 10px; }
.intro-card .intro-meta { display: flex; align-items: center; font-size: 13px; color: var(--text-faint); margin-bottom: 12px; flex-wrap: wrap; }
.intro-card .intro-meta > * + * { margin-left: 16px; }
.intro-card .intro-meta a { color: var(--text-sub); }
.intro-card .intro-meta a:hover { color: var(--primary); }
.intro-card p { font-size: 14px; color: var(--text-sub); }

/* 章节卡 */
.chapter-card {
  display: flex; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 18px 20px; margin-bottom: 14px;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.chapter-card > * + * { margin-left: 16px; }
.chapter-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.chapter-card .chapter-num {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
  display: grid; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; font-family: var(--font-display);
}
.chapter-card .chapter-body { flex: 1; min-width: 0; }
.chapter-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.chapter-card h3 a:hover { color: var(--primary); }
.chapter-card .chapter-summary {
  font-size: 13px; color: var(--text-sub);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chapter-card .read-btn {
  flex-shrink: 0; align-self: center; padding: 7px 18px; border-radius: 999px;
  background: var(--primary); color: #fdfaf3; font-size: 13px; font-weight: 600;
  transition: background .2s var(--ease);
}
.chapter-card .read-btn:hover { background: var(--primary-hover); }

/* ---------- 章节阅读页 ---------- */
/* 正文卡 */
.reader-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 32px 40px; }
.reader-card h1 { font-family: var(--font-display); font-size: 24px; line-height: 1.5; margin-bottom: 12px; }
.reader-meta { display: flex; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-faint); padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.reader-meta > * + * { margin-left: 16px; }
.reader-meta a { color: #ff0000; }
.reader-meta a:hover { color: var(--primary); }
.reader-content { font-size: 16px; line-height: 1.9; }
.reader-content p { margin-bottom: 1em; }
.reader-content img.pic { display: block; margin: 16px auto; max-width: 100%; border-radius: var(--radius-sm); }
.reader-content a.keywordlink { color: var(--primary); border-bottom: 1px dashed var(--primary); }

/* 查看所有图片按钮 */
.load-images-wrap { text-align: center; margin: 0 0 20px; }
.load-images-btn { padding: 10px 28px; border-radius: 999px; background: var(--primary); color: #fdfaf3; font-size: 14px; font-weight: 600; transition: background .2s var(--ease); }
.load-images-btn:hover { background: var(--primary-hover); }
.load-images-btn:disabled { background: var(--text-faint); cursor: default; }

/* 上一章/下一章 */
.chapter-nav { display: flex; justify-content: space-between; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.chapter-nav .nav-link {
  flex: 1; max-width: 48%; padding: 12px 18px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); font-size: 14px; color: var(--text-sub);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: all .18s var(--ease);
}
.chapter-nav .nav-link:hover { border-color: var(--primary); color: var(--primary); }
.chapter-nav .nav-link.next { text-align: right; margin-left: auto; }

/* 目录当前章高亮 */
.toc-list li a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.toc-list li.toc-hide { display: none; }
.toc-more { display: block; text-align: center; font-size: 13px; color: var(--text-sub); padding: 8px; border-radius: var(--radius-sm); }
.toc-more:hover { color: var(--primary); background: var(--surface-2); }

/* 阅读页：侧栏拉满列高（否则 sticky 没有滑动空间） */
.reader-page .sidebar { align-self: stretch; }

/* 阅读页：书籍信息不吸附，只有目录卡吸附；移动端抽屉模式不受影响 */
@media (min-width: 993px) {
  .toc-sticky { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; }
}

/* 底部工具栏 */
.bottom-toolbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  display: flex; justify-content: center; padding: 10px 16px;
  background: rgba(245, 239, 227, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.bottom-toolbar > * + * { margin-left: 8px; }
.toolbar-btn {
  display: inline-flex; align-items: center; padding: 8px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--primary); color: #fdfaf3;
  border: 1px solid var(--primary); text-decoration: none; box-shadow: var(--shadow-sm); transition: all .18s var(--ease);
}
.toolbar-btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fdfaf3; }
.toolbar-btn .toolbar-ico { flex: 0 0 auto; margin-right: 6px; }
body.has-bottom-toolbar { padding-bottom: 80px; }

/* 移动端目录切换悬浮按钮（左侧中间，箭头） */
.toc-fab {
  display: none;
  position: fixed; left: 0; top: 50%; transform: translateY(-50%);
  z-index: 210;
  width: 34px; height: 64px;
  align-items: center; justify-content: center;
  background: var(--primary); color: #fdfaf3;
  border: none; border-radius: 0 12px 12px 0;
  box-shadow: var(--shadow-md);
  cursor: pointer; font-size: 22px; line-height: 1;
  transition: left .25s var(--ease);
}
.toc-fab:hover { background: var(--primary-hover); }

/* 复制验证码弹窗 */
.copy-modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 300; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(43, 36, 32, .45); }
.copy-modal.show { display: flex; }
.copy-box { position: relative; width: 340px; max-width: 100%; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; text-align: center; }
.copy-box .copy-qr { width: 180px; margin: 0 auto 14px; border-radius: var(--radius-sm); }
.copy-box .copy-tip { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }
.copy-box .copy-input-row { display: flex; }
.copy-box .copy-input-row .copy-ok { margin-left: 8px; }
.copy-box input {
  flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); font-size: 14px; font-family: inherit; color: var(--text);
}
.copy-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.copy-box input.input-error { border-color: var(--danger); }
.copy-box .copy-ok { padding: 10px 18px; border-radius: var(--radius-md); background: var(--primary); color: #fdfaf3; font-size: 14px; font-weight: 600; }
.copy-box .copy-ok:hover { background: var(--primary-hover); }
.copy-box .copy-close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border-radius: 50%; color: var(--text-faint); font-size: 14px; }
.copy-box .copy-close:hover { background: var(--surface-2); color: var(--text); }
.copy-box .copy-success { padding: 12px 0; color: var(--success); font-size: 15px; font-weight: 600; }

/* 移动端：侧栏变抽屉（仅阅读页） */
@media (max-width: 992px) {
  .reader-page .channel { grid-template-columns: minmax(0, 1fr); }
  .reader-page .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 200;
    background: var(--bg); padding: 16px; overflow-y: auto;
    transform: translateX(-105%); transition: transform .25s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .reader-page .sidebar.sidebar-active { transform: none; }
  .toc-fab { display: flex; }
  .toc-fab.open { left: 280px; }
  .reader-card { padding: 22px 20px; }
}

/* 下一章自动加载提示 */
.chapter-loader {
  display: flex; align-items: center; justify-content: center;
  padding: 22px 0; font-size: 13px; color: var(--text-faint);
}
.chapter-loader > * + * { margin-left: 10px; }
.chapter-loader .loader-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
  animation: loaderPulse 1s var(--ease) infinite;
}
@keyframes loaderPulse {
  0%, 100% { transform: scale(.6); opacity: .4; }
  50% { transform: scale(1); opacity: 1; }
}
.chapter-loader.load-end { color: var(--text-sub); }
.retry-next-btn {
  padding: 10px 26px; border-radius: 999px;
  background: var(--primary); color: #fdfaf3; border: 1px solid var(--primary);
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .18s var(--ease);
}
.retry-next-btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* 已加载章节的起始分隔带 */
.chapter-sep {
  display: flex; align-items: center; margin: 26px 0 18px;
  font-family: var(--font-display); font-size: 14px; color: var(--text-sub); letter-spacing: 1px;
}
.chapter-sep::before, .chapter-sep::after {
  content: ""; flex: 1; height: 1px; background: var(--border-strong);
}
.chapter-sep::before { margin-right: 14px; }
.chapter-sep::after { margin-left: 14px; }

/* ---------- 书卡补充（等高点 + 作者行 + 收藏按钮） ---------- */
.book-card h3 { min-height: 48px; }
.book-card .author { height: 22px; font-size: 13px; color: var(--text-sub); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 新增：确保底部的标签和日期被推到底部 */
.book-card .meta {
    margin-top: auto; /* 利用 flex 自动外边距将底部元素推到最下方 */
    padding-top: 8px; /* 避免和上面的内容贴得太紧 */
    /* 如果需要底部高度完全一致，可以给 meta 设定一个固定高度 */
    /* height: 24px; */
}
.book-card .fav-btn {
  position: absolute; top: -16px;right: -10px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; display: grid; align-items: center; justify-content: center;
  background: rgba(253, 250, 243, .92); border: 1px solid var(--border); color: var(--text-sub);
  box-shadow: var(--shadow-sm); transition: all .2s var(--ease);
}
.book-card .fav-btn:hover { color: var(--primary); border-color: var(--primary); }
.book-card .fav-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.book-card .fav-btn .ic { font-size: 16px; }

/* 头部收藏角标 */
.header-actions { display: flex; align-items: center; }
.header-actions > * + * { margin-left: 10px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%;
  display: grid; align-items: center; justify-content: center; color: var(--text-sub); border: 1px solid transparent;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.icon-btn:hover { background: var(--surface); color: var(--primary); }
.icon-btn .badge {
  position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--primary); color: #fff; font-size: 10px; line-height: 16px;
  text-align: center; display: none;
}
.icon-btn .badge.show { display: block; }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .channel { grid-template-columns: 200px 1fr; gap: 24px; }
}
@media (max-width: 768px) {
  .channel { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 12px 0 24px; }
  .channel > * { min-width: 0; }
  /* 侧栏分类：移动端胶囊换行平铺，全部可见不遮挡 */
  .side-card { padding: 12px 14px; margin-bottom: 12px; }
  .side-card h4 { margin-bottom: 8px; }
  .cat-filter { display: flex; flex-wrap: wrap; }
  .cat-filter li { border: 1px solid var(--border); border-radius: 999px; margin: 0 8px 8px 0; }
  .cat-filter li a { padding: 5px 12px; font-size: 13px; }
  .cat-filter li a .dot { margin-right: 6px; }
  .cat-filter .cnt { display: none; }
  /* 工具条收紧 */
  .toolbar { padding: 4px 0; }
}

/* ---------- 社区（底部入口 + 右侧抽屉） ---------- */
.community-mask {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 290;
  background: rgba(0, 0, 0, .32); opacity: 0; pointer-events: none;
  transition: opacity .28s var(--ease);
}
.community-mask.show { opacity: 1; pointer-events: auto; }

.community-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 300;
  width: 340px; max-width: 88vw; background: var(--surface);
  box-shadow: var(--shadow-lg); transform: translateX(120%);
  transition: transform .28s var(--ease); display: flex; flex-direction: column;
}
.community-drawer.open { transform: translateX(0); }

.community-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.community-head .community-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: 1px; color: var(--text); }
.community-close {
  position: absolute; left: 0; top: 50%; transform: translate(-100%, -50%);
  width: 34px; height: 64px; border-radius: 12px 0 0 12px;
  background: var(--primary); color: #fdfaf3; border: none;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
}
.community-close:hover { background: var(--primary-hover); }

.community-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.community-item { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.community-item:last-child { border-bottom: none; }
.community-item .ci-nick { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.community-item .ci-content { font-size: 14px; color: var(--text); line-height: 1.7; word-break: break-word; }
.community-item .ci-time { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.community-empty { text-align: center; color: var(--text-faint); font-size: 13px; padding: 30px 0; }
.community-loading { text-align: center; color: var(--text-faint); font-size: 13px; padding: 10px 0; }

.community-form { padding: 12px 16px; border-top: 1px solid var(--border); }
.community-nick { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.community-nick strong { color: var(--primary); margin: 0 2px; }
.community-form textarea {
  width: 100%; height: 78px; resize: none; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.6; color: var(--text); background: var(--surface-2);
  font-family: inherit; box-sizing: border-box;
}
.community-form textarea:focus { outline: none; border-color: var(--primary); }
.community-submit {
  display: block; width: 100%; margin-top: 10px; padding: 10px 0;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--primary); color: #fdfaf3; font-size: 14px; font-weight: 600;
  transition: background .18s var(--ease); font-family: inherit;
}
.community-submit:hover { background: var(--primary-hover); }
.community-submit:disabled { background: var(--text-faint); cursor: default; }
