/* ==========================================================================
   AIM TOKEN COMPAT LAYER  —  deprecated names, repointed at the canonical set
   --------------------------------------------------------------------------
   Load AFTER aim-canonical.css.

   WHY THIS EXISTS
   446 CSS files consume the old vocabulary. Renaming them all at once is a
   446-file diff nobody can review. Instead every deprecated name becomes an
   ALIAS of its canonical equivalent, so from this commit there is exactly ONE
   value per concept even though the callsites still say the old thing.

   That inverts the historical failure. The 2026-08-05 audit found twelve
   comments in theme-definitions.css recording a missing token being DEFINED
   rather than the callsite corrected — each rescue grew the vocabulary and the
   wrong name became permanently valid. This file does the opposite: it makes
   the wrong names harmless AND redundant, so the codemod that follows is a
   pure find-and-replace with no behaviour change.

   ORDER OF WORK
     1. this file lands                     -> one value per concept, no diff
     2. CSS12 ratchet lands                 -> no NEW use of a deprecated name
     3. codemod, file by file               -> callsites move to canonical
     4. delete this file                    -> vocabulary is actually gone

   Anything below is deletable once step 3 clears its consumers. Nothing new
   should ever be added here.
   ========================================================================== */

/* ==========================================================================
   TIER A — no visual change.
   These already resolved to the canonical value. Repointed so there is one
   source of truth rather than several that happen to agree.
   ========================================================================== */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {

  /* surfaces ------------------------------------------------------------- */
  --surface-base:            var(--ground);
  --surface-1:               var(--ground);
  --surface-3:               var(--ground);
  --body-bg-color:           var(--ground);
  --dashboard-bg:            var(--ground);

  --surface-raised:          var(--raised);
  --surface-2:               var(--raised);
  --surface:                 var(--raised);
  --surface-content:         var(--raised);
  --surface-elevated:        var(--raised);
  --surface-overlay:         var(--raised);
  --color-surface:           var(--raised);
  --surface-primary:         var(--raised);

  --surface-anchor:          var(--anchor);
  --card-header-bg:          var(--anchor);
  --color-hover-bg:          var(--anchor);
  --surface-row-hover:       var(--anchor);
  --color-table-header-bg:   var(--anchor);

  --surface-row-stripe:      var(--sunken);
  --main-input-background:   var(--sunken);
  --color-secondary-bg:      var(--sunken);

  /* ink ------------------------------------------------------------------ */
  --color-text-primary:      var(--ink);
  --color-text:              var(--ink);
  --body-text-color:         var(--ink);

  --color-text-secondary:    var(--ink-muted);
  --color-text-muted:        var(--ink-muted);
  --color-secondary:         var(--ink-muted);
  --colour-text-secondary:   var(--ink-muted);   /* British-spelling stragglers */
  --colour-text-primary:     var(--ink);
  --colour-text-muted:       var(--ink-muted);

  --color-text-tertiary:     var(--ink-faint);
  --text-tertiary:           var(--ink-faint);

  /* line ----------------------------------------------------------------- */
  --border-subtle:           var(--line);
  --color-border-light:      var(--line);
  --border-default:          var(--line);
  --color-border:            var(--line);
  --colour-border:           var(--line);
  --table-border-color:      var(--line);
  --aim-table-cell-border:   var(--line);

  --border-strong:           var(--line-strong);
  --color-border-strong:     var(--line-strong);

  /* table chrome --------------------------------------------------------- */
  --aim-table-header-bg:     var(--anchor);
  --aim-table-header-color:  var(--ink);
  --aim-table-header-border: var(--line);
  --aim-table-stripe-bg:     var(--sunken);
  --aim-table-row-hover:     var(--anchor);
  --aim-table-sticky-col-bg: var(--raised);
  --aim-table-sticky-col-header-bg: var(--anchor);
  --aim-table-section-divider-bg:   var(--anchor);
  --aim-table-row-nested-bg: var(--anchor);
  --table-header-bg:         var(--anchor);
  --table-hover-bg:          var(--anchor);

  /* elevation ------------------------------------------------------------ */
  --shadow-sm:               var(--lift-1);
  --shadow-md:               var(--lift-2);
  --shadow-lg:               var(--lift-3);

  /* focus ---------------------------------------------------------------- */
  /* was declared once at :root and never redeclared per theme, so it resolved
     to the LIGHT slate in dark mode — 1.14:1, i.e. invisible. Routed through
     --brand-edge, which every theme block does define. */
  --focus-ring-color:        var(--brand-edge);
  --focus-ring-halo:         var(--action-wash);
}

/* ==========================================================================
   TIER B — agreed visual change (unification plan, 2026-08-05).
   The action colour moves from #2563EB to the AIM secondary blue, which is
   what it was always closest to. dE from the old value is 39; from the blue
   James picked (#4b7bc5) it is 8.1.
   ========================================================================== */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {
  --interactive-base:        var(--action);
  --interactive-hover:       var(--action-hover);
  --main-link-color:         var(--action);
  --body-link-color:         var(--action);
  --primary:                 var(--action);
  --action-primary:          var(--action);
  --color-aim-secondary:     var(--action);
  --main-link-highlight:     var(--action-hover);
  --body-link-hover-color:   var(--action-hover);
}

