/* ============================================
   FML — Fundamentals of Machine Learning
   Design System & Global Styles
   ============================================ */

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---------- CSS Variables ---------- */
:root {
  /* Palette */
  --bg-primary: #0b0f1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, .65);
  --bg-glass: rgba(255, 255, 255, .04);
  --border-glass: rgba(255, 255, 255, .08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-1: #6366f1;
  /* Indigo */
  --accent-2: #8b5cf6;
  /* Violet */
  --accent-3: #06b6d4;
  /* Cyan */
  --accent-4: #10b981;
  /* Emerald */
  --accent-5: #f97316;
  /* Orange */
  --accent-6: #ec4899;
  /* Pink */
  --gradient-hero: linear-gradient(135deg, #6366f1 0%, #8b5cf6 40%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(99, 102, 241, .15), rgba(139, 92, 246, .10));
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .45);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, .25);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: .3s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Base ---------- */
html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--accent-3);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-1);
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Typography ---------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  line-height: 1.25;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
}

h2 {
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
}

h3 {
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
}

h4 {
  font-size: 1.1rem;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px);
}

.section {
  padding: clamp(3rem, 8vw, 6rem) 0;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-2);
}

/* ============================================
   Navigation
   ============================================ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(11, 15, 26, .82);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  transition: background var(--transition), box-shadow var(--transition);
}

.site-nav.scrolled {
  background: rgba(11, 15, 26, .95);
  box-shadow: var(--shadow-lg);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: .85rem clamp(16px, 4vw, 32px);
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  align-items: center;
}

.nav-links a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: .9rem;
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: rgba(99, 102, 241, .12);
}

/* Mobile menu */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }

  .nav-links {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(11, 15, 26, .97);
    backdrop-filter: blur(20px);
    gap: 1.2rem;
    transform: translateX(100%);
    transition: transform .4s ease;
  }

  .nav-links.open {
    transform: translateX(0);
  }

  .nav-links a {
    font-size: 1.1rem;
    padding: .6rem 1.2rem;
  }
}

/* ============================================
   Hero Section (Home page)
   ============================================ */
.hero {
  min-height: 92vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding-top: 70px;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(99, 102, 241, .18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(6, 182, 212, .12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 780px;
}

.hero-badge {
  display: inline-block;
  padding: .35rem 1rem;
  border-radius: 50px;
  background: rgba(99, 102, 241, .15);
  border: 1px solid rgba(99, 102, 241, .3);
  color: var(--accent-1);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .04em;
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin-bottom: 1rem;
}

.hero h1 .gradient-text {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  max-width: 600px;
  margin: 0 auto 2.5rem;
}

/* Floating particles behind hero (JS-driven) */
.hero-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.hero-particles span {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: rgba(99, 102, 241, .25);
  animation: float-particle linear infinite;
}

@keyframes float-particle {
  0% {
    transform: translateY(0) scale(1);
    opacity: .6;
  }

  100% {
    transform: translateY(-110vh) scale(.3);
    opacity: 0;
  }
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1.6rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--accent-1);
  color: #fff;
}

.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99, 102, 241, .35);
}

.btn-outline {
  background: transparent;
  color: var(--accent-3);
  border: 1.5px solid rgba(6, 182, 212, .4);
}

.btn-outline:hover {
  background: rgba(6, 182, 212, .1);
  border-color: var(--accent-3);
  transform: translateY(-2px);
}

.btn-ghost {
  background: rgba(255, 255, 255, .06);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, .12);
}

.btn-sm {
  padding: .5rem 1rem;
  font-size: .85rem;
}

/* ============================================
   Cards
   ============================================ */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: clamp(1.2rem, 3vw, 2rem);
  transition: all var(--transition);
}

.glass-card:hover {
  border-color: rgba(99, 102, 241, .25);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}

/* Unit cards on home page */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
}

.unit-card {
  background: var(--gradient-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.unit-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-hero);
  opacity: 0;
  transition: opacity var(--transition);
}

.unit-card:hover {
  transform: translateY(-6px);
  border-color: rgba(99, 102, 241, .3);
  box-shadow: var(--shadow-glow);
}

.unit-card:hover::before {
  opacity: 1;
}

.unit-card .unit-number {
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent-1);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}

.unit-card h3 {
  margin-bottom: .6rem;
  font-size: 1.15rem;
}

.unit-card p {
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: 1rem;
}

