/**
 * Accessibility CSS
 * Screen reader utilities and focus management
 */

/* Screen reader only - visually hidden but accessible to screen readers */
.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;
}

/* Allow sr-only elements to be visible when focused (skip links) */
.sr-only.focus\:not-sr-only:focus,
.focus\:not-sr-only:focus {
  position: absolute;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus visible styles for keyboard navigation */
:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

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

/* Skip link styles */
a[href^="#"]:focus {
  z-index: 9999;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :focus-visible {
    outline: 3px solid currentColor;
    outline-offset: 3px;
  }
  
  button, a, input, select, textarea {
    border-width: 2px;
  }
}

/* Reduced motion support */
@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;
  }
}

/* Ensure buttons and links have minimum touch target size */
button,
a,
[role="button"],
[role="menuitem"] {
  min-height: 44px;
  min-width: 44px;
}

/* Exception for inline links and small buttons that are part of text */
p a,
span a,
.inline-link,
.text-btn {
  min-height: auto;
  min-width: auto;
}

/* Live region announcements */
[aria-live="polite"],
[aria-live="assertive"],
[role="status"],
[role="alert"] {
  /* Ensure live regions don't affect layout when empty */
}

/* Focus trap indicator for modals */
[role="dialog"],
[aria-modal="true"] {
  /* Modal styles handled elsewhere, this ensures proper focus management */
}

/* Disabled state styling */
[aria-disabled="true"],
[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Current page indicator in navigation */
[aria-current="page"] {
  font-weight: 600;
}

/* Menu item states */
[role="menuitem"]:hover:not([aria-disabled="true"]) {
  background-color: rgba(0, 0, 0, 0.05);
}

[role="menuitem"]:focus-visible {
  background-color: rgba(37, 99, 235, 0.1);
}

/* Ensure form labels are associated with inputs */
label {
  cursor: pointer;
}

/* Error state for form fields */
[aria-invalid="true"] {
  border-color: #dc2626;
}

[aria-invalid="true"]:focus {
  outline-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* Required field indicator */
[aria-required="true"]::after {
  content: "";
}
