/* =========================================================
   课程页设计层（learn/*.html：课程地图 / 课时 / 参考速查）
   风格 B · 在 style.css 之上加载
   两件事：
   1. 定义内容页旧模板使用的同名 CSS 变量，值映射到本站设计 token，
      使各页内联样式自动融入风格 B；
   2. 补齐原主题（site.css / lesson.css，未随内容提供）的全部基础排版
      与组件：对象框、知识地图、10 种 callout、术语卡、自测题、
      步骤列表、练习卡、课时导航等。
   ========================================================= */

/* ---------- 1. 旧模板变量 → 风格 B token（仅课程内容区生效） ---------- */
.wrap {
  --accent: #2563EB;
  --accent-soft: #EFF6FF;
  --rule: #E2E8F0;
  --ink: #0F172A;
  --ink-soft: #475569;
  --ink-faint: #64748B;
  --paper-edge: #F8FAFC;
  --surface: #FFFFFF;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 6px 16px rgba(15, 23, 42, .06);
  --shadow: 0 16px 32px rgba(15, 23, 42, .10);
  --code-bg: #F1F5F9;
}

/* ---------- 2. 内容容器与基础排版 ---------- */
.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 46px 24px 64px;
}

.wrap p { margin: .95em 0; }
.wrap p:first-child { margin-top: 0; }

.wrap h1 {
  font-size: clamp(27px, 3.6vw, 36px);
  font-weight: 900;
}

.wrap p.subtitle {
  margin: 12px 0 0;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  font-size: 16.5px;
  color: var(--text-2);
}

.wrap h2 {
  margin: 2.5em 0 .8em;
  padding-left: 13px;
  border-left: 5px solid var(--primary);
  font-size: 22.5px;
  font-weight: 900;
}

.wrap h3 {
  margin: 2em 0 .6em;
  font-size: 17.5px;
  font-weight: 800;
}

.wrap ul, .wrap ol { margin: .85em 0; padding-left: 1.6em; }
.wrap li { margin: .38em 0; }
.wrap strong { font-weight: 700; }
.wrap em { font-style: italic; }

.wrap small,
.wrap p > small { font-size: .86em; color: var(--ink-soft); }

.wrap code {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: .12em .4em;
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: .88em;
  overflow-wrap: anywhere;
}

.wrap pre {
  margin: .8em 0;
  padding: 14px 16px;
  background: var(--ink);
  color: #7DD3FC;
  border-radius: 10px;
  overflow-x: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13.5px;
  line-height: 1.75;
}
.wrap pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

.wrap a { text-decoration: none; }
.wrap p a:hover,
.wrap li a:hover { text-decoration: underline; }

/* ---------- 3. 表格 ---------- */
.wrap table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14.6px;
}
.wrap th, .wrap td {
  border: 1px solid var(--rule);
  padding: .62em .78em;
  text-align: left;
  vertical-align: top;
  line-height: 1.68;
  overflow-wrap: anywhere;
}
.wrap th {
  background: var(--bg-soft);
  font-weight: 800;
  color: var(--text);
}
/* 表头在窄屏允许折行（nowrap 会抬高列宽下限导致 375px 溢出），宽屏再保持不折 */
@media (min-width: 641px) {
  .wrap th { white-space: nowrap; }
}
.wrap tbody tr:hover td { background: #FAFCFF; }

/* ---------- 4. 页面眉头：元信息行 ---------- */
.lesson-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: .04em;
}
.lesson-meta .part {
  background: var(--accent-soft);
  color: var(--primary-dark);
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12.5px;
}

/* ---------- 5. 学习目标框 ---------- */
.wrap .objectives {
  margin: 26px 0;
  padding: 20px 24px;
  background: linear-gradient(0deg, rgba(239, 246, 255, .65), rgba(239, 246, 255, .65)), var(--surface);
  border: 1px solid #BFDBFE;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
}
.wrap .objectives h2 {
  margin: 0 0 10px;
  padding: 0;
  border: none;
  font-size: 16.5px;
  font-weight: 900;
  color: var(--primary-dark);
  letter-spacing: .02em;
}
.wrap .objectives ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.wrap .objectives li {
  position: relative;
  padding-left: 26px;
  margin: .5em 0;
  font-size: 15.2px;
  line-height: 1.75;
}
.wrap .objectives li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 900;
}
.wrap .objectives > p {
  border-top: 1px dashed #BFDBFE;
  padding-top: .75rem;
}
.wrap .objectives > p strong { color: var(--text); }

