/**
 * Accessibility Styles
 * WCAG 2.1 AAA Compliant Styles
 * Focus indicators, skip links, screen reader utilities
 */

/* ============================================
   SKIP LINKS
   ============================================ */

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 100000;
  padding: 16px 24px;
  background: var(--Accent-Color, #00d2ff);
  color: #000;
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  border-radius: 0 0 8px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ============================================
   FOCUS INDICATORS - WCAG 2.1 AAA (2.4.7)
   Visible focus indicators with 3:1 contrast
   ============================================ */

/* High visibility focus outline */
*:focus {
  outline: 3px solid var(--Accent-Color, #00d2ff);
  outline-offset: 2px;
}

/* Focus-visible for keyboard navigation only */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--Accent-Color, #00d2ff);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px rgba(0, 210, 255, 0.2);
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--Accent-Color, #00d2ff);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(0, 210, 255, 0.25);
  transition: box-shadow 0.2s ease, outline-offset 0.2s ease;
}

/* Button focus states */
button:focus-visible,
.btn:focus-visible,
.PrimaryButton:focus-visible,
.SecondaryButton:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(0, 210, 255, 0.4);
}

/* Link focus states */
a:focus-visible {
  background: rgba(0, 210, 255, 0.1);
  border-radius: 2px;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Input focus states */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--Accent-Color, #00d2ff);
  box-shadow: 0 0 0 4px rgba(0, 210, 255, 0.2);
}

/* ============================================
   SCREEN READER ONLY CONTENT
   ============================================ */

.sr-only,
.visually-hidden {
  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 but focusable */
.sr-only-focusable:focus,
.visually-hidden-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

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

/* Ensure tab order is logical */
[tabindex="-1"] {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  *:focus-visible {
    outline: 4px solid currentColor;
    outline-offset: 4px;
  }
  
  .skip-link {
    border: 3px solid #000;
  }
}

/* ============================================
   REDUCED MOTION - WCAG 2.1 (2.3.3)
   ============================================ */

@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;
  }
  
  .skip-link {
    transition: none;
  }
}

/* ============================================
   TOUCH TARGET SIZE - WCAG 2.1 AAA (2.5.5)
   Minimum 44x44px touch targets
   ============================================ */

button,
a,
input[type="checkbox"],
input[type="radio"],
select,
[role="button"],
[tabindex="0"] {
  min-height: 44px;
  min-width: 44px;
}

/* Exception for inline text links */
p a,
li a,
span a {
  min-height: auto;
  min-width: auto;
}

/* ============================================
   COLOR CONTRAST HELPERS
   ============================================ */

/* Ensure decorative icons don't interfere with screen readers */
[aria-hidden="true"] {
  pointer-events: none;
}

/* Loading and status indicators */
[aria-busy="true"] {
  cursor: wait;
}

[aria-disabled="true"],
[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ============================================
   MODAL AND DIALOG ACCESSIBILITY
   ============================================ */

/* Trap focus within modals */
.modal[aria-modal="true"],
.dialog[aria-modal="true"],
[role="dialog"][aria-modal="true"] {
  position: fixed;
}

/* Ensure modal overlays are perceivable */
.modal-overlay,
.dialog-overlay {
  background: rgba(0, 0, 0, 0.75);
  position: fixed;
  inset: 0;
  z-index: 9999;
}

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

[aria-live="polite"],
[aria-live="assertive"] {
  position: relative;
}

/* ============================================
   FORM ACCESSIBILITY
   ============================================ */

/* Required field indicators */
[aria-required="true"]::after,
[required]::after {
  content: " *";
  color: #dc3545;
  font-weight: bold;
}

/* Error states */
[aria-invalid="true"] {
  border-color: #dc3545 !important;
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/* Helper text */
.form-helper-text {
  font-size: 14px;
  color: var(--Text-Secondary, #888);
  margin-top: 4px;
}

[aria-describedby] + .form-helper-text {
  display: block;
}

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

@media (max-width: 768px) {
  /* Larger touch targets on mobile */
  button,
  a,
  [role="button"] {
    min-height: 48px;
    min-width: 48px;
    padding: 12px 16px;
  }
  
  /* More prominent focus indicators */
  *:focus-visible {
    outline-width: 4px;
    outline-offset: 3px;
  }
}

/* ============================================
   PRINT ACCESSIBILITY
   ============================================ */

@media print {
  .skip-link,
  [aria-hidden="true"],
  .sr-only {
    display: none !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 90%;
    color: #666;
  }
  
  /* Don't print decorative external link icons */
  a[href^="http"]:not([href*="faforever.com"])::before {
    content: "🔗 ";
  }
}

/* ============================================
   LANGUAGE AND DIRECTION SUPPORT
   ============================================ */

[dir="rtl"] {
  direction: rtl;
}

[lang]:not([lang="en"]) {
  font-style: inherit;
}

/* ============================================
   FOCUS TRAP UTILITY
   ============================================ */

.focus-trap {
  position: relative;
}

.focus-trap-start,
.focus-trap-end {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
