/* =================================================================
   ACCESSIBILITY & PERFORMANCE - WCAG 2.1 AA + Core Web Vitals
================================================================= */

/* Focus management for keyboard navigation */
:focus {
  outline: 2px solid #123e73;
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid #123e73;
  outline-offset: 2px;
}

/* Skip to main content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #123e73;
  color: white;
  padding: 8px;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* Color contrast - WCAG AA minimum 4.5:1 */
body {
  color: #1a1a1a;
} /* 10.5:1 contrast */
h1,
h2,
h3 {
  color: #0f172a;
} /* 13:1 contrast */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  body {
    background: #0f172a;
    color: #f5f7fa;
  }
  a {
    color: #60d5ff;
  }
}

/* Form accessibility */
input,
textarea,
select {
  font-size: 16px; /* Prevent zoom on iOS */
  border: 1px solid #cbd5e1;
  padding: 0.5rem;
  border-radius: 0.375rem;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid #123e73;
  outline-offset: 2px;
}

/* Font smoothing */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Native lazy loading */
img {
  loading: lazy;
  max-width: 100%;
  height: auto;
}

/* Touch target size (minimum 44x44px) */
.btn,
button,
a[role='button'] {
  min-height: 44px;
  min-width: 44px;
}

/* Remove tap delay */
button,
a,
input[type='button'] {
  touch-action: manipulation;
}

/* Performance - GPU acceleration */
.card:hover,
.btn:hover {
  will-change: transform;
}

/* Prevent CLS (Cumulative Layout Shift) */
img,
iframe,
video {
  width: 100%;
  height: auto;
  display: block;
}

/* Accessible table */
table {
  border-collapse: collapse;
  width: 100%;
}

th {
  background: #f0f3ff;
  color: #123e73;
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid #cbd5e1;
}

/* Link underlines */
a:not(.btn):not(.header-link):not(.btn-header-primary):not(.btn-header-secondary) {
  text-decoration: underline;
}

/* High contrast mode */
@media (prefers-contrast: more) {
  body {
    background: #fff;
    color: #000;
  }
  .btn-primary {
    border: 2px solid #000;
    background: white;
    color: #000;
  }
}

/* Error states */
[aria-invalid='true'] {
  border-color: #ef4444;
  background: #fef2f2;
}

/* Loading animation */
@keyframes loading {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: loading 1.5s ease-in-out infinite;
}

/* Text rendering optimization */
body {
  text-rendering: optimizeLegibility;
  text-size-adjust: 100%;
}
