/*  rushxo-v2.css  --  sitewide contrast repair layer
 *  ==================================================
 *  WHY THIS FILE EXISTS
 *  Every page carries an inline dark retrofit (<style id="rx-dark-theme"> plus
 *  <style id="rx-universal-dark">). Those blocks force light text with !important on
 *  very broad selectors -- p,li,td / strong,b / a / section[style] a /
 *  [style*="background:#142c44"] *. A number of components, however, kept the light
 *  background of the original light design: .fare-table, .veh-card, .breadcrumb,
 *  .chip, and the inline "background:#F8F8F8" town / route pills. Their text ends up
 *  white on white and is invisible.
 *
 *  The mirror fault exists too: components whose background WAS darkened by the
 *  retrofit (.quote-card and friends) still take dark text from the original
 *  stylesheet (.qmeta .val, .field-value, .section-head h2) -- navy on navy.
 *
 *  This file repairs both directions. It is pulled in by the <link> that already
 *  exists on every page, so no page markup has to change.
 *
 *  HOW THE CASCADE IS HANDLED
 *  The <link> to this file sits BEFORE the inline retrofit <style> blocks, so an
 *  equal-specificity rule here would lose. Every rule below uses !important plus a
 *  specificity boost -- the harmless [class] / [style] attribute selector in front of
 *  :is(...) -- so it out-ranks .qmeta .val, section[style] a and .section-head h2
 *  without touching any markup.
 *  Section order matters: light-surface rules come last and carry one extra [class]
 *  so that a light card nested inside a dark card wins (e.g. .veh.active inside
 *  .quote-card).
 *
 *  A runtime safety net lives in /ghostfix.js. It measures real contrast after paint
 *  and repairs anything this static layer does not know about.
 */

:root{
  --rx-ink:#0d1b2a;        /* primary text on a light surface   */
  --rx-ink-soft:#4a5b6d;   /* secondary text on a light surface */
  --rx-ink-link:#0a6f4a;   /* brand green, darkened for light   */
  --rx-paper:#e8eef4;      /* primary text on a dark surface    */
  --rx-paper-soft:#b6c8da; /* secondary text on a dark surface  */
  --rx-paper-link:#7df3bf; /* brand green, lifted for dark      */
}

/* =====================================================================
   1  DARK SURFACES LEFT WITH DARK TEXT   (navy on navy)
   ===================================================================== */
[class]:is(.quote-card,.feature-card,.fleet-card,.how-step,.trust-card),
[class]:is(.quote-card,.feature-card,.fleet-card,.how-step,.trust-card) :is(.val,.field-value,.veh-name,.handle,.a,summary,p,li,td,h3,h4){
  color:var(--rx-paper) !important;
  -webkit-text-fill-color:var(--rx-paper) !important;
}

[class]:is(.quote-card,.feature-card,.fleet-card,.how-step,.trust-card) :is(.qlab,.lab,.label,.field-label,.hero-stat-label,.veh-cap,[class*="-label"],[class*="-cap"]){
  color:var(--rx-paper-soft) !important;
  -webkit-text-fill-color:var(--rx-paper-soft) !important;
}

/* section headings pinned to navy by ".section-head h2{color:#0d1b2a !important}" */
[class]:is(.section-head,.sec-head) :is(h1,h2,h3,h4){
  color:var(--rx-paper) !important;
  -webkit-text-fill-color:var(--rx-paper) !important;
}
[class]:is(.section-head,.sec-head) :is(h1,h2,h3,h4) em{
  color:var(--rx-paper-link) !important;
  -webkit-text-fill-color:var(--rx-paper-link) !important;
}

/* =====================================================================
   2  LIGHT SURFACES THAT INHERITED LIGHT TEXT   (white on white)
   ===================================================================== */
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured),
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) *{
  color:var(--rx-ink) !important;
  -webkit-text-fill-color:var(--rx-ink) !important;
}

