/*
 * FoundContext v4 CSS Variables
 * Design tokens matching card-deck-v3 established visual language
 */

/* Import FoundContext fonts - matching card-deck-v3 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700&display=swap');

:root {
  /* FoundContext Design System - Theater Burgundy Primary */
  --theater-burgundy: #8B1538;
  --theater-burgundy-light: #A91B47;
  --theater-burgundy-dark: #6B0F2B;
  
  --primary-color: var(--theater-burgundy);
  --primary-color-dark: var(--theater-burgundy-dark);
  --primary-color-light: var(--theater-burgundy-light);
  --primary-color-alpha: rgba(139, 21, 56, 0.1);
  
  --secondary-color: var(--theater-burgundy-light);
  --accent-color: var(--theater-burgundy);
  --accent-background: rgba(139, 21, 56, 0.1);
  
  /* FoundContext Neutral Colors - matching card-deck-v3 */
  --neutral-50: #FAFAFA;
  --neutral-100: #F4F4F5;
  --neutral-200: #E4E4E7;
  --neutral-300: #D4D4D8;
  --neutral-400: #A1A1AA;
  --neutral-500: #71717A;
  --neutral-600: #52525B;
  --neutral-700: #3F3F46;
  --neutral-800: #27272A;
  --neutral-900: #18181B;
  
  /* Text Colors - FoundContext System */
  --text-color: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-muted: var(--neutral-500);
  --text-inverse: #ffffff;
  
  /* Background Colors - FoundContext System */
  --background-color: #ffffff;
  --background-secondary: var(--neutral-50);
  --background-tertiary: var(--neutral-100);
  --background-overlay: rgba(255, 255, 255, 0.95);
  
  /* Surface Colors - FoundContext System */
  --surface-color: #ffffff;
  --surface-secondary: var(--neutral-50);
  --surface-elevated: #ffffff;
  
  /* Border Colors - FoundContext System */
  --border-color: var(--neutral-200);
  --border-secondary: var(--neutral-300);
  --border-accent: var(--theater-burgundy);
  
  /* Card Specific - Playing Card System */
  --card-background: var(--surface-color);
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --card-shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.2);
  --card-border-radius: 16px; /* card-deck-v3 standard */
  --card-border-radius-lg: 20px; /* reference cards */
  
  /* FoundContext Typography System */
  --font-family-body: 'Inter', system-ui, sans-serif;
  --font-family-display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --font-family-base: var(--font-family-body);
  --font-family-mono: 'Fira Code', Consolas, Monaco, 'Courier New', monospace;
  
  /* Font Sizes - Mobile First */
  --font-size-xs: 0.75rem;   /* 12px */
  --font-size-sm: 0.875rem;  /* 14px */
  --font-size-base: 1rem;    /* 16px */
  --font-size-lg: 1.125rem;  /* 18px */
  --font-size-xl: 1.25rem;   /* 20px */
  --font-size-2xl: 1.5rem;   /* 24px */
  --font-size-3xl: 1.875rem; /* 30px */
  --font-size-4xl: 2.25rem;  /* 36px */
  --font-size-5xl: 3rem;     /* 48px */
  
  /* Font Weights */
  --font-weight-light: 300;
  --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;
  
  /* Spacing Scale - Mobile First */
  --space-xs: 0.25rem;   /* 4px */
  --space-sm: 0.5rem;    /* 8px */
  --space-md: 1rem;      /* 16px */
  --space-lg: 1.5rem;    /* 24px */
  --space-xl: 2rem;      /* 32px */
  --space-2xl: 3rem;     /* 48px */
  --space-3xl: 4rem;     /* 64px */
  
  /* Layout Dimensions */
  --max-width-container: 1200px;
  --max-width-content: 800px;
  --max-width-card: 400px;
  
  /* Header and Navigation */
  --header-height: 60px;
  --nav-drawer-width: 280px;
  
  /* Playing Card Dimensions - Proper dvh calculation now that height auto override is fixed */
  --card-aspect-ratio: 0.714; /* 2.5:3.5 ratio (playing card) */
  --card-width-mobile: min(90vw, 400px);
  --card-max-width: 400px;
  /* Desktop: Using DVH with VH fallback for older browsers */
  --card-height-mobile: calc(100vh - 72px - 40px - 20px);
  --card-height-mobile: calc(100dvh - 72px - 40px - 20px);
  
  /* Show selection cards */
  --show-card-width: min(85vw, 320px);
  --show-card-aspect: 5 / 7; /* poster aspect ratio */
  
  /* Reference card viewport optimization */
  --available-height: calc(100vh - 60px - 80px - 40px);
  --available-width: calc(100vw - 40px);
  --height-constrained-width: calc(var(--available-height) * var(--card-aspect-ratio));
  --width-constrained-height: calc(var(--available-width) / var(--card-aspect-ratio));
  --reference-card-width: min(var(--available-width), var(--height-constrained-width));
  --reference-card-height: min(var(--available-height), var(--width-constrained-height));
  
  /* Animation Properties - Sacred card-deck-v3 System */
  --animation-duration-fast: 0.15s;
  --animation-duration-normal: 0.25s; /* card-deck-v3 standard for 0.5s total */
  --animation-duration-slow: 0.4s;
  --animation-easing: cubic-bezier(0.25, 0.46, 0.45, 0.94); /* card-deck-v3 standard */
  --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Shadow Levels */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  
  /* Border Radius Scale */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  
  /* Touch Targets - iOS/Android Guidelines */
  --touch-target-min: 44px;
  --button-height: 48px;
  --input-height: 48px;
  
  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal: 1040;
  --z-popover: 1050;
  --z-tooltip: 1060;
  
  /* Breakpoints (for use in JS) */
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  
  /* Performance Budget */
  --max-animation-duration: 0.5s; /* Strategic requirement */
  
  /* Tag System Colors - Search Integration v4 */
  --tag-background: var(--background-secondary);
  --tag-background-active: var(--primary-color);
  --tag-background-hover: var(--primary-color-alpha);
  --tag-text: var(--text-color);
  --tag-text-active: var(--text-inverse);
  --tag-border: var(--border-color);
  --tag-border-active: var(--primary-color);

  /* Tag Layout - Search Integration v4 */
  --tag-padding: var(--space-xs) var(--space-md);
  --tag-border-radius: var(--radius-full);
  --tag-font-size: var(--font-size-sm);
  --tag-line-height: var(--line-height-tight);
  --tag-gap: var(--space-xs);

  /* Tag Categories - Cultural Reference Types */
  --tag-era-color: #2563eb;
  --tag-person-color: #dc2626;
  --tag-event-color: #059669;
  --tag-media-color: #7c2d12;
  --tag-politics-color: #4338ca;
  --tag-culture-color: #be185d;
  --tag-other-color: var(--neutral-500);

  /* Search Interface - Tag Integration */
  --search-autocomplete-max-height: 300px;
  --search-filter-width: 280px;
  --search-suggestions-z: var(--z-dropdown);
  
  /* Mobile Landscape Optimizations */
  --card-width-mobile-landscape: min(95vw, 820px);
  --card-height-mobile-landscape: calc(100vh - 48px - 20px);
  --landscape-meta-column-width: 220px;
  --landscape-content-column-flex: 1;
  --header-height-landscape: 48px;
  --landscape-padding: var(--space-xs);
  --landscape-scrollbar-width: 6px;

  /* Admin page compatibility aliases */
  --color-primary: var(--primary-color);
  --color-text: var(--text-color);
  --color-text-secondary: var(--text-secondary);
  --color-background: var(--background-color);
  --color-card-bg: var(--card-background);
  --color-border: var(--border-color);
}

