/* ============================================================
   Sand to Silicon — style.css
   Theming via CSS custom properties. Dark is default;
   [data-theme="light"] on <html> switches to light mode.
   ============================================================ */

:root {
  /* ---- Dark theme (default) ---- */
  --bg: #070b14;
  --bg-elev: #0d1322;
  --bg-card: #111a2e;
  --bg-card-hover: #16213a;
  --bg-inset: #0a101f;
  --text: #e6ecf7;
  --text-soft: #9fb0ca;
  --text-faint: #64748f;
  --line: rgba(148, 180, 255, 0.14);
  --accent: #38d6d0;          /* silicon teal */
  --accent-2: #f5a623;        /* furnace amber */
  --accent-3: #8b7cf6;        /* uv violet */
  --accent-4: #ff6b81;        /* defect red */
  --good: #34d399;
  --bad: #f87171;
  --glow: rgba(56, 214, 208, 0.35);
  --hero-grad: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(56,214,208,0.16), transparent 60%),
               radial-gradient(ellipse 50% 40% at 85% 20%, rgba(139,124,246,0.12), transparent 60%),
               radial-gradient(ellipse 50% 40% at 10% 30%, rgba(245,166,35,0.08), transparent 60%);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --chip-bg: rgba(56, 214, 208, 0.1);
  --chip-text: #7fe7e2;
  --code-bg: #0a1120;
  --scroll-thumb: #24314f;

  /* diagram palette */
  --dgm-stroke: #4b5d80;
  --dgm-fill: #16213a;
  --dgm-metal: #f5a623;
  --dgm-si: #38d6d0;
  --dgm-oxide: #8b7cf6;
  --dgm-label: #9fb0ca;
}

html[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f4fc;
  --bg-inset: #eef1f8;
  --text: #16213a;
  --text-soft: #46557a;
  --text-faint: #7c89a6;
  --line: rgba(22, 42, 90, 0.12);
  --accent: #0d9488;
  --accent-2: #d97706;
  --accent-3: #6d5ae6;
  --accent-4: #e11d48;
  --good: #059669;
  --bad: #dc2626;
  --glow: rgba(13, 148, 136, 0.25);
  --hero-grad: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(13,148,136,0.12), transparent 60%),
               radial-gradient(ellipse 50% 40% at 85% 20%, rgba(109,90,230,0.10), transparent 60%),
               radial-gradient(ellipse 50% 40% at 10% 30%, rgba(217,119,6,0.08), transparent 60%);
  --shadow: 0 10px 30px rgba(30, 45, 90, 0.10);
  --chip-bg: rgba(13, 148, 136, 0.1);
  --chip-text: #0f766e;
  --code-bg: #eef1f8;
  --scroll-thumb: #c3cde0;

  --dgm-stroke: #8496b8;
  --dgm-fill: #eef1f8;
  --dgm-metal: #d97706;
  --dgm-si: #0d9488;
  --dgm-oxide: #6d5ae6;
  --dgm-label: #46557a;
}

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 0.35s ease, color 0.35s ease;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: "Space Grotesk", "Inter", sans-serif; line-height: 1.2; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; }
::selection { background: var(--accent); color: var(--bg); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 5px; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ---- Top nav ---- */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 16px; height: 62px;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; flex-shrink: 0; }
.brand .grad { background: linear-gradient(90deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--text-soft); font-size: 0.88rem; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: var(--bg-card-hover); text-decoration: none; }

.theme-toggle {
  margin-left: 8px;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: all 0.2s; font-size: 1.05rem;
}
.theme-toggle:hover { border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }
.theme-toggle svg { width: 18px; height: 18px; }
html[data-theme="light"] .icon-moon { display: none; }
html:not([data-theme="light"]) .icon-sun { display: none; }

/* progress bar under nav */
.progress-bar {
  position: absolute; bottom: -1px; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  transition: width 0.15s linear;
}

