/* ============ 奥数练习纸排版（叠加在 sheet.css 之上） ============
   纸张骨架（.sheet / .sheet-head / .sheet-meta / .sheet-foot）与打印规则
   全部复用 sheet.css；本文件只定义奥数自己的两种网格：
   题目页 .aoshu-grid 与解析页 .sol-grid。每页块数不固定：块高由
   js/aoshu-render.js 实测内容后以内联 style 写死（动态装页），
   打印段的 min-height 与那边的 MM.capacity（225mm）硬对应。 */

/* ---------- 题目页：单列网格，块高由 JS 内联给定 ---------- */

.aoshu-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
}

.aq {
  display: flex;
  flex-direction: column;
  padding: 3mm 0 2mm;
  overflow: hidden; /* 兜底同 .q：极端情况不侵入邻块 */
  break-inside: avoid;
  page-break-inside: avoid;
  border-bottom: 1px dashed #bbb; /* 分题虚线，孩子看题不串行 */
}

.aq:last-child {
  border-bottom: none;
}

.aq-num {
  font-size: 13px;
  margin-right: 2mm;
}

.aq-stem {
  font-size: 16px; /* 一年级可读字号 */
  line-height: 1.8;
}

/* 题干里的图形（SVG）限高，防止题块被撑得过高 */
.aq-stem svg {
  display: block;
  max-height: 18mm;
  width: auto;
  margin: 0.5mm 0 0;
}

.sol-stem svg {
  display: block;
  max-height: 13mm;
  width: auto;
}

/* 扇形的射线图压到 18mm 高，五六条射线挤成一团、编号叠在一起，单独放宽 */
.aq-stem svg.fig-tall {
  max-height: 26mm;
}

.sol-stem svg.fig-tall {
  max-height: 18mm;
}

/* 演算留白：高度由 aoshu-render.js 内联给定（有上限），不再吃掉整块剩余高度 */
.aq-work {
  flex: none;
}

/* 收尾留白：块高摊分后多出来的部分落在答题线下方，充当题与题之间的距离 */
.aq-tail {
  flex: 1;
}

.aq-ans {
  font-size: 15px;
}

.aq-ans .blank {
  display: inline-block;
  width: 3em;
  height: 1em;
  border-bottom: 2px solid #000;
  vertical-align: -3px;
}

.aq-ans .blank-expr {
  width: 12em; /* 「列式：」后的长横线 */
}

/* ---------- 解析页：块高按内容实测，由 JS 内联给定 ---------- */

.sol-grid {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
}

.sol {
  padding: 3mm 0 2mm;
  overflow: hidden;
  break-inside: avoid;
  page-break-inside: avoid;
  border-bottom: 1px dashed #bbb;
}

.sol:last-child {
  border-bottom: none;
}

.sol-stem {
  font-size: 13px;
  color: #444;
  line-height: 1.6;
}

/* 综合复习卷：解析里标出这道题出自哪个知识点 */
.sol-topic {
  display: inline-block;
  margin-right: 1.5mm;
  padding: 0 1.2mm;
  font-size: 11px;
  color: #333;
  border: 1px solid #999;
  border-radius: 1mm;
}

.sol-steps {
  margin: 1.5mm 0 0;
  padding-left: 1.2em;
  font-size: 13.5px;
  line-height: 1.75;
}

.sol-steps li {
  list-style: none;
}

.sol-steps .step-tag {
  font-weight: 700;
  color: #000;
}

/* 圆点对比图 */
.sol-diagram {
  margin: 1.5mm 0 0.5mm;
  font-size: 13px;
}

.sol-diagram .dot-row {
  line-height: 1.6;
  white-space: nowrap;
}

.sol-diagram .dot-label {
  display: inline-block;
  min-width: 3em;
  color: #444;
}

.sol-diagram .dots {
  letter-spacing: 2px;
}

.sol-diagram .dot-note {
  font-size: 12px;
  color: #666;
}

