/* /assets/css/physics/electromagnetism/how-a-diode-rectifier-circuit-works-explained.css — 本页专属样式（en/zh 共用） */
/* ============ 二极管整流电路 · Diode bridge rectifier ============ */
/* 图形/动画样式，自 svgs/todo/physics-33-how-a-diode-rectifier-circuit-works-explained.html 预览 <style> 并入驻此
   （页面禁止内联 <style>）。零件区分色按 body[data-topic="diode-rectifier"] 作用域限定，避免与 physics 其他页面同名类冲突；
   动画由 #stage 的 .is-running 驱动，减弱动效在本文件末尾兜底。 */

/* ============ 零件本体/区分色 ============ */
body[data-topic="diode-rectifier"] .part .body{fill:#c2d1e4;stroke:#2563eb;stroke-width:1.6}
body[data-topic="diode-rectifier"] .part .body2{fill:#dde7f4;stroke:#60a5fa;stroke-width:1.2}
body[data-topic="diode-rectifier"] .part .body3{fill:#aab9cd;stroke:none}
body[data-topic="diode-rectifier"] .part .accent{fill:none;stroke:#6b7b8c;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
body[data-topic="diode-rectifier"] .part.is-active .body{fill:#9dc3f5;stroke:#1d4ed8;stroke-width:2.2}
body[data-topic="diode-rectifier"] .part.is-active .body2{fill:#c4daf8;stroke:#3b82f6;stroke-width:1.4}
body[data-topic="diode-rectifier"] .part.is-active .body3{fill:#1d4ed8}
body[data-topic="diode-rectifier"] .part.is-active .accent{stroke:#1d4ed8}
body[data-topic="diode-rectifier"] .part.is-active{filter:drop-shadow(0 0 12px rgba(29,78,216,.5))}
body[data-topic="diode-rectifier"] .tag{font-size:13.5px}
body[data-topic="diode-rectifier"] .tag-sm{fill:#5b6472;font-size:11px}

/* 各部件区分色（作用域限定 · 均在中灰蓝值域内，禁用近白） */
body[data-topic="diode-rectifier"] .part[data-id="part-ac-source"]:not(.is-active) .body{fill:#bfcee2}
body[data-topic="diode-rectifier"] .part[data-id="part-dc-load"]:not(.is-active) .body{fill:#c6d3e5}
body[data-topic="diode-rectifier"] .part[data-id="part-dc-load"]:not(.is-active) .body2{fill:#dce7f3}

/* 导线 */
body[data-topic="diode-rectifier"] .rect-wire{fill:none;stroke:#8ea0b5;stroke-width:5;stroke-linecap:round;stroke-linejoin:round}

/* 二极管（三角形 + 阴极横条） */
body[data-topic="diode-rectifier"] .rect-diode{stroke:#5b6a7d;stroke-width:2;stroke-linejoin:round}
body[data-topic="diode-rectifier"] .rect-bar{stroke:#5b6a7d;stroke-width:4;stroke-linecap:round}

/* 电流流向 */
body[data-topic="diode-rectifier"] .rect-flow-line{fill:none;stroke:#1d4ed8;stroke-width:2.6;stroke-dasharray:7 13;stroke-linecap:round}

/* 波形面板 */
body[data-topic="diode-rectifier"] .rect-wave-panel{fill:#f7f9fc;stroke:#d4dbe6;stroke-width:1.5}
body[data-topic="diode-rectifier"] .rect-wave-axis{stroke:#c3ccd9;stroke-width:1.5}
body[data-topic="diode-rectifier"] .rect-wave-in{fill:none;stroke:#2563eb;stroke-width:2.5;stroke-linecap:round}
body[data-topic="diode-rectifier"] .rect-wave-out{fill:none;stroke:#1d4ed8;stroke-width:2.5;stroke-linecap:round}
body[data-topic="diode-rectifier"] .rect-dot{fill:#1d4ed8}

/* ============ 动画（纯 CSS · 由 #stage 的 .is-running 驱动） ============ */
.rect-flow-pos{animation:rect-pos 4s linear infinite,rect-dash 1s linear infinite}
.rect-flow-neg{animation:rect-neg 4s linear infinite,rect-dash 1s linear infinite}
.rect-flow-dc{animation:rect-dash 1s linear infinite}
@keyframes rect-pos{0%,44%{opacity:1}50%,100%{opacity:0}}
@keyframes rect-neg{0%,46%{opacity:0}52%,100%{opacity:1}}
@keyframes rect-dash{to{stroke-dashoffset:-40}}

/* 正向半周导通 D1/D3，负向半周导通 D2/D4 */
.rect-d1,.rect-d3{animation:rect-cond 4s linear infinite}
.rect-d2,.rect-d4{animation:rect-cond-inv 4s linear infinite}
@keyframes rect-cond{0%,44%{fill:#1d4ed8;stroke:#1e40af}52%,100%{fill:#a9bccf;stroke:#5b6a7d}}
@keyframes rect-cond-inv{0%,44%{fill:#a9bccf;stroke:#5b6a7d}52%,100%{fill:#1d4ed8;stroke:#1e40af}}

/* 波形面板上的移动光点 */
.rect-dot-in{animation:rect-dot-in 4s linear infinite}
@keyframes rect-dot-in{
  0%{transform:translate(0,0)}12.5%{transform:translate(52px,-55px)}25%{transform:translate(105px,0)}
  37.5%{transform:translate(157px,55px)}50%{transform:translate(210px,0)}62.5%{transform:translate(262px,-55px)}
  75%{transform:translate(315px,0)}87.5%{transform:translate(367px,55px)}100%{transform:translate(420px,0)}}
.rect-dot-out{animation:rect-dot-out 4s linear infinite}
@keyframes rect-dot-out{
  0%{transform:translate(0,0)}12.5%{transform:translate(50px,-55px)}25%{transform:translate(100px,0)}
  37.5%{transform:translate(150px,-55px)}50%{transform:translate(200px,0)}62.5%{transform:translate(250px,-55px)}
  75%{transform:translate(300px,0)}87.5%{transform:translate(350px,-55px)}100%{transform:translate(400px,0)}}

/* 统一动画开关（引擎给 #stage 加 .is-running 后运行） */
.rect-anim{animation-play-state:paused}
body[data-topic="diode-rectifier"] .is-running .rect-anim{animation-play-state:running}

/* ============ 无障碍：减弱动效 ============ */
@media (prefers-reduced-motion:reduce){
  .rect-anim,.rect-flow-pos,.rect-flow-neg,.rect-flow-dc,
  .rect-d1,.rect-d2,.rect-d3,.rect-d4,.rect-dot-in,.rect-dot-out{animation:none !important}
  .rect-flow-pos,.rect-flow-dc{opacity:1}
  .rect-flow-neg{opacity:0}
  .rect-d1,.rect-d3{fill:#1d4ed8;stroke:#1e40af}
  .rect-d2,.rect-d4{fill:#a9bccf;stroke:#5b6a7d}
}