/* ---- Hero ---- */
.hero {
  position: relative; min-height: 92vh;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 120px 24px 80px;
  background: var(--hero-grad);
  overflow: hidden;
}
.hero-kicker {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; background: var(--chip-bg); margin-bottom: 26px;
}
.hero h1 {
  font-size: clamp(2.6rem, 6.5vw, 4.6rem); margin: 0 0 20px; font-weight: 700;
  letter-spacing: -0.02em;
}
.hero h1 .grad {
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 55%, var(--accent-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.sub {
  max-width: 660px; color: var(--text-soft); font-size: clamp(1rem, 2vw, 1.18rem); margin: 0 auto 36px;
}
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 26px; border-radius: 12px; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; border: 1px solid transparent; transition: all 0.25s;
  font-family: inherit;
}
.btn-primary { background: linear-gradient(90deg, var(--accent), var(--accent-3)); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px var(--glow); text-decoration: none; }
.btn-ghost { border-color: var(--line); color: var(--text); background: var(--bg-card); }
.btn-ghost:hover { border-color: var(--accent); text-decoration: none; }

.hero-wafer { margin-top: 56px; width: min(430px, 80vw); filter: drop-shadow(0 0 60px var(--glow)); }
.hero-wafer .die-cell { transition: fill 0.4s; }

.hero-stats {
  display: flex; gap: clamp(20px, 5vw, 64px); margin-top: 56px; flex-wrap: wrap; justify-content: center;
}
.hero-stat { text-align: center; }
.hero-stat .num {
  font-family: "Space Grotesk", sans-serif; font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700; color: var(--accent);
}
.hero-stat .lbl { font-size: 0.8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }

/* scroll hint */
.scroll-hint {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  color: var(--text-faint); font-size: 1.4rem; animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, 9px); } }

/* ---- Journey map (module grid) ---- */
.journey { padding: 90px 0 60px; }
.section-head { text-align: center; max-width: 720px; margin: 0 auto 56px; }
.section-head .eyebrow {
  font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 700;
  color: var(--accent); margin-bottom: 10px;
}
.section-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 14px; letter-spacing: -0.01em; }
.section-head p { color: var(--text-soft); margin: 0; }

.module-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px;
}
.module-card {
  position: relative; display: block; padding: 22px 20px 20px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px;
  color: var(--text); transition: all 0.25s; overflow: hidden;
}
.module-card:hover {
  text-decoration: none; transform: translateY(-4px);
  border-color: var(--accent); box-shadow: var(--shadow);
  background: var(--bg-card-hover);
}
.module-card .m-num {
  font-family: "Space Grotesk", monospace; font-size: 0.78rem; font-weight: 700;
  color: var(--accent-2); letter-spacing: 0.1em;
}
.module-card h3 { margin: 8px 0 6px; font-size: 1.02rem; }
.module-card p { margin: 0; font-size: 0.84rem; color: var(--text-soft); line-height: 1.5; }
.module-card .m-icon { position: absolute; right: 14px; top: 14px; font-size: 1.3rem; opacity: 0.85; }
.module-card.soon { opacity: 0.65; border-style: dashed; }
.module-card.soon:hover { transform: none; border-color: var(--line); box-shadow: none; }
.badge-soon {
  display: inline-block; margin-top: 10px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 12%, transparent);
  padding: 3px 10px; border-radius: 999px;
}

/* ---- Stage sections ---- */
.stage { padding: 96px 0 40px; scroll-margin-top: 60px; }
.stage + .stage { border-top: 1px solid var(--line); }
.stage-header { max-width: 820px; margin-bottom: 44px; }
.stage-num {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: "Space Grotesk", monospace; font-weight: 700; font-size: 0.82rem;
  letter-spacing: 0.14em; color: var(--accent-2);
}
.stage-num::before { content: ""; width: 34px; height: 2px; background: var(--accent-2); border-radius: 2px; }
.stage-header h2 { font-size: clamp(1.7rem, 3.6vw, 2.4rem); margin: 12px 0 12px; letter-spacing: -0.01em; }
.stage-tag { color: var(--text-soft); font-size: 1.02rem; margin: 0; }

