/* eCircuitCalc — AC, Filters & Op-Amps (reuses base.css tokens/components) */

/* Reading progress */
.rprog{position:fixed;top:0;left:0;right:0;height:3px;z-index:120;pointer-events:none}
.rprog span{display:block;height:100%;width:0;background:var(--grad);transition:width .1s linear}

/* Sticky in-page module nav */
.acf-bar{position:sticky;top:var(--nav-h,64px);z-index:90;background:color-mix(in srgb,var(--bg) 84%,transparent);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border-bottom:1px solid var(--border)}
.acf-chips{display:flex;gap:.4rem;overflow-x:auto;padding:.6rem 0 .75rem;scrollbar-width:thin;scrollbar-color:var(--border2) transparent}
.acf-chips::-webkit-scrollbar{height:6px}
.acf-chips::-webkit-scrollbar-thumb{background:var(--border2);border-radius:99px}
.acf-chip{flex:none;font-size:.82rem;padding:.45rem .85rem;border-radius:999px;border:1px solid var(--border);
  color:var(--text2);background:var(--surface);white-space:nowrap;transition:transform .2s var(--ease),color .2s,border-color .2s}
.acf-chip:hover{color:var(--accent);border-color:var(--accent);transform:translateY(-1px)}
.acf-chip.active{color:#fff;background:var(--grad);border-color:transparent}
.acf-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Prose */
.prose{width:min(1120px,92%);margin:0 auto;display:grid;gap:clamp(2.4rem,5vw,3.4rem);padding:1.5rem 0 2rem}
.prose section{scroll-margin-top:120px}
.prose h2{font-size:clamp(1.35rem,3vw,1.8rem);font-weight:800;letter-spacing:-.02em;margin-bottom:.9rem}
.prose h3{font-size:1.05rem;margin:1.4rem 0 .5rem}
.prose p{color:var(--text2);line-height:1.72;margin-bottom:.9rem}
.prose ul,.prose ol{color:var(--text2);line-height:1.7;margin:0 0 .9rem 1.2rem}
.prose li{margin-bottom:.4rem}
.prose li::marker{color:var(--accent)}
.prose a{color:var(--accent);text-decoration:underline;text-underline-offset:3px}
.prose strong{color:var(--text)}
.muted{color:var(--text2);font-size:.92rem}

/* Callouts */
.callout{border:1px solid var(--border);border-left:3px solid var(--accent);background:var(--surface);
  border-radius:0 12px 12px 0;padding:1rem 1.2rem;margin:1.1rem 0}
.callout p{margin:0}
.callout .tag{display:inline-block;font-family:var(--mono);font-size:.62rem;letter-spacing:.12em;text-transform:uppercase;margin-bottom:.4rem;font-weight:600}
.callout.pitfall{border-left-color:#fbbf24}
.callout.pitfall .tag{color:#fbbf24}
.callout.takeaway{border-left-color:var(--accent);background:color-mix(in srgb,var(--accent) 8%,var(--surface))}
.callout.takeaway .tag{color:var(--accent)}
.callout.important{border-left-color:var(--accent3);background:color-mix(in srgb,var(--accent3) 8%,var(--surface))}
.callout.important .tag{color:var(--accent3)}

/* Formula */
.formula{font-family:var(--mono);font-size:1rem;color:var(--accent);background:var(--surface);
  border:1px solid var(--border);border-radius:10px;padding:.85rem 1rem;margin:.9rem 0;overflow-x:auto;white-space:nowrap}
.formula sub{font-size:.72em}

/* Tables */
.table-wrap{overflow-x:auto;border:1px solid var(--border);border-radius:14px;background:var(--surface);margin:1.2rem 0}
table{width:100%;border-collapse:collapse}
table.spec{min-width:460px}
table.spec caption{caption-side:top;text-align:left;padding:.9rem 1.1rem .3rem;font-family:var(--mono);
  font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;color:var(--text2)}
.spec th,.spec td{padding:.7rem 1rem;text-align:left;border-bottom:1px solid var(--border);font-size:.92rem}
.spec th{font-family:var(--mono);font-size:.7rem;letter-spacing:.08em;text-transform:uppercase;color:var(--text2);background:var(--surface2)}
.spec tbody tr:last-child td{border-bottom:0}
.spec .mono{font-family:var(--mono);font-size:.85rem}

/* Figure / hero SVG */
.fig{padding:1.2rem;border-radius:16px;background:var(--bg2);border:1px solid var(--border);position:relative;overflow:hidden}
.fig-svg{width:100%;height:auto;max-width:760px;margin:0 auto;display:block}
.fig figcaption{margin-top:1rem;font-size:.9rem;color:var(--text2);line-height:1.6}
.fig figcaption strong{color:var(--text)}
.ac-wave{fill:none;stroke-linecap:round;stroke-linejoin:round}
.ac-wave-in{stroke:var(--accent);stroke-width:2.6;filter:drop-shadow(0 0 5px var(--glow))}
.ac-wave-out{stroke:var(--accent3);stroke-width:2.6;filter:drop-shadow(0 0 5px color-mix(in srgb,var(--accent3) 40%,transparent))}
.ac-anim{animation:acFlow 3.2s linear infinite}
@keyframes acFlow{to{transform:translateX(-240px)}}
.ac-circ{stroke:var(--text);fill:none;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
.ac-circ.thin{stroke-width:2}
.ac-node{fill:var(--text)}
.ac-lbl{font:600 15px var(--mono);fill:var(--text2)}
.ac-lbl.acc{fill:var(--accent)}
.ac-lbl.acc3{fill:var(--accent3)}
.ac-guide{stroke:var(--border2);stroke-dasharray:4 5;stroke-width:1.4;fill:none}

/* Expandable "go deeper" */
.deep{border:1px solid var(--border);border-radius:12px;background:var(--surface);margin:1rem 0;overflow:hidden}
.deep summary{cursor:pointer;padding:.9rem 1.1rem;font-weight:600;font-size:.95rem;list-style:none;display:flex;align-items:center;gap:.55rem}
.deep summary::-webkit-details-marker{display:none}
.deep summary::before{content:"+";font-family:var(--mono);color:var(--accent);font-weight:700}
.deep[open] summary::before{content:"–"}
.deep[open] summary{border-bottom:1px solid var(--border)}
.deep summary:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.deep .deep-body{padding:.4rem 1.1rem 1rem}
.deep .deep-body p{margin-bottom:.6rem}

/* Interactive tool shells */
.tool{margin:1.2rem 0;border:1px solid var(--border);border-radius:14px;background:var(--surface);padding:1.1rem;display:grid;gap:.9rem}
.tool h3{margin:0}
.calc-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.8rem}
.calc-grid .field{margin:0}
.calc-out{display:flex;align-items:baseline;gap:.7rem;flex-wrap:wrap}
.calc-out .big{font-family:var(--mono);font-size:1.5rem;font-weight:800;color:var(--accent)}
.calc-out .muted{font-size:.95rem}
.tool .muted{margin:0}
.unit-row{display:flex;gap:.5rem}
.unit-row .field{flex:1;margin:0}
.unit-row select{width:auto;min-width:74px}
.tool select,.tool input{width:100%}
.unit-row .field:first-child{flex:1 1 auto}

/* Reactance bars */
.rx-bars{display:grid;gap:.5rem}
.rx-bar{display:grid;grid-template-columns:48px 1fr 74px;align-items:center;gap:.6rem;font-size:.82rem}
.rx-bar .track{height:10px;border-radius:99px;background:var(--surface2);overflow:hidden}
.rx-bar .fill{height:100%;border-radius:99px;width:0;transition:width .4s var(--ease)}
.rx-bar .fill.cap{background:var(--accent)}
.rx-bar .fill.ind{background:var(--accent3)}
.rx-bar .val{font-family:var(--mono);text-align:right;color:var(--text2)}

/* Response / resonance curves */
.resp{border:1px solid var(--border);border-radius:12px;background:var(--bg2);padding:.6rem}
.resp svg{width:100%;height:auto;display:block}
.resp .grid{stroke:var(--border);stroke-width:1}
.resp .axis{stroke:var(--border2);stroke-width:1.4}
.resp .curve{fill:none;stroke:var(--accent);stroke-width:2.4;filter:drop-shadow(0 0 4px var(--glow))}
.resp .curve.hp{stroke:var(--accent3);filter:drop-shadow(0 0 4px color-mix(in srgb,var(--accent3) 40%,transparent))}
.resp .mark{stroke:var(--text2);stroke-dasharray:4 4;stroke-width:1.2}
.resp .mark-dot{fill:var(--accent)}
.resp .mark-dot.hp{fill:var(--accent3)}
.resp text{font:600 11px var(--mono);fill:var(--text2)}

/* Op-amp symbol */
.amp-fig{display:flex;gap:1.4rem;flex-wrap:wrap;align-items:center}
.amp-fig svg{flex:0 0 220px;max-width:220px;width:100%;height:auto}
.amp-sym{fill:none;stroke:var(--text);stroke-width:2.4;stroke-linejoin:round}
.amp-out{stroke:var(--accent);stroke-width:2.4}
.amp-lbl{font:600 13px var(--mono);fill:var(--text2)}
.amp-fig .muted{margin:0}

/* Ad slot (auto-hides when empty) */
.ad-slot{max-width:728px;margin:1.5rem auto;text-align:center;transition:max-height .5s var(--ease),opacity .4s,margin .5s;max-height:160px;overflow:hidden}
.ad-slot.ad-hidden{max-height:0;opacity:0;margin:0}
.ad-label{display:block;font-family:var(--mono);font-size:.6rem;letter-spacing:.2em;text-transform:uppercase;color:var(--text2);opacity:.6;margin-bottom:.4rem}
.ad-box{min-height:90px;border:1.5px dashed var(--border2);border-radius:12px;display:grid;place-items:center;color:var(--text2);font-size:.85rem;background:var(--surface)}

/* Focus */
.acf-chip:focus-visible,.tool select:focus-visible,.tool input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* Reduced motion */
@media (prefers-reduced-motion:reduce){
  .rprog span{transition:none}
  .ac-anim{animation:none}
  .acf-chip,.rx-bar .fill,.deep summary{transition:none}
}

/* Responsive */
@media (max-width:640px){
  .calc-grid{grid-template-columns:1fr 1fr}
  .calc-out .big{font-size:1.25rem}
  .amp-fig{flex-direction:column;align-items:flex-start}
  .amp-fig svg{flex:none;max-width:200px}
  .rx-bar{grid-template-columns:40px 1fr 66px}
  table.spec{min-width:420px}
}
