/*
 * Accessibility Enhancements for WCAG AA Compliance
 * Covers color contrast, motion preferences, and mobile accessibility
 */

/* ========================================
   Color Contrast Enhancements (WCAG AA)
   ========================================*/

/* Enhanced contrast for subtle text */
.text-gray-500 {
  --tw-text-opacity: 1;
  color: rgb(107 114 128 / var(--tw-text-opacity));
}

.dark .text-gray-500 {
  color: rgb(156 163 175 / var(--tw-text-opacity));
}

.text-gray-600 {
  --tw-text-opacity: 1;
  color: rgb(75 85 99 / var(--tw-text-opacity));
}

.dark .text-gray-600 {
  color: rgb(209 213 219 / var(--tw-text-opacity));
}

/* Enhanced link contrast */
.text-blue-600 {
  --tw-text-opacity: 1;
  color: rgb(37 99 235 / var(--tw-text-opacity)); /* Darker for better contrast */
}

.dark .text-blue-600 {
  color: rgb(96 165 250 / var(--tw-text-opacity)); /* Lighter for dark mode */
}

.text-blue-400 {
  --tw-text-opacity: 1;
  color: rgb(96 165 250 / var(--tw-text-opacity));
}

/* Focus states with enhanced contrast */
.focus-visible\:outline-blue-500:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

/* Button contrast improvements */
.marketing-cta-primary {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: 2px solid transparent;
  transition: all 0.2s ease-in-out;
}

.marketing-cta-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.3);
}

.marketing-cta-primary:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.marketing-cta-secondary {
  background: white;
  color: #1f2937;
  border: 2px solid #d1d5db;
  transition: all 0.2s ease-in-out;
}

.dark .marketing-cta-secondary {
  background: #1f2937;
  color: #f9fafb;
  border-color: #4b5563;
}

.marketing-cta-secondary:hover {
  border-color: #9ca3af;
  background: #f9fafb;
  transform: translateY(-1px);
}

.dark .marketing-cta-secondary:hover {
  border-color: #6b7280;
  background: #374151;
}

/* Enhanced interactive states */
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

.dark button:focus-visible,
.dark a:focus-visible,
.dark input:focus-visible,
.dark textarea:focus-visible,
.dark select:focus-visible {
  outline-color: #93c5fd;
}

/* ========================================
   Motion and Animation Preferences
   ========================================*/

/* Enhanced prefers-reduced-motion support */
@media (prefers-reduced-motion: reduce) {
  /* Disable all animations and transitions */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  /* Specific animation disabling */
  .animate-bounce,
  .animate-spin,
  .animate-ping,
  .animate-pulse {
    animation: none !important;
  }
  
  /* Video autoplay prevention */
  video[autoplay] {
    animation: none !important;
  }
  
  /* Transform resets */
  .hover\:scale-105:hover,
  .hover\:scale-110:hover,
  .group:hover .group-hover\:scale-105,
  .group:hover .group-hover\:scale-110 {
    transform: none !important;
  }
  
  /* Parallax and complex transforms */
  .transform,
  .translate-x-full,
  .translate-y-full,
  .-translate-x-full,
  .-translate-y-full {
    transform: none !important;
  }
}

