/**
 * ============================================
 * JOODNESS DESIGN SYSTEM - CSS CUSTOM PROPERTIES
 * ============================================
 * Version: 1.0.0
 * Created: 2026-01-21
 *
 * Usage: Include this file FIRST, before any other stylesheets
 *
 * <link rel="stylesheet" href="/assets/css/design-tokens.css">
 * <link rel="stylesheet" href="/assets/css/styles.css">
 * ============================================
 */

:root {
  /* ============================================
     COLOR SYSTEM
     ============================================ */

  /* Primary - Joodness Green
     Used for: Primary buttons, links, active states, brand elements
     -------------------------------------------- */
  --color-primary-50: #ECFDF5;
  --color-primary-100: #D1FAE5;
  --color-primary-200: #A7F3D0;
  --color-primary-300: #6EE7B7;
  --color-primary-400: #34D399;
  --color-primary-500: #10B981;  /* PRIMARY - Main brand color */
  --color-primary-600: #059669;  /* Hover state */
  --color-primary-700: #047857;  /* Active state */
  --color-primary-800: #065F46;
  --color-primary-900: #064E3B;

  /* Amber - Accent Color
     Used for: Featured badges, star ratings, highlights, CTAs
     -------------------------------------------- */
  --color-amber-50: #FFFBEB;
  --color-amber-100: #FEF3C7;
  --color-amber-200: #FDE68A;
  --color-amber-300: #FCD34D;  /* Stars */
  --color-amber-400: #FBBF24;
  --color-amber-500: #F59E0B;  /* ACCENT - Featured elements */
  --color-amber-600: #D97706;  /* Hover */
  --color-amber-700: #B45309;

  /* Neutral Colors
     Used for: Text, backgrounds, borders, disabled states
     -------------------------------------------- */
  --color-neutral-50: #F9FAFB;   /* Page background */
  --color-neutral-100: #F3F4F6;  /* Card background, inputs */
  --color-neutral-200: #E5E7EB;  /* Borders, dividers */
  --color-neutral-300: #D1D5DB;  /* Disabled states */
  --color-neutral-400: #9CA3AF;  /* Placeholder text */
  --color-neutral-500: #6B7280;  /* Secondary text */
  --color-neutral-600: #4B5563;  /* Body text */
  --color-neutral-700: #374151;  /* Subheadings */
  --color-neutral-800: #1F2937;  /* Dark backgrounds */
  --color-neutral-900: #111827;  /* Darkest (footer) */

  /* Brand Navy
     Used for: Primary text, headings, navbar
     -------------------------------------------- */
  --color-navy: #202835;

  /* Semantic Colors
     Used for: Status messages, alerts, validation
     -------------------------------------------- */
  --color-success: #22C55E;
  --color-success-light: #DCFCE7;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-info: #3B82F6;
  --color-info-light: #DBEAFE;

  /* Special Purpose
     -------------------------------------------- */
  --color-white: #FFFFFF;
  --color-black: #000000;
  --color-overlay: rgba(17, 24, 39, 0.5);
  --color-focus-ring: rgba(16, 185, 129, 0.5);

  /* Semantic Aliases (Light Mode)
     Use these in components for easy dark mode support
     -------------------------------------------- */
  --color-bg-primary: var(--color-white);
  --color-bg-secondary: var(--color-neutral-50);
  --color-bg-tertiary: var(--color-neutral-100);
  --color-bg-elevated: var(--color-white);
  --color-bg-overlay: rgba(17, 24, 39, 0.5);
  --color-text-primary: var(--color-navy);
  --color-text-secondary: var(--color-neutral-600);
  --color-text-muted: var(--color-neutral-500);
  --color-text-inverted: var(--color-white);
  --color-border: var(--color-neutral-200);
  --color-border-light: var(--color-neutral-100);
  --color-border-focus: var(--color-primary-500);

  /* Semantic Color Backgrounds (Light Mode) */
  --color-success-bg: #DCFCE7;
  --color-error-bg: #FEE2E2;
  --color-warning-bg: #FEF3C7;
  --color-info-bg: #DBEAFE;

  /* Component Tokens (Light Mode) */
  --color-card-bg: var(--color-white);
  --color-card-border: var(--color-border);
  --color-input-bg: var(--color-white);
  --color-input-border: var(--color-neutral-300);
  --color-input-placeholder: var(--color-neutral-400);
  --color-header-bg: var(--color-white);
  --color-footer-bg: var(--color-neutral-900);
  --color-footer-text: var(--color-neutral-300);

  /* Theme Transition */
  --theme-transition: background-color var(--duration-300) var(--ease-in-out),
                      color var(--duration-300) var(--ease-in-out),
                      border-color var(--duration-300) var(--ease-in-out),
                      box-shadow var(--duration-300) var(--ease-in-out);

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

  /* Font Families */
  --font-family-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-family-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Andale Mono', monospace;

  /* Font Sizes */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 1.875rem;   /* 30px */
  --text-4xl: 2.25rem;    /* 36px */
  --text-5xl: 3rem;       /* 48px */
  --text-6xl: 3.75rem;    /* 60px */

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Line Heights */
  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;

  /* ============================================
     SPACING
     Based on 4px unit (0.25rem)
     ============================================ */

  --space-0: 0;
  --space-px: 1px;
  --space-0-5: 0.125rem;  /* 2px */
  --space-1: 0.25rem;     /* 4px */
  --space-1-5: 0.375rem;  /* 6px */
  --space-2: 0.5rem;      /* 8px */
  --space-2-5: 0.625rem;  /* 10px */
  --space-3: 0.75rem;     /* 12px */
  --space-3-5: 0.875rem;  /* 14px */
  --space-4: 1rem;        /* 16px */
  --space-5: 1.25rem;     /* 20px */
  --space-6: 1.5rem;      /* 24px */
  --space-7: 1.75rem;     /* 28px */
  --space-8: 2rem;        /* 32px */
  --space-9: 2.25rem;     /* 36px */
  --space-10: 2.5rem;     /* 40px */
  --space-11: 2.75rem;    /* 44px */
  --space-12: 3rem;       /* 48px */
  --space-14: 3.5rem;     /* 56px */
  --space-16: 4rem;       /* 64px */
  --space-20: 5rem;       /* 80px */
  --space-24: 6rem;       /* 96px */
  --space-28: 7rem;       /* 112px */
  --space-32: 8rem;       /* 128px */

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

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

  /* Layout Dimensions */
  --header-height: 72px;
  --header-height-tablet: 68px;
  --header-height-mobile: 64px;
  --header-height-xs: 60px;
  --sidebar-width: 280px;
  --sidebar-width-collapsed: 64px;

  /* Z-Index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  --z-toast: 1080;

  /* ============================================
     BORDERS
     ============================================ */

  /* Border Radius */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-default: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Border Widths */
  --border-0: 0;
  --border-1: 1px;
  --border-2: 2px;
  --border-4: 4px;
  --border-8: 8px;

  /* ============================================
     SHADOWS
     ============================================ */

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.25);
  --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-none: none;

  /* Focus Shadow */
  --shadow-focus: 0 0 0 3px var(--color-focus-ring);
  --shadow-focus-error: 0 0 0 3px rgba(239, 68, 68, 0.5);

  /* ============================================
     MOTION & ANIMATION
     ============================================ */

  /* Durations */
  --duration-75: 75ms;
  --duration-100: 100ms;
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
  --duration-700: 700ms;
  --duration-1000: 1000ms;

  /* Easing Functions */
  --ease-linear: linear;
  --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-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Standard Transitions */
  --transition-none: none;
  --transition-all: all var(--duration-200) var(--ease-in-out);
  --transition-colors: color var(--duration-150) var(--ease-in-out),
                       background-color var(--duration-150) var(--ease-in-out),
                       border-color var(--duration-150) var(--ease-in-out);
  --transition-opacity: opacity var(--duration-200) var(--ease-in-out);
  --transition-shadow: box-shadow var(--duration-200) var(--ease-in-out);
  --transition-transform: transform var(--duration-200) var(--ease-in-out);

  /* ============================================
     COMPONENT TOKENS
     ============================================ */

  /* Buttons */
  --btn-height-sm: 32px;
  --btn-height-md: 40px;
  --btn-height-lg: 48px;
  --btn-height-xl: 56px;
  --btn-padding-x-sm: var(--space-3);
  --btn-padding-x-md: var(--space-4);
  --btn-padding-x-lg: var(--space-6);
  --btn-font-size-sm: var(--text-sm);
  --btn-font-size-md: var(--text-base);
  --btn-font-size-lg: var(--text-lg);

  /* Inputs */
  --input-height-sm: 36px;
  --input-height-md: 44px;
  --input-height-lg: 56px;
  --input-padding-x: var(--space-4);
  --input-border-radius: var(--radius-default);

  /* Cards */
  --card-padding: var(--space-6);
  --card-border-radius: var(--radius-lg);
  --card-shadow: var(--shadow-sm);
  --card-shadow-hover: var(--shadow-lg);

  /* Icons */
  --icon-xs: 12px;
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
  --icon-xl: 32px;
  --icon-2xl: 48px;

  /* ============================================
     BREAKPOINTS (for JS reference)
     ============================================ */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;

  /* ============================================
     RESPONSIVE SPACING
     ============================================ */
  --section-padding-y: var(--space-12);
  --card-padding-responsive: var(--space-4);
  --stack-gap: var(--space-4);

  /* ============================================
     FLUID TYPOGRAPHY
     ============================================ */
  --heading-1: clamp(2rem, 5vw + 1rem, 3.75rem);
  --heading-2: clamp(1.75rem, 3vw + 1rem, 3rem);
  --heading-3: clamp(1.5rem, 2vw + 0.75rem, 2.25rem);
  --heading-4: clamp(1.25rem, 1.5vw + 0.75rem, 1.5rem);
  --heading-5: clamp(1.125rem, 1vw + 0.75rem, 1.25rem);
  --heading-6: 1rem;
}

