/* ============================================================
   @layer theme — skins for migrated pages.
   The palette is scoped to .app-screen (the migrated-page root), NOT
   to body globally, so un-migrated legacy pages are never affected.
   Swapping the skin rebinds --t-* only; no migrated markup changes.
   Token references only — no raw hex (D10).
   ============================================================ */
@layer theme {

  /* Default (desk/light) — inherits the default.css --t-* palette; the
     .app-screen root just re-declares the handful migrated components use
     so a migrated page is self-contained regardless of host context. */
  .app-screen {
    --t-bg: var(--mea-gray-50);        --t-bg-elevated: var(--mea-white);
    --t-bg-recessed: var(--mea-gray-100); --t-bg-active: var(--mea-gray-200);
    --t-text: var(--mea-gray-900);     --t-text-secondary: var(--mea-gray-700); --t-text-muted: var(--mea-gray-600);
    /* Page background text — text on the page bg. --t-bg is light here. */
    --t-bg-text: var(--mea-gray-900);  --t-bg-text-secondary: var(--mea-gray-700); --t-bg-text-muted: var(--mea-gray-600);
    --t-border: var(--mea-gray-200);
    --t-card-bg: var(--mea-white);     --t-card-border: var(--mea-gray-200);
    --t-accent: var(--mea-blue);       --t-accent-hover: var(--mea-blue-dark); --t-accent-text: var(--mea-white);
    --t-success: var(--mea-green);     --t-success-text: var(--mea-green-dark);
    --t-warning: var(--mea-amber);     --t-warning-text: var(--mea-amber-dark);
    --t-error: var(--mea-red);         --t-error-text: var(--mea-red-dark);
    --t-link: var(--mea-blue);         --t-link-hover: var(--mea-blue-dark);
    --t-border-focus: var(--mea-blue);
    /* Hero card + progress track + primary CTA (light/staff persona — the
       DA console uses a solid royal CTA, faithful to MEA-DA-Dashboard). */
    --t-hero-bg: var(--mea-white);     --t-hero-shadow: var(--mea-shadow-card);
    --t-track: var(--mea-gray-200);
    --t-cta-bg: var(--mea-blue);       --t-cta-shadow: var(--mea-shadow-sm); --t-cta-text: var(--mea-white);

	--t-danger-bg: var(--mea-red);
	--t-danger-fg: var(--mea-red-dark);
  }

  /* Citizen (participant) dark identity. Applies only to migrated content
     under the participant theme — legacy citizen styling is untouched. */
  body.citizen-theme .app-screen {
    --t-bg: var(--mea-dark);           --t-bg-elevated: var(--mea-card-dark);
    --t-bg-recessed: var(--mea-dark-2); --t-bg-active: var(--mea-navy-mid);
    --t-text: var(--mea-white);        --t-text-secondary: var(--mea-cg-3); --t-text-muted: var(--mea-cg-4);
    /* Page background text — text on the page bg. --t-bg is dark here. */
    --t-bg-text: var(--mea-white);     --t-bg-text-secondary: var(--mea-cg-3); --t-bg-text-muted: var(--mea-cg-4);
    --t-border: var(--mea-navy-light);
    --t-card-bg: var(--mea-white); --t-card-border: var(--mea-gray-200);
    /* Accent FILLS use the royal-blue family both design references specify
       for participant CTAs (reconciliation 2026-06-09); baby-blue had no
       design provenance as an accent. Bright royal pops on the #060A1E
       surface; white text sits on the fill. Baby-blue is retained only
       where it is genuinely contrast-safe on dark: text links and the
       focus ring. */
    --t-accent: var(--mea-blue-bright); --t-accent-hover: var(--mea-blue); --t-accent-text: var(--mea-white);
    --t-success: var(--mea-green-mobile); --t-success-text: var(--mea-green-mobile);
    --t-warning: var(--mea-amber);     --t-warning-text: var(--mea-amber);
    --t-error: var(--mea-red);         --t-error-text: var(--mea-red-muted);
    --t-link: var(--mea-baby-blue);    --t-link-hover: var(--mea-baby-mid);
    --t-border-focus: var(--mea-baby-blue);
    /* Hero card gets the dark-card gradient + depth shadow; the progress
       track is a visible translucent white (was #0A0F30-on-#0F1540, invisible).
       Primary CTA gets the royal-blue gradient pill + glow both references
       specify. (reconciliation 2026-06-09) */
    --t-hero-bg: var(--mea-grad-dark-card); --t-hero-shadow: var(--mea-shadow-hero);
    --t-track: color-mix(in srgb, var(--mea-white) 14%, transparent);
    --t-cta-bg: var(--mea-grad-cta);   --t-cta-shadow: var(--mea-shadow-btn); --t-cta-text: var(--mea-white);
  }

  /* White cards on the participant dark page. The block above sets --t-text
     and the --t-bg-* family for the dark page, but participant content sits
     on --t-card-bg (white) cards, which then showed white text and navy
     controls. Every class that paints --t-card-bg is listed here unless it
     rebinds --t-text itself (.onboarding-panel);
     web/tests/test_card_palette.py fails when a new one is left out. Page-level
     text keeps the dark-page values. .stat and .proof-assurance are white
     surfaces painted another way. Desk pages need it too: the desk shell's
     body text is white for the dark page, so a white card that sets no
     color of its own inherited white text. .pane is the design-system pane,
     a raised surface: its components read the surface, and legacy markup
     inside it reads these. */
  :is(body.citizen-theme .app-screen, body.desk-portal) :is(
    .active-timer, .ada-board,
    .balance, .bulk-action-bar,
    .dashboard-actions,
    .deal-modal,
    .drill-modal,
    .feedback-panel, .history, .invite-handoff,
    .issue-citizen, .issue-facts, .issue-screening, .issue-statement,
    .officer-citation, .officer-issue__body,
    .onboarding-media__card, .onboarding-overlay__panel, .pane, .payment-action,
    .payment-dialog, .proof-assurance, .proof-empty, .proof-ledger,
    .restitution-empty, .schedule,
    .stat-figure,
    .tracker-panel,
    .tracker-stat, .upcoming-task
  ) {
    color: var(--t-text);
    --t-text: var(--mea-gray-900);     --t-text-secondary: var(--mea-gray-700); --t-text-muted: var(--mea-gray-600);
    --t-bg: var(--mea-white);
    /* Text on --t-bg follows it: inside the card that is white. */
    --t-bg-text: var(--mea-gray-900);  --t-bg-text-secondary: var(--mea-gray-700); --t-bg-text-muted: var(--mea-gray-600);
    --t-bg-elevated: var(--mea-white); --t-bg-recessed: var(--mea-gray-100); --t-bg-active: var(--mea-gray-200);
    --t-border: var(--mea-gray-200);
    /* Numbers and amounts are coloured with the fill tokens, so those take
       the dark variants too (also better behind white marker glyphs). */
    --t-success: var(--mea-green-dark); --t-warning: var(--mea-amber-dark);
    --t-success-text: var(--mea-green-dark); --t-warning-text: var(--mea-amber-dark);
    --t-error-text: var(--mea-red-dark);
    --t-link: var(--mea-blue);         --t-link-hover: var(--mea-blue-dark);
    --t-border-focus: var(--mea-blue);
  }

}
