/* ==========================================================
   数据挖掘 · 可视化复习 — 样式表
   ========================================================== */
:root {
  --navy: #10233B;
  --accent: #1D4ED8;
  --accent2: #0F766E;
  --exam: #B45309;
  --bg: #F4F7FA;
  --card: #FFFFFF;
  --text: #233346;
  --muted: #5B6B7F;
  --border: #D8E1EA;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  gap: 18px;
  align-items: center;
  position: sticky; top: 0; z-index: 50;
  border-bottom: 2px solid var(--accent);
}
.logo {
  width: 44px; height: 44px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-weight: 800; font-size: 20px; color: #fff;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.4px; }
.sub { margin: 2px 0 0; font-size: 12px; color: #B8C6D9; }
.tabs { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .tab {
  background: transparent; border: 1px solid rgba(255,255,255,.25); color: #cfd8e8;
  padding: 6px 14px; border-radius: 20px; font-size: 13px; cursor: pointer;
}
.tabs .tab.active { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.4); }
.tabs .tab:hover { border-color: rgba(255,255,255,.5); }

.global-progress {
  display: flex; gap: 12px; align-items: center; padding: 8px 20px;
  background: #fff; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--muted);
}
.gp-bar { flex: 1; height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.gp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .4s; }
.next-btn {
  background: var(--accent2); color: #fff; border: none; padding: 6px 14px; border-radius: 20px;
  font-size: 12.5px; cursor: pointer; font-weight: 600;
}
.next-btn:hover { filter: brightness(.9); }

main { padding: 18px 20px; max-width: 1280px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ===== 学习路径 ===== */
.path-hero {
  background: linear-gradient(135deg, var(--navy) 60%, #163350 100%);
  color: #fff; padding: 26px 28px; border-radius: var(--radius);
  margin-bottom: 18px; position: relative;
  overflow: hidden;
}
.path-hero::before {
  content:""; position:absolute; inset:-40px -40px auto auto;
  background: radial-gradient(circle at 100% 20%, rgba(29,78,216,.25), transparent 60%);
}
.path-hero h2 { margin: 0 0 8px; font-size: 22px; }
.path-hero p { margin: 0 0 14px; opacity: .92; font-size: 14px; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 700; letter-spacing: .3px; vertical-align: middle;
}
.badge.exam { background: #FDCD78; color: #7a3a00; }
.hero-stats { display: flex; gap: 24px; font-size: 13px; opacity: .85; margin-top: 8px; }
.path-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

/* ===== 卡片 / 章节 ===== */
.chapter-list { display: flex; flex-direction: column; gap: 8px; }
.chapter-btn {
  width: 100%; text-align: left; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-size: 14px; cursor: pointer;
}
.chapter-btn:hover { border-color: var(--accent); color: var(--accent); }
.chapter-btn.active { background: #E8F0FF; border-color: var(--accent); font-weight: 700; color: var(--navy); }
.chapter-btn .k { font-weight: 600; }
.chapter-btn .v { float: right; font-size: 12px; color: var(--muted); background: #f0f4f9; padding: 2px 8px; border-radius: 10px; }

/* 分章学习：侧栏 + 主内容两列 */
#view-learn.active { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.sidebar { height: fit-content; position: sticky; top: 96px; }
.content { min-height: 520px; min-width: 0; }
.empty-state {
  display: grid; place-items: center; text-align: center;
  padding: 60px 24px; color: var(--muted); min-height: 480px;
}
.empty-icon { font-size: 40px; opacity: .4; margin-bottom: 10px; }
.empty-state h2 { margin: 0 0 6px; color: var(--text); }

/* 知识点卡片 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; position: relative; overflow: hidden;
}
.card::before { content:""; position:absolute; left:0; top:0; width:4px; height:100%; background: var(--accent2); opacity: 0; transition: opacity .2s; }
.card.exam::before { background: var(--exam); opacity: 1; }
.card.exam { border-left: 4px solid var(--exam); padding-left: 12px; }
.card .card-header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.card .card-title { font-weight: 700; font-size: 15px; color: var(--navy); }
.card .card-tag { font-size: 11px; padding: 1px 7px; border-radius: 10px; margin-left: auto; font-weight: 700; }
.card .tag-exam { background: #FDE9D4; color: var(--exam); }
.card .tag-new { background: #E2E8F0; color: var(--muted); }
.card .card-body { font-size: 14px; line-height: 1.55; color: #374759; margin-bottom: 10px; }
.card .card-body p { margin: 0 0 7px; }
.card .formula {
  background: #f0f4f9; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px;
  margin: 8px 0; font-size: 13px; color: var(--navy); font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.card .tagline { font-size: 12px; color: var(--muted); border-top: 1px solid #EEF2F7; margin-top: 8px; padding-top: 7px; }

/* 例题 / 新题 */
.q-wrap { background: #F8FAFC; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 10px; }
.q-wrap .q-head { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-bottom: 6px; }
.q-wrap .q-body { font-size: 14px; line-height: 1.55; color: #374759; white-space: pre-wrap; }
.q-wrap .q-ans {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed #C9D6E3; font-size: 14px; color: var(--accent2);
  display: none; line-height: 1.55;
}
.q-wrap .q-ans.show { display: block; }
.ans-btn {
  background: transparent; border: 1px solid var(--border); color: var(--accent);
  padding: 4px 10px; border-radius: 10px; font-size: 12px; cursor: pointer; margin-left: 8px;
}
.ans-btn:hover { background: #EEF4FF; }
.q-wrap .done-tag { font-size: 11.5px; background: #D1FAE5; color: #065F46; padding: 1px 7px; border-radius: 10px; font-weight: 700; }

.nav { margin-top: 14px; display: flex; gap: 10px; }
.nav-btn {
  padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 14px; cursor: pointer;
}
.nav-btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-btn:disabled { opacity: .5; cursor: not-allowed; }

/* 考点 / 新题列表 */
.list-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.item-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.item-card .item-q { font-size: 14px; line-height: 1.5; margin-bottom: 8px; color: #374759; white-space: pre-wrap; }
.item-card .item-meta { font-size: 12px; color: var(--muted); border-top: 1px solid #EEF2F7; padding-top: 7px; display: flex; gap: 12px; }

footer { background: #fff; border-top: 1px solid var(--border); padding: 12px 20px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.link-btn { background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--accent2); }
.search-box { margin-bottom: 12px; }
.search-box input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }

/* 进度页专用 */
.drill-count { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

@media (max-width: 900px) {
  #view-learn.active { grid-template-columns: 1fr; }
  .sidebar { order: 2; position: static; }
  .tabs { order: 3; width: 100%; justify-content: center; margin-top: 10px; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 10px; }
}
/* 矩阵/代码块：保留空格对齐 */
.q-wrap .q-ans pre.mat, .item-card pre.mat {
  font-family: Consolas, 'Courier New', monospace; font-size: 13px; line-height: 1.5;
  background: #F6F8FB; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; margin: 8px 0; overflow-x: auto; color: #10233B; white-space: pre;
}



/* ==========================================================
   移动端适配（手机竖屏 ≤640px）
   策略：叠加增强，不改动桌面原设计
   ========================================================== */
@media (max-width: 640px) {
  body { font-size: 14px; }

  /* --- 顶栏：纵向堆叠，tabs 横滑 --- */
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .brand .sub { display: none; }
  .tabs {
    width: 100%;
    order: 3;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
    margin-top: 0;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; font-size: 12.5px; }

  /* --- 进度条与下一题按钮 --- */
  .global-progress { flex-wrap: wrap; padding: 8px 14px; gap: 10px; }
  .gp-bar { min-width: 120px; }
  .next-btn { padding: 8px 14px; font-size: 13px; }

  /* --- main 边距收紧 --- */
  main { padding: 12px 12px 32px; }

  /* --- 学习路径 --- */
  .path-hero { padding: 18px 16px; }
  .path-hero h2 { font-size: 18px; }
  .hero-stats { gap: 14px; }
  .path-list { grid-template-columns: 1fr; }

  /* --- 分章学习：单列 --- */
  #view-learn.active { grid-template-columns: 1fr; gap: 12px; }
  .sidebar { order: 2; position: static; }
  .search-box input { font-size: 16px; }
  .card { padding: 14px 12px; }
  .card .card-title { font-size: 14.5px; }

  /* --- 考点/新题列表单列 --- */
  .list-wrap { grid-template-columns: 1fr; }
  .drill-filter { flex-wrap: wrap; }
  .drill-filter select, .drill-filter input { flex: 1 1 44%; font-size: 16px; }

  /* --- 公式与代码防溢出 --- */
  .fx { font-size: 12.5px; padding: 8px 10px; }
  pre.mat, .steps pre { font-size: 12px; }

  /* --- footer --- */
  footer { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 14px; }

  html, body { overflow-x: hidden; }
}