/* 线段图（条形示意图）：知识点生成器用 diagramHTML 输出，宽度用内联 style 按比例给 mm */
.seg-diagram {
  margin: 1.5mm 0 0.5mm;
  font-size: 12px;
}

.seg-diagram .seg-row {
  display: flex;
  align-items: center;
  line-height: 1.9;
}

.seg-diagram .seg-label {
  flex: none;
  width: 3.5em;
  color: #444;
}

.seg-diagram .seg {
  display: inline-block;
  height: 4.5mm;
  border: 1px solid #000;
  box-sizing: border-box;
  margin-right: -1px; /* 相邻段边框重合成一条线 */
  text-align: center;
  font-size: 11px;
  line-height: 4mm;
  background: #fff;
}

.seg-diagram .seg-note {
  font-size: 12px;
  color: #666;
}

.sol-answer {
  margin-top: 1mm;
  font-size: 14px;
  font-weight: 700;
}

/* ---------- 知识点讲解页：自由排版（非网格），内容手工编写保证一页放得下 ---------- */

.lesson-sec {
  margin-bottom: 6mm;
}

.lesson-h {
  margin: 0 0 2mm;
  padding-left: 2.5mm;
  font-size: 16px;
  border-left: 3.5px solid #000;
}

.lesson-p {
  margin: 0 0 1.5mm;
  font-size: 14.5px;
  line-height: 1.85;
}

/* 一个例题一块；多个例题相邻时靠 .lesson-sec 的 margin-bottom 隔开 */
/*
 * 「怎么想」里按题型逐条列的思路。每条一句话，前面挂题型名的标签。
 * 用 list-style:none + 标签本身当项目符号，比圆点更清楚「这条属于哪种题型」。
 */
.lesson-ideas {
  margin: 2mm 0 0;
  padding: 0;
}

.lesson-ideas li {
  list-style: none;
  margin-bottom: 1.2mm;
  font-size: 14px;
  line-height: 1.75;
}

.lesson-ideas .lesson-vtag {
  margin: 0 1.5mm 0 0;
  vertical-align: 1px;
}

.lesson-example {
  padding: 2.5mm 3.5mm;
  border: 1px solid #999;
  border-radius: 2mm;
}

/*
 * 例题上方的题型名。一页上可能并排三四个例题（勾了几种题型就有几个），
 * 不标名字家长分不清哪个例题对应面板上的哪一项。
 */
.lesson-vtag {
  display: inline-block;
  margin-bottom: 1.5mm;
  padding: 0.2mm 1.8mm;
  font-size: 11.5px;
  font-weight: 700;
  /*
   * 【不能靠背景色】：浏览器打印默认丢掉背景，深底白字会直接印成一片空白。
   * 这里跟 .sol-topic 用同一套「深字 + 细框」，屏幕和纸上都清楚。
   */
  color: #222;
  background: none;
  border: 1px solid #888;
  border-radius: 1mm;
}

.lesson-stem {
  margin-bottom: 1mm;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.7;
}

.lesson-chant {
  padding: 2mm 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
}

/* ---------- 打印：与 sheet.css 同套路，用最小高度锁定网格区 ---------- */

@media print {
  .aoshu-grid {
    min-height: 225mm; /* 与 aoshu-render.js 的 MM.capacity 对应 */
  }

  .sol-grid {
    min-height: 225mm; /* 同上 */
  }

  .lesson-flow {
    min-height: 225mm; /* 撑满内容区，把页脚推到纸张底部 */
  }
}

/* ============ 屏幕：知识点目录、顶栏「已学」、讲解视频 ============
   只在屏幕上出现，打印时整块隐藏（.topic-nav / .panel / .work-head 见 sheet.css 打印段）。 */

.topic-nav {
  flex: none;
  width: 264px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--card-edge);
}

.topic-nav-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #e4e7ec;
}

