/* ============================================================
   ch20「器电路通」章节样式
   元婴一层·器电路通（元婴期开篇章）
   境界色：月白 #D6ECF0（清冷如月光照硅城）
   章节Boss：延迟真君（银甲武将，"快"字刀）
   本命石新痕：第二十痕「衡纹」（天平，PPA权衡标志）
   ============================================================ */
:root {
  --realm-color: #D6ECF0;
  --realm-glow: #D6ECF033;
  --moon-strong: #B6D8E0;
  --moon-soft: #D6ECF055;
  --tower-color: #8FA8B0;       /* 六层延迟塔 银灰 */
  --fast-color: #C0D8E0;        /* "快"字刀 银 */
  --collapse-color: #D24735;    /* 硅渣熔毁 红 */
  --balance-color: #A8C8D0;      /* 天平银辉 */
}

/* 开场标题 */
.op-title span,
.op-sub {
  color: var(--realm-color);
  text-shadow: 0 0 18px rgba(214, 236, 240, 0.35);
}
/* 元婴期·月白光晕：开场与场景头点缀 */
.op-kicker,
.scene-kicker {
  color: var(--realm-color);
}
/* focus-breath 呼吸光晕（下一场景按钮引导） */
.focus-breath {
  box-shadow: 0 0 0 0 #D6ECF066;
  animation: ch20Breath 2s ease-in-out infinite;
}
@keyframes ch20Breath {
  0%, 100% { box-shadow: 0 0 0 0 #D6ECF066; }
  50% { box-shadow: 0 0 16px 4px #D6ECF044; }
}

/* S0 月白门：开场门洞光晕 */
.scene[data-scene="s0"] .scene-title {
  background: linear-gradient(90deg, var(--realm-color) 0%, var(--moon-strong) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* S2 功耗殿：被高热染红的过渡警示 */
.scene[data-scene="s2"] .scene-kicker {
  color: #E8A87C;
}

/* S6 衡天台·PPA天平：月白+银辉渐变 */
.scene[data-scene="s6"] .scene-title {
  background: linear-gradient(90deg, var(--realm-color) 0%, var(--balance-color) 50%, var(--realm-color) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* S7 终极崩塌：硅渣熔毁红光 */
.scene[data-scene="s7"] .scene-kicker {
  color: var(--collapse-color);
}
.scene[data-scene="s7"] .insight {
  border-left-color: var(--collapse-color);
}

/* S8 度化之夜：银甲→月白渐变 */
.scene[data-scene="s8"] .scene-title {
  background: linear-gradient(90deg, var(--fast-color) 0%, var(--realm-color) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* S9 Boss 战触发按钮：月白描边 + 银辉光晕 */
#s9-start {
  border-color: var(--realm-color);
  color: var(--realm-color);
  position: relative;
}
#s9-start::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, #D6ECF022, transparent 70%);
  animation: ch20BossPulse 2.4s ease-in-out infinite;
}
@keyframes ch20BossPulse {
  0%, 100% { opacity: .4; }
  50% { opacity: 1; }
}
#s9-start:hover {
  background: var(--realm-color);
  color: #1a1a1a;
}

/* ============================================================
   PPA 天平（S0/S6 交互容器视觉）
   三端：Delay / Energy / Area，月白+银辉
   ============================================================ */
.ppa-balance {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 0.6rem;
  margin: 1rem 0;
  padding: 0.8rem;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
}
.ppa-balance .ball {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--realm-color), var(--tower-color));
  box-shadow: 0 0 12px #D6ECF055;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #1a1a1a;
  font-family: var(--font-mono, monospace);
}
.ppa-balance .beam {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--balance-color), transparent);
  align-self: center;
}

/* 六层延迟塔视觉（S1-S6 场景头点缀） */
.tower-rune {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 0.3rem;
  background: linear-gradient(180deg, var(--realm-color) 0%, var(--tower-color) 100%);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  vertical-align: middle;
  opacity: 0.7;
}

/* ============================================================
   衡纹（S10 本命石第二十痕）
   银色天平：左端"快"字、右端"省"字、指针在正中
   ============================================================ */
.s10-scar-hengwen {
  display: inline-block;
  width: 96px;
  height: 56px;
  position: relative;
  vertical-align: middle;
  margin: 0 0.4rem;
}
.s10-scar-hengwen svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.s10-scar-hengwen .hwen-beam {
  stroke: var(--realm-color);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 0 4px #D6ECF066);
}
.s10-scar-hengwen .hwen-arm {
  stroke: var(--balance-color);
  stroke-width: 1.6;
  fill: none;
}
.s10-scar-hengwen .hwen-pan {
  stroke: var(--realm-color);
  stroke-width: 1.4;
  fill: rgba(214,236,240,0.12);
}
.s10-scar-hengwen .hwen-pointer {
  stroke: var(--realm-color);
  stroke-width: 2.2;
  filter: drop-shadow(0 0 3px var(--realm-color));
  animation: hwenBalance 3.6s ease-in-out infinite;
}
@keyframes hwenBalance {
  0%, 100% { transform: rotate(-3deg); transform-origin: 48px 18px; }
  50% { transform: rotate(3deg); transform-origin: 48px 18px; }
}
.s10-scar-hengwen .hwen-glyph {
  font-family: var(--font-serif, serif);
  font-size: 7px;
  fill: var(--realm-color);
  text-anchor: middle;
}
.s10-scar-hengwen .hwen-tau {
  font-family: var(--font-mono, monospace);
  font-size: 8px;
  fill: var(--balance-color);
  text-anchor: middle;
}

/* S10 碎片归位容器（K20-01~K20-22） */
.s10-curve-host {
  margin: 1.2rem 0;
  padding: 1rem;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}
.s10-curve-host .frag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.5rem;
}
.frag-node {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.1));
  border-radius: 8px;
  background: transparent;
  color: var(--text-3, #75878A);
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.25s var(--ease-out, ease);
}
.frag-node:hover {
  border-color: var(--realm-color);
  color: var(--realm-color);
}
.frag-node.lit {
  border-color: var(--realm-color);
  background: rgba(214,236,240,0.12);
  color: var(--realm-color);
  box-shadow: 0 0 12px rgba(214,236,240,0.3);
}

