/* ==================== 初中数学板块 · 通用样式 ==================== */
:root {
  --math-bg: #f7f9fc;
  --math-card: #ffffff;
  --math-ink: #1f2d3d;
  --math-ink-soft: #5b6b7f;
  --math-line: #e3e9f2;
  --math-blue: #2b7de9;
  --math-blue-soft: #eaf2fe;
  --math-orange: #f2913d;
  --math-orange-soft: #fef3e7;
  --math-green: #12b886;
  --math-green-soft: #e6f8f1;
  --math-purple: #7048e8;
  --math-purple-soft: #f0ecfe;
  --math-pink: #f06292;
  --math-radius: 18px;
  --math-shadow: 0 6px 24px rgba(31, 45, 61, 0.07);
}

* { box-sizing: border-box; }

body.math-body {
  margin: 0;
  background: var(--math-bg);
  color: var(--math-ink);
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.math-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ==================== 顶部导航 ==================== */
.math-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--math-line);
}
.math-nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.math-logo {
  font-weight: 800;
  font-size: 17px;
  color: var(--math-ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.math-logo .logo-badge {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--math-blue), var(--math-purple));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.math-nav-links { display: flex; gap: 6px; flex-wrap: wrap; }
.math-nav-links a {
  color: var(--math-ink-soft);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 10px;
  transition: all .2s;
}
.math-nav-links a:hover { background: var(--math-blue-soft); color: var(--math-blue); }
.math-nav-links a.active { background: var(--math-blue); color: #fff; }

/* ==================== 面包屑 ==================== */
.math-crumb {
  font-size: 13px;
  color: var(--math-ink-soft);
  padding: 18px 0 4px;
}
.math-crumb a { color: var(--math-blue); text-decoration: none; font-weight: 700; }
.math-crumb span.sep { margin: 0 7px; color: #b9c4d4; }

/* ==================== Hero ==================== */
.math-hero {
  padding: 34px 0 26px;
}
.math-hero h1 {
  font-size: 34px;
  margin: 0 0 10px;
  letter-spacing: -0.5px;
  line-height: 1.3;
}
.math-hero p.lead {
  color: var(--math-ink-soft);
  font-size: 16px;
  margin: 0 0 18px;
  max-width: 720px;
}
.math-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.math-tag {
  font-size: 12.5px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--math-blue-soft);
  color: var(--math-blue);
}
.math-tag.green { background: var(--math-green-soft); color: var(--math-green); }
.math-tag.orange { background: var(--math-orange-soft); color: var(--math-orange); }
.math-tag.purple { background: var(--math-purple-soft); color: var(--math-purple); }

/* ==================== 卡片 ==================== */
.math-card {
  background: var(--math-card);
  border: 1px solid var(--math-line);
  border-radius: var(--math-radius);
  box-shadow: var(--math-shadow);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.math-card h2 {
  font-size: 21px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.math-card h2 .num {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: var(--math-blue);
  color: #fff;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.math-card h3 {
  font-size: 16.5px;
  margin: 20px 0 8px;
  color: var(--math-ink);
}
.math-card h3:first-of-type { margin-top: 4px; }
.math-card p { margin: 8px 0; }
.math-card ul, .math-card ol { margin: 8px 0; padding-left: 22px; }
.math-card li { margin: 6px 0; }

/* 结论条目 */
.concl {
  border-left: 4px solid var(--math-green);
  background: var(--math-green-soft);
  border-radius: 0 12px 12px 0;
  padding: 12px 16px;
  margin: 10px 0;
}
.concl.blue { border-color: var(--math-blue); background: var(--math-blue-soft); }
.concl.purple { border-color: var(--math-purple); background: var(--math-purple-soft); }
.concl.orange { border-color: var(--math-orange); background: var(--math-orange-soft); }
.concl .concl-title { font-weight: 800; }
.concl .concl-body { color: var(--math-ink-soft); font-size: 14.5px; }

/* 提示框 */
.note {
  background: #fffbf0;
  border: 1px solid #ffe8b3;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14.5px;
  color: #7a5a10;
  margin: 14px 0;
}
.note.warn { background: #fff5f5; border-color: #ffd3d3; color: #a33; }

/* 对照表（知识点表格） */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border-radius: 12px;
  border: 1px solid var(--math-line);
  background: var(--math-card);
}
.mth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 520px;
}
.mth-table thead th {
  background: linear-gradient(180deg, #f4f8fe, #eaf2fe);
  color: var(--math-blue);
  font-weight: 800;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--math-line);
  white-space: nowrap;
}
.mth-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--math-line);
  color: var(--math-ink);
  vertical-align: middle;
}
.mth-table tbody tr:last-child td { border-bottom: none; }
.mth-table tbody tr:nth-child(even) { background: #fafcff; }
.mth-table .center { text-align: center; }
.mth-table strong { color: var(--math-blue); }
.mth-table .mth, .mth-table code { white-space: nowrap; }
@media (max-width: 760px) {
  .mth-table { font-size: 13.5px; min-width: 460px; }
  .mth-table thead th, .mth-table tbody td { padding: 8px 10px; }
}

/* 口诀 */
.mnemonic {
  text-align: center;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #fff8e7, #ffeef6);
  border: 1px dashed #ffd8e6;
  border-radius: 14px;
  padding: 16px;
  color: #b3457d;
  margin: 16px 0 4px;
}

/* 公式/数学排版 */
.m { font-family: "Cambria Math", "Times New Roman", serif; font-style: italic; }
.mth { font-family: "Cambria Math", "Times New Roman", serif; }
.math-block {
  background: #f5f7fb;
  border-radius: 12px;
  padding: 12px 16px;
  margin: 10px 0;
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 16px;
  line-height: 2;
  overflow-x: auto;
}
.math-block .lbl { color: var(--math-ink-soft); font-family: "Nunito", sans-serif; font-size: 13px; }

/* ==================== 分类区块 ==================== */
.cat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 34px 0 16px;
}
.cat-head .cat-icon {
  width: 42px; height: 42px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  background: var(--math-blue-soft);
}
.cat-head .cat-icon.algebra { background: #fdeef6; }
.cat-head h2 { margin: 0; font-size: 22px; }
.cat-head .cat-sub { font-size: 13px; color: var(--math-ink-soft); font-weight: 600; }

/* 模型卡片网格 */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.model-card {
  display: block;
  background: #fff;
  border: 1px solid var(--math-line);
  border-radius: 16px;
  padding: 18px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--math-shadow);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
}
.model-card:hover {
  transform: translateY(-3px);
  border-color: #c9dcfa;
  box-shadow: 0 12px 28px rgba(43, 125, 233, 0.13);
}
.model-card .mc-emoji { font-size: 24px; }
.model-card .mc-title { font-weight: 800; font-size: 16.5px; margin: 8px 0 4px; }
.model-card .mc-desc { font-size: 13.5px; color: var(--math-ink-soft); min-height: 42px; }
.model-card .mc-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: #6b7c90;
}
.chip.on { background: var(--math-green-soft); color: var(--math-green); }
.chip.new { background: #ffe9f2; color: #d6336c; }
.model-card.disabled {
  opacity: .62;
  cursor: default;
  box-shadow: none;
}
.model-card.disabled:hover { transform: none; border-color: var(--math-line); }

/* ==================== 动画演示区 ==================== */
.demo-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(240px, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 860px) { .demo-wrap { grid-template-columns: 1fr; } }

.figure-box {
  background: #fbfcfe;
  border: 1px solid var(--math-line);
  border-radius: 16px;
  padding: 8px;
}
.figure-box svg { display: block; width: 100%; height: auto; }

.panel { display: flex; flex-direction: column; gap: 14px; }
.panel-block {
  background: #fbfcfe;
  border: 1px solid var(--math-line);
  border-radius: 14px;
  padding: 14px;
}
.panel-block .pb-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--math-ink-soft);
  letter-spacing: .4px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.slider-row { margin-bottom: 12px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row .sr-label {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 5px;
}
.slider-row .sr-val { color: var(--math-blue); font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #e6ecf5;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--math-blue);
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(43,125,233,.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--math-blue);
  border: 3px solid #fff;
  cursor: pointer;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: none;
  border-radius: 11px;
  padding: 9px 15px;
  font-weight: 800;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  background: var(--math-blue);
  color: #fff;
  transition: filter .18s, transform .1s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: #eef2f7; color: #55657a; }
.btn.purple { background: var(--math-purple); }
.btn.green { background: var(--math-green); }

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  color: #46566b;
  padding: 5px 0;
  cursor: pointer;
  user-select: none;
}
.check-row input { width: 16px; height: 16px; accent-color: var(--math-blue); cursor: pointer; }

.readout { display: flex; flex-direction: column; gap: 9px; }
.ro-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--math-line);
  border-radius: 11px;
  padding: 9px 12px;
}
.ro-item .ro-k { color: var(--math-ink-soft); font-weight: 700; }
.ro-item .ro-v {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--math-blue);
}
.ro-item .ro-v.green { color: var(--math-green); }
.ro-item .ro-v.purple { color: var(--math-purple); }
.ro-item .ro-v.equal::after {
  content: "相等 ✓";
  font-size: 11px;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--math-green-soft);
  color: var(--math-green);
}
.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--math-green);
  background: var(--math-green-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--math-green);
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ==================== 视频讲解 ==================== */
.video-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(230px, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) { .video-wrap { grid-template-columns: 1fr; } }