/* secondary / muted copy inside those surfaces */
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) :is(small,.sub,.muted,.meta,.note,.cap,.veh-cap,.lab,.label,.qlab,[class*="-label"],[class*="-cap"],[class*="-meta"]){
  color:var(--rx-ink-soft) !important;
  -webkit-text-fill-color:var(--rx-ink-soft) !important;
}

/* links and green accents stay on brand, just dark enough to read on light */
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) a,
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) a *,
[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) :is(.stars,.pin,.rating,.pr,.icon,[class*="num"],[class*="price"],[class*="fare"]){
  color:var(--rx-ink-link) !important;
  -webkit-text-fill-color:var(--rx-ink-link) !important;
}

[class][class]:is(.breadcrumb,.topbar,.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table,.area-card,.feat-card,.info-card,.note-card,.tip-card,.veh-card,.veh.active,.test-card,.pop-card,.time-pill,.coord-pill,.chip,.trust-badge,.review-widget,.map-card,.hero-stats,.j-stat,.pp,.callout,.related,.featured) a:focus-visible{
  outline:2px solid var(--rx-ink-link) !important;
  outline-offset:2px !important;
}

/* a dark header bar inside one of those light tables keeps its light text */
[class][class]:is(.fare-table,.fares-table,.compare-table,.price-table,.times-table,.incl-table) thead :is(th,td){
  color:var(--rx-paper) !important;
  -webkit-text-fill-color:var(--rx-paper) !important;
}

/* =====================================================================
   3  INLINE LIGHT BACKGROUNDS  (the town / route pill links)
      <a style="...background:#F8F8F8; ... color:#1A1A1A ...">Norwich</a>
   ===================================================================== */
[style][style]:is([style*="background:#f8f8f8" i],[style*="background: #f8f8f8" i],[style*="background:#f9f9f9" i],[style*="background: #f9f9f9" i],[style*="background:#fafafa" i],[style*="background: #fafafa" i],[style*="background:#f5f5f5" i],[style*="background: #f5f5f5" i],[style*="background:#f0f0f0" i],[style*="background: #f0f0f0" i],[style*="background:#eee" i],[style*="background: #eee" i],[style*="background:#f4f1ea" i],[style*="background: #f4f1ea" i],[style*="background:#f3f3f0" i],[style*="background: #f3f3f0" i],[style*="background:#ede9df" i],[style*="background: #ede9df" i],[style*="background:#f6f0e2" i],[style*="background: #f6f0e2" i],[style*="background:#fff9e6" i],[style*="background: #fff9e6" i],[style*="background:#fefefe" i],[style*="background: #fefefe" i],[style*="background:#ffffff" i],[style*="background: #ffffff" i],[style*="background:#fff" i],[style*="background: #fff" i]),
[style][style]:is([style*="background:#f8f8f8" i],[style*="background: #f8f8f8" i],[style*="background:#f9f9f9" i],[style*="background: #f9f9f9" i],[style*="background:#fafafa" i],[style*="background: #fafafa" i],[style*="background:#f5f5f5" i],[style*="background: #f5f5f5" i],[style*="background:#f0f0f0" i],[style*="background: #f0f0f0" i],[style*="background:#eee" i],[style*="background: #eee" i],[style*="background:#f4f1ea" i],[style*="background: #f4f1ea" i],[style*="background:#f3f3f0" i],[style*="background: #f3f3f0" i],[style*="background:#ede9df" i],[style*="background: #ede9df" i],[style*="background:#f6f0e2" i],[style*="background: #f6f0e2" i],[style*="background:#fff9e6" i],[style*="background: #fff9e6" i],[style*="background:#fefefe" i],[style*="background: #fefefe" i],[style*="background:#ffffff" i],[style*="background: #ffffff" i],[style*="background:#fff" i],[style*="background: #fff" i]) *{
  color:var(--rx-ink) !important;
  -webkit-text-fill-color:var(--rx-ink) !important;
}
