/**
 * lesson.css：课程页统一排版规范
 *
 * 对标站的模板其实并不统一（466 页分期堆出来的，有的有速览有的没有）。
 * 我们从第一天就把规范定死，每节课都是：
 *   速览 → 目标卡 → 正文 → 金句条 → 交互区 → 练习卡 → 收尾卡 → 免责
 *
 * 主色由每个篇章自己在页面里覆盖 --accent 三兄弟，就近继承。
 * 变量同时挂在 :root 和 .lesson 上：learn.html 的 iframe 注入会在页面样式
 * 之后再写一次 :root，靠 .lesson 这一层才保得住篇章色。
 */

:root {
  --bg: #fbfaf8;
  --card: #ffffff;
  --text: #1f2430;
  --sub: #5c6577;
  --line: #e6e3dd;
  --radius: 14px;
  --accent: #b45309;
  --accent-deep: #7c3d06;
  --accent-soft: rgba(180, 83, 9, .085);
  --maxw: 760px;
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --card: #1c1f26;
  --text: #e8e6e3;
  --sub: #9aa3b2;
  --line: #2a2f39;
}

/**
 * ⚠️ 篇章色的暗色变体是每个课页自己的责任，不是这里的。
 *
 * --accent-deep 在浅色下是「比主色更深」，用在 strong / mark / 金句上。
 * 到了暗色背景，「更深」等于「更看不清」，对比度会掉到 3:1 以下。
 *
 * 所以每个课页在声明篇章色时必须给两组，照这个格式写：
 *
 *   :root, .lesson { --accent:#dc2626; --accent-deep:#991b1b;
 *                    --accent-soft:rgba(220,38,38,.075) }
 *   :root[data-theme="dark"], :root[data-theme="dark"] .lesson {
 *     --accent:#f87171; --accent-deep:#fca5a5;
 *     --accent-soft:rgba(248,113,113,.1) }
 *   @media (prefers-color-scheme:dark){
 *     :root:not([data-theme="light"]), :root:not([data-theme="light"]) .lesson {
 *       --accent:#f87171; --accent-deep:#fca5a5;
 *       --accent-soft:rgba(248,113,113,.1) } }
 *
 * 暗色组的 accent-deep 要比 accent 更亮，方向跟浅色组相反。
 * build/new_lesson.py 生成骨架时会自动带上这三块。
 */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --card: #1c1f26;
    --text: #e8e6e3;
    --sub: #9aa3b2;
    --line: #2a2f39;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.9 -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* 首屏淡入，避免主题切换时的白闪 */
@keyframes _si { to { opacity: 1 } }
body { opacity: 0; animation: _si .15s ease .08s forwards; }

.lesson {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 40px 24px 96px;
}

/* ── 页头 ────────────────────────────────────────────────── */
.lesson-header {
  position: relative;
  overflow: hidden;
  padding: 0 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.lesson-header:after {
  content: "";
  position: absolute;
  right: -70px; top: -90px;
  width: 220px; height: 220px;
  border: 1px solid var(--accent-soft);
  border-radius: 50%;
  box-shadow: 0 0 0 26px rgba(0, 0, 0, .012), 0 0 0 52px rgba(0, 0, 0, .008);
  pointer-events: none;
}
.lesson-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
  padding: 5px 12px; border-radius: 999px;
  margin-bottom: 16px;
}
.lesson h1 {
  margin: 0 0 12px;
  font-size: 28px; line-height: 1.4; font-weight: 800;
  letter-spacing: -.01em;
}
.lesson-meta { margin: 0; font-size: 13.5px; color: var(--sub); }

/* ── 一句话速览：喂 meta description 和 llms.txt 的同一段话 ─ */
.tldr {
  display: grid; grid-template-columns: auto 1fr; gap: 14px;
  align-items: start;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 0 0 32px;
  font-size: 14.5px; line-height: 1.85;
}
.tldr b { color: var(--accent-deep); display: block; margin-bottom: 4px; }

