/* ==================================================================
   pages/knowledge.css — 专业知识页（页面层：只写本页布局几何）
   ------------------------------------------------------------------
   依赖：static/base.css（公共层，唯一视觉来源）
        卡片家族 .tree-card/.detail-card/.mm-card/.hot-card/.search-result-card
        .btn/.btn-primary/.btn-outline/.btn-danger/.btn-sm
        .node-tag/.chip 家族 · .toast · .g-empty/.g-skeleton · :focus-visible
   纪律：不用强制权重覆盖（important 关键字 0 处）、无字面色值（只用
        var(--g-*)）、字号 ≥ 12.5px、不写 outline（焦点环交给 base.css）。
   ================================================================== */

/* ---------- 1. 顶部：页标题 + 全站检索 ---------- */
.top-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--g-sp-3);
  margin-bottom: var(--g-sp-4);
}
.top-row .page-title { flex: 0 0 auto; }
.search-box {
  flex: 1 1 260px; min-width: 0;
  display: flex; align-items: center; gap: var(--g-sp-2);
}
.search-box input { flex: 1 1 auto; min-width: 0; }
.search-box .btn { flex: 0 0 auto; }

/* V9.1：知识线是"侧栏 + 文档流"双栏应用页，用宽版心填满横向空间 */
body[data-page="knowledge"] .page-container { max-width: var(--g-page-wide); }

/* ---------- 1b. 知识线总览条 ---------- */
.kb-overview {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--g-sp-3); margin-bottom: var(--g-sp-4);
}
.kb-tile {
  padding: var(--g-sp-3) var(--g-sp-4);
  border: 1px solid var(--g-line); border-radius: var(--g-r-md);
  background: var(--g-surface);
}
.kb-num { font-size: var(--g-fs-2xl); font-weight: 800; color: var(--g-ink); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kb-lab { margin-top: 2px; font-size: var(--g-fs-xs); color: var(--g-mute); }

/* ---------- 2. 主栅格：左侧知识树 290px + 右侧内容 ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: var(--g-sp-4);
  align-items: start;
}
.main-col { display: flex; flex-direction: column; gap: var(--g-sp-4); min-width: 0; }

/* ---------- 3. 知识树卡（V9.1：钉住——滚动正文时树始终在视野内） ---------- */
.tree-card {
  padding: var(--g-sp-3);
  position: sticky; top: calc(var(--g-nav-h) + var(--g-sp-2));
  max-height: calc(100vh - var(--g-nav-h) - var(--g-sp-6));
  overflow-y: auto;
}
.tree-card h3 {
  display: flex; align-items: center; justify-content: space-between; gap: var(--g-sp-2);
  margin-bottom: var(--g-sp-2);
  font-size: var(--g-fs-base); font-weight: 700; color: var(--g-ink-2);
}
.tree-caption { margin-bottom: var(--g-sp-2); }
.tree-search input { width: 100%; font-size: var(--g-fs-sm); }
.tree-tools {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--g-sp-2); margin-top: 6px;
}
.tree-tool {
  padding: 2px 8px; border: 1px solid var(--g-line); border-radius: var(--g-r-pill);
  background: var(--g-surface-2); color: var(--g-mute);
  font-size: var(--g-fs-xs); cursor: pointer;
  transition: border-color var(--g-dur) var(--g-ease), color var(--g-dur) var(--g-ease);
}
.tree-tool:hover { border-color: var(--g-primary); color: var(--g-primary); }
.tree-count { font-size: var(--g-fs-xs); color: var(--g-mute-2); }

