/* =============================================================================
 * theme.css —— 《托勒密不等式》主题样式
 * -----------------------------------------------------------------------------
 * 风格：浅色学术风（与 symmetry-period 同源），几何图为主角。
 *   · 动画只动 transform / opacity（GPU 合成）
 *   · ⚠️ 动画状态段（.is-on 等）必须留在文件**末尾**，否则被同权重规则覆盖
 *     （slidekit/AGENTS.md 坑 E3）
 * ========================================================================== */

/* ------------------------------------------------------------------ 基线 */
/* 全站禁止选中文字：触摸屏上"点击推进"很容易变成"选中整页文字"，出现一片蓝色高亮。
   课件不需要复制文本，直接关掉，同时禁用长按菜单与点击高亮。 */
html, body {
  -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}

/* ---------------------------------------------------------------- 0. 变量 */
:root {
  --bg:        #FAFAF8;
  --ink:       #1F2A44;
  --ink-2:     #5A6478;
  --ink-3:     #8A93A6;
  --geo:       #1D4ED8;   /* 四边形 / 三角形 主线条 */
  --geo-2:     #60A5FA;   /* 次级辅助线 */
  --geo-3:     #93C5FD;   /* 更弱的构造线 */
  --diag:      #B45309;   /* 对角线（与边区分开） */
  --accent:    #E8552D;   /* 结论 / 答案 / 按钮强调 */
  --accent-l:  #FDE8D8;
  --equal:     #0E9488;   /* 全等 / 取等相关 */
  --equal-l:   #D6F3EF;
  --fill-a:    rgba(16, 185, 129, .30);   /* 相似三角形填充 A */
  --fill-b:    rgba(100, 116, 139, .26);  /* 相似三角形填充 B */
  --grid:      #F0F2F7;
  --axis:      #8A93A6;
  --line:      #D5DAE5;
  --cn: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --math: "Cambria Math", "Latin Modern Math", "Times New Roman", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #E9EAE6;
  font-family: var(--cn);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- 1. 舞台 */
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1920px; height: 1080px;
  background: var(--bg);
  transform-origin: 50% 50%;
  overflow: hidden;
}

.slide {
  position: absolute; inset: 0;
  padding: 70px 110px 120px;   /* 底部多留：工具栏与 HUD 固定在舞台底边 */
  opacity: 0; visibility: hidden;
  transition: opacity 300ms ease, transform 300ms ease;
  transform: translateY(14px);
}
.slide.active {
  opacity: 1; visibility: visible;
  transform: translateY(0);
}

/* ------------------------------------------------------------ 1.5 品牌 logo */
#brand {
  position: absolute; top: 36px; right: 46px;
  width: 160px; height: 45px;
  object-fit: contain;
  z-index: 50;
  opacity: .92;
  pointer-events: none;
}

/* ---------------------------------------------------------------- 2. 页头 */
.head { text-align: center; margin-bottom: 18px; }
.head__title {
  font-size: 46px; font-weight: 700; line-height: 1.2; letter-spacing: .5px;
}
.head__formula {
  margin-top: 12px; font-size: 30px; color: var(--ink);
}
.head__formula .katex { font-size: 1em; }

/* ---------------------------------------------------------------- 3. 封面 */
.slide--cover {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.cover__kicker {
  font-size: 24px; color: var(--ink-2); letter-spacing: 3px; margin-bottom: 30px;
}
.cover__title {
  font-size: 92px; font-weight: 700; letter-spacing: 8px; line-height: 1.1;
}
.cover__sub {
  margin-top: 22px; font-size: 34px; color: var(--ink-2); letter-spacing: 2px;
}
.cover__rule {
  width: 160px; height: 5px; background: var(--accent);
  margin: 40px 0 34px; border-radius: 3px;
}
.cover__meta {
  font-size: 28px; color: var(--ink-2); letter-spacing: 1px;
}
.cover__meta b { color: var(--ink); }
.cover__dot { margin: 0 14px; color: var(--ink-3); }

/* ------------------------------------------------------- 4. 动画页（几何图） */
.slide--anim { display: flex; flex-direction: column; }

.figwrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 0 10px;
}
/* 交给 SVG 的 preserveAspectRatio 适配：填满图区且不变形 */
.fig { width: 100%; height: 100%; }

