/* ==================================================================
   WCAG AAA (7:1) contrast overrides — site-wide.
   Selectors are prefixed with `html body` so they out-specify
   Bootstrap's single-class `.text-*` utilities (which use !important)
   REGARDLESS of stylesheet load order. Darkens colours that pass AA
   (4.5:1) but fail AAA (7:1). Only colours that are always on a light
   background are darkened globally here.
   ================================================================== */

/* --- Default (unstyled) links on light backgrounds --- */
:root {
    --bs-link-color: #0842a5;               /* full var (some builds use this, not -rgb) */
    --bs-link-color-rgb: 8, 66, 165;        /* #0842a5 ~7.3:1 on #fff (was #0d6efd 4.5) */
    --bs-link-hover-color: #062f78;
    --bs-link-hover-color-rgb: 6, 47, 120;
    /* Marker read by js/nocss-hidden.js (GIGW 5.1.16): present = author CSS is on.
       Gone when a reader turns style sheets off. Do not remove. */
    --author-css: on;
}

/* The :root values above lose: Bootstrap is linked again later (local + CDN copy), and its
   :root resets --bs-link-color-rgb to #0d6efd (4.5:1 - fails AAA). Declared on body, the
   values are inherited by every link whatever the stylesheet order. */
html body {
    --bs-link-color: #0842a5;
    --bs-link-color-rgb: 8, 66, 165;
    --bs-link-hover-color: #062f78;
    --bs-link-hover-color-rgb: 6, 47, 120;
}

/* About-Us branch cards: the <h3> title inherits the link colour (blue #0d6efd).
   Target the card link + title directly. The description sets its own colour, so
   it's unaffected. */
html body a.about,
html body a.about .about-card-title {
    color: #0842a5 !important;   /* ~7.3:1 on #fff */
}

/* --- Error / required / danger text (always on a light background) --- */
html body .text-danger,
html body .text-danger *,
html body .field-validation-error,
html body .invalid-feedback,
html body .required,
html body .required-mark,           /* the "*" in the required-fields legend (was #c62828, 5.62:1) */
html body a.pdf-link {              /* Resources "( PDF · language · size )" (was #dc3545, 4.53:1) */
    color: #a4161a !important;   /* ~7.8:1 on #fff (was #dc3545 4.5) */
}

/* --- Muted / secondary grey text --- */
html body .text-muted,
html body small.text-muted,
html body .text-secondary {
    /* was #495057: 8.18 on #fff but only 6.70 on the blue theme's #dbeafe panel (and
       6.73 / 6.69 on the orange / red tinted panels). #40464d clears 7.8:1 on every
       theme's card colour (#dbeafe 7.82, #ffe5c7 7.85, #fee2e2 7.81, #d1fae5 8.41). */
    color: #40464d !important;
}

/* --- Bootstrap primary-blue text (used as links/titles on light cards) --- */
html body .text-primary {
    color: #0842a5 !important;   /* ~7.3:1 on #fff (was #0d6efd 4.5) */
}

/* ==================================================================
   GIGW 5.2.18 / WCAG 1.4.11 — boundaries of interactive controls (3:1)

   Measured on the home page: twelve controls had no perceivable edge at all.
     .scroll-btn (news prev / pause / next)   white 0.9 fill on #f0fdfa   1.04:1
     .btn-pill   (the unselected tab pills)   #ccfbf1     on #f0fdfa      1.08:1
     #services buttons (21 service links)     white border on #f0fdfa     1.04:1
     search field, mic and search buttons     #ccc border on white        1.61:1
   All need 3:1. A control you cannot find the edge of is the thing 1.4.11 is about.

   Only the BORDER is set. Every fill, radius and text colour is left exactly as
   designed, so this adds an outline rather than restyling anything.

   var(--nav-bg) per the project rule on themeable colour: it follows the selected
   theme instead of freezing one palette. The default #095a6f measures 7.7:1 on the
   mint #f0fdfa panel and 8.4:1 on white - both well clear of 3:1, and it stays clear
   in the other themes because --nav-bg is always dark enough to carry white nav text.

   On the pills that are currently active the fill is already dark, so the border
   lands on a colour close to its own and nothing visibly changes there.
   `!important` is required, not cosmetic: styles.css sets `#dictionarySearch`, `#micBtn`
   and `#searchBtn` to `border: 1px solid #ccc !important`, and the pills lose to a
   `.gallery-toggle:not(.active)` rule that is more specific than a single class. Measured
   both times - without it the rule is delivered and ignored. The `html body` prefix is kept
   so this still out-specifies those id rules once both carry !important.

   Bootstrap's global `box-sizing: border-box` means the added 1px eats into the padding
   instead of growing the control, so nothing reflows.
   ================================================================== */