.tree-node { user-select: none; }
.tree-label {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: var(--g-r-sm);
  font-size: var(--g-fs-sm); color: var(--g-ink-2); cursor: pointer;
  transition: background var(--g-dur) var(--g-ease), color var(--g-dur) var(--g-ease);
}
.tree-label:hover { background: var(--g-surface-3); }
.tree-label.active { background: var(--g-primary-soft); color: var(--g-primary); font-weight: 700; }
.tree-label.dim { opacity: 0.32; }
.tree-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-caret {
  flex: 0 0 14px; width: 14px; text-align: center;
  color: var(--g-mute-2); font-size: var(--g-fs-xs);
}
.tree-dot {
  flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%;
  border: 1px solid var(--g-mute-2); background: transparent;
}
.tree-dot.on { border-color: var(--g-ok-2); background: var(--g-ok-2); }
.tree-children {
  display: none; margin-left: var(--g-sp-4); padding-left: var(--g-sp-1);
  border-left: 1px dashed var(--g-line);
}
.tree-children.open { display: block; }
.tree-empty { padding: var(--g-sp-4) var(--g-sp-2); color: var(--g-mute); font-size: var(--g-fs-xs); }

/* ---------- 4. 详情区（V9.1：去卡片化——正文是文档不是卡片；
   面包屑 + 标题 + 元信息直接排在页面上，与下方导图/热点卡形成密度对比） ---------- */
.detail-card {
  padding: var(--g-sp-1) 0 var(--g-sp-4);
  background: transparent; border: none; box-shadow: none;
}
.crumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-bottom: var(--g-sp-2); font-size: var(--g-fs-xs); color: var(--g-mute);
}
.crumb-link { color: var(--g-primary); text-decoration: none; cursor: pointer; }
.crumb-link:hover { text-decoration: underline; }
.crumb-sep { color: var(--g-mute-2); }
.crumb-cur { color: var(--g-ink-2); font-weight: 600; }

.detail-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: var(--g-sp-3); margin-bottom: var(--g-sp-2);
}
.detail-title { font-size: var(--g-fs-lg); font-weight: 700; color: var(--g-ink); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-meta {
  display: flex; flex-wrap: wrap; gap: var(--g-sp-3);
  margin-bottom: var(--g-sp-3);
  font-size: var(--g-fs-xs); color: var(--g-mute);
}
.detail-tags { align-items: center; }

.detail-content { font-size: var(--g-fs-base); line-height: 1.9; color: var(--g-ink-2); overflow-wrap: anywhere; }
.detail-content h3, .detail-content strong { color: var(--g-ink); }
.detail-content code {
  padding: 1px 5px; border-radius: 4px;
  background: var(--g-surface-3); font-size: 0.92em;
}
.detail-content pre {
  margin: var(--g-sp-3) 0; padding: var(--g-sp-3);
  border-radius: var(--g-r-sm); background: var(--g-surface-2); overflow-x: auto;
}
.detail-content pre code { padding: 0; background: transparent; }
.detail-content .detail-list { margin: 6px 0; padding-left: 22px; list-style: disc; }
.detail-content blockquote {
  margin: var(--g-sp-2) 0; padding-left: var(--g-sp-3);
  border-left: 3px solid var(--g-primary-3); color: var(--g-mute);
}

/* 4b. 正文分节：定义 / 要点 / 易错点 / 考法 / 学习路径 */
.sec { margin-bottom: var(--g-sp-3); padding: var(--g-sp-3) var(--g-sp-4); border-radius: var(--g-r-sm); border-left: 3px solid var(--g-line); background: var(--g-surface-2); }
.sec:last-child { margin-bottom: 0; }
.sec-head { margin-bottom: 4px; }
.sec-name { font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-ink); }
.sec-body > p:not(:last-child) { margin-bottom: 6px; }
.sec-def { border-left-color: var(--g-primary); background: var(--g-primary-soft); }
.sec-def .sec-name { color: var(--g-primary); }
.sec-point { border-left-color: var(--g-primary-3); }
.sec-trap { border-left-color: var(--g-warn); background: var(--g-warn-bg); }
.sec-trap .sec-name { color: var(--g-warn); }
.sec-exam { border-left-color: var(--g-ok); background: var(--g-ok-bg); }
.sec-exam .sec-name { color: var(--g-ok); }
.sec-path { border-left-color: var(--g-knowledge-2); background: var(--g-knowledge-bg); }
.sec-path .sec-name { color: var(--g-knowledge); }
.sec-note { border-left-color: var(--g-line); }
.sec-plain { margin-bottom: var(--g-sp-3); }
.md-h { margin: var(--g-sp-3) 0 6px; font-size: var(--g-fs-base); font-weight: 700; color: var(--g-ink); }
.md-table { width: 100%; border-collapse: collapse; margin: var(--g-sp-2) 0; font-size: var(--g-fs-sm); }
.md-table th, .md-table td { padding: 6px 10px; border: 1px solid var(--g-line); text-align: left; }
.md-table th { background: var(--g-surface-3); color: var(--g-ink); font-weight: 700; }

