/* Design Tokens - CSS Custom Properties
 * Purpose: Centralized design system for responsive UI
 * Usage: var(--spacing-sm), var(--color-primary), var(--breakpoint-tablet)
 */

:root {
    /* === Spacing System === */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;

    /* === Typography === */
    /* Base font sizes - mobile-first */
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px; /* Minimum for iOS to prevent zoom on input focus */
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 30px;
    --font-size-4xl: 36px;

    /* Font weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Line heights */
    --line-height-tight: 1.25;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.75;

    /* === Accessibility === */
    /* Touch targets - WCAG 2.1 AA requirement */
    --touch-target-min: 44px; /* Minimum tap target size */
    --touch-target-spacing: 8px; /* Spacing between touch targets */

    /* Focus indicators */
    --focus-outline-width: 2px;
    --focus-outline-offset: 2px;
    --focus-outline-color: #0066cc;

    /* Text contrast ratios (WCAG 2.1 AA) */
    --text-contrast-normal: 4.5; /* Normal text: 4.5:1 */
    --text-contrast-large: 3; /* Large text (18px+ or 14px+ bold): 3:1 */

    /* === Responsive Breakpoints === */
    /* Mobile-first approach: base styles for mobile, enhance for larger screens */
    --breakpoint-mobile-min: 320px;
    --breakpoint-mobile-max: 767px;
    --breakpoint-tablet-min: 768px;
    --breakpoint-tablet-max: 1279px;
    --breakpoint-desktop-min: 1280px;
    --breakpoint-desktop-max: 2560px;

    /* === Layout === */
    --max-content-width: 1400px; /* Maximum content width for desktop centering */
    --container-padding-mobile: var(--spacing-sm);
    --container-padding-tablet: var(--spacing-md);
    --container-padding-desktop: var(--spacing-lg);

    /* Grid system */
    --grid-columns-mobile: 1;
    --grid-columns-tablet: 2;
    --grid-columns-desktop: 4;
    --grid-gap-mobile: var(--spacing-sm);
    --grid-gap-tablet: var(--spacing-md);
    --grid-gap-desktop: var(--spacing-lg);

    /* === Colors === */
    /* Primary brand colors */
    --color-primary: #0066cc;
    --color-primary-hover: #0052a3;
    --color-primary-active: #003d7a;

    /* Neutral colors */
    --color-text-primary: #1a1a1a;
    --color-text-secondary: #4a4a4a;
    --color-text-tertiary: #757575;
    --color-background: #ffffff;
    --color-background-secondary: #f5f5f5;
    --color-border: #e0e0e0;

    /* Semantic colors */
    --color-success: #28a745;
    --color-error: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;

    /* === Shadows === */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* === Transitions === */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 300ms ease-in-out;
    --transition-slow: 500ms ease-in-out;

    /* === Z-index Scale === */
    --z-index-dropdown: 1000;
    --z-index-sticky: 1020;
    --z-index-fixed: 1030;
    --z-index-modal-backdrop: 1040;
    --z-index-modal: 1050;
    --z-index-popover: 1060;
    --z-index-tooltip: 1070;
}

/* === Dark Mode Support === */
/* Respects user's color scheme preference (WCAG 2.1 - FR-009) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-text-primary: #f5f5f5;
        --color-text-secondary: #d0d0d0;
        --color-text-tertiary: #a0a0a0;
        --color-background: #1a1a1a;
        --color-background-secondary: #2a2a2a;
        --color-border: #404040;
        --color-primary: #3399ff;
        --color-primary-hover: #5cadff;
        --color-primary-active: #1f85e6;
    }
}

/* === High Contrast Mode === */
/* Enhanced contrast for users with low vision (WCAG 2.1 - FR-009) */
@media (prefers-contrast: high) {
    :root {
        --color-text-primary: #000000;
        --color-background: #ffffff;
        --color-border: #000000;
        --focus-outline-width: 3px;
        --focus-outline-color: #000000;
    }
}

/* === Reduced Motion === */
/* Disable animations for users with motion sensitivity (WCAG 2.1 - FR-009) */
@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
        --transition-normal: 0ms;
        --transition-slow: 0ms;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