/* 境界突破铭刻 */
.inscription {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--realm-color);
  border-radius: 8px;
  background: rgba(214,236,240,0.1);
  color: var(--realm-color);
  font-family: var(--font-serif, serif);
  text-align: center;
  animation: ch20Inscription 1.2s var(--ease-out, ease);
}
@keyframes ch20Inscription {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ch21 解锁链接：月白 */
.s10-next-link {
  display: inline-block;
  padding: 0.5rem 1.4rem;
  border-radius: 8px;
  border: 1px solid var(--realm-color);
  background: rgba(214,236,240,0.12);
  color: var(--realm-color);
  text-decoration: none;
  transition: all 0.3s var(--ease-out, ease);
}
.s10-next-link:hover {
  background: rgba(214,236,240,0.22);
  box-shadow: 0 0 18px rgba(214,236,240,0.35);
}
/* 五重失效崩塌图例（S7） */
.collapse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0;
}
.collapse-card {
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(210,71,53,0.4);
  border-radius: 8px;
  background: rgba(210,71,53,0.08);
  font-size: 0.8rem;
  color: #E8A87C;
}
.collapse-card b {
  color: var(--collapse-color);
}

/* 互连预告时间轴（S10） */
.interconnect-timeline {
  margin: 1rem 0;
  padding: 0.8rem;
  border: 1px solid var(--glass-border, rgba(255,255,255,0.08));
  border-radius: 8px;
  background: rgba(0,0,0,0.2);
  font-size: 0.82rem;
  line-height: 1.8;
}
.interconnect-timeline .cross-point {
  color: var(--realm-color);
  font-family: var(--font-mono, monospace);
}

/* ============================================================
   ch20 交互组件通用样式（元婴期紫色 #8B5CF6）
   ============================================================ */
.cmp-ppa-balance, .cmp-power-threeknob, .cmp-edp-assembler, .cmp-boss-eliminator,
.cmp-delay-eq, .cmp-rf-ft, .cmp-logical-effort, .cmp-pvt, .cmp-sublimate {
  padding: 0.8rem;
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 12px;
  background: rgba(30,20,50,0.55);
}
.cmp-header {
  margin-bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.cmp-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #E2E8F0;
}
.cmp-sub {
  font-size: 0.75rem;
  color: #94A3B8;
}