/* 4c. 子节点导读卡 */
.child-sec { margin-top: var(--g-sp-5); }
.child-sec-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: var(--g-sp-2); margin-bottom: var(--g-sp-2);
  font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-ink-2);
}
.child-sec-count { font-size: var(--g-fs-xs); font-weight: 400; color: var(--g-mute); }
.child-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--g-sp-3);
}
.child-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--g-sp-3); cursor: pointer;
  border: 1px solid var(--g-line); border-radius: var(--g-r-md);
  background: var(--g-surface-2);
  transition: border-color var(--g-dur) var(--g-ease), box-shadow var(--g-dur) var(--g-ease),
    transform var(--g-dur-2) var(--g-ease);
}
.child-card:hover { border-color: var(--g-primary); transform: translateY(-2px); box-shadow: var(--g-sh-sm); }
.child-card.is-empty { background: var(--g-surface); }
.child-card.is-empty .child-card-desc { color: var(--g-mute-2); }
.child-card-title { font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-ink); }
.child-card-flag {
  margin-left: 6px; padding: 1px 6px; border-radius: var(--g-r-pill);
  background: var(--g-warn-bg); color: var(--g-warn); font-size: var(--g-fs-xs); font-weight: 600;
}
.child-card-desc { font-size: var(--g-fs-xs); color: var(--g-mute); line-height: 1.6; }
.child-card-points { margin: 2px 0 0; padding-left: 15px; list-style: disc; }
.child-card-points li { font-size: var(--g-fs-xs); color: var(--g-ink-2); line-height: 1.55; }
.child-card-foot { margin-top: auto; padding-top: 4px; font-size: var(--g-fs-xs); color: var(--g-mute-2); }

/* 4d. 相关题目（三线联动） */
.rel-sec { margin-top: var(--g-sp-4); padding: var(--g-sp-3) var(--g-sp-4); border: 1px solid var(--g-line); border-radius: var(--g-r-md); background: var(--g-surface-2); }
.rel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--g-sp-2); margin-bottom: var(--g-sp-2);
  font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-ink-2);
}
.rel-list { display: flex; flex-direction: column; gap: 4px; }
.rel-item { display: flex; gap: var(--g-sp-2); align-items: baseline; font-size: var(--g-fs-xs); color: var(--g-ink-2); }
.rel-type {
  flex: 0 0 auto; padding: 1px 7px; border-radius: var(--g-r-pill);
  background: var(--g-surface-3); color: var(--g-mute); font-size: var(--g-fs-xs);
}
.rel-stem { flex: 1 1 auto; min-width: 0; }

