/* fincalcs DSS dark-mode overrides (v63.29 — universal coverage fix)
 *
 * Applies to ALL DSS variants: fc-dss-*, st-dss-*, nw-dss-*, sp-dss-*, tx-dss-*
 * (and future variants). v63.25 had selective coverage that produced a
 * checkerboard dark/light in dark mode. v63.29 uses a true universal base
 * rule that catches every -dss-* element, then specific carve-outs preserve
 * intentional colors (banners stay navy, verdict tags stay color-coded,
 * matrix status icons keep their semantic hues).
 *
 * Wrapped in @media — zero impact in light mode.
 */

@media (prefers-color-scheme: dark) {

  /* ────────────────────────────────────────────────────────────
   * UNIVERSAL BASE: every -dss-* element gets dark bg + light text.
   * Exceptions are explicitly carved out below via more-specific
   * selectors that override this base.
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-"] {
    background-color: #222240 !important;
    color: #e0e0e0 !important;
    border-color: rgba(42,157,143,0.25) !important;
  }

  /* Typography inside DSS */
  [class*="-dss-"] h2,
  [class*="-dss-"] h3,
  [class*="-dss-"] h4 {
    color: #e8e8f0 !important;
  }
  [class*="-dss-"] p,
  [class*="-dss-"] li,
  [class*="-dss-"] span,
  [class*="-dss-"] div {
    color: #e0e0e0;
  }
  [class*="-dss-"] strong {
    color: #ffffff !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 1: Banner (header band) stays navy gradient — intentional
   * high-contrast header element, not a background-competing surface.
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-banner"],
  [class*="-dss-header"] {
    background: linear-gradient(135deg, #1b2a4a 0%, #253a66 100%) !important;
    color: #ffffff !important;
    border-color: #2a3d66 !important;
  }
  [class*="-dss-banner-title"] {
    color: #ffffff !important;
  }
  [class*="-dss-banner-sub"] {
    color: rgba(255,255,255,0.82) !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 2: Freshness bar — subtle top strip with its own palette
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-fresh"] {
    background: linear-gradient(90deg, #1f2540 0%, #242b4a 100%) !important;
    border-color: rgba(42,157,143,0.30) !important;
    color: #c0c0d0 !important;
  }
  [class*="-dss-fresh-check"] { color: #3ab8a8 !important; }
  [class*="-dss-fresh-src"]   { color: #aaa !important; }
  [class*="-dss-fresh-mode"]  { color: #3ab8a8 !important; font-style: italic; }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 3: Exclusive section (gold-bordered) — keeps gold accent
   * but flips light-ivory gradient to dark-gold-tinted
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-exclusive"] {
    background: linear-gradient(135deg, #2a2540 0%, #32284a 100%) !important;
    border-color: #c9a84c !important;
    color: #e8e8f0 !important;
  }
  [class*="-dss-exclusive-label"] {
    color: #e0c36a !important;
  }
  [class*="-dss-exclusive"] h2 {
    color: #f0e8d0 !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 4: Surface-level cards (verdict/card/act/xlink/formula/
   * quiz-item/method/email) — slightly LIGHTER dark than the section
   * background so cards pop against the container
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-verdict"],
  [class*="-dss-card"],
  [class*="-dss-act"],
  [class*="-dss-xlink"],
  [class*="-dss-formula"],
  [class*="-dss-quiz-item"],
  [class*="-dss-method"],
  [class*="-dss-email"],
  [class*="-dss-sc-card"] {
    background: #2a2a48 !important;
    border-color: rgba(42,157,143,0.30) !important;
    color: #e0e0e0 !important;
  }

  /* Card sub-elements */
  [class*="-dss-card-label"]  { color: #aaa !important; }
  [class*="-dss-card-value"]  { color: #e8e8f0 !important; }
  [class*="-dss-card-sub"]    { color: #888 !important; }
  [class*="-dss-act-title"]   { color: #e8e8f0 !important; }
  [class*="-dss-act-text"]    { color: #c8c8d8 !important; }
  [class*="-dss-xlink-title"] { color: #e8e8f0 !important; }
  [class*="-dss-xlink-sub"]   { color: #aaa !important; }
  [class*="-dss-xlink-val"]   { color: #3ab8a8 !important; }
  [class*="-dss-pct-label"]   { color: #e8e8f0 !important; }
  [class*="-dss-pct-sub"]     { color: #aaa !important; }

  /* Formula block — monospace math display, keep teal accents */
  [class*="-dss-formula"] {
    background: #2a2a48 !important;
    border-color: rgba(42,157,143,0.30) !important;
  }
  [class*="-dss-formula"] strong {
    color: #3ab8a8 !important;
  }

  /* Email capture — slight teal tint */
  [class*="-dss-email"] {
    background: rgba(42,157,143,0.08) !important;
    border-color: rgba(42,157,143,0.30) !important;
  }
  [class*="-dss-email"] input[type="email"],
  [class*="-dss-"] input[type="email"] {
    background: #222240 !important;
    border-color: #444 !important;
    color: #e0e0e0 !important;
  }
  [class*="-dss-email"] input::placeholder { color: #666 !important; }

  /* Quiz item — number badge keeps teal */
  [class*="-dss-quiz-num"] {
    background: #2a9d8f !important;
    color: #ffffff !important;
  }
  [class*="-dss-quiz-q"] {
    color: #e0e0e0 !important;
  }

  /* Method footer — subtle */
  [class*="-dss-method"] {
    background: #1f1f3a !important;
    color: #aaa !important;
    border-color: #333 !important;
  }
  [class*="-dss-method"] strong {
    color: #e8e8f0 !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 5: Verdict-tag chips — keep color-coded semantic
   * backgrounds but use higher-luminance versions for dark mode
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-verdict-tag"] {
    /* base — overridden by .struggling/.getting_by/.comfortable/.thriving */
    background: #2a2a48 !important;
    color: #e0e0e0 !important;
  }
  [class*="-dss-verdict-tag"].struggling {
    background: rgba(231,111,81,0.22) !important;
    color: #ff9373 !important;
  }
  [class*="-dss-verdict-tag"].getting_by {
    background: rgba(201,168,76,0.25) !important;
    color: #e0c36a !important;
  }
  [class*="-dss-verdict-tag"].comfortable {
    background: rgba(58,184,168,0.22) !important;
    color: #3ab8a8 !important;
  }
  [class*="-dss-verdict-tag"].thriving {
    background: rgba(58,184,168,0.35) !important;
    color: #6dcebe !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 6: Bar/percentile — track dark, fill stays teal
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-bar-track"] {
    background: #1a1a2e !important;
  }
  [class*="-dss-bar-fill"],
  [class*="-dss-bar-marker"] {
    background: #3ab8a8 !important;
  }
  [class*="-dss-bar-pct"] {
    color: #3ab8a8 !important;
  }
  [class*="-dss-bar-scale"] {
    color: #888 !important;
    background: transparent !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 7: Grid container (layout, not a visible background)
   * — make it transparent so child cards show against section bg
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-grid"] {
    background: transparent !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 8: Tables inside DSS
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-"] table,
  [class*="-dss-city-table"] {
    background: #222240 !important;
    color: #e0e0e0 !important;
  }
  [class*="-dss-"] table th,
  [class*="-dss-city-table"] th {
    background: #1b2a4a !important;
    color: #e8e8f0 !important;
    border-color: #333 !important;
  }
  [class*="-dss-"] table td,
  [class*="-dss-city-table"] td {
    color: #e0e0e0 !important;
    border-color: #333 !important;
  }
  [class*="-dss-"] table tr:nth-child(even) td,
  [class*="-dss-city-table"] tr:nth-child(even) td {
    background: #272747 !important;
  }
  [class*="-dss-"] tr.highlight,
  [class*="-dss-"] tr.active-cohort,
  [class*="-dss-"] tr.highlight td,
  [class*="-dss-city-table"] tr.highlight td,
  [class*="-dss-matrix"] td.highlight {
    background: rgba(201,168,76,0.18) !important;
    color: #e0c36a !important;
  }

  /* .fc-dss-ref-tbl table on AZ/TX state pages (not caught by attribute
   * selector above because class is fc-dss-ref-tbl, which contains -dss-
   * so it IS caught — but explicit for clarity) */
  .fc-dss-ref-tbl {
    background: #222240 !important;
    color: #e0e0e0 !important;
  }
  .fc-dss-ref-tbl th {
    background: #1b2a4a !important;
    color: #e8e8f0 !important;
  }
  .fc-dss-ref-tbl td {
    color: #e0e0e0 !important;
    border-color: #333 !important;
  }
  .fc-dss-ref-tbl tr:nth-child(even) td {
    background: #272747 !important;
  }
  .fc-dss-ref-tbl tr.fc-dss-ref-highlight td {
    background: rgba(201,168,76,0.18) !important;
    color: #e0c36a !important;
  }
  .fc-dss-ref-tbl a {
    color: #3ab8a8 !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 9: Matrix/status dots (action plan check/amber/red)
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-mx-dot"]    { background: #3ab8a8 !important; }
  [class*="-dss-mx-status"] { color: #e8e8f0 !important; }
  [class*="-dss-mx-green"]  { color: #3ab8a8 !important; }
  [class*="-dss-mx-amber"]  { color: #e0c36a !important; }
  [class*="-dss-mx-red"]    { color: #ff9373 !important; }
  [class*="-dss-mx-gray"]   { color: #888 !important; }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 10: Cross-links, action/method sub-blocks
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-"] a {
    color: #3ab8a8 !important;
  }
  [class*="-dss-"] a:hover {
    color: #4dcaba !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 11: Pill labels and small tags
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-pill"],
  [class*="-dss-tag"]:not([class*="-dss-verdict-tag"]),
  [class*="-dss-label"] {
    background: #2a2a48 !important;
    color: #e8e8f0 !important;
    border-color: #444 !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 12: TOC heading on spoke pages
   * ──────────────────────────────────────────────────────────── */
  .fc-auto-toc-heading {
    color: #e8e8f0 !important;
    border-color: rgba(42,157,143,0.30) !important;
  }

  /* ────────────────────────────────────────────────────────────
   * CARVE-OUT 13: Section/body containers — they already get the
   * universal base. But explicitly keep them consistent in case
   * inline styles try to override.
   * ──────────────────────────────────────────────────────────── */
  [class*="-dss-wrap"],
  [class*="-dss-body"],
  [class*="-dss-section"] {
    background: #222240 !important;
    border-color: rgba(42,157,143,0.25) !important;
  }
  [class*="-dss-section"]:last-child {
    border-bottom: none !important;
  }
}

/* ── FC_V63.30: city-angle gold-bordered section (TX city spokes) ───────── */
[class*="-dss-angle"] {
  background: linear-gradient(135deg, #2d2815 0%, #1f1f3a 100%) !important;
  border-color: #c9a84c !important;
  border-left-color: #e0c36a !important;
  color: #e8e8d8 !important;
}
[class*="-dss-angle"] h2 {
  color: #e0c36a !important;
}
[class*="-dss-angle"] p {
  color: #e0e0e0 !important;
}
[class*="-dss-angle"] p strong {
  color: #ffffff !important;
}
[class*="-dss-angle-label"] {
  color: #e0c36a !important;
}

/* ── FC_V63.33: contrast fixes ────────────────────────────────────────────
   Problem: inline page CSS (e.g., .fl-dss-section p { color: #333 }) has
   same specificity as dark-mode rules but wins cascade due to document
   order. Add !important to key text-color rules, and add overrides for
   previously uncovered class suffixes.
   ───────────────────────────────────────────────────────────────────────── */

/* Text color override — must use !important to beat inline light-mode rules */
[class*="-dss-"] p,
[class*="-dss-"] li {
  color: #e0e0e0 !important;
}

/* Strong/bold inside DSS paragraphs — crisper white for emphasis */
[class*="-dss-"] p strong,
[class*="-dss-"] li strong {
  color: #ffffff !important;
}

/* The big dollar number (e.g., "$70,829") — was invisible dark-navy text */
[class*="-dss-big"] {
  color: #e8e8f0 !important;
}

/* Caption text under big numbers (e.g., "Annual take-home · 70.8% of gross") */
[class*="-dss-sub"] {
  color: #aaa !important;
}

/* Cross-city pill bar container on spoke pages */
[class*="-dss-xlinks"] {
  background: rgba(42,157,143,0.12) !important;
  color: #e0e0e0 !important;
}
[class*="-dss-xlinks"] strong {
  color: #e8e8f0 !important;
}
[class*="-dss-xlinks"] a {
  color: #3ab8a8 !important;
}

/* Quiz wrapper */
[class*="-dss-quiz"]:not([class*="-dss-quiz-item"]):not([class*="-dss-quiz-num"]):not([class*="-dss-quiz-q"]) {
  background: transparent !important;
  color: #e0e0e0 !important;
}

/* State-page city-linking table */
[class*="-dss-ref-tbl"] {
  background: #222240 !important;
  color: #e0e0e0 !important;
  border-color: rgba(42,157,143,0.25) !important;
}
[class*="-dss-ref-tbl"] th {
  background: #1b2a4a !important;
  color: #ffffff !important;
}
[class*="-dss-ref-tbl"] td {
  color: #e0e0e0 !important;
  border-bottom-color: rgba(42,157,143,0.15) !important;
}
[class*="-dss-ref-tbl"] tr:nth-child(even) td {
  background: #1f1f3a !important;
}
[class*="-dss-ref-tbl"] tr:hover td {
  background: #2a2a48 !important;
}
[class*="-dss-ref-tbl"] tr[class*="-dss-ref-highlight"] td,
[class*="-dss-ref-tbl"] tr.fc-dss-ref-highlight td {
  background: rgba(201,168,76,0.18) !important;
  color: #e8e8d8 !important;
}
[class*="-dss-ref-tbl"] a {
  color: #3ab8a8 !important;
}
[class*="-dss-ref-lead"] {
  color: #c8c8d8 !important;
}

/* Action cards — the title/text already had rules but title wasn't !important */
[class*="-dss-act-title"] {
  color: #e8e8f0 !important;
}
[class*="-dss-act-text"] {
  color: #c8c8d8 !important;
}

/* Formula box text (was inheriting dark gray) */
[class*="-dss-formula"] {
  color: #e0e0e0 !important;
}
[class*="-dss-formula"] strong {
  color: #ffffff !important;
}

/* Card value + label adjustments for contrast — add !important to existing */
[class*="-dss-card-label"]  { color: #aaa !important; }
[class*="-dss-card-value"]  { color: #e8e8f0 !important; }
[class*="-dss-card-sub"]    { color: #888 !important; }

/* Pct label + sub (AZ calc page verdict) */
[class*="-dss-pct-label"] { color: #e8e8f0 !important; }
[class*="-dss-pct-sub"]   { color: #aaa !important; }

/* Section headings — H2/H3 inside DSS sections were also affected */
[class*="-dss-section"] h2,
[class*="-dss-section"] h3,
[class*="-dss-wrap"] h2,
[class*="-dss-wrap"] h3 {
  color: #e8e8f0 !important;
}
