/* ============================================================
   AM/FM Telecom Lab — Design System
   Dark technical / oscilloscope aesthetic
   ============================================================ */

:root {
  /* Surfaces */
  --bg-deep: #070d18;
  --bg-base: #0a1220;
  --bg-panel: #0f1a2e;
  --bg-elev: #162338;
  --bg-elev-2: #1d2c44;

  /* Borders */
  --border-subtle: rgba(148, 184, 220, 0.08);
  --border-soft: rgba(148, 184, 220, 0.14);
  --border-strong: rgba(148, 184, 220, 0.24);

  /* Text */
  --text-primary: #e6edf7;
  --text-secondary: #97a8c4;
  --text-muted: #5d6f8a;
  --text-faint: #3a4a64;

  /* Accents */
  --cyan: #22d3ee;
  --cyan-dim: #0891b2;
  --cyan-glow: rgba(34, 211, 238, 0.5);

  --blue: #60a5fa;
  --blue-dim: #2563eb;

  --lime: #a3e635;
  --lime-dim: #65a30d;
  --lime-glow: rgba(163, 230, 53, 0.5);

  --amber: #fbbf24;
  --amber-dim: #d97706;
  --amber-glow: rgba(251, 191, 36, 0.5);

  --pink: #f472b6;
  --pink-dim: #db2777;
  --pink-glow: rgba(244, 114, 182, 0.5);

  --red: #fb7185;
  --green: #4ade80;

  /* Type */
  --font-ui: 'Inter Tight', 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  --font-display: 'Inter Tight', sans-serif;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

#root {
  min-height: 100vh;
  position: relative;
}

/* Subtle grid background */
.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 30%, black 30%, transparent 90%);
  z-index: 0;
}

.scanline-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(34, 211, 238, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(244, 114, 182, 0.05), transparent 60%);
  z-index: 0;
}

/* ============== Top chrome ============== */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 18, 32, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--cyan), var(--blue-dim));
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.35), inset 0 0 0 1px rgba(255,255,255,0.15);
}
.brand-mark::before {
  content: '';
  position: absolute; inset: 6px;
  border: 1.5px solid rgba(255,255,255,0.85);
  border-radius: 4px;
  border-top-color: transparent;
  border-right-color: transparent;
  transform: rotate(-45deg);
}
.brand-name { color: var(--text-primary); }
.brand-name b { color: var(--cyan); font-weight: 600; }

.crumbs {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.crumbs .sep { color: var(--text-faint); }
.crumbs .here { color: var(--text-secondary); }

.topbar-status {
  display: flex; align-items: center; gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.04);
}
.status-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime-glow);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============== Generic ============== */
.page {
  flex: 1;
  padding: 40px 48px 80px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  position: relative;
}
.page-narrow { max-width: 1100px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 12px;
}

h1.page-title {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 12px;
  text-wrap: balance;
}
.page-sub {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.5;
  margin-bottom: 32px;
}

/* ============== Buttons ============== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--text-primary);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(180deg, var(--cyan) 0%, var(--cyan-dim) 100%);
  color: #04141a;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.35), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(34, 211, 238, 0.5), inset 0 1px 0 rgba(255,255,255,0.4); }

.btn-secondary {
  background: var(--bg-elev);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-elev-2); border-color: var(--cyan); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-soft);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-strong); background: rgba(255,255,255,0.02); }

.btn-lime {
  background: linear-gradient(180deg, var(--lime) 0%, var(--lime-dim) 100%);
  color: #0d1f00;
  box-shadow: 0 4px 20px rgba(163, 230, 53, 0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

.btn-pink {
  background: linear-gradient(180deg, var(--pink) 0%, var(--pink-dim) 100%);
  color: #1a0010;
  box-shadow: 0 4px 20px rgba(244, 114, 182, 0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ============== Cards ============== */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 24px;
  position: relative;
  transition: all 0.18s ease;
}
.card:hover { border-color: var(--border-soft); }
.card-elev { background: var(--bg-elev); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}
.card-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.tag-cyan { color: var(--cyan); border-color: rgba(34, 211, 238, 0.3); background: rgba(34, 211, 238, 0.06); }
.tag-lime { color: var(--lime); border-color: rgba(163, 230, 53, 0.3); background: rgba(163, 230, 53, 0.06); }
.tag-amber { color: var(--amber); border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.06); }
.tag-pink { color: var(--pink); border-color: rgba(244, 114, 182, 0.3); background: rgba(244, 114, 182, 0.06); }

