/* =============================================================================
   AIToolsay — Dark-mode button contrast corrections
   -----------------------------------------------------------------------------
   Loaded last in <head> from layouts/public.blade.php, on every public page.

   ── WHY THIS FILE EXISTS ───────────────────────────────────────────────────
   A DOM-wide contrast audit in dark mode (11 pages) found 24 distinct button
   classes whose label failed WCAG AA against their own fill. They were not 24
   separate mistakes — they were two, repeated across every kit on the site:

   A. `#60A4F5` USED AS A FILL.  That colour is --aits-blue-light: an INK token.
      Dark mode substitutes it for the brand blue so that *text and glyphs* stay
      legible on a dark card. Several kits then paint BUTTONS with it and put
      white text on top → **2.58:1**, and 1.67:1 where a lighter stop exists.
      This is the "button text is not visible in dark mode" report.

   B. `#3680ED` (brand blue) UNDER WHITE TEXT → **3.84:1**. Fails AA (4.5:1) by a
      little; legible but not compliant. Corrected here in DARK ONLY, because in
      light mode the same fill is the site's primary-button look on every page
      and changing it there is a design decision, not a bug fix. See the note at
      the end of this file.

   ── THE REPLACEMENT RAMP IS MEASURED ───────────────────────────────────────
   White-on-fill contrast:  #2E6FD0 4.88:1 · #2762C2 5.81:1 · #1B4E9E 7.98:1
   so the worst point of the gradient clears AA for normal-size labels, and
   clears the 3:1 non-text minimum for white glyphs sitting on the same fill.
   Anything lighter than ~#2E6FD0 under white text fails — compute before
   changing. Brand blue #3680ED is fine for ink, borders and tints; it must
   never sit under white text.

   ── WHY !important ─────────────────────────────────────────────────────────
   These classes live in ~10 independent kits, several of which ship their CSS
   in an inline <style> inside the component blade — i.e. AFTER this file, so
   they win any specificity tie. This is a corrective layer over code it does
   not own; !important is the honest tool for that, and it is confined to the
   two properties that carry the defect. Fix a kit at source and delete its
   selector from here.
   ========================================================================== */

body.theme-dark {
  --aa-fill-1: #2E6FD0;
  --aa-fill-2: #2762C2;
  --aa-fill-3: #1B4E9E;
  --aa-fill: linear-gradient(135deg, var(--aa-fill-1), var(--aa-fill-2) 52%, var(--aa-fill-3));
}

/* ── A · Ink token used as a fill (2.58:1 and worse) ────────────────────────
   Homepage Studio (.hpx-*), the sitewide footer newsletter button, the shared
   form-pages kit, and the AI-models directory. */
body.theme-dark .hpx-search-btn,
body.theme-dark .hpx-btn.hpx-btn-solid,
body.theme-dark .hpx-tab.is-on,
body.theme-dark .hpx-nrtab.is-on,
body.theme-dark .aitsft-nl-btn,
body.theme-dark .aitfm-btn,
body.theme-dark .dir-tc-btn,

/* ── B · Brand blue under white (3.53–3.84:1) ───────────────────────────────
   The header CTA is on EVERY page; the rest are the per-kit primary buttons. */
body.theme-dark .aitshd-cta-primary,
body.theme-dark .aits-btn.aits-btn-primary,
body.theme-dark .aits-btn.aits-btn-gradient,
body.theme-dark .aits-btn-search,
body.theme-dark .ezb-rt-btn,
body.theme-dark .dir-hh-search-btn,
body.theme-dark .dir-fx-apply,
body.theme-dark .dir-tb-views .is-on,
body.theme-dark .nwsp-skip,
body.theme-dark .gdp-btn.gdp-btn-primary,
body.theme-dark .dl-btn,
/* `.pa-btn` only — NOT `.pa-act__btn`. The article's two action cards carry
   their own measured ramps (the amber one is dark-ink-on-amber, which this
   layer would wreck by repainting it brand blue and leaving dark ink on it). */
body.theme-dark .pa-btn:not(.pa-act__btn),
body.theme-dark .pa-authorbox .pa-ab-cta,

/* ── Deals kit ──────────────────────────────────────────────────────────────
   All three run `#2060C0 → #3680ED → #60A4F5`, i.e. the ramp ENDS on the pale
   ink token, so the far half of every button is the unreadable half.
   `.go` is scoped through `.dl-card` — on its own it is far too generic a
   class name to touch site-wide. */
body.theme-dark .dl-deal-btn,
body.theme-dark .dl-sub,
body.theme-dark .dl-card .go {
  background-image: var(--aa-fill) !important;
  /* A background-COLOR under the gradient matters: several of these kits paint
     a flat colour and no image, and a few animate the image on hover — if the
     image is ever dropped, the colour underneath must still be AA-safe. */
  background-color: var(--aa-fill-2) !important;
  color: #fff !important;
}

/* Keep the hover states from re-introducing a pale fill. */
body.theme-dark .hpx-search-btn:hover,
body.theme-dark .hpx-btn.hpx-btn-solid:hover,
body.theme-dark .aitsft-nl-btn:hover,
body.theme-dark .aitfm-btn:hover,
body.theme-dark .dir-tc-btn:hover,
body.theme-dark .aitshd-cta-primary:hover,
body.theme-dark .aits-btn.aits-btn-primary:hover,
body.theme-dark .aits-btn.aits-btn-gradient:hover,
body.theme-dark .aits-btn-search:hover,
body.theme-dark .ezb-rt-btn:hover,
body.theme-dark .dir-hh-search-btn:hover,
body.theme-dark .dir-fx-apply:hover,
body.theme-dark .gdp-btn.gdp-btn-primary:hover,
body.theme-dark .dl-btn:hover,
body.theme-dark .dl-deal-btn:hover,
body.theme-dark .dl-sub:hover,
body.theme-dark .dl-card .go:hover {
  /* One stop deeper than rest, so hover still reads as a state change while
     moving AWAY from the failing direction rather than toward it. */
  background-image: linear-gradient(135deg, var(--aa-fill-2), var(--aa-fill-3)) !important;
  background-color: var(--aa-fill-3) !important;
  color: #fff !important;
}

/* ── C · Inverted one-offs ──────────────────────────────────────────────────
   These are not "too pale" — their fill and their ink are the same lightness,
   so the label is effectively invisible. Each needs ink, not a new fill. */

/* /guides — a WHITE button whose label was recoloured to #C9C9CE for dark,
   leaving light-grey text on a white pill (1.65:1). The fill is correct for a
   secondary button; the ink is what is wrong. */
body.theme-dark .gdp-btn.gdp-btn-light {
  color: #16202c !important;
  border-color: rgba(16, 32, 44, .14) !important;
}
body.theme-dark .gdp-btn.gdp-btn-light:hover { color: #0f1720 !important; }

/* /ai-models — the ACTIVE news tab fills with a pale violet (#BFA6FB) and keeps
   white text (1.57:1). Scoped to `.is-on` on purpose: the inactive tabs have a
   transparent fill and light ink, and giving THEM dark ink would invert the
   bug onto the other half of the control. */
body.theme-dark .dir-nr-tab.is-on {
  color: #241a4d !important;
}

/* /gpts — the ten category chips kept a WHITE surface in dark mode while their
   ink followed the theme to near-white: #F5F5F6 on #FFFFFF = 1.09:1, i.e. the
   labels are simply not there. The surface is the half that is wrong, so it
   gets the site's own dark-chip treatment (same values as .dl-chip on /deals)
   rather than the fill ramp — these are chips, not buttons. */
body.theme-dark .gptp-chip {
  background: rgba(255, 255, 255, .07) !important;
  border-color: rgba(255, 255, 255, .14) !important;
  color: #D4DDF2 !important;
}

/* ── STILL OUTSTANDING, deliberately ────────────────────────────────────────
   In LIGHT mode, brand blue #3680ED under white text is 3.84:1 and also fails
   AA. It is not corrected here because it is the primary-button fill on every
   page of the site in the theme most people see, so deepening it is a design
   change to sign off, not a defect to patch silently. The ramp above is the
   drop-in if that call gets made — remove the `body.theme-dark` scope. */