/* Responsive spacing adjustments */
@media (min-width: 768px) {
  :root {
    --section-padding-y: var(--space-16);
    --card-padding-responsive: var(--space-5);
    --stack-gap: var(--space-5);
  }
}

@media (min-width: 1024px) {
  :root {
    --section-padding-y: var(--space-20);
    --card-padding-responsive: var(--space-6);
    --stack-gap: var(--space-6);
  }
}

/* ============================================
   DARK MODE
   ============================================ */

/* System preference detection */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* Backgrounds */
    --color-bg-primary: var(--color-neutral-900);
    --color-bg-secondary: var(--color-neutral-800);
    --color-bg-tertiary: var(--color-neutral-700);
    --color-bg-elevated: var(--color-neutral-800);
    --color-bg-overlay: rgba(0, 0, 0, 0.7);

    /* Text */
    --color-text-primary: var(--color-neutral-50);
    --color-text-secondary: var(--color-neutral-300);
    --color-text-muted: var(--color-neutral-400);
    --color-text-inverted: var(--color-neutral-900);

    /* Borders */
    --color-border: var(--color-neutral-700);
    --color-border-light: var(--color-neutral-600);
    --color-border-focus: #34D399;

    /* Adjust primary for better visibility on dark */
    --color-primary-500: #34D399;
    --color-primary-600: #6EE7B7;

    /* Semantic Color Backgrounds (Dark Mode) */
    --color-success-bg: #14532D;
    --color-error-bg: #7F1D1D;
    --color-warning-bg: #78350F;
    --color-info-bg: #1E3A8A;

    /* Adjusted semantic colors for visibility */
    --color-success: #4ADE80;
    --color-error: #F87171;
    --color-warning: #FBBF24;
    --color-info: #60A5FA;

    /* Component Tokens (Dark Mode) */
    --color-card-bg: var(--color-neutral-800);
    --color-card-border: var(--color-neutral-700);
    --color-input-bg: var(--color-neutral-800);
    --color-input-border: var(--color-neutral-600);
    --color-input-placeholder: var(--color-neutral-500);
    --color-header-bg: var(--color-neutral-900);
    --color-footer-bg: #000000;
    --color-footer-text: var(--color-neutral-400);

    /* Shadows (darker) */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.15);
  }
}

