/*
 * Foundation: Design Tokens
 *
 * Campfire Design System - CSS Custom Properties
 * Character-based responsive design: 40-75 characters per line optimal reading
 *
 * Rails Convention: Foundation files define the core design system tokens
 * that are used across all components and domains.
 */

:root {
  /* OKLCH Color System - Base LCH Values - Dark Forest Theme */
  --lch-bg: 18% 0.015 155;
  /* Dark background with green tint */
  --lch-accent-bg: 21% 0.015 155;
  /* Accent background with green tint */
  --lch-text: 89% 0.002 160;
  /* Light text with subtle green */
  --lch-text-light: 65% 0.005 160;
  /* Medium text with subtle green - increased for WCAG AA compliance */
  --lch-text-lighter: 72% 0.008 160;
  /* Lighter text with subtle green - increased for better contrast */
  --lch-border: 30% 0.015 155;
  /* Border with green tint */
  --lch-accent: 85% 0.20 155;
  /* Bright neon green accent */
  --lch-valid: 85% 0.21 153;
  /* Valid green */
  --lch-invalid: 38% 0.15 29;
  /* Invalid red */
  --lch-required: 62% 0.13 68;
  /* Required orange */
  --lch-excellent: 70% 0.18 290;
  /* Excellent purple */

  /* Semantic Color Abstractions */
  --color-bg: oklch(var(--lch-bg));
  --color-accent-bg: oklch(var(--lch-accent-bg));
  --color-text: oklch(var(--lch-text));
  --color-text-light: oklch(var(--lch-text-light));
  --color-text-lighter: oklch(var(--lch-text-lighter));
  --color-border: oklch(var(--lch-border));
  --color-accent: oklch(var(--lch-accent));
  --color-valid: oklch(var(--lch-valid));
  --color-invalid: oklch(var(--lch-invalid));
  --color-required: oklch(var(--lch-required));
  --color-excellent: oklch(var(--lch-excellent));

  /* Legacy RGB values for compatibility */
  --bg: var(--color-bg);
  --accent-bg: var(--color-accent-bg);
  --text: var(--color-text);
  --text-light: var(--color-text-light);
  --text-lighter: var(--color-text-lighter);
  --border: var(--color-border);
  --accent: var(--color-accent);
  --valid: var(--color-valid);
  --invalid: var(--color-invalid);
  --required: var(--color-required);
  --excellent: var(--color-excellent);

  /* Modal-specific colors using OKLCH */
  --modal-backdrop: oklch(var(--lch-bg) / 0.85);
  --modal-backdrop-opaque: oklch(var(--lch-bg) / 0.92);
  /* Higher opacity for Safari without blur */
  --modal-surface: var(--color-accent-bg);
  --modal-border: var(--color-border);

  /* Spacing Scale - Based on content hierarchy, not device sizes */
  --space-xs: 0.25rem;
  /* 4px - extra small gaps */
  --space-sm: 0.5rem;
  /* 8px - small gaps */
  --space-md: 1rem;
  /* 16px - base spacing */
  --space-lg: 1.5rem;
  /* 24px - section spacing */
  --space-xl: 2rem;
  /* 32px - large sections */
  --space-2xl: 3rem;
  /* 48px - major sections */

  /* Icon Size Scale */
  --icon-xs: 16px;
  /* Extra small icons */
  --icon-sm: 20px;
  /* Small icons */
  --icon-md: 24px;
  /* Medium icons (default) */
  --icon-lg: 32px;
  /* Large icons */
  --icon-2xl: 64px;
  /* 2X large icons */

  /* Fixed Typography - Consistent across all screen sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.125rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2rem;
  --text-4xl: 2.25rem;

  /* Transitions and Animations */
  /* Fast feedback - hover backgrounds, text colors, small UI changes */
  --transition-fast: 0.15s ease;
  /* Standard interactions - buttons, cards, photos, most UI elements */
  --transition-standard: 0.2s ease;
  /* Smooth transforms - complex state changes, panel slides */
  --transition-smooth: 0.25s ease;
  /* Legacy alias for compatibility */
  --transition-base: var(--transition-standard);
  /* Button easing - optimized for perceived responsiveness */
  --transition-button: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  /* Active state - instant feedback on press */
  --transition-active: 0.05s ease;
  /* iOS-inspired spring easing - feels native on mobile */
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  /* Panel/modal duration */
  --duration-panel: 0.25s;

  /* Scale Transforms */
  /* Zoom amount for panel/modal effects and page transitions (3% zoom) */
  --scale-zoom: 0.97;

  /* Shadows and Effects using OKLCH */
  --shadow-md: 0 4px 20px oklch(0% 0 0 / 0.2);
  --shadow-lg: 0 8px 25px oklch(0% 0 0 / 0.3);
  --shadow-xl: 0 12px 30px oklch(0% 0 0 / 0.4);

  /* Border Radius Scale */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-2xl: 2rem;
  --radius-full: 9999px;

  /* Component Sizes */
  --nav-height-mobile: 3.5rem;
  /* 52px - nav height */
  --touch-target-min: 2.75rem;
  /* 44px - minimum touch target */
  --touch-target-recommended: 3rem;
  /* 48px - recommended touch target */
}


