/* === Accessibility — WCAG 2.1 AA === */

/* Skip to main content link */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 99999;
  background: var(--lime);
  color: #0a0a0f;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  font-family: var(--font);
  transition: left 0.2s;
}
.skip-to-content:focus {
  left: 8px;
  outline: 3px solid var(--lime);
  outline-offset: 2px;
}

/* Focus styles — visible on all focusable elements */
:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Don't show outline on mouse clicks */
:focus:not(:focus-visible) {
  outline: none;
}

/* Buttons and interactive elements */
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

/* Ensure focus ring is never hidden accidentally */
*:focus {
  outline: 2px solid transparent;
}
*:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

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

/* ARIA live region: visually hidden but announced */
.aria-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Modal focus trap */
.modal-focus-trap:focus-within {
  /* children are focusable */
}

/* Disabled elements: reduce opacity, not cursor (already default) */
:disabled,
[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Error state — link error message via aria-describedby */
.has-error {
  border-color: #ef4444 !important;
}
.field-error {
  display: block;
  font-size: 0.78rem;
  color: #f87171;
  margin-top: 4px;
}

/* Toast notifications — aria-live */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--lime);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  z-index: 9000;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.toast.badge-unlock {
  border-color: #eab308;
  background: rgba(234, 179, 8, 0.12);
}
.toast-icon { margin-right: 8px; }
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 12px;
  font-size: 1.1rem;
  padding: 0;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }

/* Animated badge unlock toast */
@keyframes badgePop {
  0% { transform: translateY(20px) scale(0.9); opacity: 0; }
  60% { transform: translateY(-4px) scale(1.05); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.toast-badge-unlock {
  animation: badgePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Loading state — aria-busy */
[aria-busy="true"] {
  opacity: 0.7;
}

/* Format unavailable state */
.format-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--text-dim);
}
.format-unavailable .unavail-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.format-unavailable .unavail-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.format-unavailable .unavail-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 14px;
  max-width: 260px;
  line-height: 1.5;
}
.format-unavailable .unavail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--lime-dim);
  color: var(--lime);
  border: 1px solid var(--lime-border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
.format-unavailable .unavail-link:hover {
  background: var(--lime);
  color: #0a0a0f;
}

/* Onboarding: keyboard navigable format options */
.format-option {
  cursor: pointer;
  outline: none;
}
.format-option:focus-visible {
  outline: 2px solid var(--lime);
  outline-offset: 3px;
}

/* Step indicators: keyboard accessible */
.step-dot button,
.step-circle {
  background: none;
  border: none;
  cursor: pointer;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: rgba(255,255,255,0.25);
    --border-h: rgba(255,255,255,0.4);
  }
  *:focus-visible {
    outline-width: 3px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-badge-unlock,
  @keyframes badgePop,
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Touch targets: minimum 44x44px */
button, [role="button"], a, input, select, label {
  min-height: 44px;
  min-width: 44px;
}
.icon-btn {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Tab order helpers */
[data-tab-start] { }
[data-tab-end] { }

/* Chart accessible data table */
.chart-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.chart-data-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.chart-data-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.chart-data-table tr:hover td {
  background: var(--surface-2);
}

/* Headings hierarchy */
.page-heading { font-size: 1.75rem; font-weight: 800; margin-bottom: 20px; }
.section-heading { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }