/* ===================================
   ACCESSIBILITY FEATURES & FALLBACKS
   =================================== */

/* ===================================
   REDUCED MOTION PREFERENCES
   =================================== */

/* Respect user's motion preferences - disable animations for users who prefer reduced motion */
@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;
  }
  
  /* Disable specific hero animations */
  .hero-title-line,
  .hero-subtitle-text,
  .hero-role,
  .hero-divider,
  .hero-cta,
  .hero-scroll-indicator {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  
  /* Disable floating elements animation */
  .floating-element {
    animation: none !important;
    transform: none !important;
  }
  
  /* Disable gradient mesh animation */
  .gradient-mesh {
    animation: none !important;
    transform: none !important;
  }
  
  /* Disable scroll animations */
  .scroll-reveal,
  .fade-in-up,
  .slide-in-left,
  .slide-in-right {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  
  /* Disable hover transforms */
  .card:hover,
  .btn:hover,
  .nav-link:hover,
  .hero-btn:hover {
    transform: none !important;
  }
  
  /* Disable parallax effects */
  .parallax {
    transform: none !important;
  }
}

/* ===================================
   FOCUS MANAGEMENT & KEYBOARD NAVIGATION
   =================================== */

/* Enhanced focus styles for better visibility */
*:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Custom focus styles for interactive elements */
.btn:focus,
.nav-link:focus,
.nav-mobile-link:focus,
.contact-link:focus,
.social-link:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(0, 102, 255, 0.2);
}

/* Focus styles for form elements */
input:focus,
textarea:focus,
select:focus {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  z-index: 9999;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 6px;
  outline: 3px solid var(--color-white);
  outline-offset: 2px;
}

/* Ensure interactive elements have minimum touch target size (44px) */
.btn,
.nav-link,
.nav-mobile-link,
.nav-toggle,
.btn-expand,
.social-link,
.contact-link {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===================================
   HIGH CONTRAST MODE SUPPORT
   =================================== */

/* Support for Windows High Contrast Mode */
@media (prefers-contrast: high) {
  /* Ensure sufficient contrast for text */
  .hero-title,
  .hero-subtitle,
  .hero-role {
    color: ButtonText;
    background: ButtonFace;
    border: 1px solid ButtonText;
  }
  
  /* Ensure buttons have proper contrast */
  .btn,
  .hero-btn {
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
  }
  
  /* Ensure links are distinguishable */
  a {
    color: LinkText;
    text-decoration: underline;
  }
  
  /* Ensure cards have visible borders */
  .card,
  .experience-content,
  .philosophy-card,
  .contact-card {
    border: 2px solid ButtonText;
    background: ButtonFace;
  }
}

/* ===================================
   SCREEN READER SUPPORT
   =================================== */

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

/* Screen reader only text that becomes visible on focus */
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ===================================
   COLOR CONTRAST ENHANCEMENTS
   =================================== */

/* Ensure WCAG AA compliance for color contrast */
:root {
  /* Enhanced contrast colors */
  --color-text-primary-contrast: #1a1a1a;
  --color-text-secondary-contrast: #4a4a4a;
  --color-link-contrast: #0052cc;
  --color-link-hover-contrast: #003d99;
}

/* Apply enhanced contrast colors when needed */
@media (prefers-contrast: more) {
  body {
    color: var(--color-text-primary-contrast);
  }
  
  p,
  .text-secondary {
    color: var(--color-text-secondary-contrast);
  }
  
  a {
    color: var(--color-link-contrast);
  }
  
  a:hover {
    color: var(--color-link-hover-contrast);
  }
}

/* ===================================
   KEYBOARD NAVIGATION ENHANCEMENTS
   =================================== */

/* Ensure tab order is logical */
.nav-menu {
  display: flex;
}

.nav-menu .nav-item {
  order: 1;
}

/* Mobile menu keyboard navigation */
.nav-mobile.active .nav-mobile-link:first-child {
  /* Auto-focus first item when mobile menu opens */
}

/* Expandable content keyboard support */
.btn-expand[aria-expanded="true"] + .experience-details {
  display: block;
}

.btn-expand[aria-expanded="false"] + .experience-details {
  display: none;
}

/* ===================================
   ARIA LIVE REGIONS
   =================================== */

/* Status announcements for screen readers */
.status-announcement {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ===================================
   PRINT STYLES
   =================================== */

@media print {
  /* Hide interactive elements in print */
  .nav-toggle,
  .nav-mobile,
  .nav-overlay,
  .hero-btn,
  .btn-expand,
  .floating-elements,
  .scroll-progress,
  .hero-scroll-indicator {
    display: none !important;
  }
  
  /* Ensure good contrast in print */
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }
  
  /* Show URLs for links */
  a[href]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  /* Page breaks */
  .experience-content,
  .philosophy-card,
  .contact-card {
    page-break-inside: avoid;
  }
  
  section {
    page-break-after: auto;
  }
}

/* ===================================
   FALLBACKS FOR OLDER BROWSERS
   =================================== */

/* Fallback for browsers that don't support CSS Grid */
@supports not (display: grid) {
  .hero {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .philosophy-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }
  
  .philosophy-card {
    flex: 1 1 300px;
  }
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(10px)) {
  .main-nav {
    background: rgba(255, 255, 255, 0.95);
  }
  
  .hero-btn {
    background: rgba(0, 102, 255, 0.8);
  }
  
  .glass {
    background: rgba(255, 255, 255, 0.9);
  }
}

/* Fallback for browsers that don't support CSS custom properties */
@supports not (color: var(--color-primary)) {
  body {
    font-family: 'Source Sans Pro', Arial, sans-serif;
    color: #202124;
  }
  
  .btn-primary {
    background-color: #0066FF;
    color: white;
  }
  
  .hero {
    background: linear-gradient(135deg, #0066FF 0%, #00D4FF 50%, #6C5CE7 100%);
  }
}

/* ===================================
   RESPONSIVE ACCESSIBILITY
   =================================== */

/* Ensure touch targets are large enough on mobile */
@media (max-width: 768px) {
  .btn,
  .nav-link,
  .social-link,
  .contact-link {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }
  
  /* Increase spacing for easier touch interaction */
  .nav-mobile-link {
    padding: 16px 20px;
    margin-bottom: 8px;
  }
}

/* ===================================
   ERROR STATES AND FEEDBACK
   =================================== */

/* Error states for form validation */
.error {
  color: #d32f2f;
  border-color: #d32f2f;
}

.error:focus {
  outline-color: #d32f2f;
  box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.2);
}

/* Success states */
.success {
  color: #2e7d32;
  border-color: #2e7d32;
}

.success:focus {
  outline-color: #2e7d32;
  box-shadow: 0 0 0 4px rgba(46, 125, 50, 0.2);
}

/* Loading states */
.loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Disable loading animation for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .loading::after {
    animation: none;
    border: 2px solid var(--color-primary);
    border-radius: 0;
    width: 4px;
    height: 4px;
  }
}