/* 
 * Accessibility Utilities and Enhancements
 * Provides screen reader support, focus management, and reduced motion preferences
 */

/* 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;
}

/* Screen Reader Only Content that becomes visible on focus */
.sr-only-focusable:active,
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: #000;
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  z-index: 10000;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  transition: top 0.2s ease;
  border: 2px solid transparent;
}

.skip-link:focus {
  top: 6px;
  border-color: #ff6b35;
  outline: none;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .site-header,
  .hero-section,
  .about-section,
  .footer {
    border: 1px solid currentColor;
  }
  
  .btn,
  .social-link,
  .carousel-image,
  .game-element {
    border: 2px solid currentColor !important;
  }
}

/* Reduced 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;
  }
  
  /* Keep fade animations but remove transforms */
  .fade-enter-active,
  .fade-leave-active,
  .carousel-transition,
  .game-element,
  .social-link {
    transform: none !important;
  }
}

/* Focus Management */
body.keyboard-navigation *:focus {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
}

body:not(.keyboard-navigation) *:focus {
  outline: none;
}

/* Custom focus styles for specific components */
.btn:focus,
.carousel-nav-button:focus,
.video-controls button:focus,
.social-link:focus {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
  box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.2);
}

/* Focus for interactive elements */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[tabindex]:focus,
[role="button"]:focus,
[role="tab"]:focus,
[role="menuitem"]:focus {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
}

/* Focus styles for custom components */
.carousel-slide:focus,
.game-element__card:focus,
.instagram-post:focus {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
  transform: translateY(-2px);
}

/* Error message styling */
.error-message {
  color: #d32f2f;
  font-size: 0.875rem;
  margin-top: 4px;
  display: block;
}

.error-message:not(.sr-only) {
  background: #ffebee;
  padding: 8px 12px;
  border-radius: 4px;
  border-left: 4px solid #d32f2f;
}

/* Form validation states */
input:invalid:not(:focus),
textarea:invalid:not(:focus) {
  border-color: #d32f2f;
  box-shadow: 0 0 0 1px rgba(211, 47, 47, 0.2);
}

input:valid:not(:focus),
textarea:valid:not(:focus) {
  border-color: #4caf50;
}

/* Required field indicator */
.required::after {
  content: ' *';
  color: #d32f2f;
  font-weight: bold;
}

/* Loading states with proper announcements */
.loading-spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid #ff6b35;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@media (prefers-reduced-motion: reduce) {
  .loading-spinner {
    animation: none;
    border: 3px solid #ff6b35;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Status announcements */
.status-announcement {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Interactive element states */
button:disabled,
[role="button"][aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ARIA live regions */
[aria-live="polite"],
[aria-live="assertive"] {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

[aria-live="polite"].show-announcement,
[aria-live="assertive"].show-announcement {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  background: #fff3cd;
  color: #856404;
  padding: 12px;
  border: 1px solid #ffeaa7;
  border-radius: 4px;
  margin: 8px 0;
}

/* Card interaction feedback */
.card-interactive:hover,
.card-interactive:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

@media (prefers-reduced-motion: reduce) {
  .card-interactive:hover,
  .card-interactive:focus {
    transform: none;
  }
}

/* Mobile accessibility enhancements */
@media (max-width: 768px) {
  /* Increase touch targets */
  button,
  a,
  [role="button"],
  .carousel-nav-button,
  .mobile-toggle {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Improve spacing for easier touch interaction */
  .social-link,
  .game-element__card,
  .carousel-slide {
    margin: 8px;
  }
}

/* Color contrast enhancements */
.high-contrast {
  --text-color: #000;
  --background-color: #fff;
  --link-color: #0066cc;
  --border-color: #000;
}

@media (prefers-contrast: high) {
  :root {
    --text-color: #000;
    --background-color: #fff;
    --link-color: #0066cc;
    --border-color: #000;
  }
}

/* Text scaling support */
@media (min-resolution: 2dppx) {
  body {
    font-size: 18px;
  }
}

/* Language direction support */
[dir="rtl"] .carousel-nav-button--prev {
  transform: scaleX(-1);
}

[dir="rtl"] .carousel-nav-button--next {
  transform: scaleX(-1);
}

/* Print accessibility */
@media print {
  .skip-link,
  .mobile-toggle,
  .video-controls,
  .social-links {
    display: none !important;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}