/* 4e. 上一个 / 下一个 */
.node-nav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--g-sp-2); margin-top: var(--g-sp-5); padding-top: var(--g-sp-3);
  border-top: 1px solid var(--g-line);
}
.node-nav .btn { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-nav-pad { flex: 0 0 0; }

/* 4f. 掌握度小圆点（刷题正确率） */
.dot-mastery { display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; }
.dot-mastery.good { background: var(--g-ok); }
.dot-mastery.mid { background: var(--g-warn); }
.dot-mastery.bad { background: var(--g-danger); }

/* 编辑区 */
.edit-area { min-height: 300px; line-height: 1.8; }
.edit-label { margin-top: var(--g-sp-3); }
.edit-actions { display: flex; flex-wrap: wrap; gap: var(--g-sp-2); margin-top: var(--g-sp-4); }
.tag-select { display: flex; flex-wrap: wrap; gap: var(--g-sp-2); }
.tag-opt {
  display: inline-flex; align-items: center;
  padding: 3px 12px; border: 1px solid var(--g-line); border-radius: var(--g-r-pill);
  background: var(--g-surface); color: var(--g-mute);
  font-size: var(--g-fs-xs); font-weight: 600; cursor: pointer;
  transition: border-color var(--g-dur) var(--g-ease), color var(--g-dur) var(--g-ease),
    background var(--g-dur) var(--g-ease);
}
.tag-opt:hover { border-color: var(--g-primary); color: var(--g-primary); }
.tag-opt.on { background: var(--g-primary-soft); border-color: var(--g-primary); color: var(--g-primary); }

.children-row { display: flex; flex-wrap: wrap; gap: var(--g-sp-2); margin-top: var(--g-sp-4); }
.child-chip {
  padding: 4px 12px; border: 1px solid var(--g-line); border-radius: var(--g-r-pill);
  background: var(--g-surface-2); color: var(--g-ink-2);
  font-size: var(--g-fs-xs); cursor: pointer;
  transition: border-color var(--g-dur) var(--g-ease), color var(--g-dur) var(--g-ease);
}
.child-chip:hover { border-color: var(--g-primary); color: var(--g-primary); }

/* 引导卡主按钮：长教材名可换行，不撑破卡片（修 4-23） */
.guide-btn {
  max-width: 100%; height: auto; min-height: 36px; padding: 8px 16px;
  white-space: normal; text-align: center;
}

/* ---------- 5. 思维导图卡 ---------- */
.mm-card { padding: var(--g-sp-4); }
.mm-card.is-collapsed { display: none; }
.mm-card h3 {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--g-sp-2);
  margin-bottom: var(--g-sp-2);
  font-size: var(--g-fs-base); font-weight: 700; color: var(--g-ink-2);
}
.mm-hint { font-size: var(--g-fs-xs); font-weight: 400; color: var(--g-mute); }
.mm-actions { margin-left: auto; }
#mindmap-svg { width: 100%; height: 420px; }
.mm-fallback { display: none; font-size: var(--g-fs-sm); color: var(--g-ink-2); white-space: pre-wrap; }
.mm-tip { margin-top: 6px; font-size: var(--g-fs-xs); color: var(--g-mute-2); }

/* ---------- 6. 研究热点卡 ---------- */
.hot-card { padding: var(--g-sp-4); }
.hot-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--g-sp-2); margin-bottom: var(--g-sp-3);
}
.hot-head h3 { font-size: var(--g-fs-base); font-weight: 700; color: var(--g-ink-2); }
.hot-hint { font-size: var(--g-fs-xs); font-weight: 400; color: var(--g-mute); }
.hot-head-actions { display: flex; flex-wrap: wrap; gap: var(--g-sp-2); }
.hot-trend {
  margin-bottom: var(--g-sp-3); padding: var(--g-sp-3);
  border: 1px solid var(--g-line); border-radius: var(--g-r-md); background: var(--g-surface-2);
  height: 240px;
}
.hot-row {
  display: flex; align-items: center; gap: var(--g-sp-2);
  margin-bottom: var(--g-sp-2); padding: 3px 6px; border-radius: var(--g-r-sm);
  cursor: pointer;
  transition: background var(--g-dur) var(--g-ease);
}
.hot-row:hover { background: var(--g-surface-3); }
.hot-rank {
  flex: 0 0 18px; width: 18px; text-align: center;
  font-size: var(--g-fs-xs); font-weight: 700; color: var(--g-mute-2);
}
.hot-kw {
  flex: 0 0 132px; width: 132px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
  font-size: var(--g-fs-sm); color: var(--g-ink-2);
}
.hot-bar-bg {
  flex: 1 1 auto; min-width: 0; height: 18px;
  border-radius: var(--g-r-pill); background: var(--g-surface-3); overflow: hidden;
}
.hot-bar {
  height: 100%; border-radius: var(--g-r-pill);
  background: linear-gradient(90deg, var(--g-primary-3), var(--g-primary-2));
}
.hot-num { flex: 0 0 30px; font-size: var(--g-fs-xs); font-weight: 700; color: var(--g-primary); }
.hot-tag {
  flex: 0 0 auto; padding: 1px 8px;
  border: 1px solid var(--g-line); border-radius: var(--g-r-pill);
  background: var(--g-surface); color: var(--g-primary);
  font-size: var(--g-fs-xs); font-weight: 600; cursor: pointer;
}
.hot-tag:hover { border-color: var(--g-primary); }
.hot-note { margin-top: 6px; font-size: var(--g-fs-xs); color: var(--g-mute); }
.hot-note a { color: var(--g-primary); font-weight: 600; text-decoration: none; }
.hot-note a:hover { text-decoration: underline; }