.unit-card .topics-list {
  list-style: none;
}

.unit-card .topics-list li {
  color: var(--text-muted);
  font-size: .82rem;
  padding: .2rem 0;
  padding-left: 1rem;
  position: relative;
}

.unit-card .topics-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent-3);
  font-weight: 700;
}

.unit-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.2rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border-glass);
}

.unit-card .progress-bar-mini {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, .06);
  border-radius: 2px;
  margin-right: .8rem;
  overflow: hidden;
}

.unit-card .progress-bar-mini span {
  display: block;
  height: 100%;
  background: var(--accent-4);
  border-radius: 2px;
  transition: width .6s ease;
}

.unit-card .arrow {
  color: var(--accent-1);
  font-size: 1.2rem;
  transition: transform var(--transition);
}

.unit-card:hover .arrow {
  transform: translateX(4px);
}

/* ============================================
   Progress Tracker (Home page)
   ============================================ */
.progress-section {
  margin-bottom: 3rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 10px;
  background: rgba(255, 255, 255, .06);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--gradient-hero);
  border-radius: 5px;
  transition: width .8s ease;
}

.progress-text {
  font-size: .9rem;
  color: var(--text-secondary);
}

/* ============================================
   Unit Page Layout
   ============================================ */
.unit-hero {
  padding: 8rem 0 3rem;
  text-align: center;
  background:
    radial-gradient(ellipse 60% 40% at 50% 30%, rgba(99, 102, 241, .12) 0%, transparent 70%);
}

.unit-hero .unit-number-lg {
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent-1);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: .8rem;
}

.unit-hero h1 {
  margin-bottom: .8rem;
}

.unit-hero p {
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Sticky sidebar TOC */
.unit-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.unit-sidebar {
  position: sticky;
  top: 80px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
}

.unit-sidebar h4 {
  font-size: .82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .8rem;
}

.toc-list {
  list-style: none;
}

.toc-list li a {
  display: block;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .85rem;
  transition: all var(--transition);
  border-left: 2px solid transparent;
  margin-bottom: 2px;
}

.toc-list li a:hover,
.toc-list li a.active {
  color: var(--text-primary);
  background: rgba(99, 102, 241, .1);
  border-left-color: var(--accent-1);
}

@media (max-width: 900px) {
  .unit-layout {
    grid-template-columns: 1fr;
  }

  .unit-sidebar {
    position: static;
  }
}

/* Content sections inside unit */
.content-block {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  margin-bottom: 2rem;
}

.content-block h2 {
  margin-bottom: 1.2rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: .6rem;
}

.content-block h2 .icon {
  font-size: 1.4rem;
}

.content-block h3 {
  color: var(--accent-3);
  margin: 1.5rem 0 .8rem;
}

.content-block h4 {
  color: var(--accent-2);
  margin: 1.2rem 0 .6rem;
}

.content-block p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.content-block ul,
.content-block ol {
  color: var(--text-secondary);
  margin: .8rem 0 1.2rem 1.5rem;
}

.content-block li {
  margin-bottom: .4rem;
}

.content-block strong {
  color: var(--text-primary);
}

/* ============================================
   Interactive Components
   ============================================ */

/* -- Comparison Grid -- */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 1.5rem 0;
}

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

.compare-card {
  padding: 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  transition: all var(--transition);
}

.compare-card:hover {
  transform: translateY(-3px);
}

.compare-card.type-a {
  background: linear-gradient(135deg, rgba(99, 102, 241, .18), rgba(139, 92, 246, .12));
  border-color: rgba(99, 102, 241, .2);
}

.compare-card.type-b {
  background: linear-gradient(135deg, rgba(6, 182, 212, .18), rgba(16, 185, 129, .12));
  border-color: rgba(6, 182, 212, .2);
}

.compare-card.type-c {
  background: linear-gradient(135deg, rgba(249, 115, 22, .18), rgba(236, 72, 153, .12));
  border-color: rgba(249, 115, 22, .2);
}

.compare-card h4 {
  margin-bottom: .8rem;
}

.compare-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compare-card li {
  padding: .3rem 0 .3rem 1.2rem;
  position: relative;
  font-size: .92rem;
  color: var(--text-secondary);
}

.compare-card li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: var(--accent-4);
}

