/* Persistent accessibility toolbar — patient portal only (layouts.patientdash) */

/* ---- Layout integration: reserve space for the fixed toolbar + the
   Samaritans banner row fixed directly beneath it. The Samaritans row's
   real height varies with viewport width (its locked wording wraps to 2
   lines at most normal widths, 1 line on very wide screens) — rather than
   measuring it with JS, --a11y-samaritans-h is a generous fixed allowance
   that comfortably fits 2 lines with room to spare, so nothing is ever
   clipped; any left-over space just reads as a little extra breathing
   room around the text. ---- */
:root {
    --a11y-toolbar-h: 48px;
    --a11y-samaritans-h: 46px;
}
/* Narrow viewports wrap the locked Samaritans wording onto more lines —
   bump the reserved allowance so the dashboard content below still starts
   clear of it, not just the banner itself (which never clips — min-height,
   not height). */
@media (max-width: 480px) {
    :root {
        --a11y-samaritans-h: 72px;
    }
}
body.has-a11y-toolbar {
    padding-top: calc(var(--a11y-toolbar-h) + var(--a11y-samaritans-h));
}
body.has-a11y-toolbar .dashboardWrap .leftNav {
    top: calc(var(--a11y-toolbar-h) + var(--a11y-samaritans-h));
    height: calc(100% - var(--a11y-toolbar-h) - var(--a11y-samaritans-h));
}
/* "Jump to" slide-out panel (.slidepanel, in partials/patientshortquesjumpto
   and patientmedicaljumpto) is a second top:0/height:100% element — same fix
   as .leftNav above, or its heading renders half-hidden under the toolbar. */
body.has-a11y-toolbar .slidepanel {
    top: calc(var(--a11y-toolbar-h) + var(--a11y-samaritans-h));
    height: calc(100% - var(--a11y-toolbar-h) - var(--a11y-samaritans-h));
}

/* ---- Toolbar bar ---- */
.a11y-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--a11y-toolbar-h);
    z-index: 1030;
    background: var(--color-dark-blue);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    font-family: Verdana, sans-serif;
    font-size: 13px;
}
.a11y-toolbar * {
    box-sizing: border-box;
}
.a11y-toolbar button,
.a11y-toolbar select {
    font-family: inherit;
    font-size: 13px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 5px;
    padding: 7px 11px;
    height: 34px;
    line-height: 1;
    cursor: pointer;
    transition: background-color .15s ease;
    flex-shrink: 0;
}
.a11y-toolbar select {
    background: #fff;
    color: var(--color-dark-blue);
    border-color: transparent;
}
.a11y-toolbar select option {
    color: var(--color-dark-blue);
    background: #fff;
}
.a11y-toolbar button:hover,
.a11y-toolbar button.is-active {
    background: rgba(255,255,255,0.22);
}
.a11y-toolbar button.is-active {
    border-color: var(--color-orange);
}
.a11y-toolbar .a11y-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding-right: 8px;
    border-right: 1px solid rgba(255,255,255,0.15);
    margin-right: 2px;
}
.a11y-toolbar .a11y-group:last-of-type {
    border-right: none;
}
.a11y-toolbar .a11y-label {
    opacity: 0.7;
    font-size: 12px;
    margin-right: 2px;
    flex-shrink: 0;
}
.a11y-toolbar .a11y-textsize-value {
    min-width: 34px;
    text-align: center;
    opacity: 0.85;
    flex-shrink: 0;
}

/* Google Translate mount point — restyled to sit quietly in the toolbar
   rather than hidden (Google's terms require the attribution stay visible;
   hiding it via font-size:0/color:transparent also left a broken-looking
   half-rendered logo, since the logo <img> ignores `color`). */
.a11y-toolbar #google_translate_element {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.a11y-toolbar .goog-te-gadget {
    font-family: Verdana, sans-serif !important;
    font-size: 11px !important;
    color: rgba(255,255,255,0.65) !important;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}
.a11y-toolbar .goog-te-gadget > span,
.a11y-toolbar .goog-te-gadget > span a,
.a11y-toolbar .goog-te-gadget > span a:visited {
    color: rgba(255,255,255,0.65) !important;
    text-decoration: none !important;
}
.a11y-toolbar .goog-te-gadget img {
    vertical-align: middle;
}
.a11y-toolbar .goog-te-gadget .goog-te-combo {
    font-size: 13px !important;
    height: 34px;
    border-radius: 5px;
    padding: 7px 8px;
    border: none;
    margin: 0 4px 0 0;
}