/* ---------- 7. 检索结果（四分区） ---------- */
#search-results { margin-bottom: var(--g-sp-4); }
.sr-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--g-sp-2); margin-bottom: var(--g-sp-3);
}
.sr-head-tip { font-size: var(--g-fs-sm); color: var(--g-ink-2); }
.search-result-card { padding: var(--g-sp-5); margin-bottom: var(--g-sp-3); }
.search-result-card h4 { margin-bottom: var(--g-sp-3); font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-mute); }
.sr-item {
  margin-bottom: 7px; padding: 9px 12px;
  border: 1px solid var(--g-line); border-radius: var(--g-r-sm);
  font-size: var(--g-fs-sm); color: var(--g-ink-2);
}
.sr-item:last-child { margin-bottom: 0; }
.sr-item a { color: var(--g-primary); font-weight: 600; text-decoration: none; }
.sr-item a:hover { text-decoration: underline; }
.sr-preview { margin-top: 2px; font-size: var(--g-fs-xs); color: var(--g-mute); }
.sr-badge {
  margin-left: 6px; padding: 1px 6px; border-radius: var(--g-r-pill);
  background: var(--g-surface-3); color: var(--g-mute); font-size: var(--g-fs-xs);
}
.sr-go { margin-left: 6px; font-size: var(--g-fs-xs); }
.sr-note {
  margin-bottom: var(--g-sp-3); padding: 9px 12px;
  border: 1px dashed var(--g-line); border-radius: var(--g-r-sm);
  font-size: var(--g-fs-xs); color: var(--g-mute);
}
.sr-note a { color: var(--g-primary); font-weight: 600; text-decoration: none; }
.sr-note a:hover { text-decoration: underline; }

/* 占位节点（尚未拆分到考点层级）：给学生看的说明，不是正文 */
.ph-box {
  padding: var(--g-sp-4); border: 1px dashed var(--g-line); border-radius: var(--g-r-md);
  background: var(--g-surface-2);
}
.ph-title { margin-bottom: 4px; font-size: var(--g-fs-sm); font-weight: 700; color: var(--g-ink-2); }
.ph-desc { font-size: var(--g-fs-sm); color: var(--g-mute); line-height: 1.8; }
.ph-desc a { color: var(--g-primary); font-weight: 600; text-decoration: none; }
.ph-desc a:hover { text-decoration: underline; }

/* ---------- 8. 响应式（与公共层 860px 断点对齐） ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .tree-card { max-height: 40vh; }
  .detail-card { padding: var(--g-sp-1) 0 var(--g-sp-3); }
  .search-result-card { padding: var(--g-sp-4); }
  #mindmap-svg { height: 320px; }
  .kb-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hot-trend { height: 220px; }
}
@media (max-width: 560px) {
  .top-row { gap: var(--g-sp-2); }
  .search-box { flex-basis: 100%; }
  .hot-row { gap: var(--g-sp-1); }
  .hot-kw { flex-basis: 88px; width: 88px; }
  .hot-rank { display: none; }
  .child-grid { grid-template-columns: minmax(0, 1fr); }
  .node-nav .btn { max-width: 100%; }
}
