/* ==========================================================================
   STACKSAGE DESIGN SYSTEM — Codecademy Dark Editorial Theme
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* ── Color Palette: Dark Navy + Yellow-Gold ── */
  --bg-base:             #0d1117;
  --bg-surface:          #161b22;
  --bg-surface-elevated: #1e242c;
  --bg-card:             #1c2128;
  --bg-card-hover:       #242b35;
  --bg-input:            #0d1117;

  /* Primary Accent — Codecademy Yellow-Gold */
  --primary:             #f5c518;
  --primary-hover:       #ffd33d;
  --primary-dark:        #d4a300;
  --primary-muted:       rgba(245, 197, 24, 0.14);
  --primary-border:      rgba(245, 197, 24, 0.4);
  --primary-text:        #0d1117; /* text ON yellow buttons */

  /* Blue Accent — code links, highlights */
  --accent-blue:         #58a6ff;
  --accent-blue-muted:   rgba(88, 166, 255, 0.14);
  --accent-blue-border:  rgba(88, 166, 255, 0.35);

  /* Green — success, completed */
  --success:             #3fb950;
  --success-bg:          rgba(63, 185, 80, 0.14);
  --success-border:      rgba(63, 185, 80, 0.4);

  /* Red — errors */
  --error:               #f85149;
  --error-bg:            rgba(248, 81, 73, 0.14);
  --error-border:        rgba(248, 81, 73, 0.4);

  /* Orange — streaks, warnings */
  --streak-fire:         #ff7849;
  --streak-bg:           rgba(255, 120, 73, 0.14);
  --streak-border:       rgba(255, 120, 73, 0.38);

  /* Text — High Contrast & WCAG AA/AAA Compliant */
  --text-primary:        #f0f6fc;
  --text-secondary:      #adbac7;
  --text-muted:          #8b949e;
  --text-faint:          #656d76;
  --text-on-yellow:      #0d1117;

  /* ── Backward-compat aliases (used in player.js, simulations.js inline styles) ── */
  --primary-light:       #ffd33d;
  --primary-glow:        rgba(245, 197, 24, 0.35);
  --primary-gradient:    linear-gradient(135deg, #ffd33d 0%, #f5c518 50%, #d4a300 100%);
  --secondary:           #58a6ff;
  --secondary-light:     #79b8ff;
  --secondary-glow:      rgba(88, 166, 255, 0.25);
  --xp-gold:             #f5c518;
  --xp-gradient:         linear-gradient(135deg, #ffd33d 0%, #f5c518 100%);
  --streak-fire-glow:    rgba(255, 120, 73, 0.35);
  --streak-fire-gradient: linear-gradient(135deg, #ff944d 0%, #ff5722 100%);
  --border-medium:       rgba(240, 246, 252, 0.2);
  --border-highlight:    rgba(245, 197, 24, 0.4);
  --bg-surface-glass:    rgba(22, 27, 34, 0.88);
  --bg-card-hover:       #242b35;

  /* Borders — Crisp outlines for dark cards */
  --border-subtle:       rgba(240, 246, 252, 0.1);
  --border-default:      rgba(240, 246, 252, 0.16);
  --border-muted:        rgba(240, 246, 252, 0.07);
  --border-emphasis:     rgba(240, 246, 252, 0.3);

  /* Shadows & Glows */
  --shadow-sm:   0 1px 0 rgba(27, 31, 35, 0.04);
  --shadow-md:   0 3px 8px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg:   0 8px 24px rgba(0, 0, 0, 0.55), 0 16px 48px rgba(0, 0, 0, 0.35);
  --shadow-yellow: 0 0 16px rgba(245, 197, 24, 0.35);
  --shadow-glow: 0 0 20px rgba(88, 166, 255, 0.18);
  --shadow-fire: 0 0 20px rgba(255, 120, 73, 0.3);

  /* Border radius — sharp like Codecademy/GitHub */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-full: 9999px;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Layout */
  --max-width:          1280px;
  --header-height:      60px;
  --sidebar-width:      240px;
  --bottom-nav-height:  56px;

  /* Typography */
  --font-sans:  'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Dot-grid background pattern (Codecademy signature) ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(88, 166, 255, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* Subtle ambient glow — top center */
body::after {
  content: '';
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(245, 197, 24, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── App shell ── */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Main content area — shifts right on desktop to account for sidebar */
.main-content {
  flex: 1;
  width: 100%;
  padding: calc(var(--header-height) + 2rem) 1.5rem 4rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.875rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.35rem); }

p { color: var(--text-secondary); }

/* Monospace utility */
.mono, .code-font {
  font-family: var(--font-mono);
}

/* Section label — Codecademy's uppercase mono category labels */
.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.section-label-yellow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

/* ── Dark Card (solid, sharp-cornered) ── */
.dark-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dark-card:hover {
  border-color: var(--border-default);
}

.dark-card-interactive {
  cursor: pointer;
}

.dark-card-interactive:hover {
  border-color: var(--border-emphasis);
  background: var(--bg-card-hover);
}

/* Keep glass-card as alias for backwards compat */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease;
}

.glass-card:hover {
  border-color: var(--border-default);
}

.glass-card-interactive:hover {
  border-color: var(--border-emphasis);
  background: var(--bg-card-hover);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: 40px;
  user-select: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

/* Yellow primary — Codecademy style */
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 12px rgba(245, 197, 24, 0.2);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(245, 197, 24, 0.35);
  transform: translateY(-1px);
}

/* Dark bordered secondary */
.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-emphasis);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
  font-weight: 700;
  box-shadow: 0 0 12px rgba(63, 185, 80, 0.25);
}

.btn-success:hover {
  background: #2ea043;
  border-color: #2ea043;
  box-shadow: 0 4px 16px rgba(63, 185, 80, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border-color: var(--border-emphasis);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── Pills & Tags — monospace, uppercase, Codecademy-style ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.pill-primary {
  background: var(--primary-muted);
  color: var(--primary);
  border-color: var(--primary-border);
}

.pill-cyan, .pill-blue {
  background: var(--accent-blue-muted);
  color: var(--accent-blue);
  border-color: var(--accent-blue-border);
}

.pill-amber {
  background: var(--streak-bg);
  color: var(--streak-fire);
  border-color: var(--streak-border);
}

.pill-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.pill-muted {
  background: rgba(139, 148, 158, 0.1);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

/* ── Progress Bars ── */
.progress-container {
  width: 100%;
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Grid utilities ── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

/* ── Dividers ── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: 1.5rem 0;
}

/* ── Text utilities ── */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-yellow    { color: var(--primary) !important; }
.text-blue      { color: var(--accent-blue) !important; }
.text-green     { color: var(--success) !important; }
.text-orange    { color: var(--streak-fire) !important; }
.text-gradient  { color: var(--primary) !important; }
.text-cyan      { color: var(--accent-blue) !important; }
.text-amber     { color: var(--streak-fire) !important; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .main-content {
    padding-bottom: calc(var(--bottom-nav-height) + 2rem);
  }
}