.video-wrap video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 14px;
  background: #0d1420;
  box-shadow: 0 8px 26px rgba(31, 45, 61, 0.16);
}

.video-side {
  background: #fbfcfe;
  border: 1px solid var(--math-line);
  border-radius: 14px;
  padding: 15px 16px;
}
.video-side h3 {
  margin: 0 0 9px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.video-side ul { margin: 0; padding-left: 4px; list-style: none; }
.video-side li {
  font-size: 13.5px;
  color: var(--math-ink-soft);
  padding: 5px 0;
  border-bottom: 1px dashed #eef2f7;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.video-side li:last-child { border-bottom: none; }
.video-side li .v-t {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--math-blue);
  flex: 0 0 auto;
  font-size: 12.5px;
  min-width: 34px;
}
.video-side .v-note {
  margin-top: 10px;
  font-size: 12.5px;
  color: #8a97a8;
  line-height: 1.6;
}

/* ==================== 例题 ==================== */
.problem {
  background: linear-gradient(180deg, #fff, #fbfcfe);
  border: 1px solid var(--math-line);
  border-left: 5px solid var(--math-purple);
  border-radius: 0 16px 16px 0;
  padding: 18px 20px;
  margin: 14px 0;
}
.problem .p-title {
  font-weight: 800;
  color: var(--math-purple);
  font-size: 14px;
  margin-bottom: 8px;
}
.steps { margin-top: 14px; }
details.step {
  background: #fff;
  border: 1px solid var(--math-line);
  border-radius: 12px;
  margin-bottom: 10px;
  overflow: hidden;
}
details.step[open] { border-color: #cddffb; box-shadow: 0 4px 14px rgba(43,125,233,.07); }
details.step summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 800;
  font-size: 15px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 9px;
}
details.step summary::-webkit-details-marker { display: none; }
details.step summary::before {
  content: "▸";
  color: var(--math-blue);
  font-size: 13px;
  transition: transform .2s;
}
details.step[open] summary::before { transform: rotate(90deg); }
details.step .step-body { padding: 2px 18px 16px; font-size: 15px; }

.ans {
  background: var(--math-green-soft);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 700;
  color: #0b7a5b;
  margin-top: 10px;
}

/* ==================== 底部 ==================== */
.math-footer {
  border-top: 1px solid var(--math-line);
  margin-top: 40px;
  padding: 26px 0 40px;
  color: var(--math-ink-soft);
  font-size: 13.5px;
  text-align: center;
}
.math-footer a { color: var(--math-blue); text-decoration: none; font-weight: 700; }

/* 知识点锚点导航 */
.kp-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0 18px;
}
.kp-nav a {
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 800;
  color: #55657a;
  background: #fff;
  border: 1px solid var(--math-line);
  padding: 7px 13px;
  border-radius: 999px;
  transition: all .18s;
}
.kp-nav a:hover { border-color: #c9dcfa; color: var(--math-blue); background: var(--math-blue-soft); }

/* ===== 例题配图：左侧题干、右侧静态图形 ===== */
.ex-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 268px);
  gap: 18px;
  align-items: start;
  margin-top: 4px;
}
.ex-text ol { margin: 8px 0 10px; }
.ex-fig { margin: 0; padding: 6px; }
.ex-fig svg {
  width: auto;
  max-width: 100%;
  max-height: 300px;
  height: auto;
  margin: 0 auto;
}
.ex-fig figcaption {
  font-size: 12px;
  line-height: 1.55;
  color: var(--math-ink-soft);
  text-align: center;
  padding: 5px 4px 2px;
  border-top: 1px dashed var(--math-line);
  margin-top: 4px;
}
@media (max-width: 760px) {
  .ex-layout { grid-template-columns: 1fr; }
  .ex-fig { max-width: 340px; margin: 0 auto; }
}

