/* Accessibility improvements */

/* Focus management */
*:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Skip link positioning */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: 999;
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--color-primary);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-small);
}

.skip-link:focus {
  left: var(--spacing-md);
  top: var(--spacing-md);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-primary: #000;
    --color-secondary: #333;
    --color-text: #000;
    --color-background: #fff;
    --color-border: #000;
  }
  
  a {
    text-decoration: underline;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .scrolldown a:hover {
    transform: none;
  }
  
  #go-top a:hover {
    transform: none;
  }
}

/* Screen reader only text */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Ensure interactive elements have minimum touch targets */
button, .button, a[role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Improve readability */
p {
  max-width: 65ch;
}

/* Better link contrast */
a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover, a:focus {
  text-decoration-thickness: 2px;
}

/* Form elements accessibility */
input, textarea, select {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-small);
  padding: var(--spacing-sm);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-accent);
}

/* Image accessibility */
img {
  max-width: 100%;
  height: auto;
}

img[alt=""] {
  border: 2px dashed var(--color-accent);
}

/* Ensure sufficient color contrast for text */
.text-light {
  color: var(--color-text-light);
}

.text-critical {
  color: #d63031; /* Red for critical information */
}

/* Icon accessibility */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.icon svg {
  width: 100%;
  height: 100%;
}

/* Hide decorative elements from screen readers */
.decorative {
  aria-hidden: true;
}

/* Loading state for dynamic content */
[aria-busy="true"] {
  cursor: wait;
}

[aria-busy="true"] * {
  pointer-events: none;
}

/* Error message styling */
[role="alert"] {
  background-color: rgba(231, 76, 60, 0.1);
  border-left: 4px solid var(--color-accent);
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
}

/* Success message styling */
[role="status"] {
  background-color: rgba(39, 174, 96, 0.1);
  border-left: 4px solid #27ae60;
  padding: var(--spacing-md);
  margin: var(--spacing-md) 0;
}
