/**
 * DESIGN SYSTEM - 2025 World-Class Standards
 * Apple-level glassmorphism | Stripe-level spacing | Linear-level precision
 * Notion-level comfort | Vercel-level aesthetics
 */

:root {
  /* ============================================
     GLASSMORPHISM SYSTEM (Apple Design Awards Level)
     ============================================ */

  /* Blur Scale - Consistent across all components */
  --blur-xs: 8px;    /* Subtle hover states */
  --blur-sm: 12px;   /* Small cards, badges */
  --blur-md: 20px;   /* Standard cards, panels */
  --blur-lg: 30px;   /* Headers, modals, feature sections */
  --blur-xl: 40px;   /* Hero sections, full-screen overlays */

  /* Glass Background Layers */
  --glass-ultra-light: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.03)
  );
  --glass-light: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.06)
  );
  --glass-medium: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.08)
  );
  --glass-strong: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.20),
    rgba(255, 255, 255, 0.10)
  );

  /* Glass Borders */
  --glass-border-subtle: 1px solid rgba(255, 255, 255, 0.10);
  --glass-border-medium: 1px solid rgba(255, 255, 255, 0.18);
  --glass-border-strong: 1px solid rgba(255, 255, 255, 0.25);

  /* ============================================
     SHADOW SYSTEM (Elevation Hierarchy)
     ============================================ */

  /* Base Shadows (Ambient + Direct Light) */
  --shadow-xs:
    0 2px 8px rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.08);

  --shadow-sm:
    0 4px 16px rgba(0, 0, 0, 0.16),
    0 2px 4px rgba(0, 0, 0, 0.12);

  --shadow-md:
    0 8px 32px rgba(0, 0, 0, 0.24),
    0 4px 8px rgba(0, 0, 0, 0.16);

  --shadow-lg:
    0 16px 48px rgba(0, 0, 0, 0.32),
    0 8px 16px rgba(0, 0, 0, 0.24);

  --shadow-xl:
    0 24px 64px rgba(0, 0, 0, 0.40),
    0 12px 24px rgba(0, 0, 0, 0.32);

  /* Inner Glow for Glass Elements */
  --glow-subtle: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --glow-medium: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --glow-strong: inset 0 2px 0 rgba(255, 255, 255, 0.25);

  /* ============================================
     SPACING SYSTEM (Strict 8px Grid)
     ============================================ */

  /* Base Scale (8px increments) */
  --space-0: 0;
  --space-1: 0.25rem;   /* 4px - Micro adjustments */
  --space-2: 0.5rem;    /* 8px - Minimum spacing */
  --space-3: 0.75rem;   /* 12px - Tight spacing */
  --space-4: 1rem;      /* 16px - Standard gap */
  --space-5: 1.25rem;   /* 20px - DEPRECATED (use 24px) */
  --space-6: 1.5rem;    /* 24px - Comfortable spacing */
  --space-8: 2rem;      /* 32px - Section spacing */
  --space-10: 2.5rem;   /* 40px - Large gaps */
  --space-12: 3rem;     /* 48px - Extra large gaps */
  --space-16: 4rem;     /* 64px - Section dividers */
  --space-20: 5rem;     /* 80px - Major sections */
  --space-24: 6rem;     /* 96px - Hero sections */
  --space-32: 8rem;     /* 128px - Massive spacing */

  /* Fluid Spacing (Responsive with clamp) */
  --space-fluid-xs: clamp(1rem, 2vw, 1.5rem);      /* 16-24px */
  --space-fluid-sm: clamp(1.5rem, 3vw, 2rem);      /* 24-32px */
  --space-fluid-md: clamp(2rem, 5vw, 3rem);        /* 32-48px */
  --space-fluid-lg: clamp(3rem, 8vw, 5rem);        /* 48-80px */
  --space-fluid-xl: clamp(4rem, 10vw, 7.5rem);     /* 64-120px */

  /* ============================================
     TYPOGRAPHY SYSTEM (Notion-Level Comfort)
     ============================================ */

  /* Fluid Font Sizes */
  --text-xs: clamp(0.75rem, 0.5vw + 0.625rem, 0.875rem);       /* 12-14px */
  --text-sm: clamp(0.875rem, 0.5vw + 0.75rem, 1rem);           /* 14-16px */
  --text-base: clamp(1rem, 0.5vw + 0.875rem, 1.125rem);        /* 16-18px */
  --text-lg: clamp(1.125rem, 1vw + 0.875rem, 1.25rem);         /* 18-20px */
  --text-xl: clamp(1.25rem, 1vw + 1rem, 1.5rem);               /* 20-24px */
  --text-2xl: clamp(1.5rem, 2vw + 1rem, 2rem);                 /* 24-32px */
  --text-3xl: clamp(1.875rem, 3vw + 1rem, 2.5rem);             /* 30-40px */
  --text-4xl: clamp(2.25rem, 4vw + 1rem, 3rem);                /* 36-48px */
  --text-5xl: clamp(3rem, 5vw + 1rem, 4rem);                   /* 48-64px */
  --text-6xl: clamp(3.75rem, 6vw + 1.5rem, 5rem);              /* 60-80px */

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.1;
  --leading-snug: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;
  --leading-loose: 1.75;

  /* Letter Spacing (for display text) */
  --tracking-tighter: -0.04em;  /* Large headlines */
  --tracking-tight: -0.02em;    /* Subheadings */
  --tracking-normal: 0;
  --tracking-wide: 0.02em;      /* Uppercase labels */
  --tracking-wider: 0.04em;     /* Buttons, badges */

  /* ============================================
     COLOR SYSTEM (WCAG AAA Compliant)
     ============================================ */

  /* Text Contrast Levels */
  --text-primary: rgba(255, 255, 255, 0.95);      /* Headings, key content */
  --text-secondary: rgba(255, 255, 255, 0.85);    /* Body text */
  --text-tertiary: rgba(255, 255, 255, 0.65);     /* Captions, labels */
  --text-quaternary: rgba(255, 255, 255, 0.45);   /* Disabled, placeholder */

  /* Text Shadow for Glass Backgrounds */
  --text-shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.3);
  --text-shadow-medium: 0 2px 4px rgba(0, 0, 0, 0.4);
  --text-shadow-strong: 0 2px 8px rgba(0, 0, 0, 0.5);

  /* ============================================
     ANIMATION SYSTEM (Vercel-Level Polish)
     ============================================ */

  /* Timing Functions */
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);          /* Material Design standard */
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55); /* Playful bounce */
  --ease-sharp: cubic-bezier(0.4, 0, 0.6, 1);           /* Quick snap */
  --ease-elegant: cubic-bezier(0.25, 0.1, 0.25, 1);     /* iOS-like */

  /* Duration Scale */
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 700ms;

  /* Stagger Delays (for list animations) */
  --stagger-1: 0s;
  --stagger-2: 0.1s;
  --stagger-3: 0.2s;
  --stagger-4: 0.3s;
  --stagger-5: 0.4s;

  /* ============================================
     LAYOUT SYSTEM
     ============================================ */

  /* Container Widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
  --container-2xl: 1536px;

  /* Border Radius (Consistent curves) */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-popover: 600;
  --z-tooltip: 700;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Glass Effect Utilities */