/* ── 目标卡 ──────────────────────────────────────────────── */
.objective {
  display: grid; grid-template-columns: auto 1fr; gap: 16px;
  align-items: center;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin: 0 0 32px;
}
.objective svg { color: var(--accent); flex: 0 0 auto; }
.objective b { display: block; color: var(--accent); margin-bottom: 5px; }
.objective span { font-size: 14px; line-height: 1.9; color: var(--text); }

/* ── 正文 ────────────────────────────────────────────────── */
.lesson > p { margin: 0 0 20px; }
.lesson strong { font-weight: 700; color: var(--accent-deep); }
.lesson mark {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 700;
  padding: 2px 5px; border-radius: 5px;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.sec-label {
  margin: 52px 0 20px;
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
  color: var(--sub); text-transform: uppercase;
}
.sec-label:before {
  content: ""; display: inline-block;
  width: 18px; height: 2px; background: var(--accent);
  vertical-align: middle; margin-right: 10px;
}
.lesson h2 { font-size: 20px; margin: 44px 0 16px; font-weight: 800; }
.lesson h3 { font-size: 16px; margin: 32px 0 12px; font-weight: 700; }

/* 编号列表 */
ol.numbered { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: f; }
ol.numbered li {
  counter-increment: f; position: relative;
  padding-left: 32px; margin-bottom: 12px;
}
ol.numbered li:last-child { margin-bottom: 0; }
ol.numbered li:before {
  content: counter(f);
  position: absolute; left: 0; top: 6px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
  color: var(--accent-deep);
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
ol.numbered li b { font-weight: 700; color: var(--accent-deep); }

/* ── 金句条 ──────────────────────────────────────────────── */
.key-line {
  margin: 36px 0;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
  text-align: center;
  font-size: 17px; font-weight: 800; line-height: 1.8;
  color: var(--accent-deep);
}

/* ── 数据卡：所有引用的数字都必须带来源 ──────────────────── */
.datum {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 0 0 20px;
}
.datum-num {
  font-size: 32px; font-weight: 800; line-height: 1.2;
  color: var(--accent); letter-spacing: -.02em;
}
.datum-label { font-size: 14px; margin: 6px 0 12px; }
.datum-src {
  font-size: 12px; color: var(--sub);
  padding-top: 12px; border-top: 1px dashed var(--line);
}
.datum-src a { color: var(--sub); }

/* ── 交互组件容器 ────────────────────────────────────────── */
.widget {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 32px 0;
}
.widget-title {
  font-size: 13px; font-weight: 800; color: var(--sub);
  letter-spacing: .04em; margin: 0 0 18px;
}
.widget-note {
  font-size: 12px; color: var(--sub);
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--line);
}
/* 宽内容自己滚，页面 body 永远不横向滚 */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ── 练习卡 ──────────────────────────────────────────────── */
.exercise {
  display: grid; grid-template-columns: 46px 1fr; gap: 18px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 32px 0 0;
}
.exercise-num {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 900;
}
.exercise h3 { margin: 0 0 10px; font-size: 16px; }
.exercise p { margin: 0 0 12px; color: var(--sub); font-size: 14px; }
.exercise p:last-child { margin: 0; }

/* ── 收尾卡 ──────────────────────────────────────────────── */
.takeaway {
  margin-top: 32px; padding: 24px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft);
  display: flex; gap: 14px;
  font-size: 14px; line-height: 1.9;
}
.takeaway svg { flex: 0 0 auto; color: var(--accent); }
.takeaway b { color: var(--accent-deep); }

/* ── 正文内链 ────────────────────────────────────────────── */
/* 不设的话就是浏览器默认的蓝色下划线，跟篇章色完全不搭。
   放在 .lesson 作用域下，不影响 .datum-src 里的外部来源链接。 */
.lesson a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color .13s ease;
}
.lesson a:hover { border-bottom-color: var(--accent); }
/* 来源引用保持低调，它不是让人点的重点 */
.datum-src a { color: var(--sub); border-bottom-color: var(--line); }