/* -- Interactive Calculator (Confusion Matrix, etc.) -- */
.calculator-box {
  background: rgba(0, 0, 0, .2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.calculator-box table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.calculator-box th,
.calculator-box td {
  padding: .6rem .8rem;
  text-align: center;
  border: 1px solid var(--border-glass);
}

.calculator-box th {
  background: rgba(99, 102, 241, .1);
  color: var(--accent-1);
  font-size: .85rem;
}

.calculator-box input[type="number"] {
  width: 70px;
  padding: .4rem;
  text-align: center;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1rem;
}

.calculator-box input:focus {
  outline: none;
  border-color: var(--accent-1);
}

.metrics-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.metric-tile {
  background: rgba(99, 102, 241, .08);
  border: 1px solid rgba(99, 102, 241, .15);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.metric-tile .label {
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .3rem;
}

.metric-tile .value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-1);
}

.metric-tile .formula {
  display: block;
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

/* -- Slider Controls -- */
.slider-group {
  margin: 1rem 0;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .4rem;
  font-size: .9rem;
  color: var(--text-secondary);
}

.slider-group label span {
  color: var(--accent-1);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, .08);
  border-radius: 3px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-1);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(99, 102, 241, .4);
}

/* -- Visualization Canvas Area -- */
.viz-canvas {
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  min-height: 300px;
  position: relative;
  overflow: hidden;
  margin: 1rem 0;
}

.viz-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* -- Code Blocks -- */
.code-block {
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.5rem;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .85rem;
  line-height: 1.6;
  color: #e2e8f0;
  overflow-x: auto;
  margin: 1rem 0;
  position: relative;
}

