/* Accessibility Enhancements - Phase 2 */

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--brand-teal);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 10000;
  font-weight: 600;
  border-radius: 0 0 4px 0;
  transition: top 0.2s ease;
}

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

/* Focus indicators for all interactive elements */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus,
[role="button"]:focus,
[tabindex]:focus {
  outline: 3px solid var(--brand-teal);
  outline-offset: 2px;
}

/* Modern focus-visible (keyboard-only focus) */
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--brand-teal);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  a:focus,
  button:focus,
  input:focus,
  select:focus,
  textarea:focus {
    outline-width: 4px;
  }
}

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

/* Screen reader only text */
.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;
}

/* Ensure sufficient color contrast */
:root {
  --focus-color: var(--brand-teal);
  --focus-offset: 2px;
  --focus-width: 3px;
}

/* Touch target minimum size (44x44px) */
button,
a,
input[type="submit"],
input[type="button"],
input[type="checkbox"],
input[type="radio"],
select,
[role="button"] {
  min-height: 44px;
  min-width: 44px;
}

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

/* Ensure form labels are properly associated */
label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--dark-slate);
}

/* Required field indicator */
.required::after {
  content: " *";
  color: var(--danger);
  font-weight: bold;
}

/* Error message styling */
.error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.error-message::before {
  content: "⚠";
  font-size: 1rem;
}

/* Success message styling */
.success-message {
  color: #059669;
  font-size: 0.875rem;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.success-message::before {
  content: "✓";
  font-size: 1rem;
  font-weight: bold;
}

/* Ensure proper heading hierarchy */
h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2 {
  font-size: 2rem;
  line-height: 1.3;
  margin-bottom: 0.875rem;
}

h3 {
  font-size: 1.5rem;
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }
  
  h2 {
    font-size: 1.75rem;
  }
  
  h3 {
    font-size: 1.5rem;
  }
}

/* Ensure sufficient line height for readability */
body {
  line-height: 1.6;
}

p,
li {
  line-height: 1.7;
}

/* Ensure proper list semantics */
ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

/* Ensure images have alt text (visual indicator in dev) */
img:not([alt]) {
  outline: 3px dashed var(--danger);
}

/* Loading state for async content */
[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

/* Live region for dynamic content */
[aria-live="polite"],
[aria-live="assertive"] {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Ensure proper button states */
button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Ensure proper link states */
a {
  color: var(--brand-teal);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--brand-teal-dark);
  text-decoration-thickness: 2px;
}

a:visited {
  color: var(--brand-teal-dark);
}

/* Ensure proper contrast for placeholder text */
::placeholder {
  color: #6b7280;
  opacity: 1;
}

/* Ensure proper focus for custom checkboxes/radios */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: 3px solid var(--brand-teal);
  outline-offset: 2px;
}

/* Ensure tables are accessible */
table {
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  font-weight: 600;
  background-color: var(--off-white);
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
}

td {
  padding: 0.75rem;
  border: 1px solid #e5e7eb;
}

/* Ensure proper caption for tables */
caption {
  font-weight: 600;
  text-align: left;
  padding: 0.75rem;
  caption-side: top;
}

/* Print styles for accessibility */
@media print {
  .skip-link,
  nav,
  .no-print {
    display: none;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
  }
  
  abbr[title]::after {
    content: " (" attr(title) ")";
  }
}