/* 滑块/旋钮控制行 */
.ppa-ctrl, .knob-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.ppa-row, .knob-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: #E2E8F0;
}
.ppa-row label, .knob-row label {
  min-width: 5rem;
  color: #94A3B8;
  font-family: var(--font-mono, monospace);
}
.ppa-row input[type=range], .knob-row input[type=range] {
  flex: 1;
  accent-color: #8B5CF6;
}
.ppa-val, .knob-val {
  min-width: 4rem;
  text-align: right;
  font-family: var(--font-mono, monospace);
  color: #8B5CF6;
  font-weight: 600;
}
.ppa-wbtns {
  display: inline-flex;
  gap: 0.25rem;
}
.wbtn {
  padding: 0.2rem 0.7rem;
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 6px;
  background: transparent;
  color: #94A3B8;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all 0.2s ease;
}
.wbtn:hover { border-color: #8B5CF6; color: #E2E8F0; }
.wbtn.active {
  background: rgba(139,92,246,0.2);
  border-color: #8B5CF6;
  color: #8B5CF6;
}

/* 结果面板 */
.ppa-result {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.ppa-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border: 1px solid rgba(148,163,184,0.2);
  border-radius: 8px;
  min-width: 5rem;
}
.m-label { font-size: 0.65rem; color: #94A3B8; text-transform: uppercase; }
.m-val { font-size: 1.1rem; font-weight: 700; color: #E2E8F0; font-family: var(--font-mono, monospace); }
.m-unit { font-size: 0.6rem; color: #75878A; }

/* Boss 区 */
.ppa-boss, .boss-stage {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(210,71,53,0.3);
  border-radius: 8px;
  background: rgba(210,71,53,0.06);
}
.boss-sprite {
  font-size: 1.3rem;
  color: #DC2626;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(220,38,38,0.4);
}
.boss-bet, .boss-dialogue {
  font-size: 0.8rem;
  color: #E8A87C;
}

/* 弯路区 */
.ppa-wrong { margin: 0.4rem 0; }
.wrong-path {
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(210,71,53,0.4);
  border-radius: 6px;
  background: rgba(210,71,53,0.1);
  color: #E8A87C;
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
}
.wrong-path b { color: var(--collapse-color); }

/* 导师提示 */
.ppa-mentor {
  padding: 0.5rem 0.7rem;
  border-left: 3px solid #8B5CF6;
  background: rgba(139,92,246,0.08);
  color: #C4B5FD;
  font-size: 0.8rem;
  border-radius: 0 6px 6px 0;
  margin-top: 0.4rem;
}

/* 确认按钮 */
.cmp-confirm-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem 1rem;
  border: 1px solid #8B5CF6;
  border-radius: 8px;
  background: rgba(139,92,246,0.15);
  color: #8B5CF6;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}
.cmp-confirm-btn:hover {
  background: rgba(139,92,246,0.3);
  box-shadow: 0 0 12px rgba(139,92,246,0.3);
}
.cmp-confirm-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 功耗条 */
.power-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.5rem 0;
}
.pbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
}
.bar-label { min-width: 5.5rem; color: #94A3B8; }
.bar-track {
  flex: 1;
  height: 14px;
  background: rgba(148,163,184,0.12);
  border-radius: 7px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s ease;
}
.bar-num {
  min-width: 4rem;
  text-align: right;
  font-family: var(--font-mono, monospace);
  color: #E2E8F0;
}

/* 热像图读数 */
.temp-readout {
  font-size: 0.75rem;
  color: #94A3B8;
  margin-top: 0.3rem;
  font-family: var(--font-mono, monospace);
}

/* 公式组装区 */
.formula-zone {
  margin: 0.5rem 0;
}
.formula-slots {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.slot {
  padding: 0.6rem 1rem;
  border: 2px dashed rgba(139,92,246,0.3);
  border-radius: 8px;
  background: rgba(139,92,246,0.05);
  min-width: 6rem;
  text-align: center;
  font-size: 0.85rem;
  color: #94A3B8;
  transition: all 0.25s ease;
}
.slot.filled {
  border-style: solid;
  border-color: #8B5CF6;
  background: rgba(139,92,246,0.12);
  color: #E2E8F0;
}
.slot.slot-edp {
  border-style: solid;
  border-color: rgba(139,92,246,0.5);
  color: #C4B5FD;
}
.slot-label { font-family: var(--font-mono, monospace); }
.formula-fragments {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.ffrag {
  padding: 0.35rem 0.7rem;
  border: 1px solid rgba(148,163,184,0.3);
  border-radius: 6px;
  background: transparent;
  color: #94A3B8;
  cursor: pointer;
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  transition: all 0.2s ease;
}
.ffrag:hover {
  border-color: #8B5CF6;
  color: #E2E8F0;
  background: rgba(139,92,246,0.08);
}
.formula-result {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  margin-top: 0.4rem;
  font-size: 0.78rem;
}
.formula-result.ok {
  border: 1px solid #22C55E;
  background: rgba(34,197,94,0.08);
  color: #86EFAC;
}
.formula-result.bad {
  border: 1px solid #EF4444;
  background: rgba(239,68,68,0.08);
  color: #FCA5A5;
}
.formula-ok b, .formula-wrong b { font-weight: 700; }

/* 崩塌区 */
.collapse-zone { margin: 0.5rem 0; }
.collapse-hint {
  font-size: 0.78rem;
  color: #E8A87C;
  margin-bottom: 0.4rem;
}
.collapse-card {
  transition: all 0.4s ease;
}
.collapse-card.active {
  animation: ch20CollapseFlash 0.5s ease;
}
@keyframes ch20CollapseFlash {
  0% { transform: scale(0.95); opacity: 0.3; }
  100% { transform: scale(1); opacity: 1; }
}

/* Boss 问答 */
.question-panel {
  margin-top: 0.5rem;
}
.question-text {
  font-size: 0.85rem;
  color: #E2E8F0;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.q-option {
  display: block;
  width: 100%;
  margin-bottom: 0.3rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(139,92,246,0.2);
  border-radius: 8px;
  background: rgba(139,92,246,0.05);
  color: #E2E8F0;
  cursor: pointer;
  text-align: left;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}
.q-option:hover {
  border-color: #8B5CF6;
  background: rgba(139,92,246,0.12);
}
.q-option.correct {
  border-color: #22C55E;
  background: rgba(34,197,94,0.15);
  color: #86EFAC;
}
.q-option.wrong {
  border-color: #EF4444;
  background: rgba(239,68,68,0.15);
  color: #FCA5A5;
}
.boss-transform {
  padding: 0.6rem;
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 8px;
  background: rgba(139,92,246,0.08);
  color: #C4B5FD;
  font-size: 0.82rem;
  text-align: center;
}
.boss-transform p { margin-top: 0.3rem; color: #94A3B8; font-size: 0.75rem; }

/* 刻痕条目 */
.carve-item {
  padding: 0.3rem 0.5rem;
  border-left: 2px solid #8B5CF6;
  color: #C4B5FD;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
  font-family: var(--font-serif, serif);
}
.carve-item.used {
  border-left-color: #22C55E;
  color: #86EFAC;
}

/* ============================================================
   S1/S3/S4/S5/S8 新增交互组件 · 画布与布局
   （容器边框/背景沿用上方 .cmp-* 共享规则，色随章节紫色 #8B5CF6）
   ============================================================ */
/* 画布：全宽自适应，高度按内容设定（fitCanvas 读取 clientWidth 触发 resize） */
.s1-bar-cv, .s3-curve-cv, .s4-curve-cv, .s5-cloud-cv, .s8-cv {
  display: block;
  width: 100%;
  height: 250px;
  margin: 0.5rem 0;
}
.s4-chain-cv {
  display: block;
  width: 100%;
  height: 130px;
  margin: 0.4rem 0;
}

/* S1 · C_L 四分量分解区 / W 加倍自负载实验区 */
.cl-zone, .w-zone {
  margin: 0.6rem 0;
}
.cl-hint {
  font-size: 0.78rem;
  color: #94A3B8;
  margin-bottom: 0.4rem;
  line-height: 1.6;
}
.cl-btns {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.cl-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cl-item {
  padding: 0.45rem 0.6rem;
  border-left: 2px solid #8B5CF6;
  border-radius: 0 6px 6px 0;
  background: rgba(139,92,246,0.07);
  color: #C4B5FD;
  font-size: 0.76rem;
  line-height: 1.55;
}
.cl-item b {
  color: #E2E8F0;
}

/* S4 · 门 g 值对比面板（INV / NAND2 / NOR2） */
.s4-gpanel {
  margin: 0.5rem 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 8px;
  background: rgba(139,92,246,0.08);
  color: #C4B5FD;
  font-size: 0.8rem;
  line-height: 1.6;
  font-family: var(--font-mono, monospace);
}