/* ── 尚未上线的内链 ──────────────────────────────────────── */
/* build/link_guard.py 会把指向未撰写课页的 <a> 降级成这个，
   避免上线后一堆 404。等目标页面写好，--restore 会自动换回链接。 */
/* 用 a.pending 而不是 .pending：页面内的 .act-link 之类是单类选择器，
   优先级跟 .pending 相同，而页面 <style> 在 lesson.css 之后，会赢。
   加上标签选择器才压得住，否则降级过的链接看起来仍像能点。 */
a.pending, a.pending:hover {
  color: var(--sub) !important;
  background: transparent !important;
  border-color: var(--line) !important;
  border-bottom: 1px dotted var(--line);
  cursor: default;
  text-decoration: none;
  transform: none !important;
}
a.pending:after {
  content: "（即将上线）";
  font-size: .85em;
  opacity: .7;
}

/* ── 免责声明：每页必带 ──────────────────────────────────── */
.disclaimer {
  margin-top: 48px; padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.8; color: var(--sub);
}
.disclaimer b { color: var(--sub); }
/* 章级强化免责，目前只有 P8 情绪周期用 */
.disclaimer.strong {
  background: rgba(220, 38, 38, .05);
  border: 1px solid rgba(220, 38, 38, .2);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
}

/* ── 移动端 ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .lesson { padding: 28px 18px 80px; }
  .lesson h1 { font-size: 23px; }
  .key-line { font-size: 15.5px; padding: 20px; }
  .objective, .exercise { grid-template-columns: 1fr; }
  .exercise-num { display: none; }
  .datum-num { font-size: 27px; }
}

/* ── 打印与可访问性 ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  body { opacity: 1; animation: none; }
  * { transition: none !important; animation: none !important; }
}

/* ══════════════════════════════════════════════════════════
   交互组件通用样式

   A股 频道那 143 节里，每页各写各的内联样式，类名也各不相同，
   那是因为它们的交互形态差异很大，统一反而是束缚。

   期货频道换了做法：把反复出现的那几种组件（数值卡片、输入行、
   结论条、参考表、按钮行）统一成一套类名放在这里，课页只写自己
   特有的部分。125 节课，每节省下 50 到 70 行重复的 CSS。

   A股 页面不受影响：它们的内联 <style> 在这个文件之后加载，
   同名类会覆盖掉这里的定义。
   ══════════════════════════════════════════════════════════ */