/* Default motion preferences */
@media (prefers-reduced-motion: no-preference) {
  /* Smooth scrolling for better UX */
  html {
    scroll-behavior: smooth;
  }
  
  /* Enhanced hover effects */
  .marketing-cta-primary,
  .marketing-cta-secondary {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Smooth video controls */
  video {
    transition: opacity 0.3s ease-in-out;
  }
}

/* ========================================
   Mobile Accessibility and Transforms
   ========================================*/

/* Mobile-first approach for transforms */
@media (max-width: 768px) {
  /* Avoid complex transforms on mobile */
  .lg\:hover\:scale-105:hover,
  .md\:hover\:scale-105:hover {
    transform: none;
  }
  
  /* Simplified parallax on mobile */
  .parallax-element {
    transform: none !important;
  }
  
  /* Touch-friendly sizing */
  button,
  .btn,
  a[role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Enhanced touch targets */
  .touch-target {
    padding: 12px;
    margin: 4px;
  }
  
  /* Avoid heavy transforms that impact performance */
  .complex-transform {
    transform: none;
  }
  
  /* Mobile video considerations */
  video {
    max-width: 100%;
    height: auto;
  }
}

/* Large screen enhancements */
@media (min-width: 1024px) {
  /* Safe transforms for desktop */
  .desktop-hover-transform:hover {
    transform: translateY(-2px);
    transition: transform 0.2s ease-out;
  }
}

/* ========================================
   High Contrast Mode Support
   ========================================*/

@media (prefers-contrast: high) {
  /* Enhanced borders and outlines */
  .card,
  .border {
    border-width: 2px;
    border-color: currentColor;
  }
  
  /* Remove subtle shadows in high contrast */
  .shadow,
  .shadow-sm,
  .shadow-md,
  .shadow-lg {
    box-shadow: none;
    border: 2px solid currentColor;
  }
  
  /* Enhanced button contrast */
  .marketing-cta-primary {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
  }
  
  .marketing-cta-secondary {
    background: transparent;
    color: currentColor;
    border: 2px solid currentColor;
  }
}

/* ========================================
   Focus Management and Keyboard Navigation
   ========================================*/

/* Enhanced focus indicators */
.focus-ring {
  transition: box-shadow 0.15s ease-in-out;
}

.focus-ring:focus-visible {
  outline: none;
  box-shadow: 
    0 0 0 3px #3b82f6,
    0 0 0 6px rgba(59, 130, 246, 0.3);
}

/* Skip links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px;
  text-decoration: none;
  z-index: 1000;
  border-radius: 4px;
}

.skip-link:focus {
  top: 6px;
}

/* Keyboard navigation improvements */
.keyboard-navigation {
  outline-style: solid;
  outline-width: 2px;
  outline-offset: 2px;
}

/* ========================================
   Video Accessibility Enhancements
   ========================================*/

/* Video player controls */
.video-controls {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px;
  border-radius: 6px;
}

.video-controls button {
  background: transparent;
  border: 2px solid white;
  color: white;
  padding: 8px 12px;
  margin: 0 4px;
  border-radius: 4px;
  cursor: pointer;
}

.video-controls button:hover {
  background: white;
  color: black;
}

.video-controls button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* Caption styling */
::cue {
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 1rem;
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ========================================
   Responsive Text and Readability
   ========================================*/

/* Enhanced line height for readability */
.marketing-hero-title {
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.marketing-hero-subtitle {
  line-height: 1.6;
}

/* Text scaling for accessibility */
@media (min-width: 1024px) {
  .marketing-hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
  }
  
  .marketing-hero-subtitle {
    font-size: clamp(1.125rem, 2vw, 1.5rem);
  }
}

/* ========================================
   Print Styles
   ========================================*/

@media print {
  /* Remove animations and videos for print */
  video,
  .animate-bounce,
  .animate-spin {
    display: none !important;
  }
  
  /* Ensure good contrast for print */
  .text-gray-500,
  .text-gray-600 {
    color: #000 !important;
  }
  
  /* Print-friendly links */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* ========================================
   Layout Stability and CLS Prevention
   ========================================*/

/* Prevent content injection above existing content */
.prevent-layout-shift {
  contain: layout style;
}

/* Reserve space for dynamic content */
.content-placeholder {
  min-height: var(--expected-height, 2rem);
  transition: min-height 0.3s ease-out;
}

/* Prevent images from causing layout shifts */
img, video {
  max-width: 100%;
  height: auto;
}

/* Ensure videos maintain aspect ratio */
video {
  aspect-ratio: 16/9;
}

/* Prevent font loading from causing layout shifts */
.font-loading-container {
  font-display: swap;
  visibility: hidden;
}

.font-loaded .font-loading-container {
  visibility: visible;
}

/* Stable grid layouts */
.marketing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: center;
}

@media (min-width: 1024px) {
  .marketing-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Prevent notification/toast from affecting layout */
.notifications-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  pointer-events: none;
}

.notifications-container > * {
  pointer-events: auto;
}

/* Stable card layouts */
.card {
  contain: layout;
  overflow: hidden;
}

/* Prevent accordion content from causing shifts */
.accordion-content {
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.accordion-content.hidden {
  max-height: 0;
}

.accordion-content:not(.hidden) {
  max-height: 1000px; /* Reasonable max height */
}

/* ========================================
   Utility Classes for Accessibility
   ========================================*/

/* Screen reader only content */
.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;
}

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
}

/* High contrast utilities */
.high-contrast-border {
  border: 1px solid currentColor;
}

.high-contrast-text {
  color: #000;
}

.dark .high-contrast-text {
  color: #fff;
}

/* Accessible color combinations */
.bg-accessible-primary {
  background-color: #1f2937;
  color: #f9fafb;
}

.bg-accessible-secondary {
  background-color: #f9fafb;
  color: #1f2937;
}

/* Focus trap for modals */
.focus-trap:focus-within {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}
