/**
 * MathPulse K-12 - Core Design System & CSS Variables (2026 Edition)
 */

:root {
  /* Brand Palette */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Color System - Dark Theme (Default) */
  --color-bg: #090d16;
  --color-bg-secondary: #0f172a;
  --color-surface: rgba(18, 26, 47, 0.75);
  --color-surface-hover: rgba(30, 41, 69, 0.9);
  --color-surface-solid: #151f38;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(56, 189, 248, 0.4);

  --color-text: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-text-dim: #64748b;

  --color-primary: #38bdf8;
  --color-primary-glow: rgba(56, 189, 248, 0.35);
  --color-accent: #a855f7;
  --color-accent-glow: rgba(168, 85, 247, 0.35);
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  --nav-height: 72px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 30px var(--color-primary-glow);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Theme Override */
[data-theme="light"] {
  --color-bg: #f8fafc;
  --color-bg-secondary: #f1f5f9;
  --color-surface: rgba(255, 255, 255, 0.85);
  --color-surface-hover: #ffffff;
  --color-surface-solid: #ffffff;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(14, 165, 233, 0.5);

  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-dim: #94a3b8;

  --color-primary: #0284c7;
  --color-primary-glow: rgba(2, 132, 199, 0.2);
  --color-accent: #7c3aed;
  --color-accent-glow: rgba(124, 58, 237, 0.2);

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.12);
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(168, 85, 247, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select {
  font-family: inherit;
}

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

/* Layout Utilities */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 4vw, 2rem);
  padding-right: clamp(1rem, 4vw, 2rem);
}

/* Header & Navbar */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: var(--color-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  transition: border-color var(--transition-normal);
}

.nav-wrapper {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  box-shadow: var(--shadow-sm);
}

.brand-text-accent {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

.nav-link {
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.nav-link.active {
  color: var(--color-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Stat Chips */
.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}

.theme-icon-btn, .audio-icon-btn, .mobile-menu-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.theme-icon-btn:hover, .audio-icon-btn:hover, .mobile-menu-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
}

.mobile-menu-btn {
  display: none;
}

/* Mobile Drawer */
.mobile-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--color-surface-solid);
  z-index: 200;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transition: right var(--transition-normal);
}

.mobile-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  list-style: none;
}

.drawer-link {
  display: block;
  padding: 0.8rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
}

.drawer-link:hover, .drawer-link.active {
  background: var(--color-primary-glow);
  color: var(--color-primary);
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  padding-bottom: 4rem;
}

/* Footer */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  padding: 3.5rem 0 2rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-brand-info p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 0.75rem;
  max-width: 360px;
}

.footer-col h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-links a {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--color-text-dim);
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .nav-links {
    display: none;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
}