/* Samaritans banner — always visible, every page, its own full-width row
   directly below the accessibility toolbar (not squeezed inside it — see
   the --a11y-samaritans-h note above). Green (not red), so it never reads
   as a safety alert — red stays reserved for genuine urgent alerts
   elsewhere in the app. Flat full-width bar rather than the old pill
   shape, which looked fine on one line but cramped once the wording
   wrapped to two. */
.a11y-samaritans-bar {
    position: fixed;
    top: var(--a11y-toolbar-h);
    left: 0;
    right: 0;
    z-index: 1029;
    min-height: var(--a11y-samaritans-h);
    background: var(--color-green);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 5px 20px;
    font-family: Verdana, sans-serif;
    font-size: 12px;
    line-height: 1.4;
    color: #fff;
    text-align: center;
}
/* TIP's green phone icon, sitting right beside the 116 123 number. The bar itself is
   green, so the icon is a green phone in a white round badge to stay visible. The icon
   and the number never split across lines (nowrap on the pair). */
.a11y-samaritans-call {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    vertical-align: middle;
}
.a11y-samaritans-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    color: var(--color-green, #00a65a);
    font-size: 13px;
}
/* No max-width/white-space override here on purpose — the text should
   simply fill the full-width bar and only wrap (normal browser reflow)
   once the viewport genuinely can't fit it on one line. An earlier
   max-width:720px was artificially forcing a wrap on screens with plenty
   of room to spare. */
.a11y-samaritans-bar a {
    color: #fff;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.a11y-samaritans-bar a:hover {
    opacity: 0.85;
}

/* ---- Dyslexic font ---- */
html.a11y-dyslexic,
html.a11y-dyslexic body,
html.a11y-dyslexic * {
    font-family: 'OpenDyslexic', sans-serif !important;
}

/* ---- High contrast ----
   Previous version inverted the whole page to a black background — it
   remapped --color-white/--color-grey/--color-dark-blue to black and
   --color-black to white, plus forced body{background:#000}. Reported
   broken (screenshots): most of this app's card/content containers
   (.white-block, form pages, etc.) have their own white background that
   isn't driven by those variables, so they never actually turned black —
   only the (now-white) text sitting on them did, leaving it invisible
   white-on-white. The blanket `a { color: #ffff00 }` rule had the same
   problem in reverse: yellow reads fine on the dark sidebar nav, but fails
   badly on the white content cards the great majority of links sit on.

   Fixed approach: don't invert backgrounds at all — this app's normal
   light backgrounds already have good contrast potential, the problem was
   text/links being too light against them (--color-gray-text is a muted
   grey even outside high-contrast mode). Boost text/border contrast
   against the existing light layout instead, and only give the sidebar
   nav (genuinely dark by design) its own link-colour rule. */
html.a11y-contrast-high {
    --color-black: #000000;      /* body/card text — was #2A2A2A */
    --color-gray-text: #000000;  /* muted/secondary text — was #7E7E7E, already low-contrast normally */
}
html.a11y-contrast-high body {
    color: #000000 !important;
}
html.a11y-contrast-high a {
    color: #000000;
    text-decoration: underline;
    font-weight: 600;
}
/* Sidebar nav + "Jump to" slide-out panel are dark by design
   (--color-dark-blue background) — keep their links bright, not the
   content-card black/underline treatment above. */
html.a11y-contrast-high .leftNav a,
html.a11y-contrast-high .slidepanel a {
    color: #FFD500 !important;
    text-decoration: none;
}
html.a11y-contrast-high .form-input,
html.a11y-contrast-high .form-select,
html.a11y-contrast-high select,
html.a11y-contrast-high input,
html.a11y-contrast-high textarea {
    border: 2px solid #000000 !important;
    color: #000000 !important;
}

/* ---- Black & white ---- */
html.a11y-contrast-bw {
    filter: grayscale(100%);
}

/* ---- Reduce motion ---- */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

@media (max-width: 767px) {
    .a11y-toolbar {
        font-size: 12px;
    }
    .a11y-toolbar .a11y-label {
        display: none;
    }
}

