/**
 * Gator Abrasives - Accessibility Enhancements
 * WCAG 2.1 AA Compliance Styles
 */

/* ========================================
   Skip Links for Keyboard Navigation
   ======================================== */

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--gator-secondary);
  color: var(--gator-white);
  padding: 8px 16px;
  text-decoration: none;
  z-index: 10000;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--gator-primary);
  outline-offset: 2px;
}

/* ========================================
   Focus Indicators (Enhanced)
   ======================================== */

/* Ensure all interactive elements have visible focus indicators */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--gator-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Remove default outline and use custom */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--gator-primary);
  outline-offset: 2px;
}

/* ========================================
   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;
}

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

/* ========================================
   Color Contrast Improvements
   ======================================== */

/* Ensure text meets WCAG AA contrast ratio of 4.5:1 */
.text-muted {
  color: #666666 !important; /* Improved from #9E9E9E for better contrast */
}

/* Link contrast improvements */
a.text-decoration-none {
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.3s ease;
}

a.text-decoration-none:hover,
a.text-decoration-none:focus {
  text-decoration-color: currentColor;
}

/* ========================================
   Keyboard Navigation Enhancements
   ======================================== */

/* Make keyboard focus more visible on cards */
.product-card:focus-within,
.article-card:focus-within,
.distributor-card:focus-within {
  outline: 3px solid var(--gator-primary);
  outline-offset: 2px;
}

/* Improve button focus states */
.btn:focus-visible {
  outline: 3px solid var(--gator-primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(244, 121, 32, 0.2);
}

/* ========================================
   Form Accessibility
   ======================================== */

/* Ensure form labels are always visible */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--gator-secondary);
}

/* Required field indicator */
.required::after,
label .text-danger {
  color: #C41E3A; /* Darker red for better contrast */
}

/* Error messages with sufficient contrast */
.invalid-feedback,
.form-error {
  color: #C41E3A;
  font-weight: 600;
}

.is-invalid,
.form-control.is-invalid {
  border-color: #C41E3A;
  border-width: 2px;
}

/* Success messages */
.valid-feedback,
.alert-success {
  color: #2E7D32; /* Darker green for better contrast */
}

/* ========================================
   Table Accessibility
   ======================================== */

/* Ensure table headers are clearly distinguished */
th {
  font-weight: 700;
  background-color: var(--gator-gray-100);
  border-bottom: 2px solid var(--gator-secondary);
}

/* Improve table row hover for keyboard navigation */
tr:focus-within {
  outline: 2px solid var(--gator-primary);
  outline-offset: -2px;
}

/* ========================================
   Navigation Accessibility
   ======================================== */

/* Improve nav link focus states */
.nav-link:focus-visible {
  outline: 3px solid var(--gator-primary);
  outline-offset: 2px;
  background-color: rgba(244, 121, 32, 0.1);
}

/* Active page indicator with better contrast */
.nav-link.active {
  font-weight: 700;
  position: relative;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--gator-primary);
}

/* ========================================
   Modal and Dialog Accessibility
   ======================================== */

/* Ensure modals trap focus properly */
.modal:focus {
  outline: none;
}

.modal-content:focus {
  outline: 3px solid var(--gator-primary);
}

/* ========================================
   Image Accessibility
   ======================================== */

/* Decorative images should have empty alt text */
img[alt=""],
img[role="presentation"] {
  user-select: none;
}

/* ========================================
   Motion Preferences
   ======================================== */

/* 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;
  }
  
  .carousel {
    transition: none !important;
  }
}

/* ========================================
   High Contrast Mode Support
   ======================================== */

@media (prefers-contrast: high) {
  /* Increase border widths for better visibility */
  .btn,
  .form-control,
  .card {
    border-width: 2px;
  }
  
  /* Ensure focus indicators are more prominent */
  *:focus-visible {
    outline-width: 4px;
  }
}

/* ========================================
   Touch Target Sizes
   ======================================== */

/* Ensure minimum touch target size of 44x44px (WCAG 2.5.5) */
.btn,
.nav-link,
a.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
}

/* Exception for inline text links */
a:not(.btn):not(.nav-link) {
  min-height: auto;
  min-width: auto;
}

/* ========================================
   Breadcrumb Accessibility
   ======================================== */

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--gator-gray-600);
  font-weight: 600;
}

.breadcrumb-item.active {
  font-weight: 600;
  color: var(--gator-secondary);
}

/* ========================================
   Loading States
   ======================================== */

/* Ensure loading indicators are announced to screen readers */
[aria-busy="true"] {
  position: relative;
}

[aria-busy="true"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid var(--gator-gray-300);
  border-top-color: var(--gator-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
  /* Ensure good contrast in print */
  body {
    color: #000;
    background: #fff;
  }
  
  /* Show URLs for links */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
  
  /* Hide navigation and non-essential elements */
  .site-header,
  .site-footer,
  .btn,
  .skip-link {
    display: none;
  }
}