/* ---------- 6. 知识地图（键值行） ---------- */
.wrap .kmap {
  margin: 1.3em 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.wrap .kmap .row {
  display: grid;
  grid-template-columns: 172px 1fr;
  border-bottom: 1px solid var(--rule);
}
.wrap .kmap .row:last-child { border-bottom: none; }
.wrap .kmap .k {
  padding: 12px 16px;
  background: var(--bg-soft);
  border-right: 1px solid var(--rule);
  font-size: 14.2px;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.6;
}
.wrap .kmap .row > div:last-child {
  padding: 12px 16px;
  font-size: 14.8px;
  color: var(--text-2);
  line-height: 1.75;
}
.wrap .kmap p { margin: 0; }
@media (max-width: 640px) {
  .wrap .kmap .row { grid-template-columns: 1fr; }
  .wrap .kmap .k { border-right: none; border-bottom: 1px dashed var(--rule); }
}

/* ---------- 7. 提示框：10 种 callout（彩色左边 + 右上角图标） ---------- */
.wrap .callout {
  position: relative;
  margin: 1.35em 0;
  padding: 15px 46px 15px 20px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15.1px;
  line-height: 1.78;
}
.wrap .callout > p:first-child { margin-top: 0; }
.wrap .callout > p:last-child { margin-bottom: 0; }
.wrap .callout ul, .wrap .callout ol { margin: .55em 0; padding-left: 1.5em; }
.wrap .callout li { margin: .32em 0; }
.wrap .callout code { font-size: .87em; }
.wrap .callout::after {
  position: absolute;
  top: 12px;
  right: 13px;
  font-size: 15px;
  opacity: .9;
}

.wrap .callout.note    { border-left-color: #2563EB; background: #EFF6FF; }
.wrap .callout.note::after    { content: "💡"; }
.wrap .callout.warn    { border-left-color: #F59E0B; background: #FFFBEB; }
.wrap .callout.warn::after    { content: "⚠️"; }
.wrap .callout.why     { border-left-color: #7C3AED; background: #F5F3FF; }
.wrap .callout.why::after     { content: "❓"; }
.wrap .callout.summary { border-left-color: #10B981; background: #ECFDF5; }
.wrap .callout.summary::after { content: "✅"; }
.wrap .callout.task    { border-left-color: #0EA5E9; background: #F0F9FF; }
.wrap .callout.task::after    { content: "🛠️"; }
.wrap .callout.source  { border-left-color: #475569; background: #F8FAFC; }
.wrap .callout.source::after  { content: "📚"; }
.wrap .callout.ask     { border-left-color: #EC4899; background: #FDF2F8; }
.wrap .callout.ask::after     { content: "💬"; }
.wrap .callout.tip     { border-left-color: #14B8A6; background: #F0FDFA; }
.wrap .callout.tip::after     { content: "✨"; }
.wrap .callout.recap   { border-left-color: #4F46E5; background: #EEF2FF; }
.wrap .callout.recap::after   { content: "📌"; }
.wrap .callout.py      { border-left-color: #3572A5; background: #EFF6FF; }
.wrap .callout.py::after      { content: "🐍"; }

/* 提示框浅色底上的正文与链接 */
.wrap .callout a { font-weight: 600; }

/* ---------- 8. 术语卡 ---------- */
.wrap .terms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 1em 0;
}
.wrap .terms .t {
  display: inline-block;
  padding: 5px 13px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.3px;
  color: var(--text-2);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.wrap .terms .t:hover {
  border-color: #BFDBFE;
  box-shadow: 0 4px 10px rgba(37, 99, 235, .10);
  transform: translateY(-1px);
}
.wrap .terms .t b {
  margin-right: 5px;
  color: var(--primary-dark);
  font-weight: 800;
}

/* ---------- 9. 引注角标 ---------- */
.wrap a.cite {
  display: inline-block;
  padding: 0 6px;
  margin: 0 2px;
  border: 1px solid #BFDBFE;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.5;
  vertical-align: 3px;
  transition: background .15s, color .15s;
}
.wrap a.cite:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
}

/* ---------- 10. 步骤列表（圆形序号） ---------- */
.wrap ol.step-list {
  list-style: none;
  counter-reset: step;
  margin: 1em 0;
  padding-left: 0;
}
.wrap ol.step-list li {
  counter-increment: step;
  position: relative;
  margin: .55em 0;
  padding: 5px 0 5px 46px;
}
.wrap ol.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 4px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1;
}

/* ---------- 11. 练习册：级别条 / 题目卡 / 分类标签 / 题号 ---------- */
.wrap .tier {
  margin: 2.1em 0 .85em;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: #CBD5E1;
  font-size: 14.3px;
  line-height: 1.7;
}
.wrap .tier b {
  margin-right: 6px;
  color: #60A5FA;
  font-size: 15.5px;
  font-weight: 900;
}

.wrap .drill {
  position: relative;
  margin: .75em 0;
  padding: 13px 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.wrap .drill:hover {
  border-color: #BFDBFE;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .07);
}
.wrap .drill .tags {
  display: inline-block;
  margin-bottom: 7px;
  padding: 2px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .05em;
}
.wrap .drill p { margin: 0; line-height: 1.8; }
.wrap .drill .num {
  display: inline-block;
  min-width: 30px;
  margin-right: 9px;
  padding: 2px 7px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 900;
  text-align: center;
  letter-spacing: .03em;
  vertical-align: 1px;
}
.wrap .drill pre { margin-bottom: 0; }

/* 参考答案：details 折叠 */
.wrap details.answer { margin-top: 8px; }
.wrap details.answer summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--primary);
  user-select: none;
}
.wrap details.answer summary:hover { color: var(--primary-dark); text-decoration: underline; }
.wrap details.answer[open] summary { margin-bottom: 7px; }
.wrap details.answer .a {
  padding: 10px 14px;
  border-left: 3px solid var(--success);
  border-radius: 8px;
  background: #ECFDF5;
  color: #065F46;
  font-size: 14.2px;
  line-height: 1.75;
}
.wrap details.answer .a p { margin: .4em 0; }
.wrap details.answer .a p:first-child { margin-top: 0; }
.wrap details.answer .a p:last-child { margin-bottom: 0; }

/* ---------- 12. 课时导航（相关材料） ---------- */
.wrap .lesson-nav {
  margin-top: 46px;
  padding: 20px 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.wrap .lesson-nav h2 {
  margin: 0 0 12px;
  padding: 0;
  border: none;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.wrap .lesson-nav ul { list-style: none; margin: 0; padding: 0; }
.wrap .lesson-nav li {
  margin: 0;
  padding: 8px 0;
  border-bottom: 1px dotted var(--rule);
  font-size: 14.8px;
}
.wrap .lesson-nav li:last-child { border-bottom: none; padding-bottom: 0; }
.wrap .lesson-nav .tag {
  display: inline-block;
  margin-right: 9px;
  padding: 2px 10px;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .06em;
  vertical-align: 1px;
}
.wrap .lesson-nav a { font-weight: 600; }

/* ---------- 13. 文末线 ---------- */
.wrap p.footer {
  margin-top: 52px;
  padding: 18px 0 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.wrap p.footer a { text-decoration: underline; text-underline-offset: 3px; }
.wrap p.footer a:hover { color: var(--primary-dark); }

/* ---------- 14. 自测题（quiz.js 渲染） ---------- */
.wrap .quiz {
  margin: 1.3em 0;
  padding: 18px 20px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}
.wrap .quiz noscript p {
  margin: 0;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 13.8px;
}
.wrap .quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--rule);
}
.wrap .quiz-title { font-size: 15.5px; font-weight: 900; }
.wrap .quiz-score {
  padding: 4px 13px;
  border: 1px solid #BFDBFE;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
}
.wrap .q { padding: 15px 0; border-bottom: 1px dashed var(--rule); }
.wrap .q-prompt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 15.1px;
  font-weight: 700;
  line-height: 1.7;
}
.wrap .q-no {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px;
  height: 24px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  font-weight: 900;
  line-height: 1;
  margin-top: 2px;
}
.wrap .q-opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 640px) {
  .wrap .q-opts { grid-template-columns: 1fr; }
}
.wrap .q-opt {
  display: block;
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 14.3px;
  line-height: 1.6;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s, color .15s;
}
.wrap .q-opt:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  transform: translateY(-1px);
}
.wrap .q-opt.is-right {
  border-color: var(--success);
  background: #ECFDF5;
  color: #047857;
  font-weight: 700;
}
.wrap .q-opt.is-wrong {
  border-color: #EF4444;
  background: #FEF2F2;
  color: #B91C1C;
  font-weight: 700;
}
.wrap .q-opt:disabled { cursor: default; }
.wrap .q-opt:disabled:not(.is-right):not(.is-wrong) { opacity: .55; }
.wrap .q-why {
  margin-top: 9px;
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 13.8px;
  line-height: 1.75;
}
.wrap .q-why.ok { background: #ECFDF5; color: #065F46; }
.wrap .q-why.no { background: #FEF2F2; color: #991B1B; }
.wrap .q-why b { font-weight: 900; margin-right: 4px; }
.wrap .quiz-end {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 15px;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg-soft);
}
.wrap .quiz-final { font-size: 15.5px; font-weight: 900; }
.wrap .q-retry {
  padding: 7px 18px;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.wrap .q-retry:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }

/* ---------- 15. 缺图占位（截图未随内容提供时） ---------- */
.wrap .img-placeholder { margin: 8px 0; min-height: 120px; }

/* ---------- 16. 各页内联样式的容器兜底（其内联定义在后，优先生效） ---------- */
.demo {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  margin: 1.2rem 0;
  font-size: 0.85rem;
  line-height: 1.7;
}
.snippet {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  margin: 0.6rem 0;
  font-size: 0.85rem;
  line-height: 1.75;
}
.demo .lbl,
.snippet .lbl { display: block; }
.shot { margin: 1.4rem 0; }
.nest { margin: 1.4rem 0; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1.2rem 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin: 1.2rem 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 1.2rem 0; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 1rem 0; }
.regions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; margin: 1.2rem 0; }
@media (max-width: 640px) {
  .two, .grid2, .regions { grid-template-columns: 1fr; }
}
/* Grid/Flex 子项默认 min-width:auto（min-content 下限），长代码行会把轨道撑破
   导致移动端横向溢出——统一置 0，让 pre 的 overflow-x:auto 在内部滚动 */
.wrap .two > *,
.wrap .grid2 > *,
.wrap .regions > *,
.wrap .chain > *,
.wrap .flow > *,
.wrap .kmap .row > *,
.wrap .q-opts > * { min-width: 0; }
/* 浅色 code 底上的小标签保证对比度（内联样式用 --ink-faint，此处覆写） */
.wrap .demo .lbl { color: #475569; font-weight: 700; }

/* ---------- 17. 打印（参考页标注“可打印”） ---------- */
@media print {
  .nav, .back-top, .nav-toggle, .copy-btn, .q-retry, .quiz-end { display: none !important; }
  footer { display: none !important; }
  body { font-size: 12.5px; animation: none; }
  .wrap { max-width: 100%; padding: 0; }
  .callout, .kmap, .drill, .quiz, .tier, figure, table { break-inside: avoid; }
  .wrap a { color: inherit; text-decoration: underline; }
  .wrap a.cite { text-decoration: none; }
}

/* ---------- 18. 图解（第 3–6 课共用） ---------- */
.wrap .diagram {
  margin: 1.9rem 0;
  padding: 18px 20px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.wrap .diagram-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wrap .diagram svg { display: block; width: 100%; height: auto; min-width: 600px; }
.wrap .diagram figcaption {
  margin-top: 10px;
  font-size: 12.8px;
  line-height: 1.7;
  color: var(--ink-faint);
  text-align: center;
}
.wrap .diagram text { font-family: var(--font); }
.wrap .diagram .d-title { font-size: 18px; font-weight: 800; fill: var(--ink); }
.wrap .diagram .d-sub { font-size: 12px; fill: var(--ink-faint); }
.wrap .diagram .d-label { font-size: 13px; font-weight: 700; fill: var(--ink-soft); }
.wrap .diagram .d-note { font-size: 11.5px; fill: var(--ink-faint); }
.wrap .diagram .d-mono { font-family: ui-monospace, Consolas, "Courier New", monospace; }

@media (max-width: 700px) {
  .wrap .diagram { padding: 12px 10px 8px; }
  .wrap .diagram svg { min-width: 560px; }
}

@media print {
  .wrap .diagram { box-shadow: none; break-inside: avoid; }
  .wrap .diagram-scroll { overflow: visible; }
  .wrap .diagram svg { min-width: 0; }
}
