/* NSK — Learn Embedded Electronics */
:root {
  --bg: #f7f9fc;
  --paper: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7e;
  --line: #e4ebf3;
  --explore: #0078f0;
  --explore-hover: #005fc4;
  --amber: #e0a01a;
  --teal: #2bb7a9;
  --coral: #e07a4a;
  --sky: #4aa3d9;
  --max: 1080px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Plus Jakarta Sans", sans-serif;
  --shadow: 0 8px 28px rgba(26, 35, 50, 0.07);
  --shadow-hover: 0 14px 36px rgba(26, 35, 50, 0.12);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(0, 120, 240, 0.06), transparent 55%),
    radial-gradient(ellipse 45% 35% at 0% 15%, rgba(43, 183, 169, 0.07), transparent 50%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cg fill='none' stroke='%23cfd8e6' stroke-width='1' opacity='0.35'%3E%3Cpath d='M18 22h14M25 15v14'/%3E%3Ccircle cx='92' cy='28' r='6'/%3E%3Cpath d='M20 88c8 0 12-6 12-12'/%3E%3Crect x='78' y='78' width='18' height='10' rx='1'/%3E%3C/g%3E%3C/svg%3E");
  background-size: auto, auto, 120px 120px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.wrap {
  width: min(var(--max), calc(100% - 2.5rem));
  margin-inline: auto;
}

/* Top bar */
.topbar {
  padding: 1.15rem 0;
  border-bottom: 1px solid rgba(228, 235, 243, 0.9);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.brand-mark span { color: var(--amber); }
.top-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s ease;
}
.top-link:hover { color: var(--ink); }

/* Hero */
.hero {
  padding: 3.25rem 0 2.25rem;
}
.hero-copy {
  max-width: 40rem;
  animation: rise 0.7s ease both;
}
.kicker {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sky);
}
.hero-brand {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.hero-brand em {
  font-style: normal;
  display: block;
  color: var(--teal);
}
.hero-lead {
  margin: 0;
  font-size: clamp(1.02rem, 2vw, 1.18rem);
  color: var(--muted);
  max-width: 34rem;
}

/* Topic grid */
.topics {
  padding: 0.5rem 0 4rem;
}
.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.35rem;
}

.topic-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 1.25rem;
  align-items: center;
  min-height: 168px;
  padding: 1.45rem 1.4rem 1.25rem;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96), #fff),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      rgba(26, 35, 50, 0.03) 11px,
      rgba(26, 35, 50, 0.03) 12px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 11px,
      rgba(26, 35, 50, 0.03) 11px,
      rgba(26, 35, 50, 0.03) 12px
    );
  background-color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  overflow: hidden;
}
.topic-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent, var(--sky));
  opacity: 0.85;
}
.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: #d0dae8;
}
.topic-card[data-accent="violet"] { --accent: #6b3fe8; }
.topic-card[data-accent="teal"] { --accent: #00979d; }
.topic-card[data-accent="red"] { --accent: #e12b20; }
.topic-card[data-accent="coral"] { --accent: #e53a2b; }

.topic-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-self: stretch;
}
.level-tag {
  display: inline-flex;
  align-self: flex-start;
  margin: 0;
  padding: 0.18rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent, var(--sky));
  background: color-mix(in srgb, var(--accent, var(--sky)) 12%, white);
  border-radius: 999px;
}
.topic-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.topic-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 28ch;
}
.explore {
  margin-top: auto;
  padding-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--explore);
  transition: color 0.2s ease, gap 0.2s ease;
}
.explore-chevron {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}
.topic-card:hover .explore {
  color: var(--explore-hover);
  gap: 0.65rem;
}
.topic-card:hover .explore-chevron {
  background: var(--explore);
  color: #fff;
  border-color: var(--explore);
}

