/* ============================================
   Accessibility & Performance Enhancements
   Created: November 16, 2024
   Purpose: WCAG 2.1 AA Compliance & Performance
   ============================================ */

/* ============================================
   1. SKIP TO CONTENT LINK (WCAG 2.4.1)
   ============================================ */

.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #FF5722;
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 10000;
  font-weight: 600;
  border-radius: 0 0 4px 0;
  transition: top 0.3s ease;
}

.skip-to-content:focus {
  top: 0;
  outline: 3px solid #FFA024;
  outline-offset: 2px;
}

/* ============================================
   2. FOCUS INDICATORS (WCAG 2.4.7)
   ============================================ */

/* Enhanced focus states for all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[tabindex]:focus {
  outline: 3px solid #FF5722;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(255, 87, 34, 0.2);
}

/* Remove default outline but keep custom one */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid #FF5722;
  outline-offset: 2px;
}

/* Navigation focus states */
.main-menu nav ul li a:focus {
  background: rgba(255, 87, 34, 0.1);
  border-radius: 4px;
}

/* Button focus states */
.btn-primary-fill:focus,
.btn-secondary-outline:focus {
  outline: 3px solid #FF5722;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 87, 34, 0.2);
}

/* Card focus states */
.helpful-card:focus-within {
  outline: 2px solid #FF5722;
  outline-offset: 4px;
}

/* ============================================
   3. COLOR CONTRAST IMPROVEMENTS (WCAG 1.4.3)
   ============================================ */

/* Ensure all text meets WCAG AA standards (4.5:1 ratio) */

/* Body text - Enhanced contrast */
body {
  color: #1a1a1a; /* Darker for better contrast */
}

/* Paragraph text */
.pera,
.caption-para,
.pera-subtitle {
  color: #333333; /* Improved from #666 */
}

/* Links - Ensure sufficient contrast */
a {
  color: #D84315; /* Darker orange for better contrast */
}

a:hover {
  color: #BF360C; /* Even darker on hover */
}

/* Secondary text */
.text-muted,
small {
  color: #555555; /* Improved from lighter gray */
}

/* Ensure white text on colored backgrounds has sufficient contrast */
.btn-primary-fill,
.donate-btn {
  background: #E64A19; /* Slightly darker orange */
  color: #FFFFFF;
}

/* Footer text contrast */
footer {
  background: #1a1a1a;
  color: #FFFFFF;
}

footer a {
  color: #FFB74D; /* Lighter orange for dark background */
}

footer a:hover {
  color: #FFA024;
}

/* ============================================
   4. KEYBOARD NAVIGATION (WCAG 2.1.1)
   ============================================ */

/* Ensure all interactive elements are keyboard accessible */

/* Remove focus outline for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid #FF5722;
  outline-offset: 2px;
}

/* Tab order indicators */
[tabindex="0"]:focus,
[tabindex="-1"]:focus {
  outline: 3px solid #FF5722;
  outline-offset: 2px;
}

/* ============================================
   5. SCREEN READER IMPROVEMENTS (WCAG 4.1.2)
   ============================================ */

/* 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-width: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ============================================
   6. MOTION & ANIMATION (WCAG 2.3.3)
   ============================================ */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  /* Disable parallax and transform animations */
  .tilt-effect,
  .wow {
    animation: none !important;
    transform: none !important;
  }
}

/* ============================================
   7. TOUCH TARGET SIZE (WCAG 2.5.5)
   ============================================ */

/* Ensure all interactive elements are at least 44x44px */

/* Buttons */
.btn-primary-fill,
.btn-secondary-outline,
button,
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 12px 24px;
}

/* Links in navigation */
.main-menu nav ul li a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 10px 15px;
}

/* Social media icons */
.header-social-link a,
.footer-social-link a {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Mobile menu toggle */
.mobile_menu button {
  min-width: 44px;
  min-height: 44px;
}

/* ============================================
   8. FORM ACCESSIBILITY (WCAG 3.3.2)
   ============================================ */

/* Form labels and inputs */
label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #1a1a1a;
}