.glass-xs {
  background: var(--glass-ultra-light);
  backdrop-filter: blur(var(--blur-xs)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-xs)) saturate(180%);
  border: var(--glass-border-subtle);
  box-shadow: var(--shadow-xs), var(--glow-subtle);
}

.glass-sm {
  background: var(--glass-light);
  backdrop-filter: blur(var(--blur-sm)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-sm)) saturate(180%);
  border: var(--glass-border-medium);
  box-shadow: var(--shadow-sm), var(--glow-subtle);
}

.glass-md {
  background: var(--glass-medium);
  backdrop-filter: blur(var(--blur-md)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-md)) saturate(180%);
  border: var(--glass-border-medium);
  box-shadow: var(--shadow-md), var(--glow-medium);
}

.glass-lg {
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(180%);
  border: var(--glass-border-strong);
  box-shadow: var(--shadow-lg), var(--glow-strong);
}

/* Text Legibility on Glass */
.text-on-glass {
  color: var(--text-secondary);
  text-shadow: var(--text-shadow-subtle);
}

.text-on-glass-heading {
  color: var(--text-primary);
  text-shadow: var(--text-shadow-medium);
}

/* Performance-Optimized Transitions */
.transition-smooth {
  transition: transform var(--duration-normal) var(--ease-smooth),
              opacity var(--duration-normal) var(--ease-smooth);
}

.transition-elegant {
  transition: transform var(--duration-normal) var(--ease-elegant),
              opacity var(--duration-normal) var(--ease-elegant);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
