/**
 * Accessibility Styles
 * WCAG 2.1 AA Compliant styles
 */

/* 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-width: 0;
}

/* Skip links removed - not needed for navigation */

/* Focus visible styles - high contrast gold outline */
*:focus-visible {
  outline: 3px solid #d4af37 !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 6px rgba(212, 175, 55, 0.2) !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #d4af37 !important;
  outline-offset: 2px !important;
}

/* Remove default focus for mouse users, keep for keyboard */
*:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  * {
    border-color: currentColor !important;
  }
  
  .btn {
    border: 2px solid currentColor !important;
  }
  
  a {
    text-decoration: underline !important;
  }
}

/* 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;
  }
  
  /* Keep essential animations but make them instant */
  .modal,
  .notification,
  .toast {
    transition: opacity 0.01ms !important;
  }
}

/* Touch target sizes - minimum 44x44px */
@media (hover: none) and (pointer: coarse) {
  button,
  a,
  input[type="checkbox"],
  input[type="radio"],
  select,
  .btn,
  .card-button,
  .icon-button {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 12px !important;
  }
  
  .navbar-menu a {
    padding: 14px 20px !important;
  }
}

/* Ensure text is readable over backgrounds */
.overlay-text,
.badge,
.btn,
.alert {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Loading states */
[aria-busy="true"] {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

[aria-busy="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #d4af37;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Error states - ensure they're noticeable */
[aria-invalid="true"],
.error,
.is-invalid {
  border-color: #8b2e1f !important;
  border-width: 2px !important;
  background-color: rgba(139, 46, 31, 0.05) !important;
}

[aria-invalid="true"]:focus {
  outline-color: #8b2e1f !important;
  box-shadow: 0 0 0 4px rgba(139, 46, 31, 0.2) !important;
}

/* Success states */
[aria-invalid="false"],
.success,
.is-valid {
  border-color: #5a7c3e !important;
  background-color: rgba(90, 124, 62, 0.05) !important;
}

/* Disabled states */
[disabled],
[aria-disabled="true"],
.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Expandable sections */
[aria-expanded="false"] + * {
  display: none;
}

[aria-expanded="true"] + * {
  display: block;
}

/* Live regions - aria-live elements should remain visible and announce changes to screen readers
   Do not hide these elements off-screen as they contain actual content */

/* Screen reader only content (for announcements that shouldn't be visible) */
.sr-only-live {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Modal accessibility */
.modal[aria-hidden="true"] {
  display: none !important;
}

.modal[aria-hidden="false"] {
  display: flex !important;
}

/* Ensure modals have proper contrast and visibility */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-in-out;
}

/* Color blind friendly colors */
.color-blind-mode .success {
  background-color: #0077bb !important; /* Blue for success */
}

.color-blind-mode .warning {
  background-color: #ee7733 !important; /* Orange for warning */
}

.color-blind-mode .danger {
  background-color: #cc3311 !important; /* Red for danger */
}

.color-blind-mode .info {
  background-color: #33bbee !important; /* Cyan for info */
}

/* Keyboard navigation indicators */
.keyboard-mode *:focus {
  outline: 3px solid #d4af37 !important;
  outline-offset: 2px !important;
}

/* Enhance button accessibility */
button,
.btn,
[role="button"] {
  cursor: pointer;
  user-select: none;
}

button:disabled,
.btn:disabled,
[role="button"][aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Table accessibility */
table {
  border-collapse: collapse;
}

th {
  font-weight: bold;
  text-align: left;
}

caption {
  font-weight: bold;
  padding: 10px;
  caption-side: top;
}

/* Form accessibility */
label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

input[required] + label::after,
label.required::after {
  content: " *";
  color: #8b2e1f;
  font-weight: bold;
}

.form-error {
  color: #8b2e1f;
  font-size: 0.875rem;
  margin-top: 4px;
  display: block;
}

.form-help {
  color: #666;
  font-size: 0.875rem;
  margin-top: 4px;
  display: block;
}

/* Notification accessibility */
.notification {
  padding: 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  border-left: 4px solid currentColor;
}

.notification-success {
  background: rgba(90, 124, 62, 0.1);
  color: #5a7c3e;
  border-color: #5a7c3e;
}

.notification-error {
  background: rgba(139, 46, 31, 0.1);
  color: #8b2e1f;
  border-color: #8b2e1f;
}

.notification-warning {
  background: rgba(212, 175, 55, 0.1);
  color: #8b6914;
  border-color: #d4af37;
}

.notification-info {
  background: rgba(100, 116, 139, 0.1);
  color: #475569;
  border-color: #64748b;
}

/* Responsive text sizing */
@media (max-width: 768px) {
  body {
    font-size: 16px; /* Minimum readable size on mobile */
  }
  
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
  h4 { font-size: 1.1rem; }
}

/* Print styles for accessibility */
@media print {
  .no-print,
  .navbar,
  .sidebar,
  button,
  .btn {
    display: none !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
  
  * {
    background: white !important;
    color: black !important;
  }
}