/* Dark Theme Variables */
[data-theme="dark"],
.theme-dark {
  --text-color: #f7fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #a0aec0;
  --text-inverse: #1a202c;
  
  --background-color: #1a202c;
  --background-secondary: #2d3748;
  --background-tertiary: #4a5568;
  --background-overlay: rgba(26, 32, 44, 0.95);
  
  --surface-color: #2d3748;
  --surface-secondary: #4a5568;
  --surface-elevated: #374151;
  
  --border-color: #4a5568;
  --border-secondary: #2d3748;
  
  --card-background: var(--surface-color);
  --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  --card-shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.4);
  
  --primary-color-alpha: rgba(99, 179, 237, 0.2);
}

/* High Contrast Theme */
.theme-high-contrast {
  --primary-color: #0066cc;
  --text-color: #000000;
  --background-color: #ffffff;
  --border-color: #333333;
  
  --card-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  --focus-ring: 3px solid #ff6600;
}

/* Responsive Typography Scale */
@media (min-width: 640px) {
  :root {
    --font-size-xs: 0.875rem;  /* 14px */
    --font-size-sm: 1rem;      /* 16px */
    --font-size-base: 1.125rem; /* 18px */
    --font-size-lg: 1.25rem;   /* 20px */
    --font-size-xl: 1.5rem;    /* 24px */
    --font-size-2xl: 1.875rem; /* 30px */
    --font-size-3xl: 2.25rem;  /* 36px */
    --font-size-4xl: 3rem;     /* 48px */
    --font-size-5xl: 4rem;     /* 64px */
  }
}

/* Responsive Design - Proper dvh calculation: 100dvh - header - footer - margins */
@media (max-width: 768px) {
  :root {
    /* Tablet: Using DVH with VH fallback for older browsers */
    --card-height-mobile: calc(100vh - 64px - 36px - 16px);
    --card-height-mobile: calc(100dvh - 64px - 36px - 16px);
  }
}

@media (max-width: 480px) {
  :root {
    /* Mobile: Using DVH with VH fallback for older browsers - increased card size by 4px */
    --card-height-mobile: calc(100vh - 64px - 48px);
    --card-height-mobile: calc(100dvh - 64px - 48px);
  }
}

/* Reduced Motion Variables */
@media (prefers-reduced-motion: reduce) {
  :root {
    --animation-duration-fast: 0.01ms;
    --animation-duration-normal: 0.01ms;
    --animation-duration-slow: 0.01ms;
    --max-animation-duration: 0.01ms;
  }
}