/* CCSA Natal Midlands v55.12.41 — all-theme readability and WCAG 2.2 AA contrast repair. */

/* Complete the semantic token set used by older modules. A number of legacy
   components referenced these aliases without defining them in every theme. */
html[data-theme] {
  --text: var(--cream);
  --text-soft: var(--muted);
  --surface-2: var(--surface-raised);
  --panel: var(--surface);
  --panel-strong: var(--surface-raised);
  --panel-2: var(--surface-soft);
  --line: var(--border);
  --gold-border: var(--border-strong);
  --accent: var(--gold);
  --accent-2: var(--gold-light);
  --accent-contrast: var(--ink);
  --on-accent: var(--ink);
  --field: var(--surface-raised);
  --display-font: var(--font-display);
  --a11y-action-bg: var(--gold);
  --a11y-action-text: var(--ink);
  --a11y-data-bg: #123b28;
  --a11y-data-bg-alt: #0d2f20;
  --a11y-data-text: #fffaf0;
  --a11y-data-muted: #e8ded0;
  --a11y-data-accent: #ffe27c;
}

/* Themes whose primary action is deliberately dark rather than gold. */
html[data-theme="roadside-50s"] { --a11y-action-bg:#8f151a; --a11y-action-text:#ffffff; }
html[data-theme="alpine-explorer"] { --a11y-action-bg:#1e533b; --a11y-action-text:#ffffff; }
html[data-theme="midnight-rally"] { --a11y-action-bg:#d7141d; --a11y-action-text:#ffffff; }
html[data-theme="safari-lodge"] { --a11y-action-bg:#9c3e22; --a11y-action-text:#ffffff; }

/* Primary, selected and pressed controls must retain readable text in every
   palette. This includes controls rendered by modules after initial load. */
html[data-theme] :where(
  button.active,
  button.is-active,
  button[aria-pressed="true"],
  .primary,
  .admin-primary-btn,
  .classifieds-primary,
  .intention-submit,
  .park-rating-submit,
  #parkRatingSubmit,
  .settings-update-button,
  .settings-profile-submit:not(:disabled),
  .notification-setup-modal-actions .primary
) {
  color:var(--a11y-action-text) !important;
  -webkit-text-fill-color:var(--a11y-action-text) !important;
  background-color:var(--a11y-action-bg) !important;
  background-image:none !important;
  border-color:var(--a11y-action-bg) !important;
}

/* Admin statistics and storage panels intentionally use a dark data surface.
   Locally redefining the semantic variables prevents light-theme ink from
   being inherited onto these dark green cards. */
html[data-theme] :where(
  .admin-viz-metric,
  .admin-viz-card,
  .admin-classified-storage,
  .admin-game-testing-tools,
  .admin-stats > div
) {
  --cream:var(--a11y-data-text);
  --muted:var(--a11y-data-muted);
  --gold:var(--a11y-data-accent);
  --gold-light:var(--a11y-data-accent);
  --text:var(--a11y-data-text);
  --text-soft:var(--a11y-data-muted);
  --surface:var(--a11y-data-bg-alt);
  --surface-raised:var(--a11y-data-bg);
  --surface-soft:var(--a11y-data-bg);
  --panel:var(--a11y-data-bg-alt);
  --panel-strong:var(--a11y-data-bg);
  --border:rgba(255,226,124,.28);
  --border-strong:rgba(255,226,124,.56);
  color:var(--a11y-data-text) !important;
  background-color:var(--a11y-data-bg) !important;
  background-image:linear-gradient(145deg,var(--a11y-data-bg),var(--a11y-data-bg-alt)) !important;
  border-color:rgba(255,226,124,.44) !important;
}
html[data-theme] :where(
  .admin-viz-metric,
  .admin-viz-card,
  .admin-classified-storage,
  .admin-game-testing-tools,
  .admin-stats > div
) :where(h1,h2,h3,h4,h5,h6,strong,label,legend,button) {
  color:var(--a11y-data-text) !important;
  -webkit-text-fill-color:var(--a11y-data-text) !important;
}
html[data-theme] :where(
  .admin-viz-metric,
  .admin-viz-card,
  .admin-classified-storage,
  .admin-game-testing-tools,
  .admin-stats > div
) :where(p,small,span,em,li,dt,dd) {
  color:var(--a11y-data-muted) !important;
  -webkit-text-fill-color:var(--a11y-data-muted) !important;
}
html[data-theme] :where(
  .admin-viz-card > header span,
  .admin-viz-card > header > strong,
  .admin-classified-storage .admin-overline,
  .admin-classified-storage-heading > span,
  .admin-viz-metric > span
) {
  color:var(--a11y-data-accent) !important;
  -webkit-text-fill-color:var(--a11y-data-accent) !important;
}
html[data-theme] .admin-classified-storage-grid > div,
html[data-theme] .admin-viz-legend > div,
html[data-theme] .admin-viz-ring-item,
html[data-theme] .admin-viz-activity-row {
  color:var(--a11y-data-text) !important;
  background:var(--a11y-data-bg-alt) !important;
  border-color:rgba(255,226,124,.28) !important;
}

/* Light reading themes: strengthen supporting copy and small accent text. */
html[data-theme="roadside-50s"] :where(.section-kicker,.screen:not(#screen-home) .section-kicker) { color:#155b57 !important; }
html[data-theme="roadside-50s"] :where(.programme-note,.rally-total,.home-universal-search-hint,.sub,.muted,.hint) { color:#51443a !important; }
html[data-theme="heritage-club"] .screen:not(#screen-home) :where(.section-kicker,.game-card-arrow) { color:#5b3d11 !important; }
html[data-theme="alpine-explorer"] :where(.tile.visual-tile .sub,.game-card-arrow) { color:#3d4d45 !important; }
html[data-theme="safari-lodge"] :where(.tile.visual-tile .sub,.game-card-arrow) { color:#47483d !important; }

/* Midnight red is decorative on small text; use a lighter red where it is
   presented on the dark interface, while keeping solid red action buttons. */
html[data-theme="midnight-rally"] :where(
  .section-kicker,.screen-kicker,.tile-overline,.settings-overline,.committee-overline,
  .faq-overline,.intention-overline,.newsletter-overline,.calendar-overline,
  .notice-overline,.resource-overline,.recipe-overline,.merch-overline,.game-card-arrow
) {
  color:#ff5960 !important;
  -webkit-text-fill-color:#ff5960 !important;
}
html[data-theme="midnight-rally"] :where(.intention-step-number,.intention-step span:first-child) {
  color:#ffffff !important;
  -webkit-text-fill-color:#ffffff !important;
}

/* The small AI badge and common programme overlines had inherited foregrounds
   intended for gold backgrounds. */
html[data-theme] .faq-ai-badge {
  color:var(--a11y-action-text) !important;
  -webkit-text-fill-color:var(--a11y-action-text) !important;
  background:var(--a11y-action-bg) !important;
}
html[data-theme] .tile-overline { text-shadow:none !important; }

/* Form text and placeholders remain readable, including browser autofill. */
html[data-theme] :where(input,textarea,select) {
  caret-color:currentColor;
}
html[data-theme] :where(input,textarea)::placeholder {
  color:currentColor !important;
  -webkit-text-fill-color:currentColor !important;
  opacity:.72 !important;
}
html[data-theme] :where(input,textarea):-webkit-autofill,
html[data-theme] :where(input,textarea):-webkit-autofill:hover,
html[data-theme] :where(input,textarea):-webkit-autofill:focus {
  -webkit-text-fill-color:var(--text) !important;
  transition:background-color 99999s ease-out 0s;
}

/* Avoid the fixed navigation obscuring keyboard focus at AA. */
html { scroll-padding-bottom:calc(7rem + env(safe-area-inset-bottom)); }
html body .app :where(button,a[href],input,select,textarea,summary,[tabindex]):focus-visible {
  scroll-margin-block:5rem 8rem;
}

@media (forced-colors:active) {
  html[data-theme] :where(.admin-viz-metric,.admin-viz-card,.admin-classified-storage,.admin-game-testing-tools,.admin-stats > div) {
    color:CanvasText !important;
    background:Canvas !important;
    border-color:CanvasText !important;
  }
}

/* Admin navigation is a deliberately dark control strip in every theme. */
html[data-theme] {
  --a11y-page-accent:var(--gold-light);
}
html[data-theme="roadside-50s"] { --a11y-page-accent:#6f1116; }
html[data-theme="heritage-club"] { --a11y-page-accent:#5b3d11; }
html[data-theme="alpine-explorer"] { --a11y-page-accent:#1e533b; }
html[data-theme="midnight-rally"] { --a11y-page-accent:#ff5960; }
html[data-theme="safari-lodge"] { --a11y-page-accent:#87371f; }
html[data-theme="luxury"] { --a11y-page-accent:#dbbc95; }

html[data-theme] .admin-section-nav {
  color:var(--a11y-data-text) !important;
  background:#0b2115 !important;
  border-color:rgba(255,226,124,.34) !important;
}
html[data-theme] .admin-section-nav button:not(.active) {
  color:var(--a11y-data-text) !important;
  -webkit-text-fill-color:var(--a11y-data-text) !important;
  background:#12321f !important;
  border-color:rgba(255,226,124,.18) !important;
}
html[data-theme] .admin-signout {
  color:var(--a11y-data-text) !important;
  -webkit-text-fill-color:var(--a11y-data-text) !important;
  background:#12321f !important;
  border-color:rgba(255,226,124,.34) !important;
}
html[data-theme] :where(.admin-welcome .admin-overline,.admin-section-heading>span) {
  color:var(--a11y-page-accent) !important;
  -webkit-text-fill-color:var(--a11y-page-accent) !important;
}
html[data-theme] .admin-stats-view-toggle button:not(.active) {
  color:var(--text) !important;
  -webkit-text-fill-color:var(--text) !important;
  background:var(--surface-raised) !important;
  border-color:var(--border-strong) !important;
}