/* 说明文字只留"结论"——解释性语言由老师现场讲，不占版面 */
.caption { text-align: center; min-height: 96px; padding: 10px 0 0; }
.caption__conc {
  font-size: 38px; font-weight: 700; color: var(--accent); letter-spacing: .5px;
}
.caption__sub {
  margin-top: 10px; font-size: 26px; color: var(--ink-2); letter-spacing: .5px;
}

/* ------------------------------------------------------------ 5. 方法总结 */
.ttable {
  margin-top: 22px;
  border: 2px solid var(--line); border-radius: 20px; overflow: hidden;
  background: #fff;
}
.ttable__head, .ttable__row {
  display: grid; grid-template-columns: 420px 1fr; align-items: center;
}
.ttable__head {
  padding: 16px 40px; background: #F7F8FC;
  border-bottom: 2px solid var(--line);
  font-size: 24px; font-weight: 700; color: var(--ink-2); letter-spacing: 2px;
}
.ttable__row { padding: 24px 40px; border-bottom: 1px solid var(--line); }
.ttable__row:last-child { border-bottom: 0; }
.ttable__cond { font-size: 32px; color: var(--ink); }
.ttable__val {
  font-size: 38px; font-weight: 700; color: var(--geo); text-align: center;
}
.ttable__val--txt { font-size: 34px; }
.ttable__row--hl { background: var(--accent-l); }
.ttable__row--hl .ttable__val { color: var(--accent); }

.mnemonic {
  margin-top: 34px;
  display: flex; align-items: center; justify-content: center; gap: 22px;
}
.mnemonic__key {
  background: var(--ink); color: #fff; font-size: 24px; font-weight: 700;
  padding: 8px 22px; border-radius: 10px; letter-spacing: 3px;
}
.mnemonic__txt { font-size: 42px; font-weight: 700; color: var(--ink); }
.mnemonic__txt em { font-style: normal; color: var(--accent); font-size: 50px; }

.note {
  margin-top: 30px; padding: 18px 30px; font-size: 25px; line-height: 1.6; color: var(--ink-2);
  background: #fff; border-left: 6px solid var(--line); border-radius: 8px;
}
.note b { color: var(--accent); }

/* --------------------------------------------------------- 6. 课堂小结页 */
.crow {
  display: grid; grid-template-columns: 160px 1fr; gap: 20px;
  align-items: center;
  margin-top: 22px; padding: 20px 30px;
  background: #fff; border: 2px solid var(--line); border-radius: 16px;
}
.crow__k {
  font-size: 26px; font-weight: 700; color: #fff; background: var(--geo);
  border-radius: 10px; text-align: center; padding: 8px 0; letter-spacing: 2px;
}
.crow__v { font-size: 31px; line-height: 1.5; }

/* --------------------------------------------------------- 6.5 课后小练页 */
.hw {
  display: grid; grid-template-columns: 96px 1fr; gap: 30px; align-items: center;
  margin-top: 34px; padding: 30px 40px;
  background: #fff; border: 2px solid var(--line); border-radius: 22px;
}
.hw__no {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--geo); color: #fff;
  font-size: 44px; font-weight: 700; line-height: 96px; text-align: center;
}
/* 思考题用"探究色"，与必做作业区分开 */
.hw--think .hw__no { background: var(--equal); }
.hw__t { font-size: 42px; font-weight: 700; line-height: 1.35; }
.hw__s { margin-top: 14px; font-size: 26px; color: var(--ink-2); line-height: 1.6; }

/* -------------------------------------------------------------- 7. 题页 */
/* 注意：题页最容易超屏（长题干 + 选项 + 多步解析）。
   字号/间距按「P8 例1 全展开不溢出」定标，改大前先跑自检的溢出检查。 */
.slide--prob { display: flex; flex-direction: column; }
/* 带配图的题页：左文右图（图上文字少，竖着放） */
.slide--prob.prob--split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 620px;
  grid-template-rows: 1fr;
  gap: 44px; align-items: start;
  padding-right: 92px;
}
.prob__figwrap {
  display: flex; align-items: center; justify-content: center;
  height: 100%; min-height: 0;
}
.prob__body { min-width: 0; }

.prob__head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.prob__no { font-size: 30px; font-weight: 700; }
.prob__tag {
  display: inline-block; font-size: 19px; color: var(--accent);
  background: var(--accent-l); border-radius: 999px; padding: 4px 16px;
}
.prob__stem { font-size: 29px; line-height: 1.6; margin-bottom: 18px; }
/* 选项两列排布：4 个选项从 4 行压到 2 行，把省下的高度让给解析 */
.prob__opts {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 20px; margin-bottom: 14px;
}
.opt {
  display: flex; align-items: flex-start; gap: 14px;
  font-size: 29px; line-height: 1.42;
  padding: 14px 26px; border-radius: 12px; border: 2px solid transparent;
  background: #fff;
}
.opt__key { font-weight: 700; color: var(--ink-2); min-width: 38px; }
.opt.is-correct { border-color: var(--accent); background: var(--accent-l); }
.opt.is-correct .opt__key { color: var(--accent); }

