/*
 * Cure Plus Pharmacy - Accessibility Enhancements
 * WCAG 2.1 AA Compliance
 */

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

.skip-to-content {
  position: absolute;
  left: -9999px;
  z-index: var(--z-tooltip);
  padding: var(--space-4);
  background: var(--color-primary-blue);
  color: var(--color-white);
  text-decoration: none;
  border-radius: var(--radius-base);
  font-weight: var(--font-weight-semibold);
}

.skip-to-content:focus {
  left: var(--space-4);
  top: var(--space-4);
}

/* ==========================================
   FOCUS STYLES
   ========================================== */

/* Enhanced focus indicators */
:focus-visible {
  outline: 3px solid var(--color-primary-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Button focus */
.btn:focus-visible {
  outline: 3px solid var(--color-primary-blue);
  outline-offset: 2px;
}

.btn-primary:focus-visible {
  outline-color: var(--color-primary-blue-dark);
}

/* Link focus */
a:focus-visible {
  outline: 2px solid var(--color-primary-blue);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Form input focus */
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
  outline: none;
  border-color: var(--color-primary-blue);
  box-shadow: 0 0 0 4px var(--color-primary-blue-light);
}

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

/* Allow screen reader content to be focusable */
.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ==========================================
   HIGH CONTRAST MODE
   ========================================== */

@media (prefers-contrast: high) {
  :root {
    --color-primary-blue: #0052A3;
    --color-gray-600: #4A5568;
    --color-gray-700: #2D3748;
  }
  
  /* Increase border contrast */
  .card,
  .form-input,
  .form-textarea,
  .form-select,
  .accordion-item {
    border-width: 2px;
    border-color: var(--color-gray-900);
  }
  
  /* Enhance button contrast */
  .btn {
    border: 2px solid currentColor;
  }
  
  /* Remove subtle shadows */
  .card,
  .hero-image img {
    box-shadow: none;
  }
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

@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;
  }
  
  /* Disable all animations */
  .fade-in,
  .slide-up,
  .slide-down,
  .scale-in {
    animation: none !important;
  }
  
  /* Remove hover transforms */
  .btn:hover,
  .card:hover,
  .service-card:hover .service-card-icon {
    transform: none !important;
  }
}

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

/* Visible focus for keyboard users */
*:focus:not(:focus-visible) {
  outline: none;
}

/* Improve tab order visibility */
.nav-link:focus-visible,
.footer-links a:focus-visible {
  background: var(--color-primary-blue-light);
  outline: 2px solid var(--color-primary-blue);
}

/* Modal keyboard trap prevention */
.modal-overlay.active {
  /* Ensure focus stays within modal */
}

/* ==========================================
   TOUCH TARGET SIZES
   ========================================== */

/* Ensure all interactive elements meet 44x44px minimum */
.btn,
.nav-link,
.mobile-menu-toggle,
.accordion-header,
.form-check-input,
.modal-close,
a.card {
  min-width: 44px;
  min-height: 44px;
}

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

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

/* Ensure text meets WCAG AA standards (4.5:1 for normal, 3:1 for large) */

/* Error messages - ensure high contrast */
.form-error {
  color: #C81E1E; /* Higher contrast than default error color */
}

/* Placeholder text */
::placeholder {
  color: var(--color-gray-600);
  opacity: 1;
}

/* Disabled states */
.btn:disabled,
.form-input:disabled,
.form-textarea:disabled,
.form-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-gray-100);
  color: var(--color-gray-600);
}

/* ==========================================
   TEXT SPACING & READABILITY
   ========================================== */

/* Allow text spacing adjustments */
* {
  line-height: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
}

/* Ensure readable line length */
.content-readable {
  max-width: 70ch; /* Optimal reading length */
}

/* Increase spacing for readability */
p {
  margin-bottom: 1em;
}

li {
  margin-bottom: 0.5em;
}

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

/* Associate labels with inputs */
.form-label {
  cursor: pointer;
}

/* Required field indicator */
.form-label.required::after {
  content: ' *';
  color: var(--color-error);
  font-weight: bold;
}

/* Error state with icon */
.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--color-error);
  border-width: 2px;
}

.form-error::before {
  content: '⚠ ';
  font-weight: bold;
}

/* Success state */
.form-input.success {
  border-color: var(--color-success);
  border-width: 2px;
}

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

/* Styling for dynamic content announcements */
[aria-live="polite"],
[aria-live="assertive"] {
  /* These should typically be visually hidden but announced */
  /* Use .sr-only if needed */
}

/* Loading states */
[aria-busy="true"] {
  opacity: 0.6;
  cursor: wait;
  pointer-events: none;
}

/* ==========================================
   SEMANTIC HTML ENHANCEMENTS
   ========================================== */

/* Improve list readability */
ol,
ul {
  margin-left: 0;
  padding-left: 2em;
}

/* Definition lists */
dt {
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-4);
}

dd {
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
}

/* Abbreviations */
abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ==========================================
   IMAGE ACCESSIBILITY
   ========================================== */

/* Ensure all images have alt text (handled in HTML) */
img:not([alt]) {
  /* Visual indicator for missing alt text in development */
  outline: 3px solid red;
}

/* Decorative images */
img[alt=""],
img[role="presentation"] {
  /* Properly handled as decorative */
}

/* ==========================================
   TABLE ACCESSIBILITY
   ========================================== */

/* Improve table readability */
table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--space-6);
}

th {
  font-weight: var(--font-weight-semibold);
  text-align: left;
  padding: var(--space-3);
  border-bottom: 2px solid var(--color-gray-300);
  background: var(--color-gray-100);
}

td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-gray-200);
}

/* Responsive tables */
@media (max-width: 767px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================
   NOTIFICATION ACCESSIBILITY
   ========================================== */

/* Toast/Alert notifications */
.alert {
  /* Should include role="alert" in HTML */
}

.alert::before {
  font-weight: bold;
  margin-right: var(--space-2);
}

.alert-success::before {
  content: '✓ ';
  color: var(--color-success);
}

.alert-error::before {
  content: '✕ ';
  color: var(--color-error);
}

.alert-warning::before {
  content: '⚠ ';
  color: var(--color-warning);
}

.alert-info::before {
  content: 'ℹ ';
  color: var(--color-info);
}

/* ==========================================
   LANGUAGE & DIRECTION
   ========================================== */

/* RTL support (future enhancement) */
[dir="rtl"] {
  /* Reverse margins, padding, text-align as needed */
}

/* Language-specific adjustments */
:lang(fr) {
  /* French-specific typography adjustments if needed */
}

/* ==========================================
   MOBILE ACCESSIBILITY
   ========================================== */

@media (max-width: 767px) {
  /* Larger touch targets on mobile */
  .btn,
  .nav-link,
  .accordion-header {
    min-height: 48px;
  }
  
  /* Increase font size for better readability */
  body {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }
  
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px; /* Prevent iOS zoom on focus */
  }
}

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

@media print {
  /* Ensure sufficient contrast for printing */
  body {
    color: #000;
    background: #fff;
  }
  
  /* Show link URLs */
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.875rem;
    font-weight: normal;
  }
  
  /* Don't show URLs for internal links */
  a[href^="#"]:after,
  a[href^="/"]:after {
    content: "";
  }
}

