/*
 * Global, accessible text-link treatment.  Owned by Global Controls.
 * Applies to text links in normal content, case studies, blog, services,
 * footer text, and textual CTAs. Does not restyle graphical controls,
 * navigation menus, card surfaces, logo links, or button-like anchors.
 *
 * Some legacy plugins and Controls Core declare link colors/decoration
 * with !important. The two properties below are therefore narrowly
 * prioritized on text links only, not on the whole site UI.
 */
:root {
    --stlgc-link-dark: #bca0ff;
    --stlgc-link-dark-hover: #d1bcff;
}

/* The explicit exclusions are UI controls, not normal editorial links. */
html body.stlgc-global-links a:any-link:not(:where(
    .btn,
    .button,
    .wp-block-button__link,
    .elementor-button,
    .slc-btn,
    .stl-btn,
    .sbl-journal-cta__button,
    .ssv8-button,
    .ssv8-featured-cta,
    [role="button"],
    [role="tab"],
    .chip,
    .filter,
    .skip-link,
    .round,
    .project-card,
    .category-card,
    .featured,
    .postcard,
    .share-button,
    .social-button,
    .social-icon,
    .elementor-icon,
    .stlv8-brand,
    .stlv8-footer-logo-link,
    #stlv8-site-header a,
    .stlv8-header a,
    .stlv8-social-icons a,
    .elementor-location-header a,
    .elementor-widget-button a,
    .wp-block-buttons a,
    .sbl-root .article-cta a,
    .sbl-root .share-buttons a,
    .sbl-root .share-floating a,
    .sbl-root .toclist a,
    .sbl-root .postcard a,
    .scs .story-nav nav a,
    .scs .category-aside a,
    .scs .scs-category-links a,
    .scs .scs-pagination a,
    .scs .related .project-card a,
    .scs .share-panel a,
    .stlv8-header nav a,
    .stlv8-mega-menu a,
    .slmm6 a
)) {
    text-decoration-line: underline !important;
    text-decoration-color: currentColor !important;
    text-underline-offset: 0.17em;
    text-decoration-thickness: 0.08em;
}

/* The existing global header toggle controls html.sl-theme-dark.
 * Keep this one color across all textual links, including CMS content.
 * Browser default :visited colors are intentionally overridden.
 */
html.sl-theme-dark body.stlgc-global-links a:any-link:not(:where(
    .btn,
    .button,
    .wp-block-button__link,
    .elementor-button,
    .slc-btn,
    .stl-btn,
    .sbl-journal-cta__button,
    .ssv8-button,
    .ssv8-featured-cta,
    [role="button"],
    [role="tab"],
    .chip,
    .filter,
    .skip-link,
    .round,
    .project-card,
    .category-card,
    .featured,
    .postcard,
    .share-button,
    .social-button,
    .social-icon,
    .elementor-icon,
    .stlv8-brand,
    .stlv8-footer-logo-link,
    #stlv8-site-header a,
    .stlv8-header a,
    .stlv8-social-icons a,
    .elementor-location-header a,
    .elementor-widget-button a,
    .wp-block-buttons a,
    .sbl-root .article-cta a,
    .sbl-root .share-buttons a,
    .sbl-root .share-floating a,
    .sbl-root .toclist a,
    .sbl-root .postcard a,
    .scs .story-nav nav a,
    .scs .category-aside a,
    .scs .scs-category-links a,
    .scs .scs-pagination a,
    .scs .related .project-card a,
    .scs .share-panel a,
    .stlv8-header nav a,
    .stlv8-mega-menu a,
    .slmm6 a
)) {
    color: var(--stlgc-link-dark) !important;
    text-decoration-color: var(--stlgc-link-dark) !important;
}


/* Existing Blog hero breadcrumbs have a more specific !important color. */
html.sl-theme-dark body.stlgc-global-links .sbl-root .article-hero .crumb a:any-link {
    color: var(--stlgc-link-dark) !important;
    text-decoration-line: underline !important;
    text-decoration-color: var(--stlgc-link-dark) !important;
}

/* RC3.2: Global Controls is the final owner of dark-mode link and button ink.
 * Text links: lavender + underline (the rules above).
 * Heading/card links: near-white. Button labels: white.
 * Plugin templates/styles may own structure and surfaces, but not these tokens.
 * The narrowly scoped !important rules below win over legacy plugin CSS that
 * also uses !important. No other plugin is modified for this fix.
 */
:root {
    --stlgc-dark-heading-ink: #f9fafb;
    --stlgc-dark-button-ink: #ffffff;
}

/* Links that function as article or project titles, not editorial text links.
 * Include anchor-wrapped project cards and common heading-with-anchor markup.
 * Keep the global underline for actual linked headings (do not alter spacing).
 */
html.sl-theme-dark body.stlgc-global-links :is(
    h1 a:any-link,
    h2 a:any-link,
    h3 a:any-link,
    h4 a:any-link,
    h5 a:any-link,
    h6 a:any-link,
    .sbl-root .feature-copy h2 a:any-link,
    .sbl-root .postcard .post-info h2 a:any-link,
    .sbl-root .related-section .postcard .post-info h4 a:any-link,
    .scs .featured .feature-copy h2,
    .scs .project-card .card-meta h3,
    .scs .category-card h2
) {
    color: var(--stlgc-dark-heading-ink) !important;
    -webkit-text-fill-color: var(--stlgc-dark-heading-ink);
}