.topic-logo {
  width: clamp(72px, 12vw, 96px);
  height: clamp(72px, 12vw, 96px);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(26, 35, 50, 0.14);
  transition: transform 0.3s ease;
}
.topic-card:hover .topic-logo {
  transform: scale(1.05) rotate(-2deg);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.35rem 0 2rem;
  background: rgba(255, 255, 255, 0.65);
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

/* Motion */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}
.topic-card.reveal:nth-child(1) { transition-delay: 0.05s; }
.topic-card.reveal:nth-child(2) { transition-delay: 0.12s; }
.topic-card.reveal:nth-child(3) { transition-delay: 0.18s; }
.topic-card.reveal:nth-child(4) { transition-delay: 0.24s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  .topic-grid {
    grid-template-columns: 1fr;
  }
  .topic-card {
    min-height: 0;
    padding: 1.25rem 1.15rem;
  }
  .topic-card p { max-width: none; }
  .hero { padding-top: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ——— Lesson pages ——— */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  margin: 0 0 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.crumbs a {
  color: var(--explore);
  transition: color 0.15s ease;
}
.crumbs a:hover { color: var(--explore-hover); }
.crumbs .sep { opacity: 0.45; font-weight: 500; }
.crumbs .current { color: var(--ink); }

.lesson-hero {
  padding: 2.5rem 0 1.5rem;
}
.lesson-hero .hero-brand {
  font-size: clamp(1.85rem, 4vw, 2.65rem);
}
.lesson-hero .hero-brand em {
  display: inline;
  margin-left: 0.2em;
}
.lesson-lead {
  margin: 0;
  font-size: clamp(1.02rem, 2vw, 1.15rem);
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.65;
}

.lesson-body {
  padding: 0.25rem 0 3.5rem;
}

.lesson-section {
  margin: 0 0 2.75rem;
  padding: 1.6rem 1.5rem 1.7rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.lesson-section h2 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.5vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.lesson-section h3 {
  margin: 1.35rem 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
}
.lesson-section p {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
  max-width: 44rem;
}
.lesson-section p:last-child { margin-bottom: 0; }
.lesson-section ul {
  margin: 0 0 0.85rem;
  padding-left: 1.2rem;
  color: var(--muted);
  max-width: 42rem;
}
.lesson-section li {
  margin: 0.35rem 0;
  line-height: 1.55;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.15rem 0 0.25rem;
}
.compare-card {
  padding: 1.1rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fafbfd;
}
.compare-card[data-tone="conductor"] {
  border-color: #b8e0d8;
  background: linear-gradient(160deg, #e8f9f6, #fff);
}
.compare-card[data-tone="insulator"] {
  border-color: #f0d4c4;
  background: linear-gradient(160deg, #fff4ee, #fff);
}
.compare-card[data-tone="semi"] {
  border-color: #c5d8f5;
  background: linear-gradient(160deg, #eef4ff, #fff);
}
.compare-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--ink);
}
.compare-card p {
  margin: 0;
  font-size: 0.92rem;
  max-width: none;
}

.np-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.np-card {
  padding: 1.15rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.np-card.p-type {
  background: linear-gradient(145deg, #ffe8df, #fff8f5);
  border-color: #f0c4b0;
}
.np-card.n-type {
  background: linear-gradient(145deg, #dff7f3, #f5fffd);
  border-color: #a8ddd4;
}
.np-card h3 { margin-top: 0; }
.np-card .chip {
  display: inline-flex;
  margin-bottom: 0.55rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
}
.np-card.p-type .chip {
  color: #c45a2c;
  background: rgba(224, 122, 74, 0.16);
}
.np-card.n-type .chip {
  color: #1a8f84;
  background: rgba(43, 183, 169, 0.16);
}

.diagram-frame {
  margin: 1.15rem 0 0.85rem;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 4px 16px rgba(26, 35, 50, 0.06);
}
.diagram-frame img {
  width: 100%;
  height: auto;
}
.diagram-caption {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--muted);
  font-style: italic;
}

.callout {
  margin: 1.1rem 0 0;
  padding: 0.95rem 1.1rem;
  border-radius: 10px;
  border-left: 4px solid var(--teal);
  background: color-mix(in srgb, var(--teal) 10%, white);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.55;
  max-width: 44rem;
}
.callout strong { font-weight: 700; }

.next-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  padding: 1.35rem 1.4rem;
  border-radius: 14px;
  border: 1px solid #c5d8f5;
  background:
    linear-gradient(135deg, rgba(0, 120, 240, 0.06), rgba(43, 183, 169, 0.08)),
    #fff;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.next-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.next-card h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.next-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 36rem;
}
.next-card .explore { margin-top: 0.75rem; padding-top: 0; }

.bias-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  margin-top: 0.5rem;
}
.bias-grid .diagram-frame { margin-bottom: 0.5rem; }

@media (max-width: 760px) {
  .compare-grid,
  .np-row,
  .bias-grid {
    grid-template-columns: 1fr;
  }
  .lesson-section { padding: 1.25rem 1.1rem; }
  .next-card { grid-template-columns: 1fr; }
}

/* ——— Interactive Ohm’s Law circuit demo ——— */
.ohms-demo {
  margin: 1.25rem 0 0.35rem;
  padding: 1.15rem 1.1rem 1.25rem;
  border-radius: 14px;
  border: 1px solid #c5d8f5;
  background:
    linear-gradient(165deg, rgba(0, 120, 240, 0.05), rgba(43, 183, 169, 0.07) 45%, #fff 72%),
    #fafbfd;
  box-shadow: 0 4px 18px rgba(26, 35, 50, 0.06);
}
.ohms-demo-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-bottom: 0.85rem;
}
.ohms-demo-hint {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 28rem;
}
.ohms-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.95rem 0.55rem 0.7rem;
  border: 2px solid #9bb8e0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(26, 35, 50, 0.06);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.ohms-switch-btn:hover {
  border-color: var(--explore);
  box-shadow: 0 4px 14px rgba(0, 120, 240, 0.12);
}
.ohms-switch-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--explore) 45%, white);
  outline-offset: 2px;
}
.ohms-switch-track {
  position: relative;
  width: 2.6rem;
  height: 1.45rem;
  border-radius: 999px;
  background: #c5ced9;
  flex-shrink: 0;
  transition: background 0.25s ease;
}
.ohms-switch-knob {
  position: absolute;
  top: 0.18rem;
  left: 0.18rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(26, 35, 50, 0.25);
  transition: transform 0.25s ease;
}
.ohms-demo.is-on .ohms-switch-btn {
  border-color: #5ec9b8;
  background: linear-gradient(160deg, #e8f9f6, #fff);
}
.ohms-demo.is-on .ohms-switch-track {
  background: var(--teal);
}
.ohms-demo.is-on .ohms-switch-knob {
  transform: translateX(1.15rem);
}
.ohms-demo-stage {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse 50% 40% at 70% 45%, rgba(224, 122, 74, 0.08), transparent 60%),
    #fff;
  overflow: hidden;
}
.ohms-demo-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
}
.ohms-demo .wire {
  fill: none;
  stroke: #8a9bb0;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ohms-demo .wire-flow {
  fill: none;
  stroke: var(--sky);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 14;
  opacity: 0;
  pointer-events: none;
}
.ohms-demo.is-on .wire-flow {
  opacity: 1;
  animation: ohms-current-flow 0.85s linear infinite;
}
.ohms-demo .flow-dot {
  fill: var(--explore);
  opacity: 0;
}
.ohms-demo.is-on .flow-dot {
  opacity: 1;
}
.ohms-demo .sw-arm {
  stroke: #5c6b7e;
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: transform 0.28s ease;
  transform-origin: 168px 110px;
  transform: rotate(-28deg);
}
.ohms-demo.is-on .sw-arm {
  transform: rotate(0deg);
}
.ohms-demo .led-bulb {
  fill: #d8dee8;
  stroke: #9aa7b8;
  stroke-width: 2;
  transition: fill 0.3s ease, stroke 0.3s ease, filter 0.3s ease;
}
.ohms-demo .led-lens {
  fill: #b8c0cc;
  transition: fill 0.3s ease, filter 0.3s ease;
}
.ohms-demo .led-glow {
  fill: rgba(224, 122, 74, 0.35);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ohms-demo.is-on .led-bulb {
  fill: #ff9a5c;
  stroke: #e07a4a;
  filter: drop-shadow(0 0 8px rgba(224, 122, 74, 0.55));
}
.ohms-demo.is-on .led-lens {
  fill: #ffd0a8;
}
.ohms-demo.is-on .led-glow {
  opacity: 1;
}
.ohms-demo .part-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  fill: var(--ink);
}
.ohms-demo .part-sub {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  fill: var(--muted);
}
.ohms-demo-readout {
  margin: 0.9rem 0 0;
  min-height: 1.5rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  transition: color 0.25s ease;
}
.ohms-demo.is-on .ohms-demo-readout {
  color: #1a8f84;
}
.ohms-demo-readout .dim {
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--muted);
}
@keyframes ohms-current-flow {
  to { stroke-dashoffset: -22; }
}
@media (prefers-reduced-motion: reduce) {
  .ohms-demo.is-on .wire-flow {
    animation: none;
    stroke-dasharray: none;
    opacity: 0.85;
  }
}