.topic-nav-head .group-title {
  font-size: 15px;
}

.topic-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
}

.tp {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
}

.tp:hover {
  background: #f1f3f6;
}

.tp.cur {
  background: var(--blue-tint);
}

/* 「已学」圆点：空心 = 没学，绿底白勾 = 学过；点它只改已学，不切课 */
.tp-dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 32px;
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}

.tp-dot::before {
  content: "";
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
  border: 1.5px solid #b4bac4;
  border-radius: 50%;
  background: #fff;
}

.tp-dot svg {
  grid-area: 1 / 1;
  position: relative;
  width: 10px;
  height: 10px;
  fill: none;
  stroke: #fff;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.tp-dot:hover::before {
  border-color: var(--green);
}

.tp.done .tp-dot::before {
  border-color: var(--green);
  background: var(--green);
}

.tp.done .tp-dot svg {
  opacity: 1;
}

.tp-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 2px;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
}

.tp.cur .tp-name {
  color: var(--blue-deep);
  font-weight: 600;
}

.tp-name .no {
  flex: none;
  width: 20px;
  font-size: 12px;
  color: var(--ink-soft);
}

.tp-name .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tp-name:disabled {
  color: var(--ink-faint);
  cursor: default;
}

.cam {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 2;
  stroke-linejoin: round;
}

.topic-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--ink-soft);
  border-top: 1px solid #e4e7ec;
}

/* 「接着学」：按大纲顺序指向第一个还没标已学的知识点 */
.next-topic {
  display: block;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
  color: var(--green);
  background: var(--green-tint);
  border: 1px solid #b9dcc6;
  border-radius: var(--radius);
  cursor: pointer;
}

.next-topic:hover {
  background: #dcefe3;
}

/* 顶栏「标记为已学」：没学是空心圆点，学过变绿 */
.learned-btn .dot {
  width: 16px;
  height: 16px;
  border: 1.5px solid #b4bac4;
  border-radius: 50%;
}

.learned-btn.on {
  color: var(--green);
  border-color: #b9dcc6;
  background: var(--green-tint);
}

.learned-btn.on .dot {
  border-color: var(--green);
  background: var(--green);
}

/* ---------- 讲解视频：设置区小窗 → 放大浮层 ---------- */

.video-none {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ink-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.video-none .cam {
  stroke: var(--ink-faint);
}

.video-box video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #101318;
  border-radius: 8px;
}

.video-top,
.video-foot {
  display: none;
}

#video-group .btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/*
 * 放大：同一个盒子铺满屏幕，<video> 元素不换，进度不丢。
 * 宽度同时受「最宽 1040」和「屏幕高度放得下 16:9」两头限制，矮屏上也不会顶出去。
 */
.video-box.is-big {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  background: rgba(10, 12, 16, 0.86);
}

.video-box.is-big video {
  width: min(1040px, 100%, (100vh - 180px) * 16 / 9);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.video-box.is-big .video-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1040px, 100%, (100vh - 180px) * 16 / 9);
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}

.video-box.is-big .video-top .btn {
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.4);
}

.video-box.is-big .video-foot {
  display: block;
  margin: 0;
  font-size: 13px;
  color: #aeb4be;
}

@media (max-width: 900px) {
  .topic-nav {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--card-edge);
  }

  .topic-list {
    max-height: 260px;
  }
}

/* ---------- 综合复习：混哪几课（只在打开复习卷时出现） ---------- */

.review-scope {
  margin-top: 8px;
}

.scope-acts {
  display: flex;
  gap: 12px;
}

/* 39 课排成一列太长，限高自己滚 */
.scope-list {
  max-height: 300px;
  margin-top: 6px;
  overflow-y: auto;
  padding-right: 4px;
}

.scope-stage {
  margin: 8px 0 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}

.scope-stage:first-child {
  margin-top: 0;
}

.scope-no {
  display: inline-block;
  min-width: 22px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
