/* Accessibility improvements for WCAG 2.1 AA compliance */

/* Accessibility-specific CSS variables */
:root {
  /* WCAG AA compliant colors that override defaults when needed */
  --focus: #3182ce;
  --focus-bg: rgba(49, 130, 206, 0.1);
  --error: #c53030;
  --success: #38a169;
  --warning: #d69e2e;
}

/* Enhanced dark theme for accessibility */
.theme-dark {
  --focus: #90cdf4;
  --focus-bg: rgba(144, 205, 244, 0.15);
  --error: #fc8181;
  --success: #68d391;
  --warning: #f6e05e;
}

/* High contrast mode support */
@media (prefers-contrast: more) {
  :root {
    --text: #000;
    --heading: #000;
    --muted: #333;
    --accent: #00e;
    --border: #000;
  }

  .theme-dark {
    --text: #fff;
    --heading: #fff;
    --muted: #ccc;
    --accent: #88f;
    --border: #fff;
  }
}

/* Focus indicators - visible on keyboard focus only */
*:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  background-color: var(--focus-bg);
  box-shadow: 0 0 0 1px var(--focus);
}

/* Skip to main content link */
.skip-to-main {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 4px;
  z-index: 1000;
  font-weight: bold;
}

.skip-to-main:focus {
  top: 6px;
  outline: 3px solid var(--focus);
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Enhanced button focus states */
.theme-toggle:focus-visible,
.nav-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  background-color: var(--focus-bg);
}

/* Link focus improvements */
a:focus {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 2px;
}

/* Form element accessibility */
input,
textarea,
select {
  border: 2px solid var(--border);
  padding: 8px 12px;
  font-size: 16px; /* Prevent zoom on iOS */
}

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

/* Error states for forms */
.error input,
.error textarea,
.error select {
  border-color: var(--error);
  background-color: rgba(197, 48, 48, 0.05);
}

/* High contrast borders for cards and buttons */
.card {
  border: 2px solid var(--border);
}

.card:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

/* Improved text selection */
::selection {
  background-color: var(--accent);
  color: white;
}

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

/* Print styles for accessibility */
@media print {
  * {
    background: white !important;
    color: black !important;
  }

  a::after {
    content: " (" attr(href) ")";
  }

  .skip-to-main,
  .theme-toggle,
  .nav-toggle {
    display: none;
  }
}