/*
 * High Contrast Mode Support
 * Enhance contrast when users prefer high contrast
 */
@media (prefers-contrast: high) {
  :root {
    /* Increase chroma for higher contrast using original hues */
    --lch-accent: 75% 0.280 153.5;
    --lch-valid: 74% 0.279 153.31;
    --lch-invalid: 40% 0.240 29.23;

    /* Stronger borders using original hue */
    --lch-border: 30% 0.020 145.44;
  }
}

/*
 * Theme System
 * Theme variants using data-theme attribute on html element
 */

/* Dark Mode - Pitch black with green accents */
html[data-theme="dark"] {
  --lch-bg: 0% 0 0;
  --lch-accent-bg: 15% 0 0;
  --lch-text: 92% 0 0;
  --lch-text-light: 65% 0 0;
  --lch-text-lighter: 75% 0 0;
  --lch-border: 25% 0 0;
  --lch-accent: 85% 0.20 155;
  --lch-valid: 85% 0.21 153;
  --lch-invalid: 45% 0.15 29;
  --lch-required: 65% 0.13 68;
  --lch-excellent: 75% 0.20 290;
}

/* Dusk Theme - Warm oranges and purples */
html[data-theme="dusk"] {
  --lch-bg: 20% 0.025 300;
  --lch-accent-bg: 25% 0.03 300;
  --lch-text: 88% 0.02 60;
  --lch-text-light: 58% 0.015 60;
  --lch-text-lighter: 68% 0.018 60;
  --lch-border: 32% 0.025 300;
  --lch-accent: 75% 0.18 50;
  --lch-valid: 75% 0.15 130;
  --lch-invalid: 45% 0.15 25;
  --lch-required: 68% 0.15 60;
  --lch-excellent: 80% 0.20 290;
}

/* Ocean Theme - Cool blues */
html[data-theme="ocean"] {
  --lch-bg: 18% 0.02 240;
  --lch-accent-bg: 22% 0.025 240;
  --lch-text: 90% 0.01 200;
  --lch-text-light: 60% 0.015 200;
  --lch-text-lighter: 70% 0.02 200;
  --lch-border: 30% 0.03 240;
  --lch-accent: 75% 0.15 220;
  --lch-valid: 75% 0.15 160;
  --lch-invalid: 45% 0.12 20;
  --lch-required: 65% 0.12 50;
  --lch-excellent: 80% 0.20 270;
}

/* Update computed color values for all themes */
html[data-theme] {
  --color-bg: oklch(var(--lch-bg));
  --color-accent-bg: oklch(var(--lch-accent-bg));
  --color-text: oklch(var(--lch-text));
  --color-text-light: oklch(var(--lch-text-light));
  --color-text-lighter: oklch(var(--lch-text-lighter));
  --color-border: oklch(var(--lch-border));
  --color-accent: oklch(var(--lch-accent));
  --color-valid: oklch(var(--lch-valid));
  --color-invalid: oklch(var(--lch-invalid));
  --color-required: oklch(var(--lch-required));
  --color-excellent: oklch(var(--lch-excellent));
}
