/**
 * PMC1101 Public Health - Accessibility Styles
 * WCAG 2.1 AA compliance
 */

/* ============================================
   SKIP LINKS
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: var(--accent-primary);
  color: var(--text-inverse);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  z-index: var(--z-toast);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--accent-info);
  outline-offset: 2px;
}

/* ============================================
   FOCUS STYLES
   ============================================ */
:focus-visible {
  outline: 2px solid var(--accent-info);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Ensure interactive elements have visible focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-info);
  outline-offset: 2px;
}

/* ============================================
   MINIMUM TOUCH TARGETS
   ============================================ */
@media (pointer: coarse) {
  button,
  a,
  input[type="radio"],
  input[type="checkbox"],
  select,
  [role="button"],
  [role="tab"],
  [role="menuitem"] {
    min-height: 44px;
    min-width: 44px;
  }
}

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

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
  :root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-elevated: #1a1a1a;
    --bg-surface: #252525;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-tertiary: #999999;
    --border-subtle: #444444;
    --border-default: #666666;
    --border-strong: #888888;
    --accent-primary: #ff8855;
    --accent-secondary: #00ffcc;
    --accent-info: #5599ff;
    --accent-danger: #ff4466;
    --accent-warning: #ffdd22;
  }

  .card,
  .week-card {
    border-width: 2px;
  }

  .btn {
    border-width: 2px;
  }
}

/* ============================================
   FORCED COLORS (Windows High Contrast)
   ============================================ */
@media (forced-colors: active) {
  .btn {
    border: 2px solid ButtonText;
  }

  .card,
  .week-card {
    border: 2px solid CanvasText;
  }

  .progress__fill {
    background: Highlight;
  }

  .badge {
    border: 1px solid CanvasText;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .site-header,
  .site-footer,
  .nav-mobile,
  .skip-link,
  .btn,
  .toggle-group,
  .game-section,
  .test-section,
  .modal-overlay {
    display: none !important;
  }

  .card,
  .week-card {
    border: 1px solid #ccc;
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  h1, h2, h3 {
    color: black;
    page-break-after: avoid;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .hidden-print { display: none; }
  .visible-print { display: block; }
}

/* ============================================
   ARIA LIVE REGIONS
   ============================================ */
[aria-live="polite"],
[aria-live="assertive"] {
  clip: auto;
  clip-path: none;
}

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

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: inherit;
}

/* ============================================
   SELECTION STYLES
   ============================================ */
::selection {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

::-moz-selection {
  background: var(--accent-primary);
  color: var(--text-inverse);
}