html body .scroll-btn,
html body .btn-pill,
html body #services button.w-100.text-start,
html body #dictionarySearch,
html body #micBtn,
html body #searchBtn,
/* District sites: the photo-gallery arrows carry a #999 border on the near-white panel —
   2.76:1, just under the bar. Measured on /DistrictSCLR?districtId=24, the page the audit's
   screenshot 11 was taken from. */
html body #photoBtnPrev,
html body #photoBtnNext {
    border: 1px solid var(--nav-bg, #095a6f) !important;
}

/* ==================================================================
   GIGW 5.2.18 / WCAG 1.4.11 — the focus indicator itself (audit screenshot 13)

   The audit flagged the feedback Submit button while focused. Measured, the button at rest
   is fine (#095a6f fill on white = 7.77:1); the failure is its focus ring. styles.css sets
   a site-wide `:focus { outline: 3px solid #ffff00 }`, and that yellow measures 1.07:1 on
   the light background the button sits on — the ring is there but cannot be seen. That
   yellow ring is exactly what the auditor's screenshot shows.

   Site-wide because the fault is site-wide: of 141 focusable elements on the home page, 21
   were handed a ring that disappears into a light background and 13 got no ring at all.

   The indicator is two-tone, the technique WCAG 2.4.11 describes:
     - a dark ring in var(--nav-bg), 2px outside the element
     - a white band filling that gap and continuing just past the ring
   On a light background the dark ring carries the contrast, on a dark one the white band
   does, and the two always contrast with each other (7.8:1) whatever lies behind. So it
   cannot vanish the way a single yellow or white ring does.

   THE REPEATED PSEUDO-CLASS IS DELIBERATE. `html body *:focus` scores (0,1,2), and CSS
   compares the class/pseudo-class column BEFORE the element column — so a plain
   `.nav-link:focus-visible` at (0,2,0) outranks it, and !important on both does not change
   that. Measured: the rule was delivered, marked !important, matched the element, and still
   lost. Repeating the pseudo-class lifts this to (0,3,2), above every competing rule found
   on the page. Do not "tidy" it back to a single one.
   ================================================================== */