.stage-body {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: clamp(24px, 4vw, 56px); align-items: start;
}
.stage-body.rev { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }
.stage-text h3 { font-size: 1.12rem; margin: 26px 0 8px; color: var(--text); }
.stage-text h3:first-child { margin-top: 0; }
.stage-text p { color: var(--text-soft); font-size: 0.96rem; margin: 0 0 14px; }
.stage-text strong { color: var(--text); }

.step-list { list-style: none; margin: 14px 0; padding: 0; counter-reset: step; }
.step-list li {
  counter-increment: step; position: relative;
  padding: 10px 0 10px 46px; color: var(--text-soft); font-size: 0.93rem;
  border-bottom: 1px dashed var(--line);
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; left: 0; top: 10px;
  width: 30px; height: 30px; display: grid; place-items: center;
  font-family: "Space Grotesk", monospace; font-size: 0.72rem; font-weight: 700;
  color: var(--accent); background: var(--chip-bg); border-radius: 9px;
}
.step-list li strong { color: var(--text); }

.term-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.chip {
  font-size: 0.76rem; font-weight: 600; color: var(--chip-text);
  background: var(--chip-bg); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: 999px; padding: 5px 13px; cursor: default;
}

.fact-card {
  margin-top: 22px; padding: 16px 18px;
  background: color-mix(in srgb, var(--accent-2) 7%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent);
  border-radius: 14px; font-size: 0.9rem; color: var(--text-soft);
}
.fact-card .fc-title {
  display: flex; align-items: center; gap: 8px; font-weight: 700;
  color: var(--accent-2); font-size: 0.8rem; letter-spacing: 0.08em;
  text-transform: uppercase; margin-bottom: 6px;
}

/* themed inline heading icon (replaces emoji that render poorly on some platforms) */
.h-icon { width: 1em; height: 1em; vertical-align: -0.1em; display: inline-block; }
.m-icon .h-icon { width: 1.15em; height: 1.15em; }

/* side-by-side fact cards */
.fact-row { display: grid; grid-template-columns: 1fr 1.22fr; gap: 14px; align-items: stretch; }
.fact-row .fact-card { margin-top: 22px; }
.fact-row .fc-title { letter-spacing: 0.05em; white-space: nowrap; }
@media (max-width: 1100px) { .fact-row { grid-template-columns: 1fr; } .fact-row .fact-card + .fact-card { margin-top: 0; } }

.explore-link {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  font-family: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer;
  color: var(--accent); background: var(--chip-bg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 999px; padding: 6px 15px; transition: all 0.2s;
}
.explore-link:hover { box-shadow: 0 0 12px var(--glow); transform: translateY(-1px); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center; padding: 18px;
  background: rgba(4, 7, 14, 0.65); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.modal-overlay.open { display: flex; }
.modal {
  position: relative; width: 100%; max-width: 1040px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 22px;
  padding: 28px 28px 24px; box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  animation: modal-in 0.25s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 4px; font-size: 1.25rem; display: flex; align-items: center; gap: 10px; }
.modal .modal-sub { color: var(--text-soft); font-size: 0.88rem; margin: 2px 0 18px; }
.modal-close {
  position: absolute; top: 16px; right: 16px; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text); font-size: 1.05rem; cursor: pointer; transition: all 0.2s;
}
.modal-close:hover { border-color: var(--accent-4); color: var(--accent-4); }
.modal-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .modal-grid { grid-template-columns: 1fr; } }

/* world map */
.world-map { width: 100%; height: auto; display: block; background: var(--bg-inset); border-radius: 16px; border: 1px solid var(--line); }
.world-map .land { fill: var(--dgm-fill); stroke: var(--dgm-stroke); stroke-width: 1; opacity: 0.9; }
.world-map .prod-bubble { fill: var(--accent); fill-opacity: 0.26; stroke: var(--accent); stroke-width: 1.6; }
.world-map .prod-bubble.top1 { fill: var(--accent-2); fill-opacity: 0.32; stroke: var(--accent-2); stroke-width: 2; }
.world-map .prod-dot { fill: var(--text-faint); opacity: 0.55; }
.world-map .prod-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.world-map .prod-pct { fill: var(--accent); font-size: 10px; font-weight: 700; }
.world-map .prod-pct.top1 { fill: var(--accent-2); font-size: 13px; }
.world-map .minor-label { fill: var(--text-faint); font-size: 9px; }

