/* =======================
   Global CSS Variables - Dark & Light Mode System
======================= */

/* Import consolidated variables */
@import './variables.css';

/* Default: Dark Mode */
:root {
  /* ============================================
     COLOR SYSTEM
     ============================================ */

  /* Brand Colors - Safari UI inspired */
  --primary-color: #007aff;
  --primary-dark: #0051d5;
  --primary-light: #34aadc;

  /* Semantic Colors */
  --success-color: #2d9e47;

  /* Background Colors - Dark Mode */
  --bg-interactive: #030303;

  /* Text Colors - Optimized for Dark Mode */
  --text-primary: #f5f5f5;
  --text-secondary: #d4d4d4;
  --text-muted: #a3a3a3;
  --text-faded: #737373;

  /* Particle System - Dark Mode */
  --particle-color: rgb(9 139 255 / 80%);
  --particle-opacity: 0.4;

  /* Borders */
  --border-color: #2a2a2a;

  /* Link & Semantic Colors */
  --color-link: var(--primary-color);
  --color-text-main: var(--text-primary);
  --color-text-muted: var(--text-muted);
  --color-bg: var(--bg-secondary);
  --color-bg-secondary: var(--bg-tertiary);

  /* Greeting Gradient */
  --greet-grad: linear-gradient(90deg, #2563eb, #06b6d4, #10b981, #6366f1);

  /* ============================================
     SPACING SYSTEM
     ============================================ */

  --spacing-xxs: 0.1rem; /* 1.6px */
  --spacing-lg: 2rem; /* 32px */
  --spacing-xl: 3rem; /* 48px */
  --spacing-2xl: 5rem; /* 80px */

  /* Layout Spacing */
  --container-width: 1600px;
  --gap: clamp(0.75rem, 3vw, 1.5rem);

  /* ============================================
     TYPOGRAPHY
     ============================================ */

  /* Font Families - System fonts as primary */
  --font-primary:
    -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
  --font-mono: 'SF Mono', monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  --font-inter:
    -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
  --critical-font-stack:
    -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;
  --font-script:
    -apple-system, blinkmacsystemfont, 'Segoe UI', roboto, sans-serif;

  /* Typography Tokens */
  --font-family-main: var(--font-primary);
  --font-size-p: 1.08rem;
  --line-height-base: 1.7;
  --font-size-h2: 1.5rem;

  /* Typographic Design System (Headline & Body Tokens) */
  --headline-fs: clamp(3rem, 6vw, 4.5rem);
  --headline-lh: 1.03;
  --headline-weight: 900;
  --headline-letter: -0.02em;
  --lead-fs: 1.125rem;
  --body-fs: var(--font-size-p);
  --body-lh: var(--line-height-base);
  --muted-fs: 0.95rem;

  /* Project & Card Text Sizes */
  --project-title-fs: 1.25rem;
  --project-desc-fs: var(--body-fs);

  /* Greeting Variables (derived from headline tokens) */
  --greet-fs: var(--headline-fs);
  --greet-lh: var(--headline-lh);
  --greet-weight: 800;
  --greet-letter: var(--headline-letter);
  --greet-max: clamp(18ch, 44vw, 30ch);
  --greet-min-inline: clamp(18ch, 32vw, 42ch);

  /* ============================================
     TRANSITIONS & ANIMATIONS
     ============================================ */

  /* Transition Speeds */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-slow: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-bounce: 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --transition-elastic: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Timing Functions */
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Animation Delays */
  --delay-0: 0s;
  --delay-1: 1s;
  --delay-2: 2s;
  --delay-3: 3s;

  /* Animation Durations */
  --greet-anim-grad-dur: 28s;
  --greet-anim-pulse-dur: 13.2s;

  /* TypeWriter Custom Properties */
  --typing-target: 28ch;
  --typing-steps: 28;

  /* Scroll Progress */
  --scroll-progress: 0;

  /* ============================================
     TRANSFORMS
     ============================================ */

  /* Transform Standards */
  --transform-none: translateY(0);
  --transform-lift-sm: translateY(-2px);
  --transform-lift-md: translateY(-4px);
  --transform-lift-lg: translateY(-8px);
  --transform-lift-xl: translateY(-20px);
  --transform-down-sm: translateY(18px);
  --transform-down-full: translateY(100%);

  /* Scale Transforms */
  --transform-scale-sm: scale(1.02);
  --transform-scale-md: scale(1.05);
  --transform-scale-lg: scale(1.08);
  --transform-scale-none: scale(1);
  --transform-scale-fade: scale(0.98);

  /* Complex Transform Combinations */
  --transform-hover-logo: scale(1.08) translateY(-1px);
  --transform-hover-card: translateY(-8px) scale(1.02);
  --transform-hover-card-smooth: translateY(-6px) scale(1.025);
  --transform-hover-card-subtle: translateY(-3px) scale(1.015);
  --transform-rotate-slight: rotate(2deg);
  --transform-rotate-hover: rotate(-1deg) translateY(-4px);

  /* ============================================
     SHADOWS & EFFECTS
     ============================================ */

  /* Shadow Levels */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 12px 24px rgba(0, 0, 0, 0.25);
  --shadow-2xl: 0 20px 40px rgba(0, 0, 0, 0.3);

  /* Backdrop Blur Levels */
  --blur-none: blur(0);
  --blur-xs: blur(4px);
  --blur-sm: blur(8px);
  --blur-md: blur(12px);
  --blur-lg: blur(20px);
  --blur-xl: blur(24px);
  --blur-2xl: blur(40px);

  /* ============================================
     BORDER RADIUS
     ============================================ */

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;
  --radius-full: 9999px;

  /* ============================================
     Z-INDEX LAYERS
     ============================================ */

  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 500;
  --z-fixed: 1000;
  --z-modal-backdrop: 9000;
  --z-modal: 9500;
  --z-overlay: 9999;
  --z-tooltip: 10000;

  /* ============================================
     COMPONENT-SPECIFIC VARIABLES
     ============================================ */

  /* Cards / Features */
  --card-pad: clamp(0.75rem, 3vw, 2rem);
  --card-min-width: 280px;
  --card-min-height: 180px;

  /* Card-Specific Tokens */
  --card-transition-base: cubic-bezier(0.34, 1.56, 0.64, 1);
  --card-transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --card-blur-base: 24px;
  --card-blur-hover: 28px;
  --card-shadow-base: 0 10px 40px rgb(0 0 0 / 25%), 0 2px 8px rgb(0 0 0 / 15%);
  --card-shadow-hover:
    0 20px 60px rgb(0 0 0 / 35%), 0 0 40px rgb(7 161 255 / 20%);
  --card-glow-color: rgb(7 161 255 / 40%);

  /* Unified Component Variables (Menu & Footer) */
  --component-header-bg: rgb(28 28 30 / 72%);
  --component-blur-radius: 16px;
  --component-pill-radius: 24px;
  --component-card-radius: 16px;
  --component-micro-radius: 8px;
  --component-shadow-depth-2:
    0 4px 12px rgb(0 0 0 / 15%), 0 2px 4px rgb(0 0 0 / 12%);
  --component-shadow-depth-3:
    0 8px 32px rgb(0 0 0 / 18%), 0 4px 8px rgb(0 0 0 / 15%);
  --component-spring-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --component-spring-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --component-spring-quick: cubic-bezier(0.4, 0, 0.2, 1);
  --component-accent-blue: #007aff;
  --component-accent-blue-hover: #0056cc;
  --component-label-primary: rgb(255 255 255 / 95%);
  --component-label-secondary: rgb(255 255 255 / 70%);
  --component-label-tertiary: rgb(255 255 255 / 50%);
  --component-separator: rgb(255 255 255 / 15%);
  --component-fill-primary: rgb(255 255 255 / 10%);
  --component-fill-secondary: rgb(255 255 255 / 12%);
  --component-font-family:
    'Inter', -apple-system, 'SF Pro Display', 'SF Pro Text', system-ui,
    sans-serif;
  --component-text-primary: 17px;
  --component-text-secondary: 15px;
  --component-text-small: 13px;
  --component-font-weight-medium: 510;
  --component-font-weight-regular: 450;

  /* ============================================
     RESPONSIVE BREAKPOINTS
     ============================================ */

  /* Responsive tweaks: slightly smaller headings on very small viewports */
  @media (width <= 420px) {
    :root {
      --headline-fs: clamp(2.2rem, 8vw, 3rem);
      --greet-fs: var(--headline-fs);
      --greet-min-inline: clamp(14ch, 36vw, 28ch);
      --greet-max: clamp(14ch, 100vw, 26ch);
      --card-min-width: 0;
    }
  }

  @media (min-width: 1600px) {
    :root {
      --container-width: 1800px;
    }
  }

  /* Respect reduced motion preferences */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}

/* Global responsive media elements */
img,
svg,
picture,
video,
iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* =======================
   LIGHT MODE OVERRIDE (Blue Theme)
======================= */
:root[data-theme='light'] {
  --theme-mode: 'light';

  /* Blue Light Mode Background */
  --bg-primary: #1e3a8a;
  --bg-secondary: #1e40af;
  --bg-tertiary: #2563eb;
  --bg-interactive: #3b82f6;

  /* Text Colors - Optimized for blue background */
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #cbd5e1;
  --text-faded: #94a3b8;

  /* Particle System - Light Mode */
  --particle-color: rgb(248 250 252 / 80%);

  /* Adjusted Brand Colors for Light Mode */
  --primary-color: #60a5fa;
  --primary-hover: #93c5fd;
  --accent-color: #34d399;
  --accent-secondary: #f87171;

  /* Status Colors for Light Mode */
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --info-color: #3b82f6;

  /* Borders and UI Elements */
  --border-color: #3b82f6;
  --border-subtle: #1e40af;

  /* Shadows for Light Mode */
  --shadow-sm: 0 2px 4px rgb(0 0 0 / 20%);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 25%);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / 30%);
  --shadow-xl: 0 16px 48px rgb(0 0 0 / 35%);
}

