/* eCircuitCalc — LEDs & Light module (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 lesson nav */
.dsg-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)}
.dsg-chips{display:flex;gap:.4rem;overflow-x:auto;padding:.6rem 0 .75rem;scrollbar-width:thin;scrollbar-color:var(--border2) transparent}
.dsg-chips::-webkit-scrollbar{height:6px}
.dsg-chips::-webkit-scrollbar-thumb{background:var(--border2);border-radius:99px}
.dsg-chip{flex:none;font-size:.8rem;padding:.45rem .8rem;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}
.dsg-chip:hover{color:var(--accent);border-color:var(--accent);transform:translateY(-1px)}
.dsg-chip.active{color:#fff;background:var(--grad);border-color:transparent}

/* 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.3rem,3vw,1.75rem);font-weight:800;letter-spacing:-.02em;margin-bottom:.4rem}
.prose h3{font-size:1.05rem;margin:1.4rem 0 .6rem}
.prose p{color:var(--text2);line-height:1.72;margin-bottom:.9rem}
.prose a{color:var(--accent);text-decoration:underline;text-underline-offset:3px}
.muted{color:var(--text2);font-size:.92rem}
.lvl-tag{font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;text-transform:uppercase;color:var(--accent);margin-bottom:.8rem}
.objs{list-style:none;display:grid;gap:.4rem;margin:0 0 1.1rem}
.objs li{position:relative;padding-left:1.4rem;color:var(--text2)}
.objs li::before{content:"✓";position:absolute;left:0;color:var(--accent);font-weight:700}

/* 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.warning{border-left-color:#fbbf24}.callout.warning .tag{color:#fbbf24}
.callout.pitfall{border-left-color:#f87171}.callout.pitfall .tag{color:#f87171}
.callout.takeaway{border-left-color:var(--accent);background:color-mix(in srgb,var(--accent) 8%,var(--surface))}.callout.takeaway .tag{color:var(--accent)}

/* Worked example */
.worked{border:1px solid var(--border);border-radius:14px;background:var(--surface);padding:1.1rem 1.2rem;margin:1.2rem 0}
.worked .tag{display:inline-block;font-family:var(--mono);font-size:.62rem;letter-spacing:.12em;text-transform:uppercase;color:var(--accent);font-weight:600;margin-bottom:.5rem}
.worked ol{margin:0 0 0 1.2rem;color:var(--text2);line-height:1.65}
.worked li{margin-bottom:.45rem}
.worked li strong{color:var(--text)}

/* 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}
.spec{min-width:440px}
.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 td strong{color:var(--text)}

/* Reveal */
.qa{border:1px solid var(--border);border-radius:14px;background:var(--surface);padding:1rem 1.2rem;margin:1rem 0}

.qa-q{margin:0 0 .8rem}
.qa-badge{display:inline-block;font-family:var(--mono);font-size:.6rem;letter-spacing:.12em;text-transform:uppercase;color:var(--accent);border:1px solid var(--border2);border-radius:6px;padding:.15rem .5rem;margin-right:.5rem;vertical-align:middle}
.qa-body{margin-bottom:.9rem}
.qa-a{margin-bottom:.5rem}
.qa-ex{color:var(--text2);font-size:.9rem;margin:0;border-left:2px solid var(--border);padding-left:.8rem}
.qa-btn{font-size:.85rem;font-weight:600;padding:.5rem 1rem;border-radius:10px;border:1px solid var(--border2);background:var(--surface2);color:var(--accent);cursor:pointer;transition:.2s}
.qa-btn:hover{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--surface2))}