/* ---- Client A3: fit a 375px phone ----
   Desktop: the toggle button is hidden and the inner wrapper is transparent to
   layout (display: contents), so the bar looks and behaves exactly as before.
   Phones/tablets: the whole toolbar collapses behind one "Accessibility options"
   button; tapping it opens a wrapping panel under the bar. The bar itself stays
   one fixed-height row, so the layout offsets above are unchanged. */
.a11y-toolbar .a11y-toggle { display: none; }
.a11y-toolbar .a11y-toolbar-inner { display: contents; }
@media (max-width: 991px) {
    .a11y-toolbar {
        overflow: visible;
        justify-content: flex-start;
    }
    .a11y-toolbar .a11y-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    .a11y-toolbar.is-open .a11y-toggle { background: rgba(255,255,255,0.22); }
    .a11y-toolbar .a11y-toolbar-inner {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 10px 12px 12px;
        background: var(--color-dark-blue);
        box-shadow: 0 6px 10px rgba(0,0,0,0.25);
        max-height: calc(100vh - var(--a11y-toolbar-h));
        overflow-y: auto;
        white-space: normal;
    }
    .a11y-toolbar.is-open .a11y-toolbar-inner { display: flex; }
    .a11y-toolbar .a11y-group {
        flex-wrap: wrap;
        border-right: none;
        padding-right: 0;
        margin-right: 0;
    }
    .a11y-toolbar .a11y-label { display: inline; }
    .a11y-toolbar .a11y-group:has(#google_translate_element) { flex: 1 1 100%; }
    .a11y-toolbar #google_translate_element { max-width: 100%; }
    .a11y-toolbar .goog-te-gadget { flex-wrap: wrap; white-space: normal !important; max-width: 100%; }
    .a11y-toolbar .goog-te-gadget > span { white-space: normal !important; }
    .a11y-toolbar .goog-te-gadget .goog-te-combo { max-width: 100%; }
}
/* Client feedback (step 3): the same collapse also applies, whatever the window width, when the full bar would no
   longer fit - e.g. a 1024px window with text at 130%, where the page is zoomed and the bar runs off the right edge.
   The class is set by accessibility-toolbar.js (updateToolbarCompact). */
    html.a11y-toolbar-compact .a11y-toolbar {
        overflow: visible;
        justify-content: flex-start;
    }
    html.a11y-toolbar-compact .a11y-toolbar .a11y-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }
    html.a11y-toolbar-compact .a11y-toolbar.is-open .a11y-toggle { background: rgba(255,255,255,0.22); }
    html.a11y-toolbar-compact .a11y-toolbar .a11y-toolbar-inner {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 10px 12px 12px;
        background: var(--color-dark-blue);
        box-shadow: 0 6px 10px rgba(0,0,0,0.25);
        max-height: calc(100vh - var(--a11y-toolbar-h));
        overflow-y: auto;
        white-space: normal;
    }
    html.a11y-toolbar-compact .a11y-toolbar.is-open .a11y-toolbar-inner { display: flex; }
    html.a11y-toolbar-compact .a11y-toolbar .a11y-group {
        flex-wrap: wrap;
        border-right: none;
        padding-right: 0;
        margin-right: 0;
    }
    html.a11y-toolbar-compact .a11y-toolbar .a11y-label { display: inline; }
    html.a11y-toolbar-compact .a11y-toolbar .a11y-group:has(#google_translate_element) { flex: 1 1 100%; }
    html.a11y-toolbar-compact .a11y-toolbar #google_translate_element { max-width: 100%; }
    html.a11y-toolbar-compact .a11y-toolbar .goog-te-gadget { flex-wrap: wrap; white-space: normal !important; max-width: 100%; }
    html.a11y-toolbar-compact .a11y-toolbar .goog-te-gadget > span { white-space: normal !important; }
    html.a11y-toolbar-compact .a11y-toolbar .goog-te-gadget .goog-te-combo { max-width: 100%; }
/* Never let anything push the page wider than the screen. `clip` (not `hidden`)
   so fixed bars and sticky elements keep working. */
html, body { overflow-x: clip; }
/* Client B12: the very first automatic menu collapse on page load should not animate. */
html.a11y-menu-instant .dashboardWrap,
html.a11y-menu-instant .dashboardWrap * { transition: none !important; }
