/* ========================================
   BASE — Design System & Reset
   ======================================== */

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

/* --- CSS Custom Properties --- */
:root {
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Container */
  --container-max: 1280px;
  --container-padding: 1.25rem;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;

  /* Z-Index */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 500;
  --z-modal: 1000;
}

/* --- Dark Theme (default) --- */
[data-theme="dark"] {
  --color-bg: #08080d;
  --color-bg-elevated: #111118;
  --color-bg-card: #15151e;
  --color-bg-card-hover: #1c1c28;
  --color-bg-input: #1a1a26;

  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-hover: rgba(255, 255, 255, 0.12);
  --color-border-accent: rgba(99, 139, 255, 0.3);

  --color-text-primary: #ededf2;
  --color-text-secondary: #8585a0;
  --color-text-muted: #555570;

  --color-accent: #638bff;
  --color-accent-hover: #7da0ff;
  --color-accent-muted: rgba(99, 139, 255, 0.12);

  --color-green: #34d399;
  --color-green-muted: rgba(52, 211, 153, 0.12);
  --color-amber: #fbbf24;
  --color-amber-muted: rgba(251, 191, 36, 0.12);
  --color-red: #f87171;
  --color-red-muted: rgba(248, 113, 113, 0.12);
  --color-purple: #a78bfa;
  --color-purple-muted: rgba(167, 139, 250, 0.12);

  --color-glass: rgba(17, 17, 24, 0.75);
  --color-glass-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 30px rgba(99, 139, 255, 0.1);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --color-bg: #f5f5fa;
  --color-bg-elevated: #ffffff;
  --color-bg-card: #ffffff;
  --color-bg-card-hover: #f0f0f8;
  --color-bg-input: #eeeef4;

  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-hover: rgba(0, 0, 0, 0.15);
  --color-border-accent: rgba(59, 100, 230, 0.3);

  --color-text-primary: #14141f;
  --color-text-secondary: #5c5c78;
  --color-text-muted: #9090a8;

  --color-accent: #3b64e6;
  --color-accent-hover: #2f54cc;
  --color-accent-muted: rgba(59, 100, 230, 0.08);

  --color-green: #059669;
  --color-green-muted: rgba(5, 150, 105, 0.08);
  --color-amber: #d97706;
  --color-amber-muted: rgba(217, 119, 6, 0.08);
  --color-red: #dc2626;
  --color-red-muted: rgba(220, 38, 38, 0.08);
  --color-purple: #7c3aed;
  --color-purple-muted: rgba(124, 58, 237, 0.08);

  --color-glass: rgba(255, 255, 255, 0.8);
  --color-glass-border: rgba(0, 0, 0, 0.06);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-glow: 0 0 30px rgba(59, 100, 230, 0.06);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

input, textarea, select {
  font: inherit;
  color: inherit;
}

ul, ol { list-style: none; }

table {
  border-collapse: collapse;
  width: 100%;
}

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

h1 { font-size: var(--text-4xl); font-weight: 800; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

@media (min-width: 768px) {
  h1 { font-size: var(--text-5xl); }
  h2 { font-size: var(--text-3xl); }
}

p + p { margin-top: var(--space-md); }

/* --- Utilities --- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.section {
  padding: var(--space-3xl) 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  gap: var(--space-md);
}

.section-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.section-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.section-link:hover { color: var(--color-accent-hover); }
.section-link::after { content: '→'; transition: transform var(--transition-fast); }
.section-link:hover::after { transform: translateX(3px); }

/* Grid helpers */
.grid { display: grid; gap: var(--space-lg); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-accent { background: var(--color-accent-muted); color: var(--color-accent); }
.badge-green { background: var(--color-green-muted); color: var(--color-green); }
.badge-amber { background: var(--color-amber-muted); color: var(--color-amber); }
.badge-red { background: var(--color-red-muted); color: var(--color-red); }
.badge-purple { background: var(--color-purple-muted); color: var(--color-purple); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-primary);
  border-color: var(--color-border);
}
.btn-outline:hover {
  border-color: var(--color-border-hover);
  background: var(--color-bg-card);
}

/* Scroll reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
