/**
 * Accessibility Styles — WCAG 2.1 AA Target
 * 
 * Keyboard navigation, focus indicators, color contrast (4.5:1),
 * semantic HTML support, screen reader utilities, skip navigation.
 * 
 * Requirements: 33.1, 33.2, 33.3, 33.4, 33.5, 33.6, 33.7
 */

/* ─── Skip Navigation Link ─────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-primary, #1a73e8);
  color: #fff;
  padding: 0.75rem 1.5rem;
  z-index: 10000;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm, 4px) 0;
}
.skip-link:focus {
  top: 0;
  outline: 3px solid var(--color-accent, #fbbc04);
  outline-offset: 2px;
}

/* ─── Focus Indicators (Req 33.7) ───────────────────────────── */
*:focus-visible {
  outline: 3px solid var(--color-primary, #1a73e8);
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--color-primary, #1a73e8);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Remove default outline only when focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Keyboard Navigation Helpers (Req 33.2) ────────────────── */
[role="button"],
[role="link"],
[role="tab"],
[role="menuitem"] {
  cursor: pointer;
}

[role="button"]:focus-visible,
[role="tab"]:focus-visible {
  outline: 3px solid var(--color-primary, #1a73e8);
  outline-offset: 2px;
}

/* ─── Form Accessibility (Req 33.4) ─────────────────────────── */
label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  cursor: pointer;
}

/* Error states with ARIA */
[aria-invalid="true"] {
  border-color: var(--color-danger, #ea4335) !important;
  box-shadow: 0 0 0 2px rgba(234, 67, 53, 0.2);
}

.field-error {
  color: var(--color-danger, #ea4335);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}
.field-error[role="alert"] {
  font-weight: 500;
}

/* Required field indicator */
.required::after {
  content: " *";
  color: var(--color-danger, #ea4335);
  font-weight: bold;
}

/* ─── Color Contrast Helpers (Req 33.5) ─────────────────────── */
/* Ensure minimum 4.5:1 contrast ratio for normal text */
.text-on-primary {
  color: #ffffff;
  background-color: var(--color-primary, #1a73e8);
}

.text-on-dark {
  color: #ffffff;
}

.text-on-light {
  color: #202124;
}

/* Badge contrast */
.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: #34a853; color: #fff; }
.badge-warning { background: #f9ab00; color: #000; }
.badge-danger  { background: #ea4335; color: #fff; }
.badge-info    { background: #4285f4; color: #fff; }

/* ─── Screen Reader Utilities (Req 33.6) ────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* ─── Semantic HTML Support (Req 33.6) ──────────────────────── */
main { display: block; }
nav[aria-label] { display: block; }

/* Landmark regions */
[role="banner"],
[role="navigation"],
[role="main"],
[role="complementary"],
[role="contentinfo"] {
  display: block;
}

/* ─── Interactive Element Sizing (Touch Target 44x44px) ────── */
button,
[role="button"],
.btn,
input[type="checkbox"],
input[type="radio"] {
  min-height: 44px;
  min-width: 44px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* ─── 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;
  }
}

/* ─── High Contrast Mode Enhancements ───────────────────────── */
@media (forced-colors: active) {
  .btn-primary {
    border: 2px solid ButtonText;
  }
  
  a {
    text-decoration: underline;
  }
  
  *:focus-visible {
    outline: 3px solid Highlight;
  }
}

/* ─── Print Accessibility ───────────────────────────────────── */
@media print {
  .skip-link,
  .sr-only,
  [aria-hidden="true"] {
    display: none !important;
  }
  
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