/* ==========================================================================
   TIER C — visual change, wants a look before it lands.
   Everything below is correct but VISIBLE. Comment the block out to stage it.
   ========================================================================== */

/* C1 · the forked semantics.
   --color-danger is #EF4444 in 122 files; --color-danger-medium is #B91C1C in
   87; --status-danger aliases the second in 109. Two visibly different reds,
   both current, both correct-looking at the callsite. Same split for warning,
   success and info. This collapses each to one value.                        */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {
  --color-danger:            var(--bad);
  --color-danger-medium:     var(--bad);
  --status-danger:           var(--bad);
  --danger:                  var(--bad);
  --color-state-error:       var(--bad);
  --color-danger-bg:         var(--bad-wash);

  --color-warning:           var(--warn);
  --color-warning-medium:    var(--warn);
  --status-warning:          var(--warn);
  --warning:                 var(--warn);
  --color-state-warning:     var(--warn);
  --color-warning-bg:        var(--warn-wash);

  --color-success:           var(--ok);
  --color-success-medium:    var(--ok);
  --status-success:          var(--ok);
  --success:                 var(--ok);
  --color-state-success:     var(--ok);
  --color-success-bg:        var(--ok-wash);

  --color-info:              var(--info);
  --color-info-medium:       var(--info);
  --status-info:             var(--info);
  --info-color:              var(--info);
  --color-info-bg:           var(--info-wash);
}

/* C2 · the static-pastel fix.
   361 rules use a *-lightest token directly as a background. Those are fixed
   values that do not respond to theme — the exact pattern tables.md already
   bans for rows, which then migrated into 91 badge blocks, 10 of them inside
   the canonical aim-badges.css. Routing them through the washes makes every
   one theme-aware without touching a single component.                       */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {
  --color-danger-lightest:   var(--bad-wash);
  --color-warning-lightest:  var(--warn-wash);
  --color-success-lightest:  var(--ok-wash);
  --color-info-lightest:     var(--info-wash);
  --color-primary-lightest:  var(--action-wash);
  --color-primary-bg:        var(--action-wash);
  --color-primary-bg-hover:  var(--action-wash);
  --aim-danger-light:        var(--bad-wash);
  --color-error-50:          var(--bad-wash);
  --color-warning-50:        var(--warn-wash);
  --color-gray-50:           var(--sunken);
}

/* C3 · retire the navy panel family.
   --panel-* is a complete parallel design system for the same job: navy fill,
   white text, fully themed across all four blocks so it looks maintained. Its
   markup is unreachable — the only consumer, _MenuPanelSection.cshtml, is
   never included by any page — but the CSS survives in panels.css (20 uses)
   and site-details.css (3). Repointing turns the navy surfaces white.
   NOTE: PanoramaViewer also consumes these; check it before enabling.        */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {
  --panel-bg:                var(--raised);
  --panel-header-bg:         var(--anchor);
  --panel-text:              var(--ink);
  --panel-text-secondary:    var(--ink-muted);
  --panel-border:            var(--line);
  --panel-hover:             var(--anchor);
}

/* C4 · phantoms.
   313 names are consumed but never defined — 1,906 references across 142
   files, each silently resolving to whatever fallback happened to be typed.
   These are the ones with real consumer counts. The rest surface as the
   codemod runs; add them here only if a page breaks, never speculatively.    */
:root,
[data-theme="aim-dark"],
[data-theme="cornerstone-light"],
[data-theme="cornerstone-dark"] {
  --color-gray-300:          var(--line);
  --color-gray-400:          var(--ink-faint);
  --color-gray-500:          var(--ink-muted);
  --color-gray-600:          var(--ink-muted);
  --color-gray-800:          var(--ink);
  --color-gray-900:          var(--ink);
  --color-bg-hover:          var(--anchor);
  --color-primary-hover:     var(--action-hover);
  --color-error-600:         var(--bad);
  --color-success-600:       var(--ok);
  --am-primary:              var(--action);
  --aim-primary:             var(--action);
  --aim-border:              var(--line);
  --aim-danger:              var(--bad);
  --aim-success:             var(--ok);
  --aim-warning:             var(--warn);
  --aim-text-primary:        var(--ink);
  --aim-text-secondary:      var(--ink-muted);
  --color-surface-raised:    var(--raised);   /* near-miss typo of --surface-raised */
  --color-text-disabled:     var(--ink-faint);
  --overlay-bg:              rgba(0, 0, 0, .45);
  --z-overlay:               1020;
  --z-modal-backdrop:        1040;
  --z-toast:                 1050;
  --z-sticky:                1000;
  --z-popover:               1010;
}