/* Subtle interactive feedback without reverting title links to bright purple. */
html.sl-theme-dark body.stlgc-global-links :is(
    h1 a:any-link,
    h2 a:any-link,
    h3 a:any-link,
    h4 a:any-link,
    h5 a:any-link,
    h6 a:any-link,
    .scs .featured .feature-copy h2,
    .scs .project-card .card-meta h3
):is(:hover, :focus-visible),
html.sl-theme-dark body.stlgc-global-links :is(
    .scs a.featured:hover .feature-copy h2,
    .scs a.featured:focus-visible .feature-copy h2,
    .scs a.project-card:hover .card-meta h3,
    .scs a.project-card:focus-visible .card-meta h3
) {
    color: var(--stlgc-link-dark-hover) !important;
    -webkit-text-fill-color: var(--stlgc-link-dark-hover);
}

/* Actual text buttons, including anchor-style CTAs and input buttons.
 * Icon-only controls (search, carousel arrows, theme toggle, floating icons)
 * do not inherit a label rule and retain their component-specific styles.
 */
html.sl-theme-dark body.stlgc-global-links :is(
    a.btn,
    a.button,
    a.wp-block-button__link,
    a.elementor-button,
    a.slc-btn,
    a.stl-btn,
    a.sbl-journal-cta__button,
    .sbl-root .article-cta a,
    .scs a.btn,
    .scs .chip,
    .sbl-root .filter,
    button:not([aria-label]):not(.round):not(.sbl-social):not(.search button):not([class*="icon"]):not(.ssv8-filter button),
    input[type="submit"],
    input[type="button"],
    input[type="reset"]
) {
    color: var(--stlgc-dark-button-ink) !important;
    -webkit-text-fill-color: var(--stlgc-dark-button-ink);
}

/* A light/white button surface would make white text illegible.
 * These known secondary-style buttons get a dark surface in dark mode only.
 * Other filled button background colors stay in the owning components.
 */
html.sl-theme-dark body.stlgc-global-links :is(
    .sbl-root .filter:not(.active):not([aria-current="page"]),
    .scs .btn.soft,
    .scs .btn:not(.primary),
    .wp-block-button.is-style-outline .wp-block-button__link
) {
    background-color: #1e2534 !important;
    border-color: #45516b;
}

/* CTA labels may contain an icon or nested span that otherwise receives
 * an independently authored purple color from an older component stylesheet.
 */
html.sl-theme-dark body.stlgc-global-links :is(
    .sbl-journal-cta__button,
    .scs .btn.primary,
    .sbl-root .article-cta a
) :is(span, svg, i) {
    color: inherit !important;
    -webkit-text-fill-color: inherit;
}


/* RC3.4 — targeted primary CTA and filter contrast corrections.
 * The selectors deliberately name the owning templates; no generic a,
 * button, .btn, or .filter override can alter secondary controls elsewhere.
 * Existing dimensions, radii, borders, and focus outlines are unaffected.
 */
:root {
    --stlgc-primary-cta-blue: #2458ff;
    --stlgc-primary-cta-blue-hover: #1949d5;
    --stlgc-primary-cta-text: #ffffff;
}

/* Only the Homepage's explicit primary CTA and closing invitation. */
html body.stlgc-global-links #stlh-home a.btn.primary,
html body.stlgc-global-links #stlh-home .closing a.btn,
/* Only the Services archive's hero/featured CTA and single-service CTAs. */
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-archive a.ssv8-button,
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-archive a.ssv8-featured-cta,
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-single a.ssv8-button {
    background-color: var(--stlgc-primary-cta-blue) !important;
    border-color: var(--stlgc-primary-cta-blue) !important;
    color: var(--stlgc-primary-cta-text) !important;
    -webkit-text-fill-color: var(--stlgc-primary-cta-text);
    text-decoration: none !important;
}

html body.stlgc-global-links #stlh-home a.btn.primary:is(:hover, :focus-visible),
html body.stlgc-global-links #stlh-home .closing a.btn:is(:hover, :focus-visible),
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-archive a.ssv8-button:is(:hover, :focus-visible),
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-archive a.ssv8-featured-cta:is(:hover, :focus-visible),
html body.stlgc-global-links main.ssv8-ui.ssv8-r12-single a.ssv8-button:is(:hover, :focus-visible) {
    background-color: var(--stlgc-primary-cta-blue-hover) !important;
    border-color: var(--stlgc-primary-cta-blue-hover) !important;
    color: var(--stlgc-primary-cta-text) !important;
}

/* Button icons should remain white regardless of plugin nested span/SVG ink. */
html body.stlgc-global-links :is(
    #stlh-home a.btn.primary,
    #stlh-home .closing a.btn,
    main.ssv8-ui.ssv8-r12-archive a.ssv8-button,
    main.ssv8-ui.ssv8-r12-archive a.ssv8-featured-cta,
    main.ssv8-ui.ssv8-r12-single a.ssv8-button
) :is(svg, svg *, span:not(.screen-reader-text), i) {
    color: var(--stlgc-primary-cta-text) !important;
    stroke: currentColor;
    -webkit-text-fill-color: var(--stlgc-primary-cta-text);
    text-decoration: none !important;
}

/* Services filters are NOT primary CTAs.  Retain their original pale-blue
 * active surface and use the dark label already intended by Services V8.
 */
html.sl-theme-dark body.stlgc-global-links main.ssv8-ui.ssv8-r12-archive .ssv8-filter button:is(.active, [aria-pressed="true"]) {
    background-color: #dbe5ff !important;
    border-color: #dbe5ff !important;
    color: #111a35 !important;
    -webkit-text-fill-color: #111a35 !important;
}

/* Case Studies active filter: keep its dark plum background and use white
 * label text, as requested from the Blog active-filter treatment.
 * Unselected chips keep their current design and AJAX handlers.
 */
html.sl-theme-dark body.stlgc-global-links .scs .scs-filters .chip:is(.active, [aria-current="page"]),
html.sl-theme-dark body.stlgc-global-links .scs .scs-filters .chip:is(:hover, :focus-visible) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}