/* rank list */
.rank-list { display: flex; flex-direction: column; gap: 9px; }
.rank-item { font-size: 0.82rem; }
.rank-item .r-head { display: flex; justify-content: space-between; margin-bottom: 3px; color: var(--text); font-weight: 600; }
.rank-item .r-head .pct { font-family: "Space Grotesk", monospace; color: var(--accent); }
.rank-item:first-child .r-head .pct { color: var(--accent-2); }
.rank-item .r-bar { height: 8px; border-radius: 4px; background: var(--bg-inset); overflow: hidden; }
.rank-item .r-bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-3)); }
.rank-item:first-child .r-bar > i { background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.modal-note { margin-top: 16px; font-size: 0.74rem; color: var(--text-faint); }

/* figure / diagram panel */
.stage-figure {
  position: sticky; top: 86px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; box-shadow: var(--shadow);
}
.stage-figure figcaption {
  margin-top: 14px; font-size: 0.8rem; color: var(--text-faint);
  text-align: center; font-style: italic;
}
.dgm { width: 100%; height: auto; display: block; }
.dgm text { font-family: "Inter", sans-serif; fill: var(--dgm-label); }
.dgm .t-strong { fill: var(--text); font-weight: 600; }
.dgm .t-accent { fill: var(--accent); font-weight: 600; }
.dgm .t-amber { fill: var(--accent-2); font-weight: 600; }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---- Animations for diagrams ---- */
@keyframes pull-up { 0% { transform: translateY(46px); } 100% { transform: translateY(0); } }
.anim-ingot { animation: pull-up 6s ease-in-out infinite alternate; }

@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.anim-spin { animation: spin-slow 9s linear infinite; transform-origin: center; transform-box: fill-box; }

@keyframes flow-dash { to { stroke-dashoffset: -28; } }
.anim-flow { stroke-dasharray: 6 8; animation: flow-dash 1.2s linear infinite; }

@keyframes beam-pulse { 0%,100% { opacity: 0.25; } 50% { opacity: 1; } }
.anim-beam { animation: beam-pulse 1.8s ease-in-out infinite; }

@keyframes ion-fall {
  0% { transform: translateY(0); opacity: 0; }
  12% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(120px); opacity: 0; }
}
.anim-ion { animation: ion-fall 1.6s linear infinite; }
.anim-ion.d2 { animation-delay: 0.4s; }
.anim-ion.d3 { animation-delay: 0.8s; }
.anim-ion.d4 { animation-delay: 1.2s; }

@keyframes glow-pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }
.anim-glow { animation: glow-pulse 2.4s ease-in-out infinite; }

@keyframes probe-tap { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
.anim-probe { animation: probe-tap 1.6s ease-in-out infinite; }

@keyframes saw-move { 0%,100% { transform: translateX(-8px); } 50% { transform: translateX(8px); } }
.anim-saw { animation: saw-move 0.5s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---- Interactive tool panels ---- */
.tool-panel {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 20px;
  padding: 28px; margin-top: 34px; box-shadow: var(--shadow);
}
.tool-panel h3 {
  margin: 0 0 4px; font-size: 1.2rem; display: flex; align-items: center; gap: 10px;
}
.tool-panel > p { color: var(--text-soft); font-size: 0.9rem; margin: 4px 0 22px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 32px; align-items: start; }

.control-row { margin-bottom: 20px; }
.control-row label {
  display: flex; justify-content: space-between; font-size: 0.86rem; font-weight: 600;
  margin-bottom: 8px; color: var(--text);
}
.control-row label output { color: var(--accent); font-family: "Space Grotesk", monospace; }
input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px;
  background: var(--bg-inset); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-card); box-shadow: 0 0 0 1px var(--accent), 0 2px 8px rgba(0,0,0,0.3);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-card); box-shadow: 0 0 0 1px var(--accent);
}