input,
select,
textarea {
  border: 2px solid #CCCCCC;
  border-radius: 4px;
  padding: 12px;
  font-size: 16px; /* Prevent zoom on iOS */
  min-height: 44px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #FF5722;
  outline: 3px solid rgba(255, 87, 34, 0.2);
  outline-offset: 0;
}

/* Error states */
input:invalid,
select:invalid,
textarea:invalid {
  border-color: #D32F2F;
}

input:invalid:focus,
select:invalid:focus,
textarea:invalid:focus {
  outline-color: rgba(211, 47, 47, 0.2);
}

/* Required field indicator */
.required::after {
  content: " *";
  color: #D32F2F;
  font-weight: bold;
}

/* ============================================
   9. IMAGE OPTIMIZATION (Performance)
   ============================================ */

/* Lazy loading hint */
img {
  max-width: 100%;
  height: auto;
}

/* Prevent layout shift */
img[width][height] {
  height: auto;
}

/* Aspect ratio boxes for images */
.img-container {
  position: relative;
  overflow: hidden;
}

.img-container::before {
  content: '';
  display: block;
  padding-top: 56.25%; /* 16:9 aspect ratio */
}

.img-container img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   10. PRINT ACCESSIBILITY
   ============================================ */

@media print {
  /* Ensure good contrast for printing */
  body {
    color: #000000;
    background: #FFFFFF;
  }
  
  /* Show link URLs */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666666;
  }
  
  /* Don't show URLs for internal links */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
  
  /* Page breaks */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  img {
    page-break-inside: avoid;
  }
}

/* ============================================
   11. HIGH CONTRAST MODE (Windows)
   ============================================ */

@media (prefers-contrast: high) {
  /* Increase contrast for high contrast mode users */
  body {
    color: #000000;
  }
  
  a {
    color: #0000EE;
    text-decoration: underline;
  }
  
  button,
  .btn-primary-fill,
  .btn-secondary-outline {
    border: 2px solid currentColor;
  }
}

/* ============================================
   12. DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
  /* Optional: Add dark mode support */
  /* Uncomment if you want to support dark mode */
  
  /*
  body {
    background: #1a1a1a;
    color: #FFFFFF;
  }
  
  .helpful-card {
    background: #2a2a2a;
    border-color: #444444;
  }
  
  a {
    color: #FFB74D;
  }
  */
}

/* ============================================
   13. LOADING STATES (Performance)
   ============================================ */

/* Skeleton loading for images */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    #F0F0F0 25%,
    #E0E0E0 50%,
    #F0F0F0 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ============================================
   14. PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU acceleration for animations */
.helpful-card,
.btn-primary-fill,
.btn-secondary-outline {
  will-change: transform;
  transform: translateZ(0);
}

/* Optimize font rendering */
body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Reduce paint areas */
.header-area {
  contain: layout style paint;
}

/* ============================================
   15. RESPONSIVE IMAGES
   ============================================ */

/* Ensure images don't cause layout shift */
picture {
  display: block;
}

picture img {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================
   16. ARIA LIVE REGIONS
   ============================================ */

/* Style for live regions */
[aria-live="polite"],
[aria-live="assertive"] {
  position: relative;
}

/* Alert styling */
[role="alert"] {
  padding: 12px 16px;
  border-radius: 4px;
  background: #FFF3E0;
  border-left: 4px solid #FF5722;
  margin: 16px 0;
}

/* ============================================
   17. LANGUAGE SUPPORT
   ============================================ */

/* RTL support */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .main-menu nav ul {
  flex-direction: row-reverse;
}

/* ============================================
   18. REDUCED DATA MODE
   ============================================ */

@media (prefers-reduced-data: reduce) {
  /* Disable background images in reduced data mode */
  .hero-area-three,
  .about-area {
    background-image: none !important;
    background-color: #F5F5F5;
  }
}