/* ==================== 将军饮马：折线长随 P 位置变化的曲线小图 ==================== */
.fig-curve { margin: 18px 0 0; padding: 0; }
.fig-curve svg { display: block; width: 100%; height: auto; max-height: 200px; }
.fig-curve figcaption {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--math-ink-soft);
  text-align: center;
  padding-top: 8px;
  margin-top: 10px;
  border-top: 1px dashed var(--math-line);
}

/* 拖拽操作提示胶囊 */
.drag-tip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}
.drag-tip span {
  font-size: 13px;
  line-height: 1.5;
  color: var(--math-ink-soft);
  background: #f2f6fb;
  border: 1px solid var(--math-line);
  border-radius: 999px;
  padding: 4px 12px;
}
.drag-tip span b { color: var(--math-blue); }

/* 拖拽手柄：鼠标移上去给个手势提示 */
.drag-handle { cursor: grab; }
.drag-handle:active { cursor: grabbing; }
@media (max-width: 760px) {
  .fig-curve svg { max-height: 170px; }
}


/* ===== 几何全景分类入口卡（math/index.html 几何区块首卡） ===== */
.model-card-wide {
  grid-column: 1 / -1;
  display: block;
}
.model-card-wide .mc-desc { min-height: 0; }
@media (max-width: 760px) {
  .model-card-wide { grid-column: auto; }
}