.result-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.result-card {
  background: var(--bg-inset); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px;
}
.result-card .rc-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); font-weight: 700; }
.result-card .rc-value { font-family: "Space Grotesk", monospace; font-size: 1.45rem; font-weight: 700; color: var(--accent); margin-top: 2px; }
.result-card .rc-value.amber { color: var(--accent-2); }
.result-card .rc-value.good { color: var(--good); }
.result-card .rc-value.bad { color: var(--bad); }
.result-card .rc-sub { font-size: 0.72rem; color: var(--text-faint); }

.wafer-map-wrap { text-align: center; }
#waferMap { width: 100%; max-width: 380px; }
.map-legend { display: flex; gap: 18px; justify-content: center; margin-top: 12px; font-size: 0.78rem; color: var(--text-soft); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.map-legend .lg-good { background: var(--good); }
.map-legend .lg-bad { background: var(--bad); }
.map-legend .lg-edge { background: var(--text-faint); opacity: 0.4; }

.formula {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; font-family: "SF Mono", "Fira Code", monospace; font-size: 0.84rem;
  color: var(--text-soft); margin: 12px 0; overflow-x: auto; white-space: nowrap;
}
.formula b { color: var(--accent); font-weight: 600; }

/* litho interactive */
.litho-controls { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.litho-btn {
  padding: 8px 18px; font-size: 0.82rem; font-weight: 600; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text-soft);
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.litho-btn:hover { border-color: var(--accent); color: var(--text); }
.litho-btn.active { background: var(--chip-bg); border-color: var(--accent); color: var(--accent); }

/* ---- Quiz ---- */
.quiz-q { margin-bottom: 22px; }
.quiz-q .q-text { font-weight: 600; margin-bottom: 10px; font-size: 0.95rem; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
  text-align: left; padding: 11px 16px; border-radius: 11px; font-size: 0.88rem;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text-soft);
  cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.quiz-opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good); }
.quiz-opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); }
.quiz-score { font-family: "Space Grotesk", monospace; font-weight: 700; color: var(--accent); }

/* ---- Glossary ---- */
.glossary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.gloss-item {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.gloss-item dt { font-weight: 700; font-size: 0.92rem; color: var(--accent); font-family: "Space Grotesk", sans-serif; }
.gloss-item dd { margin: 6px 0 0; font-size: 0.84rem; color: var(--text-soft); }

/* ---- Roadmap / footer ---- */
.roadmap { padding: 90px 0; }
.roadmap-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; max-width: 900px; margin: 0 auto; }

footer {
  border-top: 1px solid var(--line); padding: 44px 0 54px; text-align: center;
  color: var(--text-faint); font-size: 0.85rem;
}
footer .foot-brand { font-family: "Space Grotesk", sans-serif; font-weight: 700; color: var(--text-soft); font-size: 1rem; margin-bottom: 8px; }

/* back-to-top */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 1.1rem;
  opacity: 0; pointer-events: none; transition: all 0.3s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }

/* ---- Side journey dots (desktop) ---- */
.journey-dots {
  position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 10px;
}
.journey-dots a {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint);
  opacity: 0.35; transition: all 0.25s; display: block;
}
.journey-dots a:hover { opacity: 0.8; transform: scale(1.3); }
.journey-dots a.active { background: var(--accent); opacity: 1; transform: scale(1.35); box-shadow: 0 0 8px var(--glow); }

/* ============================================================
   Module pages (Power Electronics · AI × Semiconductors)
   ============================================================ */