/* Quiz */
.quiz{border:1px solid var(--border);border-radius:14px;background:var(--surface);padding:1.1rem 1.2rem;margin:1rem 0}
.quiz-q{margin:0 0 .9rem}
.quiz-opts{display:grid;gap:.5rem;margin-bottom:.9rem}
.quiz-opt{text-align:left;font-size:.92rem;padding:.7rem .9rem;border-radius:10px;border:1px solid var(--border2);background:var(--surface2);color:var(--text);cursor:pointer;transition:.2s}
.quiz-opt:hover:not(:disabled){border-color:var(--accent);color:var(--accent)}
.quiz-opt[aria-pressed="true"]{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 14%,var(--surface2));color:var(--accent);font-weight:600}
.quiz-opt:disabled{cursor:default;opacity:.85}
.quiz-opt.correct{border-color:#4ade80;background:rgba(74,222,128,.14);color:#4ade80;font-weight:600;opacity:1}
.quiz-opt.wrong{border-color:#f87171;background:rgba(248,113,113,.14);color:#f87171;opacity:1}
.quiz-foot{display:flex;align-items:center;gap:.9rem;flex-wrap:wrap}
.quiz-check{font-size:.85rem;font-weight:600;padding:.55rem 1.1rem;border-radius:10px;background:var(--grad);color:#fff;cursor:pointer;transition:transform .2s}
.quiz-check:hover:not(:disabled){transform:translateY(-1px)}
.quiz-check:disabled{opacity:.5;cursor:default}
.quiz-feedback{margin:0;font-weight:600;font-size:.9rem}
.quiz-feedback.ok{color:#4ade80}
.quiz-feedback.no{color:#fbbf24}
.quiz-ex{margin-top:.8rem}

/* Checklist */
.checklist{border:1px solid var(--border);border-radius:14px;background:var(--surface);padding:1.1rem 1.2rem;margin:1.2rem 0}
.checklist h3{margin:0 0 .8rem}
.checklist ul{list-style:none;display:grid;gap:.55rem;margin-bottom:.9rem}
.checklist label{display:flex;gap:.6rem;align-items:flex-start;cursor:pointer;font-size:.92rem;color:var(--text2);transition:color .2s}
.checklist input{margin-top:.25rem;accent-color:var(--accent);width:17px;height:17px;flex:none;cursor:pointer}
.checklist label.done{color:var(--text);text-decoration:line-through;text-decoration-color:var(--border2)}
.checklist-status{font-family:var(--mono);font-size:.78rem;color:var(--text2)}
.checklist.all-done{border-color:#4ade80}
.checklist.all-done .checklist-status{color:#4ade80}

/* ============ LED LAB (interactive) ============ */
.ledlab{border:1px solid var(--border);border-radius:16px;background:var(--surface);padding:1.2rem;margin:1.3rem 0;overflow:hidden}
.ledlab h3{margin:0 0 1rem}
.ledlab-controls{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:1rem;margin-bottom:1rem}
.ctl{display:grid;gap:.45rem;align-content:start}
.ctl label,.ctl-legend{font-size:.83rem;font-weight:600;color:var(--text)}
.ctl select{padding:.55rem .7rem;border-radius:10px;border:1px solid var(--border2);background:var(--surface2);color:var(--text);font:inherit}
.ctl-val{font-family:var(--mono);font-size:.9rem;color:var(--accent);font-weight:600}
input[type=range]{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:99px;background:var(--surface2);outline:none;cursor:pointer}
input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;width:18px;height:18px;border-radius:50%;background:var(--grad);border:2px solid var(--bg);cursor:pointer;box-shadow:0 2px 6px var(--glow)}
input[type=range]::-moz-range-thumb{width:16px;height:16px;border-radius:50%;background:var(--accent);border:2px solid var(--bg);cursor:pointer}
input[type=range]::-moz-range-track{height:6px;border-radius:99px;background:var(--surface2)}
input[type=range]:focus-visible{outline:2px solid var(--accent);outline-offset:4px}
.radio-row{display:flex;gap:1rem;flex-wrap:wrap}
.radio-row label{display:flex;align-items:center;gap:.4rem;font-size:.9rem;color:var(--text);cursor:pointer}
.radio-row input{accent-color:var(--accent);width:16px;height:16px}
.ledlab-circuit{background:var(--bg2);border:1px solid var(--border);border-radius:12px;padding:1rem;margin-bottom:1rem}
.ledlab-result{display:grid;gap:.5rem}
.res-line{font-size:.95rem;color:var(--text2);line-height:1.6}
.res-line strong{color:var(--text)}
.res-status{font-size:.9rem;font-weight:600;padding:.7rem .9rem;border-radius:10px;border:1px solid var(--border);line-height:1.5}
.res-status.ok{color:#4ade80;border-color:rgba(74,222,128,.4);background:rgba(74,222,128,.08)}
.res-status.warn{color:#fbbf24;border-color:rgba(251,191,36,.4);background:rgba(251,191,36,.08)}
.res-status.danger,.res-status.error{color:#f87171;border-color:rgba(248,113,113,.4);background:rgba(248,113,113,.08)}

/* demo buttons + meter */
.ctl-row{display:flex;gap:.6rem;flex-wrap:wrap;margin-top:1rem}
.pol-btn{font-size:.85rem;font-weight:600;padding:.55rem 1rem;border-radius:10px;border:1px solid var(--border2);background:var(--surface2);color:var(--text);cursor:pointer;transition:.2s}
.pol-btn:hover{border-color:var(--accent)}
.pol-btn.active{background:var(--grad);color:#fff;border-color:transparent}
.pol-demo,.limit-demo{display:grid;gap:1rem;margin-bottom:.5rem}
.pol-read,.limit-read{font-size:.92rem;color:var(--text2);line-height:1.6;min-height:2.8em}
.limit-meter label{font-size:.83rem;font-weight:600}
.meter{height:10px;border-radius:99px;background:var(--surface2);overflow:hidden;border:1px solid var(--border);margin:.4rem 0}
.meter-fill{height:100%;width:20%;background:linear-gradient(90deg,#4ade80,#22c55e);transition:width .3s var(--ease),background .3s}
.meter-fill.hot{background:linear-gradient(90deg,#fbbf24,#ef4444)}
.meter-val{font-size:.9rem;color:var(--text)}

/* ============ LED SVG ============ */
.ledlab-svg{width:100%;height:auto;display:block;max-width:600px;margin:0 auto}
.ledlab-circuit .ledlab-svg{max-width:560px}
.ledlab-svg .w{stroke:var(--text2);stroke-width:2.4;fill:none;stroke-linecap:round}
.ledlab-svg .w.thick{stroke-width:5}
.ledlab-svg .comp{stroke:var(--text);stroke-width:2.4;fill:none;stroke-linecap:round;stroke-linejoin:round}
.ledlab-svg .node{fill:var(--text)}
.ledlab-svg .bus{stroke-width:3;fill:none;stroke-linecap:round}
.ledlab-svg .bus-pos{stroke:#ef4444}
.ledlab-svg .bus-neg{stroke:#3b82f6}
.ledlab-svg .iarr{stroke:var(--accent);stroke-width:2.4;fill:none;stroke-linecap:round;stroke-linejoin:round}
.ledlab-svg .led-body{fill:var(--led-color,#4ade80);fill-opacity:calc(.2 + .8 * var(--led-glow,0));stroke:var(--led-color,#4ade80);stroke-width:1.5;transition:fill-opacity .3s}
.ledlab-svg .led-bar{stroke:var(--text);stroke-width:2.4;stroke-linecap:round}
.ledlab-svg .led-arr{stroke:var(--text);stroke-width:1.6;stroke-linecap:round;opacity:.7}
.ledlab-svg .led-glow{opacity:var(--led-glow,0);transition:opacity .3s}
.ledlab-svg .gs1,.ledlab-svg .gs2{stop-color:var(--led-color,#4ade80)}
.ledlab-svg .flow{stroke:var(--accent);stroke-width:2.6;fill:none;stroke-linecap:round;stroke-dasharray:7 11;animation:ledflow 1s linear infinite;opacity:var(--led-glow,0)}
.ledlab-svg .lbl{fill:var(--text2);font:600 13px var(--mono)}
.ledlab-svg .pol-pos{fill:#ef4444}
.ledlab-svg .pol-neg{fill:#60a5fa}
@keyframes ledflow{to{stroke-dashoffset:-18}}

/* Module prev/next nav */
.modnav{display:flex;gap:1rem;justify-content:space-between;flex-wrap:wrap}
.modnav-link{flex:1 1 240px;display:flex;flex-direction:column;gap:.2rem;padding:1rem 1.2rem;border-radius:14px;border:1px solid var(--border);background:var(--surface);transition:transform .2s var(--ease),border-color .2s}
.modnav-link:hover{transform:translateY(-3px);border-color:var(--accent)}
.mn-label{font-family:var(--mono);font-size:.66rem;letter-spacing:.12em;text-transform:uppercase;color:var(--text2)}
.mn-title{font-weight:700;color:var(--text)}

/* 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)}

/* Completed-state button */
.btn.done,.btn.btn-primary.done{background:linear-gradient(135deg,#22c55e 0%,#16a34a 100%);border-color:transparent;color:#fff;cursor:default;box-shadow:0 8px 24px -10px rgba(34,197,94,.6)}
.btn.done:hover{transform:none}

/* Focus + reduced motion + responsive */
.dsg-chip:focus-visible,.qa-btn:focus-visible,.quiz-check:focus-visible,.quiz-opt:focus-visible,.modnav-link:focus-visible,.pol-btn:focus-visible,.checklist input:focus-visible,.back-top:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){
  .rprog span{transition:none}
  .ledlab-svg .flow{animation:none}
  .dsg-chip,.qa-btn,.quiz-check,.quiz-opt,.modnav-link,.pol-btn{transition:none}
  .meter-fill{transition:none}
}
@media (max-width:640px){
  .ledlab{padding:1rem}
  .ledlab-controls{grid-template-columns:1fr 1fr}
  .fig,.ledlab-circuit{padding:.8rem}
  .res-line,.res-status{font-size:.88rem}
}
@media (max-width:420px){
  .ledlab-controls{grid-template-columns:1fr}
}