html body *:focus-visible:focus-visible:focus-visible {
    outline: 3px solid var(--nav-bg, #095a6f) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px #fff !important;
}

/* Fallback for engines without :focus-visible — without it those browsers show nothing.
   It carries the white band too: without it, an element sitting on a dark panel gets a dark
   ring on a dark background and the indicator disappears again. */
html body *:focus:focus:focus {
    outline: 3px solid var(--nav-bg, #095a6f) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 5px #fff !important;
}

/* The language toggle is the one place this rule must stand aside. Its radios are clipped to
   1px so they stay focusable while invisible, and language-toggle.css deliberately draws the
   indicator on the adjacent <label> instead — in white, because the toggle's own background
   is var(--nav-bg). Applying the site-wide dark ring here put a nav-bg ring on a nav-bg
   background: measured 1.00:1, i.e. nothing. Leave that file's rule in charge. */
html body .language-toggle input[type="radio"]:focus:focus:focus,
html body .language-toggle input[type="radio"]:focus-visible:focus-visible:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* A pointer click should not leave a ring behind; only keyboard focus should. */
html body *:focus:focus:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

/* ------------------------------------------------------------------------------------------
   Hover / focus text colours (GIGW 5.2.14, 5.2.18) - measured in all 5 themes.
   styles.css sets a text colour on hover/focus without making sure of the background behind
   it, and the button's own !important fill wins the background:
   - `.nav-link:focus { color: var(--button-primary) !important }` - many filled buttons carry
     .nav-link, so on focus their text turned teal on their teal fill (1.0:1).
   - `.nav-link.active` is yellow, and the same focus rule gave it a light background (1.05:1).
   - `.nav-pills .nav-link:hover` (resources.css) fills the tab teal, text stays dark (1.17:1).
   - `.nav-link:hover { color: #F7A418 }` - orange on the light About Us band (1.96:1).
   - Bootstrap `.btn:hover` colour beat the Grievance submit button's white text (2.7:1).
   Rule: a filled button keeps light text in EVERY state; text on a light surface uses the
   theme colour. Never set a hover/focus text colour without its background.
   ------------------------------------------------------------------------------------------ */
html body .btn-gradient:hover, html body .btn-gradient:focus, html body .btn-gradient:focus-visible,
html body .btn-submit:hover, html body .btn-submit:focus, html body .btn-submit:focus-visible,
html body .btn-submit-grievance:hover,   /* hover only: its focus state has a white fill */
html body .theme-bg-primary.btn:hover, html body .theme-bg-primary.btn:focus, html body .theme-bg-primary.btn:focus-visible,
html body .map-toggle-btn:hover, html body .map-toggle-btn:focus, html body .map-toggle-btn:focus-visible,
html body .nav-pills .nav-link:hover {
    color: #fff !important;
}

/* Inactive gallery / News / Feedback pills: `.gallery-toggle.nav-link:focus` sets white text,
   but `.gallery-toggle:not(.active)` keeps the light fill - white on light, 1.13:1. Keep the
   pill's normal text colour; the focus ring shows focus. */
html body .gallery-toggle.nav-link:not(.active):focus,
html body .gallery-toggle.nav-link:not(.active):focus-visible {
    color: var(--text-color) !important;
}

/* Main menu only - an active TAB (Tenders, Resources) has its own teal fill that must stay. */
html body .navbar-links .nav-link.active:focus,
html body .navbar-links .nav-link.active:focus-visible {
    background-color: transparent !important;   /* keep the dark menu bar behind the yellow text */
}

html body .about-us-header.nav-link:hover,
html body .about-us-header.nav-link:focus {
    color: var(--nav-bg, #095a6f) !important;
}

/* Page numbers: hard-coded #0d6efd is 4.5:1 on white and 3.8:1 on the grey hover/focus fill. */
html body .pagination .page-item:not(.active):not(.disabled) a,
html body .pagination .page-item:not(.active):not(.disabled) .page-link {
    color: var(--nav-bg, #095a6f) !important;
}

/* Current page: Bootstrap 5 fills it with #0d6efd - white on it is 4.5:1 (Blogs, DataTables
   lists). The theme's --nav-bg gives 7.77-14.68:1 with white in every theme except Sunset,
   whose #b91c1c is 6.47:1, so Sunset gets its own darker red below. */
html body .pagination .page-item.active a,
html body .pagination .page-item.active .page-link {
    color: #ffffff !important;
    background-color: var(--nav-bg, #095a6f) !important;
    border-color: var(--nav-bg, #095a6f) !important;
}

html[data-theme="sunset"] body .pagination .page-item.active a,
html[data-theme="sunset"] body .pagination .page-item.active .page-link,
[data-theme="sunset"] .pagination .page-item.active .page-link {
    background-color: #991b1b !important;   /* white on it 8.3:1 */
    border-color: #991b1b !important;
}

/* Floating chatbot launcher (Pages/Index, Privacy): the button had no text colour, so the
   <title>/<desc> that svg-a11y.js adds to its icon inherited black - 2.58:1 on the theme fill
   (WCAG Contrast Checker, Web Policy page, Nature theme). The icon itself is drawn in white,
   so the button's text colour is white too, and its fill is --nav-bg like the chat-toggle and
   scroll-to-top buttons (white on it 7.77:1+ in every theme; --button-primary is too light
   for white in Dark and Sunset). */
#chatbot-launch {
    color: #ffffff !important;
    background: var(--nav-bg, #095a6f) !important;
}

[data-theme="sunset"] #chatbot-launch {
    background: #991b1b !important;   /* white on it 8.31:1 */
}

/* Disabled Previous / Next: Bootstrap 5 draws them in rgba(33,37,41,.75), which blends to
   #53565a on the #e9ecef fill = 6.22:1. #40464d (same grey as .text-muted) is 8.05:1. */
html body .pagination .page-item.disabled a,
html body .pagination .page-item.disabled .page-link {
    color: #40464d !important;
}

/* Header search results modal: the result titles were inline color:#007bff - 3.98:1 on the white
   modal (fails AA too). --nav-bg is 7.77:1+ on white in every theme except Sunset (6.47:1),
   which gets the same darker red as the pagination above. Underline on hover/focus so the
   link is not identified by colour alone. */
.search-result-link {
    font-weight: 700;
    color: var(--nav-bg, #095a6f);
    text-decoration: none;
}

.search-result-link:hover,
.search-result-link:focus-visible {
    text-decoration: underline;
}

[data-theme="sunset"] .search-result-link {
    color: #991b1b;   /* 8.3:1 on white */
}

/* "New" (navin) badges (main menu Citizens item, Citizen Corner Tenders card): white on #b91c1c is
   6.47:1 - passes AA, fails AAA for small text (WCAG Contrast Checker, live home 04-Dec-2026).
   A fixed status red, not a theme colour, so a fixed hex: #991b1b = 8.31:1 with white, same hue.
   Hover goes a shade darker as before (custom.css #991414). */
html body span.popup-blink[class],
html body .popup-blink[class] {
    color: #ffffff !important;
    background-color: #991b1b !important;
}

html body span.popup-blink[class]:hover,
html body .popup-blink[class]:hover {
    background-color: #7f1d1d !important;   /* 10.0:1 */
}