/* 填空题：没有选项，答案单独成块 */
.ansbox {
  display: inline-block; margin-bottom: 16px;
  padding: 12px 34px; border-radius: 14px;
  border: 2px solid var(--accent); background: var(--accent-l);
  font-size: 34px; font-weight: 700; color: var(--accent);
}
.ansbox__k { font-size: 24px; font-weight: 700; letter-spacing: 2px; margin-right: 16px; }

.prob__sol { margin-top: 4px; }
.sol__title {
  font-size: 27px; font-weight: 700; color: var(--accent); margin-bottom: 10px;
}
.sol__step {
  font-size: 29px; line-height: 1.58; color: var(--ink);
  padding: 8px 0 8px 56px; position: relative;
}
.sol__step::before {
  content: attr(data-idx);
  position: absolute; left: 6px; top: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--geo); color: #fff;
  font-size: 20px; line-height: 34px; text-align: center; font-weight: 700;
}

/* -------------------------------------------------------------- 8. 结束页 */
.slide--end {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.end__title { font-size: 68px; font-weight: 700; letter-spacing: 6px; }
.end__sub {
  margin-top: 30px; font-size: 30px; color: var(--ink-2); line-height: 1.9;
}
.end__thanks {
  margin-top: 54px; font-size: 34px; color: var(--accent); letter-spacing: 6px;
}
.end__teacher { margin-top: 18px; font-size: 26px; color: var(--ink-3); letter-spacing: 2px; }

/* ------------------------------------------------------------ 9. 工具栏 */
#toolbar {
  position: absolute; left: 48px; bottom: 34px;
  display: flex; align-items: center; gap: 12px; z-index: 60;
}
/* 右下角：只留页码（操作提示交给老师口述，不占版面） */
#hud {
  position: absolute; right: 48px; bottom: 34px;
  display: flex; align-items: center; z-index: 60;
  pointer-events: none;
}
.hud-page {
  font-size: 22px; font-weight: 700; color: var(--ink); letter-spacing: 1px;
  background: rgba(255,255,255,.86);
  border: 2px solid var(--line); border-radius: 999px;
  padding: 12px 22px; min-width: 96px; text-align: center;
}
.tbtn {
  width: 56px; height: 56px; border-radius: 50%;
  background: #fff; border: 2px solid var(--line); color: var(--ink);
  font-size: 26px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--cn);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 140ms ease, transform 120ms ease;
}
.tbtn:active { border-color: var(--accent); transform: scale(.94); }
.tbtn.is-hidden { display: none; }

/* ------------------------------------------------ 10. SVG 图元（几何专用） */
/* 多边形的边：深蓝粗线 */
.side      { stroke: var(--geo); stroke-width: 6; fill: none; stroke-linecap: round; }
.side--hl  { stroke: var(--geo); stroke-width: 9; }
/* 对角线：暖色，与边区分。
   ⚠️ 这些线要"描边生长"（JS 逐帧写 stroke-dashoffset），所以**不能**用 stroke-dasharray
   —— 虚线与生长互相打架，属"同一属性两个驱动源"（symmetry-period 坑 S9）。虚线只留给不生长的角度弧。 */
