/*
 * Foundation: Design Tokens
 *
 * CSS Custom Properties - Design System
 * 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 - Light Mode */
  --lch-bg: 97% 0 0;
  /* Light background — white smoke neutral */
  --lch-accent-bg: 89% 0.010 165;
  /* Slightly darker accent background with green tint */
  --lch-text: 25% 0.01 155;
  /* Dark text with subtle green */
  --lch-text-light: 45% 0.01 155;
  /* Medium text with subtle green - WCAG AA compliant */
  --lch-text-lighter: 58% 0.008 155;
  /* Lighter text for secondary content */
  --lch-border: 80% 0.012 155;
  /* Light border with green tint */
  --lch-accent: 63% 0.08 153;
  /* Saturated green accent - dark enough for light backgrounds */
  --lch-valid: 42% 0.21 153;
  /* Valid green - WCAG compliant */
  --lch-invalid: 52% 0.18 29;
  /* Invalid red - visible on light backgrounds */
  --lch-required: 48% 0.15 68;
  /* Required orange - clear on light backgrounds */
  --lch-excellent: 55% 0.18 290;
  /* Excellent purple - readable contrast */

  /* 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.15s 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);
  --ease-out-expo:   cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out-quart:  cubic-bezier(0.25, 1, 0.5, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
  /* Panel/modal duration */
  --duration-panel: 0.3s;

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

  /* Shadows and Effects using OKLCH */
  --shadow-md:
    0 2px 8px oklch(0% 0 0 / 0.06),
    0 6px 20px oklch(0% 0 0 / 0.10);
  --shadow-lg:
    0 4px 12px oklch(0% 0 0 / 0.08),
    0 12px 32px oklch(0% 0 0 / 0.12);
  --shadow-xl:
    0 8px 20px oklch(0% 0 0 / 0.10),
    0 20px 48px oklch(0% 0 0 / 0.16);
  --shadow-mint: 0 4px 16px oklch(63% 0.08 153 / 0.40);

  /* Border Radius Scale */
  --radius-sm: 0.625rem;
  --radius-md: 1rem;
  --radius-lg: 1.375rem;
  --radius-xl: 1.75rem;
  --radius-2xl: 2.5rem;
  --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 */
  --sidebar-width: 16rem;
  /* 256px - desktop sidebar width */
  --topbar-height: 3.5rem;
  /* 56px - desktop topbar height */

  /* Typography aliases for compatibility */
  --text-md: var(--text-base);
  /* Alias: same as --text-base (1.125rem) */
  --font-sm: var(--text-sm);
  /* Alias: 0.875rem */
  --font-md: var(--text-base);
  /* Alias: 1.125rem */
  --font-lg: var(--text-lg);
  /* Alias: 1.25rem */

  /* Background aliases */
  --bg-elevated: var(--accent-bg);
  /* Elevated surface background */
  --card-bg: var(--accent-bg);
  /* Card background */
  --card-hover: color-mix(in oklch, var(--accent) 8%, var(--accent-bg));
  /* Card hover state */
  --card-bg-pure: oklch(100% 0 0);
  /* Pure white card background */
}


/*
 * 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: 40% 0.280 155;
    --lch-valid: 38% 0.279 153;
    --lch-invalid: 55% 0.240 29;

    /* Stronger borders using original hue */
    --lch-border: 75% 0.020 155;
  }
}

/*
 * Dark Mode Support
 * Sage dark theme — same green hue family as light mode, dark base
 */
@media (prefers-color-scheme: dark) {
  :root {
    --lch-bg: 16% 0.012 153;
    /* Deep dark sage background */
    --lch-accent-bg: 22% 0.012 153;
    /* Elevated dark surface */
    --lch-text: 92% 0.005 165;
    /* Warm near-white text */
    --lch-text-light: 72% 0.008 165;
    /* Medium light text */
    --lch-text-lighter: 58% 0.008 165;
    /* Secondary text */
    --lch-border: 35% 0.012 153;
    /* Dark border with sage undertone */
    --lch-accent: 70% 0.08 153;
    /* Sage lifted slightly for dark bg contrast */
    --lch-valid: 70% 0.12 153;
    /* Valid green */
    --lch-invalid: 60% 0.15 29;
    /* Invalid red */
    --lch-required: 68% 0.12 68;
    /* Required orange */
    --lch-excellent: 72% 0.14 290;
    /* Excellent purple */

    /* Card background — elevated dark surface instead of pure white */
    --card-bg-pure: oklch(22% 0.012 153);
  }
}