/* 数值卡片：并排显示几个关键数字 */
.calc-row {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px;
}
.calc-cell {
  flex: 1 1 130px; min-width: 0; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.calc-cell .lbl {
  font-size: 11.5px; color: var(--sub); font-weight: 700; margin-bottom: 5px;
}
.calc-cell .val {
  font-size: 21px; font-weight: 800; color: var(--accent-deep);
  font-variant-numeric: tabular-nums; line-height: 1.2;
  overflow-wrap: anywhere;
}
.calc-cell.loss .val { color: #dc2626; }
.calc-cell.gain .val { color: #059669; }
:root[data-theme="dark"] .calc-cell.loss .val { color: #f87171; }
:root[data-theme="dark"] .calc-cell.gain .val { color: #34d399; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .calc-cell.loss .val { color: #f87171; }
  :root:not([data-theme="light"]) .calc-cell.gain .val { color: #34d399; }
}

/* 输入行：让用户填自己的数字。
   用 grid 而不是 flex，是为了让不同长度的标签也能对齐成一列列。 */
.calc-inputs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 11px; margin: 0 0 14px;
}
.calc-inputs label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--sub); font-weight: 700;
}
.calc-inputs input,
.calc-inputs select {
  font: inherit; font-size: 14px; padding: 8px 10px; width: 100%;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.calc-inputs input:focus,
.calc-inputs select:focus {
  outline: none; border-color: var(--accent);
}

/* 滑块 */
.widget input[type="range"] {
  width: 100%; margin: 0 0 14px; accent-color: var(--accent);
}

/* 结论条：交互算完之后那句话。
   三种状态用左边框区分，不靠背景色，暗色下更稳。 */
.verdict {
  margin: 14px 0 0; padding: 12px 15px; font-size: 13.5px; line-height: 1.8;
  border-left: 3px solid var(--line); border-radius: 0 8px 8px 0;
  background: var(--bg); color: var(--text);
}
.verdict.ok   { border-left-color: #059669; background: rgba(5,150,105,.06); }
.verdict.warn { border-left-color: #d97706; background: rgba(217,119,6,.07); }
.verdict.bad  { border-left-color: #dc2626; background: rgba(220,38,38,.07); }

/* 参考表 */
table.reftable {
  width: 100%; border-collapse: collapse; font-size: 14px; min-width: 380px;
}
table.reftable th,
table.reftable td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
table.reftable th {
  font-size: 12px; color: var(--sub); font-weight: 700;
}
table.reftable td:last-child {
  font-weight: 700; color: var(--accent-deep); text-align: right;
  font-variant-numeric: tabular-nums;
}
table.reftable td:first-child { color: var(--sub); }
table.reftable tr.hl td { background: var(--accent-soft); }

/* 按钮行 */
.btn-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px;
}
.btn-row button {
  font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer;
  padding: 9px 15px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff;
}
.btn-row button:hover { filter: brightness(1.07); }
.btn-row button.ghost {
  background: transparent; color: var(--sub); border-color: var(--line);
}
.btn-row button.ghost:hover { border-color: var(--accent); color: var(--accent-deep); }

/* ── 历史事件类课页的组件 ────────────────────────────
   时间线、机制框、阅读提示、数据表。原来只写在 slides/s10-6、s10-7、
   s10-8 三个页面的内联 style 里，期货那两节历史事件课（f8-6 负油价、
   f8-7 伦镍）因此只能用 sec-label 加段落，排版明显单薄。
   抽到这里之后两个频道共用，A股 那三页不受影响：
   它们的内联 style 在本文件之后加载，同名类会覆盖。          */

.tl { position: relative; margin: 26px 0 26px 8px; padding-left: 28px; }
.tl::before { content: ''; position: absolute; left: 6px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line); }
.tl-i { position: relative; padding: 0 0 22px; }
.tl-i:last-child { padding-bottom: 0; }
.tl-i::before { content: ''; position: absolute; left: -28px; top: 5px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid var(--bg); }
.tl-d { font-size: 12px; color: var(--sub); font-weight: 700;
  letter-spacing: .03em; margin-bottom: 5px; }
.tl-i h4 { margin: 0 0 7px; font-size: 15px; font-weight: 800; color: var(--accent-deep); }
.tl-i p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.85; }
.tl-i p:last-child { margin: 0; }
.tl-i .think { display: block; margin-top: 9px; padding: 11px 14px; border-radius: 7px;
  background: var(--accent-soft); font-size: 13px; line-height: 1.8; }
.tl-i .think b { color: var(--accent-deep); }

.tbl { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 13.5px; }
.tbl th, .tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line);
  text-align: left; line-height: 1.75; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--sub); font-weight: 700; }
.tbl td:first-child { font-weight: 700; color: var(--accent-deep); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 给机制起个名字，装进这个框。读者记住的往往就是这一块。 */
.key { border: 1.5px solid var(--accent); border-radius: var(--radius);
  padding: 20px 22px; margin: 26px 0; background: var(--card); }
.key h4 { margin: 0 0 12px; font-size: 16px; font-weight: 800; color: var(--accent-deep); }
.key p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.85; }
.key p:last-child { margin: 0; }
.key b { color: var(--accent-deep); }

/* 阅读提示：历史事件课的前置声明，跟页脚免责声明是双重的 */
.hind { border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 15px 18px; margin: 22px 0;
  background: var(--card); font-size: 13px; line-height: 1.8; color: var(--sub); }
.hind b { color: var(--text); }

/* 数据出处：正文里引用统计时的来源说明。字号比正文小一档，
   跟正文拉开层级但仍然可读，因为出处本身就是内容的一部分。 */
.src { margin: 18px 0; padding: 12px 15px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.85; color: var(--sub); }
.src b { color: var(--text); }
