/*
 * Accessibility overrides for the legacy /data pages (update spec P3-08).
 * Loaded last on every legacy page. Fixes WCAG AA contrast failures found by
 * axe without restyling the pages: muted grays are darkened (light theme) or
 * lightened (dark theme), the always-dark top bar gets light text, and dark-
 * theme elements that put white text on the light accent get dark text.
 */

/* Top bar is always #0d0f14 — its links and menus need light ink. */
.salttab-topnav .topnav-brand,
.salttab-topnav .topnav-links > a,
.salttab-topnav .topnav-links > .stxnav-group > summary { color: #ece9f7 !important; }
.salttab-topnav .topnav-links .stxnav-home { color: #c9b8ff !important; }
.salttab-topnav .topnav-links > a.active { color: #ffd98a !important; }

/* Light theme: muted grays → AA on white and on the lavender surfaces. */
html:not([data-theme="dark"]) :is(
  .race-context-note, .top-state-name, .top-state-rank, .region-number-label, .region-bar-label,
  .inline-search-shortcut, .whats-new-date, .filter-bar-label, .api-note, .data-stat-label,
  .data-stat-sub, .census-subtitle, .congress-subtitle, .loading-text, .census-map-hint
) { color: #55506b !important; }
html:not([data-theme="dark"]) :is(#feed-economics, #feed-health, #feed-education, [id^="feed-"]) td { color: #4a4560 !important; }
html:not([data-theme="dark"]) :is(.event-category, .update-badge, .whats-new-badge) { background: #7a5a12 !important; color: #fff !important; }

/* Dark theme: grays → AA on the dark surfaces. */
html[data-theme="dark"] :is(
  .top-state-pct, .region-top-state, .region-share, .region-pct, .census-map-hint, .loading-text,
  .census-subtitle, .congress-subtitle, .filter-bar-label, .data-stat-label, .data-stat-sub,
  .api-setup-inner p, .sub-header-note, [class*="data-stat"] span, .region-card small
) { color: #c4bedb !important; }
html[data-theme="dark"] [id^="feed-"] :is(th, td) { color: #c4bedb !important; }
html[data-theme="dark"] :is(.event-category, .update-badge, .whats-new-badge) { background: #8a6212 !important; color: #fff !important; }
/* The dark accent is near-white; text on it must be dark. */
html[data-theme="dark"] :is(
  .footer-btn, .month-title, .data-dashboard-header, .data-dashboard-title, .data-dashboard-link,
  .section-callout, .congress-preview-link, .category-btn, .nav-pill, .quick-link
) { color: #171426 !important; }
html[data-theme="dark"] :is(.race-context, .race-context-title, .race-bar-row, .race-pct, .race-highlight) { color: #1c1830 !important; }
html[data-theme="dark"] #race-context-toggle { color: #4b2fa8 !important; }
html[data-theme="dark"] :is(#congress-preview-list p, .sub-header-note) { color: #ff9b9b !important; }

/* Second pass (remaining axe findings). */
html:not([data-theme="dark"]) :is(.top-state-num, .top-state-pct, .top-state-header *, .region-top-list-label) { color: #55506b !important; }
html[data-theme="dark"] :is(footer p, .data-dashboard-source, .census-source p, .census-source strong, #census-source strong) { color: #c4bedb !important; }
html[data-theme="dark"] :is(a[href^="#"].category-link, .category-nav a, #save-api-key, #near-me-btn) { color: #171426 !important; }
html[data-theme="dark"] a[href$="#politicians"], html[data-theme="dark"] a[href$="#professional"],
html[data-theme="dark"] a[href$="#community"], html[data-theme="dark"] a[href$="#news"],
html[data-theme="dark"] a[href$="#business"], html[data-theme="dark"] a[href$="#media"] { color: #171426 !important; }
.stb-black a[href$="sources/"] { color: #c9b8ff !important; }
html:not([data-theme="dark"]) :is(.data-stat-detail, .data-stat-label) { color: #55506b !important; }
html[data-theme="dark"] .quick-links a { color: #171426 !important; }
html[data-theme="dark"] .whats-new-date { color: #c4bedb !important; }
.stb-live-badge, .stb-status-badge.critical { color: #ff8a8a !important; }
html:not([data-theme="dark"]) :is(.data-dashboard-source, .feed-source, .feed-source *) { color: #55506b !important; }
html[data-theme="dark"] .race-context-note { color: #1c1830 !important; }
html[data-theme="dark"] :is(.topic-btn.active, .vote-filter.active) { color: #171426 !important; }
html[data-theme="dark"] .congress-search-row button { color: #171426 !important; }
html[data-theme="dark"] .error-text { color: #ff9b9b !important; } html:not([data-theme="dark"]) .error-text { color: #a8321e !important; }
