/* Electromagnetism Suite — G3 Pure Physics */

:root {
  /* semantic physics colours — kept constant so they always mean the same thing */
  --c-field:   #8b5cf6;   /* magnetic field B */
  --c-current: #f97316;   /* conventional current I */
  --c-force:   #16a34a;   /* force / motion F */
  --c-north:   #ef4444;   /* N pole */
  --c-south:   #3b82f6;   /* S pole */

  /* UI */
  --bg:        #eef2f7;
  --panel:     #ffffff;
  --ink:       #0f172a;
  --ink-soft:  #475569;
  --ink-faint: #94a3b8;
  --line:      #d8e0ea;
  --accent:    #0d9488;
  --accent-dk: #0f766e;
  --good:      #16a34a;
  --bad:       #dc2626;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #ecfeff;
  padding: 14px 20px 0;
  box-shadow: var(--shadow);
}
.topbar__brand { display: flex; align-items: center; gap: 14px; }
.topbar h1 { font-size: 1.35rem; }
.topbar__sub { margin: 1px 0 0; font-size: .82rem; color: #99f6e4; }
.topbar__home {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: 10px; text-decoration: none;
  background: rgba(255,255,255,.14); color: #ecfeff;
  font-size: 1.2rem; line-height: 1;
  transition: background .15s;
}
.topbar__home:hover { background: rgba(255,255,255,.26); }

.tabs {
  display: flex; gap: 4px; margin-top: 12px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  appearance: none; border: 0; cursor: pointer;
  background: rgba(255,255,255,.10); color: #d1fae5;
  padding: 9px 15px; border-radius: 10px 10px 0 0;
  font: inherit; font-size: .88rem; font-weight: 550;
  white-space: nowrap;
  display: flex; align-items: center; gap: 7px;
  transition: background .15s, color .15s;
}
.tab:hover { background: rgba(255,255,255,.2); color: #fff; }
.tab[aria-current="true"] { background: var(--bg); color: var(--ink); }
.tab__n {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 6px;
  background: rgba(0,0,0,.16); font-size: .72rem; font-weight: 700;
}
.tab[aria-current="true"] .tab__n { background: var(--accent); color: #fff; }
.tab__star { color: #fbbf24; font-size: .8rem; }

/* ---------- layout ---------- */
.app { padding: 20px; max-width: 1500px; margin: 0 auto; }

.module__head { margin-bottom: 14px; }
.module__head h2 { font-size: 1.5rem; }
.module__outcome {
  display: inline-block; margin-top: 6px;
  font-size: .78rem; color: var(--accent-dk); font-weight: 600;
  background: #ccfbf1; border: 1px solid #99f6e4;
  padding: 3px 10px; border-radius: 999px;
}
.module__blurb { margin: 8px 0 0; color: var(--ink-soft); max-width: 80ch; font-size: .94rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* stage = the dual 3D / 2D view */
.stage { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stage[data-view="3d"] { grid-template-columns: 1fr; }
.stage[data-view="2d"] { grid-template-columns: 1fr; }
.stage[data-view="3d"] .pane--2d,
.stage[data-view="2d"] .pane--3d { display: none; }

.pane {
  position: relative;
  height: min(48vh, 430px);
  min-height: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.pane__label {
  position: absolute; top: 10px; left: 12px; z-index: 3;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-faint);
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px;
  pointer-events: none;
}
.pane__hint {
  position: absolute; bottom: 10px; left: 12px; right: 12px; z-index: 3;
  font-size: .74rem; color: var(--ink-faint); pointer-events: none; text-align: center;
}
.pane__canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.pane--3d .pane__canvas { cursor: grab; }
.pane--3d .pane__canvas:active { cursor: grabbing; }
.pane__body { position: absolute; inset: 0; }

/* view switch */
.viewswitch { display: flex; gap: 6px; align-items: center; margin: 0 0 10px; flex-wrap: wrap; }
.viewswitch__label { font-size: .78rem; color: var(--ink-soft); font-weight: 600; margin-right: 2px; }

/* ---------- controls ---------- */
.controls {
  margin-top: 14px; padding: 14px 16px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: start;
}
.ctrl { display: grid; gap: 6px; min-width: 0; }
.ctrl__label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: .82rem; font-weight: 600; color: var(--ink-soft);
}
.ctrl__val { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.ctrl input[type="range"] {
  width: 100%; margin: 0; accent-color: var(--accent); height: 22px;
}

.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: .86rem; font-weight: 600;
  padding: 9px 14px; border-radius: 10px; min-height: 40px;
  border: 1px solid var(--line); background: #f8fafc; color: var(--ink);
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #eef2f7; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent-dk); color: #fff; }
.btn--primary:hover { background: var(--accent-dk); }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent-dk); color: #fff; }
.btn--sm { padding: 6px 11px; min-height: 34px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; flex-wrap: wrap; background: #f1f5f9; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg__btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-size: .82rem; font-weight: 600;
  padding: 7px 12px; border-radius: 8px; background: transparent; color: var(--ink-soft); min-height: 34px;
}
.seg__btn[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,.14); }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: .86rem; font-weight: 600; color: var(--ink-soft); }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; margin: 0; }

.readouts { display: flex; gap: 8px; flex-wrap: wrap; }
.readout {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 12px; min-width: 92px;
}
.readout__k { display: block; font-size: .7rem; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.readout__v { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- notes / callouts ---------- */
.note {
  margin-top: 14px; padding: 12px 16px;
  border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0;
  background: #f0fdfa; color: #134e4a; font-size: .9rem;
}
.note strong { color: #0f766e; }
.note--warn { border-left-color: #f59e0b; background: #fffbeb; color: #78350f; }
.note--warn strong { color: #b45309; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-soft); margin-top: 10px; }
.legend__item { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.legend__swatch { width: 15px; height: 4px; border-radius: 2px; }

/* ---------- quiz ---------- */
.quiz { margin-top: 18px; padding: 16px 18px; }
.quiz__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.quiz__title { font-size: 1.05rem; font-weight: 650; }
.quiz__score { font-size: .85rem; color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; }
.quiz__q { font-size: 1rem; font-weight: 600; margin: 0 0 12px; }
.quiz__fig { display: block; width: 100%; max-width: 460px; height: 190px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfdff; }
.quiz__opts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.quiz__opt {
  appearance: none; cursor: pointer; font: inherit; font-size: .9rem; text-align: left;
  padding: 11px 14px; border-radius: 10px; min-height: 44px;
  border: 1px solid var(--line); background: #f8fafc; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
  transition: background .12s, border-color .12s;
}
.quiz__opt:hover:not(:disabled) { background: #eef2f7; border-color: #b9c6d6; }
.quiz__opt:disabled { cursor: default; }
.quiz__opt[data-state="correct"] { background: #dcfce7; border-color: var(--good); color: #14532d; font-weight: 650; }
.quiz__opt[data-state="wrong"] { background: #fee2e2; border-color: var(--bad); color: #7f1d1d; }
.quiz__key {
  display: grid; place-items: center; flex: none;
  width: 24px; height: 24px; border-radius: 7px;
  background: #e2e8f0; font-size: .78rem; font-weight: 700;
}
.quiz__fb { margin-top: 12px; padding: 11px 14px; border-radius: 10px; font-size: .9rem; display: none; }
.quiz__fb[data-show="1"] { display: block; }
.quiz__fb[data-kind="correct"] { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.quiz__fb[data-kind="wrong"] { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }
.quiz__foot { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.quiz__done { text-align: center; padding: 18px 8px; }
.quiz__done h3 { font-size: 1.2rem; margin-bottom: 6px; }
.quiz__stars { font-size: 1.9rem; letter-spacing: 6px; color: #fbbf24; margin: 6px 0; }

/* ---------- landing page ---------- */
.hero { padding: 34px 20px 26px; text-align: center; background: linear-gradient(135deg,#0f766e,#115e59); color: #ecfeff; }
.hero h1 { font-size: 1.9rem; }
.hero p { margin: 8px auto 0; max-width: 62ch; color: #a7f3d0; font-size: .98rem; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); padding: 24px 20px; max-width: 1200px; margin: 0 auto; }
.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  transition: transform .14s, box-shadow .14s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(15,23,42,.13); }
.card__tag { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-dk); }
.card h3 { font-size: 1.15rem; margin: 6px 0 8px; }
.card p { margin: 0; font-size: .9rem; color: var(--ink-soft); }
.card--soon { opacity: .55; pointer-events: none; }
.card__list { margin: 10px 0 0; padding-left: 18px; font-size: .85rem; color: var(--ink-soft); }

.footer { padding: 20px; text-align: center; color: var(--ink-faint); font-size: .8rem; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; }
  .app { padding: 14px; }
  .topbar { padding: 12px 14px 0; }
  .topbar h1 { font-size: 1.15rem; }
  .module__head h2 { font-size: 1.25rem; }
}
@media (max-width: 560px) {
  .quiz__opts { grid-template-columns: 1fr; }
  .controls { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