.diag      { stroke: var(--diag); stroke-width: 5; fill: none; stroke-linecap: round; }
.diag--hl  { stroke: var(--diag); stroke-width: 8; }
/* 构造线（辅助作图，出现时的"画线"效果） */
.aux       { stroke: var(--equal); stroke-width: 5; fill: none; stroke-linecap: round; }
.aux--thin { stroke: var(--equal); stroke-width: 3.5; }
/* 辅助圆 / 外接圆（同样实线，靠颜色与粗细区分） */
.circle    { stroke: var(--geo-2); stroke-width: 3.5; fill: none; }
.circle--hl{ stroke: var(--geo-2); stroke-width: 5; fill: none; }
/* 顶点与标签 */
.vtx       { fill: var(--geo); stroke: #fff; stroke-width: 3; }
.vtx--hl   { fill: var(--accent); stroke: #fff; stroke-width: 3; }
.vtx--aux  { fill: var(--equal); stroke: #fff; stroke-width: 3; }
.vlabel {
  font-family: var(--math); font-style: italic; font-size: 40px;
  fill: var(--ink); font-weight: 600;
  /* 白色描边：顶点字母常常压在几条线交汇处，没有描边就"糊"在图里（P9 的 A 点实测） */
  paint-order: stroke fill; stroke: var(--bg); stroke-width: 8px; stroke-linejoin: round;
}
.vlabel--aux { fill: var(--equal); }
/* 三角形高亮填充 */
.fill-a { fill: var(--fill-a); stroke: none; }
.fill-b { fill: var(--fill-b); stroke: none; }
.fill-eq { fill: var(--equal-l); stroke: none; opacity: .95; }
/* 图内标注 */
.mark {
  font-family: var(--cn); font-size: 27px; font-weight: 700; fill: var(--accent);
  paint-order: stroke fill; stroke: var(--bg); stroke-width: 8px; stroke-linejoin: round;
}
.mark--geo { fill: var(--geo); }
.mark--diag { fill: var(--diag); }
.mark--equal { fill: var(--equal); }
.mark--ink { fill: var(--ink-2); font-weight: 400; }
/* 直角标记 */
.right-angle { stroke: var(--ink); stroke-width: 3.5; fill: none; }
/* 等长标记（小竖线） */
.tick { stroke: var(--diag); stroke-width: 4; }
/* 折线对比高亮（BE + ED） */
.path-hl { stroke: var(--equal); stroke-width: 9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.seg-hl  { stroke: var(--accent); stroke-width: 8; fill: none; stroke-linecap: round; }

svg text { -webkit-user-select: none; user-select: none; }
svg, .fig { -webkit-tap-highlight-color: transparent; }

/* =============================================================================
 * 11. 动画状态段 —— 必须留在文件末尾（坑 E3：同权重靠文件顺序决胜）
 * ========================================================================== */

/* 默认隐藏：所有带 data-step 的元素，只有加了 .is-on 才出现 */
[data-step] { opacity: 0; }
[data-step].is-on { opacity: 1; }

/* SVG 图元同理：建图时写 opacity="0" 属性（几何元素太多，逐个挂 data-step 不现实），
   显示 = 加 .is-on 类。CSS 规则优先于 presentation attribute，所以这一条能覆盖属性值，
   而 reset() 只需移除类，浏览器自动回到 opacity="0"，无残留。 */
svg .is-on { opacity: 1; }
/* 需要常显的图元（题页配图的静态部分）：加 .always 直接可见 */
svg .always { opacity: 1; }

/* 需要位移动画的元素：基态写在这里，目标态在 .is-on */
.rise       { transform: translateY(26px); transition: opacity 520ms ease, transform 520ms ease; }
.rise.is-on { transform: translateY(0); }

/* 瞬时模式（?stage=K / ?finish=1 / ?selftest=1）：整棵子树关掉过渡。
   ⚠️ 为什么必须这样：headless + `--virtual-time-budget` 会快进 setTimeout，
   **但 CSS 过渡不跟着推进**（slidekit 坑 E6）—— 不关过渡，截图抓到的是淡入到一半的
   灰蒙蒙状态（实测：整页文字都像"没显示出来"）。关掉之后终态与帧率、机器无关。 */
.instant, .instant *, .instant *::before, .instant *::after { transition: none !important; }

/* ⚠️ 描边生长由 JS 逐帧写 stroke-dashoffset（rAF），这里**绝不能**再加
   `transition: stroke-dashoffset` —— 两者叠加会让渲染值一直"追赶"每帧的目标值
   （见 slidekit/AGENTS.md 坑 E6 与 symmetry-period 坑 S9）。 */

/* class 驱动的淡入（图形元素） */
.side, .diag, .aux, .circle, .vtx, .vlabel, .mark, .fill-a, .fill-b, .fill-eq,
.path-hl, .seg-hl, .tick, .right-angle {
  transition: opacity 420ms ease;
}
/* ⚠️ 凡是**由 JS 逐帧写 opacity** 的元素都要加这个类，
   否则 CSS 过渡会对每一帧的赋值再做一次插值（同 S9 的坑）。 */
.no-ftrans { transition: none !important; }

/* 弹入 */
.pop       { transform: scale(.94); transition: opacity 320ms ease, transform 320ms cubic-bezier(.34,1.3,.64,1); }
.pop.is-on { transform: scale(1); }