/* Manual dark mode toggle */
[data-theme="dark"] {
  /* Backgrounds */
  --color-bg-primary: var(--color-neutral-900);
  --color-bg-secondary: var(--color-neutral-800);
  --color-bg-tertiary: var(--color-neutral-700);
  --color-bg-elevated: var(--color-neutral-800);
  --color-bg-overlay: rgba(0, 0, 0, 0.7);

  /* Text */
  --color-text-primary: var(--color-neutral-50);
  --color-text-secondary: var(--color-neutral-300);
  --color-text-muted: var(--color-neutral-400);
  --color-text-inverted: var(--color-neutral-900);

  /* Borders */
  --color-border: var(--color-neutral-700);
  --color-border-light: var(--color-neutral-600);
  --color-border-focus: #34D399;

  /* Primary colors */
  --color-primary-500: #34D399;
  --color-primary-600: #6EE7B7;

  /* Semantic Color Backgrounds */
  --color-success-bg: #14532D;
  --color-error-bg: #7F1D1D;
  --color-warning-bg: #78350F;
  --color-info-bg: #1E3A8A;

  /* Adjusted semantic colors */
  --color-success: #4ADE80;
  --color-error: #F87171;
  --color-warning: #FBBF24;
  --color-info: #60A5FA;

  /* Component Tokens */
  --color-card-bg: var(--color-neutral-800);
  --color-card-border: var(--color-neutral-700);
  --color-input-bg: var(--color-neutral-800);
  --color-input-border: var(--color-neutral-600);
  --color-input-placeholder: var(--color-neutral-500);
  --color-header-bg: var(--color-neutral-900);
  --color-footer-bg: #000000;
  --color-footer-text: var(--color-neutral-400);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* Tailwind-style dark mode class (used by Alpine.js) */
.dark,
html.dark {
  /* Backgrounds */
  --color-bg-primary: var(--color-neutral-900);
  --color-bg-secondary: var(--color-neutral-800);
  --color-bg-tertiary: var(--color-neutral-700);
  --color-bg-elevated: var(--color-neutral-800);
  --color-bg-overlay: rgba(0, 0, 0, 0.7);

  /* Text */
  --color-text-primary: var(--color-neutral-50);
  --color-text-secondary: var(--color-neutral-300);
  --color-text-muted: var(--color-neutral-400);
  --color-text-inverted: var(--color-neutral-900);

  /* Borders */
  --color-border: var(--color-neutral-700);
  --color-border-light: var(--color-neutral-600);
  --color-border-focus: #34D399;

  /* Primary colors */
  --color-primary-500: #34D399;
  --color-primary-600: #6EE7B7;

  /* Semantic Color Backgrounds */
  --color-success-bg: #14532D;
  --color-error-bg: #7F1D1D;
  --color-warning-bg: #78350F;
  --color-info-bg: #1E3A8A;

  /* Adjusted semantic colors */
  --color-success: #4ADE80;
  --color-error: #F87171;
  --color-warning: #FBBF24;
  --color-info: #60A5FA;

  /* Component Tokens */
  --color-card-bg: var(--color-neutral-800);
  --color-card-border: var(--color-neutral-700);
  --color-input-bg: var(--color-neutral-800);
  --color-input-border: var(--color-neutral-600);
  --color-input-placeholder: var(--color-neutral-500);
  --color-header-bg: var(--color-neutral-900);
  --color-footer-bg: #000000;
  --color-footer-text: var(--color-neutral-400);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3), 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* Theme transition class - apply to enable smooth transitions */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition: var(--theme-transition) !important;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Reduced motion preference */
@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;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-border: var(--color-neutral-400);
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }
}

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

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

/* Focus visible */
.focus-visible:focus-visible,
:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 2px;
}

/* Remove focus outline when not using keyboard */
:focus:not(:focus-visible) {
  outline: none;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary-500);
  color: var(--color-white);
  padding: var(--space-2) var(--space-4);
  z-index: var(--z-toast);
  transition: top var(--duration-200) var(--ease-out);
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   KEYFRAME ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

/* Animation utility classes */
.animate-fade-in { animation: fadeIn var(--duration-300) var(--ease-out); }
.animate-slide-up { animation: slideUp var(--duration-300) var(--ease-out); }
.animate-scale-in { animation: scaleIn var(--duration-200) var(--ease-out); }
.animate-pulse { animation: pulse 2s var(--ease-in-out) infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-bounce { animation: bounce 1s infinite; }