.page-hero {
  position: relative; padding: 140px 24px 70px; text-align: center;
  background: var(--hero-grad);
}
.page-hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); margin: 18px 0 16px; letter-spacing: -0.02em; }
.page-hero h1 .grad {
  background: linear-gradient(90deg, var(--accent-2) 0%, var(--accent) 55%, var(--accent-3) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-hero p.sub { max-width: 640px; margin: 0 auto; color: var(--text-soft); font-size: clamp(0.98rem, 2vw, 1.12rem); }
.crumb { font-size: 0.82rem; color: var(--text-faint); }
.crumb a { color: var(--text-soft); }

/* concept cards */
.cardlets { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin: 26px 0 8px; }
.cardlet {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 18px 16px; transition: all 0.25s;
}
.cardlet:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.cardlet .cl-icon { font-size: 1.5rem; }
.cardlet h4 { margin: 8px 0 6px; font-size: 0.98rem; font-family: "Space Grotesk", sans-serif; }
.cardlet p { margin: 0; font-size: 0.83rem; color: var(--text-soft); line-height: 1.55; }
.cardlet .cl-tag {
  display: inline-block; margin-top: 10px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); background: var(--chip-bg); padding: 3px 10px; border-radius: 999px;
}

/* comparison bars (linear vs switching) */
.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.vs-col {
  background: var(--bg-inset); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.vs-col h4 { margin: 0 0 10px; font-size: 0.9rem; display: flex; gap: 8px; align-items: center; }
.eff-bar { height: 14px; border-radius: 7px; background: var(--bg-card); overflow: hidden; border: 1px solid var(--line); }
.eff-bar > i { display: block; height: 100%; border-radius: 7px; transition: width 0.3s; }
.eff-num { font-family: "Space Grotesk", monospace; font-weight: 700; font-size: 1.3rem; margin: 8px 0 2px; }
.eff-sub { font-size: 0.74rem; color: var(--text-faint); }

/* oscilloscope */
.scope {
  background: #060a12; border: 1px solid var(--line); border-radius: 14px; padding: 10px;
}
html[data-theme="light"] .scope { background: #101828; }
.scope svg { display: block; width: 100%; }
.scope-label { font-size: 0.72rem; color: var(--text-faint); text-align: center; margin-top: 6px; letter-spacing: 0.06em; text-transform: uppercase; }

/* breadboard */
.bb-wrap { text-align: center; }
.bb-experiments { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.readout {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: #0c1626; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 16px; margin: 10px 6px 0;
  font-family: "Space Grotesk", monospace;
}
html[data-theme="light"] .readout { background: #16213a; }
.readout .r-label { font-size: 0.68rem; color: #7fe7e2; text-transform: uppercase; letter-spacing: 0.1em; }
.readout .r-value { font-size: 1.25rem; font-weight: 700; color: #5eead4; }

/* demo status pills */
.pill-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pill {
  font-size: 0.78rem; font-weight: 600; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-inset); color: var(--text-soft);
}
.pill b { font-family: "Space Grotesk", monospace; }
.pill.p-good { border-color: color-mix(in srgb, var(--good) 45%, transparent); color: var(--good); }
.pill.p-bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.pill.p-amber { border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); color: var(--accent-2); }

/* AI verdict box */
.verdict {
  margin-top: 14px; padding: 14px 18px; border-radius: 14px; font-size: 0.9rem;
  background: color-mix(in srgb, var(--accent-3) 8%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent-3) 30%, transparent);
  color: var(--text-soft); text-align: left;
}
.verdict .v-title { font-weight: 700; color: var(--accent-3); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px; }
.conf-bar { height: 8px; border-radius: 4px; background: var(--bg-inset); overflow: hidden; margin: 8px 0 4px; }
.conf-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-3), var(--accent)); border-radius: 4px; transition: width 0.5s; }

@media (max-width: 560px) { .vs-grid { grid-template-columns: 1fr; } }

/* ---- Responsive ---- */
@media (max-width: 920px) {
  .stage-body, .stage-body.rev { grid-template-columns: 1fr; }
  .stage-figure { position: static; order: -1; }
  .tool-grid { grid-template-columns: 1fr; }
  .journey-dots { display: none; }
  .nav-links a:not(.nav-keep) { display: none; }
}
@media (max-width: 560px) {
  .hero { min-height: 80vh; }
  .result-cards { grid-template-columns: 1fr 1fr; }
  .stage { padding: 64px 0 28px; }
}