.code-block .lang-tag {
  position: absolute;
  top: .5rem;
  right: .8rem;
  font-size: .7rem;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.code-block .keyword {
  color: #c084fc;
}

.code-block .string {
  color: #86efac;
}

.code-block .comment {
  color: #64748b;
  font-style: italic;
}

.code-block .func {
  color: #67e8f9;
}

.code-block .number {
  color: #fdba74;
}

/* ============================================
   Quiz Component
   ============================================ */
.quiz-container {
  margin: 1.5rem 0;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.quiz-progress {
  font-size: .85rem;
  color: var(--text-muted);
}

.quiz-score {
  font-size: .85rem;
  color: var(--accent-4);
  font-weight: 600;
}

.quiz-question {
  font-size: 1.1rem;
  margin-bottom: 1.2rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.quiz-option {
  display: block;
  width: 100%;
  padding: .9rem 1.2rem;
  text-align: left;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: .95rem;
  cursor: pointer;
  transition: all var(--transition);
}

.quiz-option:hover {
  background: rgba(99, 102, 241, .1);
  border-color: rgba(99, 102, 241, .3);
}

.quiz-option.correct {
  background: rgba(16, 185, 129, .15);
  border-color: var(--accent-4);
  color: var(--accent-4);
}

.quiz-option.incorrect {
  background: rgba(239, 68, 68, .15);
  border-color: #ef4444;
  color: #ef4444;
}

.quiz-option:disabled {
  cursor: default;
  opacity: .7;
}

.quiz-explanation {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(99, 102, 241, .08);
  border-left: 3px solid var(--accent-1);
  font-size: .9rem;
  color: var(--text-secondary);
}

/* ============================================
   Flashcard / Revision Component
   ============================================ */
.flashcard-deck {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.flashcard {
  background: var(--gradient-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.flashcard:hover {
  border-color: rgba(99, 102, 241, .3);
}

.flashcard .fc-question {
  font-weight: 600;
  font-size: .95rem;
}

.flashcard .fc-answer {
  margin-top: .8rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border-glass);
  color: var(--text-secondary);
  font-size: .9rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all .4s ease;
}

.flashcard.revealed .fc-answer {
  max-height: 500px;
  opacity: 1;
}

.flashcard .fc-toggle {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ============================================
   Animations
   ============================================ */
/* Fade-in on scroll */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .7s ease, transform .7s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger children */
.stagger>* {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}

.stagger.visible>*:nth-child(1) {
  transition-delay: .05s;
}

.stagger.visible>*:nth-child(2) {
  transition-delay: .10s;
}

.stagger.visible>*:nth-child(3) {
  transition-delay: .15s;
}

.stagger.visible>*:nth-child(4) {
  transition-delay: .20s;
}

.stagger.visible>*:nth-child(5) {
  transition-delay: .25s;
}

.stagger.visible>*:nth-child(6) {
  transition-delay: .30s;
}

.stagger.visible>* {
  opacity: 0;
  transform: translateY(20px);
}

.stagger.visible>* {
  opacity: 1;
  transform: translateY(0);
}

/* Pulse glow */
@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(99, 102, 241, .15);
  }

  50% {
    box-shadow: 0 0 40px rgba(99, 102, 241, .3);
  }
}

.glow {
  animation: pulse-glow 3s ease-in-out infinite;
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  background: rgba(0, 0, 0, .3);
  border-top: 1px solid var(--border-glass);
  padding: 3rem 0;
  text-align: center;
  margin-top: 4rem;
}

.site-footer p {
  color: var(--text-muted);
  font-size: .85rem;
}

.site-footer .heart {
  color: var(--accent-6);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.mt-1 {
  margin-top: .5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: .5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-1 {
  gap: .5rem;
}

.gap-2 {
  gap: 1rem;
}

.gap-3 {
  gap: 1.5rem;
}

/* Info / Tip / Warning callouts */
.callout {
  padding: 1rem 1.2rem;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  font-size: .9rem;
  display: flex;
  gap: .8rem;
  align-items: flex-start;
}

.callout-info {
  background: rgba(6, 182, 212, .08);
  border-left: 3px solid var(--accent-3);
}

.callout-tip {
  background: rgba(16, 185, 129, .08);
  border-left: 3px solid var(--accent-4);
}

.callout-warning {
  background: rgba(249, 115, 22, .08);
  border-left: 3px solid var(--accent-5);
}

.callout .callout-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.callout p {
  margin: 0;
  color: var(--text-secondary);
}

/* Mathematical formula display */
.formula-box {
  background: rgba(0, 0, 0, .25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  margin: 1rem 0;
  font-family: 'Fira Code', monospace;
  color: var(--accent-3);
}

/* Tag pills */
.tag {
  display: inline-block;
  padding: .2rem .7rem;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 600;
}

.tag-indigo {
  background: rgba(99, 102, 241, .15);
  color: var(--accent-1);
}

.tag-cyan {
  background: rgba(6, 182, 212, .15);
  color: var(--accent-3);
}

.tag-emerald {
  background: rgba(16, 185, 129, .15);
  color: var(--accent-4);
}

.tag-orange {
  background: rgba(249, 115, 22, .15);
  color: var(--accent-5);
}

.tag-pink {
  background: rgba(236, 72, 153, .15);
  color: var(--accent-6);
}

/* Navigation between units */
.unit-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-glass);
}

.unit-nav a {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: color var(--transition);
}

.unit-nav a:hover {
  color: var(--accent-1);
}

/* Diagram containers */
.diagram-container {
  background: rgba(0, 0, 0, .2);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 2rem;
  margin: 1.5rem 0;
  text-align: center;
  overflow-x: auto;
}

.diagram-container .diagram-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  flex-wrap: wrap;
}

.diagram-node {
  padding: .6rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
}

.diagram-node.primary {
  background: rgba(99, 102, 241, .2);
  border: 1px solid rgba(99, 102, 241, .3);
  color: var(--accent-1);
}

.diagram-node.secondary {
  background: rgba(6, 182, 212, .2);
  border: 1px solid rgba(6, 182, 212, .3);
  color: var(--accent-3);
}

.diagram-node.accent {
  background: rgba(16, 185, 129, .2);
  border: 1px solid rgba(16, 185, 129, .3);
  color: var(--accent-4);
}

.diagram-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
}

/* Table styling for units */
.styled-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: .9rem;
}

.styled-table th {
  background: rgba(99, 102, 241, .1);
  color: var(--accent-1);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid rgba(99, 102, 241, .2);
}

.styled-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.styled-table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

/* ============================================
   Additional Components
   ============================================ */

/* Gradient text (reusable) */
.gradient-text {
  background: var(--gradient-hero);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Unit number large — display block */
.unit-hero .unit-number-lg {
  display: block;
}

/* Code block header bar */
.code-block .code-header,
.code-header {
  display: block;
  font-family: 'Inter', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .8rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border-glass);
}

/* Textarea styling */
textarea {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
}

/* Disabled button state */
.btn:disabled,
.btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Pre / Code inside code-block */
.code-block pre {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  overflow-x: auto;
}

.code-block code {
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: .85rem;
  line-height: 1.65;
  color: #e2e8f0;
}

/* Canvas responsive */
canvas {
  max-width: 100%;
}