/* ============== Lesson Cards ============== */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.lesson-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  padding: 22px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
  text-align: left;
  font-family: var(--font-ui);
  color: inherit;
}
.lesson-card:hover {
  border-color: var(--cyan);
  background: var(--bg-elev);
  transform: translateY(-2px);
}
.lesson-card .num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  margin-bottom: 16px;
}
.lesson-card h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 10px;
}
.lesson-card .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}
.lesson-card .arrow {
  position: absolute;
  bottom: 22px;
  right: 22px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.08);
  display: grid; place-items: center;
  color: var(--cyan);
  opacity: 0;
  transform: translateX(-6px);
  transition: all 0.2s ease;
}
.lesson-card:hover .arrow { opacity: 1; transform: translateX(0); }
.lesson-card.completed::after {
  content: '✓';
  position: absolute;
  top: 18px; right: 18px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--lime);
  color: #0d1f00;
  font-size: 12px;
  font-weight: 700;
  display: grid; place-items: center;
}

/* ============== Formula / mono blocks ============== */
.formula {
  font-family: var(--font-mono);
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-size: 15px;
  color: var(--cyan);
  display: inline-block;
}
.formula .op { color: var(--text-secondary); }
.formula .var { color: var(--lime); }
.formula .const { color: var(--amber); }

.mono { font-family: var(--font-mono); }

.kpi {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: -0.01em;
}
.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============== Inputs ============== */
.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.text-input {
  flex: 1;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--bg-deep);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: var(--cyan);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2), 0 0 12px var(--cyan-glow);
}
.range::-moz-range-thumb {
  width: 18px; height: 18px;
  background: var(--cyan);
  border-radius: 50%;
  cursor: grab;
  border: none;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.2);
}

/* ============== Waveform / Scope ============== */
.scope {
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.scope-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}
.scope-label {
  position: absolute;
  top: 10px; left: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.scope-label .ch-dot {
  width: 8px; height: 8px; border-radius: 50%;
}

/* ============== Block diagram ============== */
.block-node {
  background: var(--bg-elev);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  position: relative;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-ui);
}
.block-node:hover {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.08);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.2);
}
.block-node.active {
  border-color: var(--cyan);
  background: rgba(34, 211, 238, 0.12);
  box-shadow: 0 0 28px rgba(34, 211, 238, 0.4);
}
.block-node .icon {
  font-size: 20px;
  margin-bottom: 6px;
  display: block;
}
.block-node .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.05em;
}

/* ============== Quiz ============== */
.quiz-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--bg-elev);
  border: 1.5px solid var(--border-soft);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
  font-size: 15px;
  color: var(--text-primary);
  text-align: left;
}
.quiz-option:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}
.quiz-option .letter {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--bg-deep);
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.quiz-option.selected { border-color: var(--cyan); background: rgba(34, 211, 238, 0.06); }
.quiz-option.correct { border-color: var(--lime); background: rgba(163, 230, 53, 0.08); }
.quiz-option.correct .letter { background: var(--lime); color: #0d1f00; border-color: var(--lime); }
.quiz-option.wrong { border-color: var(--red); background: rgba(251, 113, 133, 0.08); }
.quiz-option.wrong .letter { background: var(--red); color: #1a0008; border-color: var(--red); }
.quiz-option:disabled { cursor: default; }

/* ============== Misc utilities ============== */
.row { display: flex; gap: 16px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 16px; }
.between { justify-content: space-between; }
.center { justify-content: center; align-items: center; }

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 24px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elev);
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
}

/* progress bar */
.pbar {
  height: 4px;
  background: var(--bg-deep);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.pbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 0.4s ease;
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* fade in */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeUp 0.35s ease both; }
.fade-in-2 { animation: fadeUp 0.4s 0.05s ease both; }
.fade-in-3 { animation: fadeUp 0.45s 0.1s ease both; }

/* selectable highlight color reset */
::selection { background: rgba(34, 211, 238, 0.35); color: white; }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elev-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
