/* ==========================================================================
   Tech Reeel - Master Design System Tokens & Core Styles
   ========================================================================== */

:root {
  /* Color System - Core Tokens */
  --color-primary: #2563EB;
  --color-primary-rgb: 37, 99, 235;
  --color-primary-hover: #1D4ED8;
  --color-primary-light: rgba(37, 99, 235, 0.12);

  --color-secondary: #06B6D4;
  --color-secondary-rgb: 6, 182, 212;
  --color-secondary-hover: #0891B2;
  
  --color-accent: #7C3AED;
  --color-accent-rgb: 124, 58, 237;
  --color-accent-hover: #6D28D9;

  --color-success: #22C55E;
  --color-success-light: rgba(34, 197, 94, 0.15);
  --color-warning: #F59E0B;
  --color-warning-light: rgba(245, 158, 11, 0.15);
  --color-danger: #EF4444;
  --color-danger-light: rgba(239, 68, 68, 0.15);

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #2563EB 0%, #06B6D4 50%, #7C3AED 100%);
  --gradient-accent: linear-gradient(135deg, #7C3AED 0%, #2563EB 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(37, 99, 235, 0.15) 0%, transparent 70%);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;

  /* Sizing & Spacing */
  --header-height: 72px;
  --max-width: 1280px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Micro Animations */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Mode (Default) Theme Variables */
[data-theme="dark"] {
  --color-bg: #0F172A;
  --color-surface: #1E293B;
  --color-surface-hover: #334155;
  --color-surface-active: #475569;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.18);
  
  --color-text-main: #F8FAFC;
  --color-text-muted: #94A3B8;
  --color-text-subtle: #64748B;
  --color-text-invert: #0F172A;

  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-bg-hover: rgba(51, 65, 85, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.36);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.25);
}

/* Light Mode Theme Variables */
[data-theme="light"] {
  --color-bg: #FFFFFF;
  --color-surface: #F8FAFC;
  --color-surface-hover: #F1F5F9;
  --color-surface-active: #E2E8F0;
  --color-border: rgba(15, 23, 42, 0.08);
  --color-border-hover: rgba(15, 23, 42, 0.18);

  --color-text-main: #0F172A;
  --color-text-muted: #475569;
  --color-text-subtle: #94A3B8;
  --color-text-invert: #FFFFFF;

  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-bg-hover: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 25px rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   CSS Reset & Base Styles
   ========================================================================== */

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  color-scheme: dark light;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-main);
  background-image: var(--gradient-glow);
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

/* Accessibility - Skip to Content */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 20px;
  background: var(--color-primary);
  color: #fff;
  padding: 12px 24px;
  z-index: 9999;
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: top var(--transition-fast);
  text-decoration: none;
}
.skip-to-content:focus {
  top: 20px;
}

/* Selection */
::selection {
  background: var(--color-primary);
  color: #ffffff;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-text-main);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.25rem, 5vw, 3.75rem); font-weight: 800; }
h2 { font-size: clamp(1.75rem, 3.5vw, 2.75rem); }
h3 { font-size: clamp(1.35rem, 2.5vw, 1.85rem); }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
  color: var(--color-text-muted);
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

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

ul, ol {
  list-style: none;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--color-surface-active);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* ==========================================================================
   Glassmorphism & Core Utility Classes
   ========================================================================== */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-lg);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.glass-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: var(--color-border-hover);
}

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.text-gradient-accent {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  display: inline-block;
}

.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-secondary); }
.text-accent { color: var(--color-accent); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--color-text-muted); }

.bg-primary { background-color: var(--color-primary); }
.bg-surface { background-color: var(--color-surface); }

/* Layout Wrappers */
.main-container {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--header-height) + 2rem) 1.5rem 4rem;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.section-header {
  text-align: center;
  max-width: 760px;
  margin: 0 auto 3rem;
}
.section-header p {
  font-size: 1.15rem;
  color: var(--color-text-muted);
}

/* Flex & Grid Helpers */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }

.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

/* Micro Animations & Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.icon-pulse {
  animation: pulse 2.5s infinite ease-in-out;
}

/* Spinner Loader */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  gap: 1.25rem;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-surface);
  border-top-color: var(--color-primary);
  border-right-color: var(--color-secondary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Icon Sizes */
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 18px; height: 18px; }
.icon-md { width: 22px; height: 22px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 36px; height: 36px; }

/* Responsive adjustments */
@media (max-width: 768px) {
  .main-container {
    padding: calc(var(--header-height) + 1.25rem) 1rem 3rem;
  }
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}