/* ==================== 图形显示规则（全局兜底 · 2026-10-07） ====================
   详见 docs/FIGURE-RULES.md。插图一律按原始比例限宽限高，禁止被 width:100% 拉满整行。
   这里用 :where() 把自身优先级降到 0，页面内联样式可覆盖为更小尺寸；
   .ex-fig（例题小图，max-height:300px）与 .fig-curve（max-height:200px）不受影响。 */
:where(.figure-box) > svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: min(100%, 520px);
  max-height: min(72vh, 560px);
  margin: 0 auto;
}

/* ==================== 模型页 Tab 结构（2026-11-07） ====================
   三个页签：模型（一句话 + 视频 + 演示）/ 例题精讲 / 练习（打印资料）。
   页签按钮 sticky 在导航下方；打印时全部展开、隐藏页签条。 */
.mtabs { margin-top: 4px; }
.mtab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  position: sticky;
  top: 60px;
  z-index: 8;
  background: var(--math-bg);
  padding: 10px 0 0;
  border-bottom: 2px solid var(--math-line);
  margin-bottom: 18px;
}
.mtab-bar button {
  appearance: none;
  border: 1px solid var(--math-line);
  border-bottom: none;
  background: #fff;
  color: var(--math-ink-soft);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 800;
  padding: 9px 18px;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.mtab-bar button:hover { color: var(--math-blue); background: var(--math-blue-soft); }
.mtab-bar button.active {
  color: var(--math-blue);
  background: linear-gradient(180deg, #f4f8fe, #fff);
  box-shadow: inset 0 3px 0 var(--math-blue);
}
.mtab-bar button .mtab-sub {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #9aa6ba;
  margin-top: 1px;
}
.mtab-panel { display: none; }
.mtab-panel.active { display: block; animation: mtabIn .18s ease; }
@keyframes mtabIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 练习页签：打印资料占位 */
.drill-card {
  text-align: center;
  border: 2px dashed #c9dcfa;
  border-radius: 16px;
  background: #fbfdff;
  padding: 28px 22px;
}
.drill-card .dc-emoji { font-size: 34px; }
.drill-card h3 { margin: 8px 0 6px; }
.drill-card p { margin: 4px 0; color: var(--math-ink-soft); font-size: 14.5px; }
.drill-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

@media (max-width: 760px) {
  .mtab-bar { top: 54px; gap: 4px; }
  .mtab-bar button { padding: 8px 12px; font-size: 13.5px; }
}

/* 打印：全部展开、去掉页签条与交互按钮 */
@media print {
  .mtab-bar { display: none !important; }
  .mtab-panel { display: block !important; }
  .mtab-panel { animation: none; }
}