/* =======================
   AUTO LIGHT MODE (Browser Preference)
======================= */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    /* Reuse light mode variables */
    --theme-mode: 'light';
    --bg-primary: #1e3a8a;
    --bg-secondary: #1e40af;
    --bg-tertiary: #2563eb;
    --bg-interactive: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --text-faded: #94a3b8;
    --particle-color: rgb(248 250 252 / 80%);
    --primary-color: #60a5fa;
    --primary-hover: #93c5fd;
    --accent-color: #34d399;
    --accent-secondary: #f87171;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    --border-color: #3b82f6;
    --border-subtle: #1e40af;
    --shadow-sm: 0 2px 4px rgb(0 0 0 / 20%);
    --shadow-md: 0 4px 12px rgb(0 0 0 / 25%);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 30%);
    --shadow-xl: 0 16px 48px rgb(0 0 0 / 35%);
  }
}

/* Hide scrollbars on mobile while keeping scroll intact */
@media (width <= 768px) {
  html,
  body {
    -ms-overflow-style: none;
  }

  /* Apply scrollbar-width only when supported */
  @supports (scrollbar-width: none) {
    html,
    body,
    * {
      scrollbar-width: none;
    }
  }

  /* Canonical/centralized scrollbar hide for small viewports (keep here) */
  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  *::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
  }
}
