/* Table of Contents widget and Accessibility widget (inc/widgets.php).
   Panels become visible at once when opening (so focus can move into them) and hide after the slide when closing. */
.tdi-toc-fab, .tdi-a11y-fab { position: fixed; z-index: 9990; display: grid; place-items: center; padding: 0; border: 0; color: #fff; cursor: pointer; box-shadow: 0 10px 24px -10px rgba(15, 23, 42, .55); }
.tdi-toc-fab svg, .tdi-a11y-fab svg { display: block; flex: none; pointer-events: none; }

/* Positions from Site Settings: desktop values, replaced by the mobile values up to 1000px.
   Margins are capped so the buttons and the menu always stay on screen. */
.tdi-widgets {
	--tdi-tx: min(var(--tdi-toc-x, 0px), calc(100vw - 56px));
	--tdi-ty: min(var(--tdi-toc-y, 200px), calc(100vh - 56px - var(--tdi-bottom-bar, 0px)));
	--tdi-ax: min(var(--tdi-a11y-x, 24px), calc(100vw - 60px));
	--tdi-ay: min(var(--tdi-a11y-y, 24px), calc(50vh - 60px)); /* stays in its half of the screen, leaving room for the menu */
	--tdi-pw: min(320px, calc(100vw - 32px));
	--tdi-px: min(var(--tdi-ax), calc(100vw - var(--tdi-pw) - 16px));
}
@media (max-width: 1000px) {
	.tdi-widgets {
		--tdi-tx: min(var(--tdi-toc-xm, 0px), calc(100vw - 56px));
		--tdi-ty: min(var(--tdi-toc-ym, 200px), calc(100vh - 56px - var(--tdi-bottom-bar, 0px)));
		--tdi-ax: min(var(--tdi-a11y-xm, 24px), calc(100vw - 60px));
		--tdi-ay: min(var(--tdi-a11y-ym, 24px), calc(50vh - 60px));
	}
}

/* Side (Table of Contents) and corner (Accessibility) classes set which edges the values above apply to. */
@media (min-width: 1001px) {
	.tdi-toc--right { --toc-l: auto; --toc-r: var(--tdi-tx); --toc-dl: auto; --toc-dr: 0; --toc-shift: 100%; }
	.tdi-toc--left { --toc-l: var(--tdi-tx); --toc-r: auto; --toc-dl: 0; --toc-dr: auto; --toc-shift: -100%; }
	.tdi-toc--right.tdi-toc--flush { --toc-radius: 12px 0 0 12px; }
	.tdi-toc--left.tdi-toc--flush { --toc-radius: 0 12px 12px 0; }
	.tdi-a11y--r { --a-l: auto; --a-r: var(--tdi-ax); --p-l: auto; --p-r: var(--tdi-px); }
	.tdi-a11y--l { --a-l: var(--tdi-ax); --a-r: auto; --p-l: var(--tdi-px); --p-r: auto; }
	.tdi-a11y--b { --a-t: auto; --a-b: calc(var(--tdi-ay) + var(--tdi-bottom-bar, 0px)); --p-t: auto; --p-b: calc(var(--tdi-ay) + var(--tdi-bottom-bar, 0px) + 64px); }
	.tdi-a11y--t { --a-t: var(--tdi-ay); --a-b: auto; --p-t: calc(var(--tdi-ay) + 64px); --p-b: auto; }
}
@media (max-width: 1000px) {
	.tdi-toc-m--right { --toc-l: auto; --toc-r: var(--tdi-tx); --toc-dl: auto; --toc-dr: 0; --toc-shift: 100%; }
	.tdi-toc-m--left { --toc-l: var(--tdi-tx); --toc-r: auto; --toc-dl: 0; --toc-dr: auto; --toc-shift: -100%; }
	.tdi-toc-m--right.tdi-toc-m--flush { --toc-radius: 12px 0 0 12px; }
	.tdi-toc-m--left.tdi-toc-m--flush { --toc-radius: 0 12px 12px 0; }
	.tdi-a11y-m--r { --a-l: auto; --a-r: var(--tdi-ax); --p-l: auto; --p-r: var(--tdi-px); }
	.tdi-a11y-m--l { --a-l: var(--tdi-ax); --a-r: auto; --p-l: var(--tdi-px); --p-r: auto; }
	.tdi-a11y-m--b { --a-t: auto; --a-b: calc(var(--tdi-ay) + var(--tdi-bottom-bar, 0px)); --p-t: auto; --p-b: calc(var(--tdi-ay) + var(--tdi-bottom-bar, 0px) + 64px); }
	.tdi-a11y-m--t { --a-t: var(--tdi-ay); --a-b: auto; --p-t: calc(var(--tdi-ay) + 64px); --p-b: auto; }
}

/* Table of Contents widget */
.tdi-toc-fab { top: var(--tdi-ty); left: var(--toc-l, auto); right: var(--toc-r, 0px); width: 48px; height: 48px; border-radius: var(--toc-radius, 12px); background: var(--tdi-toc-color, #20304A); }
.tdi-toc-fab svg { width: 22px; height: 22px; }
.tdi-toc-drawer { position: fixed; z-index: 10000; top: 0; bottom: 0; left: var(--toc-dl, auto); right: var(--toc-dr, 0); display: flex; flex-direction: column; width: min(360px, 88vw); background: #fff; box-shadow: 0 0 40px rgba(15, 23, 42, .25); visibility: hidden; transform: translateX(var(--toc-shift, 100%)); transition: transform .25s ease, visibility 0s linear .25s; }
body.admin-bar .tdi-toc-drawer { top: var(--wp-admin--admin-bar--height, 32px); }
.tdi-toc-drawer.is-open { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; }
.tdi-widgets .toc-list, .tdi-widgets .toc-list ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.tdi-widgets > .tdi-toc-drawer > .toc-list { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 12px 18px 24px; }
.tdi-widgets .toc-list ol { padding-left: 30px; }
.tdi-widgets .toc-list li { counter-increment: toc; margin: 0; padding: 0; }
.tdi-widgets .toc-list li::before { content: none; display: none; }
.tdi-widgets .toc-list a { display: flex; gap: 8px; padding: 5px 0; color: var(--forest-2, #085574); font-size: 15px; line-height: 1.4; text-decoration: none; }
.tdi-widgets .toc-list a::before { content: counters(toc, ".") "."; min-width: 1.6em; color: var(--ink-2, #334155); font-variant-numeric: tabular-nums; }
.tdi-widgets .toc-list a:hover { text-decoration: underline; }
.tdi-widgets .toc-list a.is-current { font-weight: 700; color: var(--forest-deep, #20304A); }
.tdi-widgets .toc-list a.is-current::before { color: var(--tdi-toc-color, #20304A); }

/* Shared panel header */
.tdi-widget-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line, #CBD5E1); color: var(--forest-deep, #20304A); font-weight: 700; font-size: 16px; }
.tdi-widget-close { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: #F1F5F9; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; }

/* Accessibility widget */
.tdi-a11y-fab { left: var(--a-l, auto); right: var(--a-r, 24px); top: var(--a-t, auto); bottom: var(--a-b, 24px); width: 52px; height: 52px; border-radius: 50%; background: var(--tdi-a11y-color, #0B6E94); }
.tdi-a11y-fab svg { width: 28px; height: 28px; }
.tdi-a11y-panel { position: fixed; z-index: 10000; left: var(--p-l, auto); right: var(--p-r, 24px); top: var(--p-t, auto); bottom: var(--p-b, 88px); width: var(--tdi-pw); max-height: calc(100vh - var(--tdi-ay) - var(--tdi-bottom-bar, 0px) - 80px); overflow: auto; border: 1px solid var(--line, #CBD5E1); border-radius: 16px; background: #fff; box-shadow: 0 20px 50px -12px rgba(15, 23, 42, .45); visibility: hidden; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s, visibility 0s linear .2s; }
.tdi-a11y-panel.is-open { visibility: visible; opacity: 1; transform: none; transition: opacity .2s, transform .2s, visibility 0s; }
.tdi-a11y-body { display: grid; gap: 10px; padding: 14px 16px 16px; }
.tdi-a11y-size { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line, #CBD5E1); border-radius: 12px; color: var(--ink, #1E293B); font-size: 14px; }
.tdi-a11y-size span { margin-right: auto; }
.tdi-a11y-size button { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line, #CBD5E1); border-radius: 50%; background: #fff; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.tdi-a11y-size button:disabled { opacity: .4; cursor: default; }
.tdi-a11y-size output { min-width: 3.2em; text-align: center; font-weight: 700; }
.tdi-a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tdi-a11y-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line, #CBD5E1); border-radius: 12px; background: #fff; color: var(--ink, #1E293B); font: 600 13px/1.25 var(--sans, system-ui, sans-serif); text-align: left; cursor: pointer; }
.tdi-a11y-opt svg { width: 20px; height: 20px; color: var(--tdi-a11y-color, #0B6E94); }
.tdi-a11y-opt[aria-pressed="true"] { border-color: var(--tdi-a11y-color, #0B6E94); background: #EEF6FA; box-shadow: inset 0 0 0 1px var(--tdi-a11y-color, #0B6E94); }
.tdi-a11y-reset { justify-self: start; padding: 6px 0; border: 0; background: none; color: var(--forest-2, #085574); font: 600 13px/1 var(--sans, system-ui, sans-serif); text-decoration: underline; cursor: pointer; }
.tdi-widgets button:focus-visible, .tdi-widgets a:focus-visible { outline: 3px solid #F59E0B; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .tdi-toc-drawer, .tdi-a11y-panel { transition: none; } }
@media print { .tdi-widgets { display: none !important; } }
/* Windows High Contrast and other forced-colour modes remove backgrounds: keep the buttons and the chosen options visible. */
@media (forced-colors: active) {
	.tdi-toc-fab, .tdi-a11y-fab { border: 2px solid ButtonText; }
	.tdi-a11y-opt[aria-pressed="true"] { border: 2px solid Highlight; }
}
body:has(#mobile-menu:not([hidden])) .tdi-widgets { display: none; } /* out of the way while the mobile menu is open */

/* What the Accessibility menu changes (classes on <html>). The widgets and the admin bar are left alone.
   Larger text: each block of text in the content and footer is enlarged and re-wraps inside its own column, and the
   top bar, desktop header and mobile menu are enlarged as a whole; the mobile call bar keeps its size. */
html.a11y-size body > :is(main, aside, footer) :is(p, li, dt, dd, th, td, blockquote, figcaption, h1, h2, h3, h4, h5, h6):not(:is(p, li, dt, dd, th, td, blockquote, figcaption, h1, h2, h3, h4, h5, h6) *),
html.a11y-size body > :is(.crisis-strip, .mobile-menu) > * { zoom: var(--a11y-zoom, 1); }
@media (min-width: 1001px) { html.a11y-size body > header > * { zoom: var(--a11y-zoom, 1); } } /* on phones the header holds only the logo and menu button */
html:is(.a11y-size, .a11y-ls, .a11y-font) body > :not(.tdi-widgets):not(#wpadminbar):not(.site-header) { overflow-wrap: anywhere; } /* the header switches layout instead (below) */
html:is(.a11y-size, .a11y-ls, .a11y-font) body > :not(.tdi-widgets):not(#wpadminbar):not(.site-header) :is(.btn, button) { white-space: normal; }
/* When the header no longer fits on one line, it switches to its mobile layout (menu button), as browser zoom would. */
html.a11y-compact-header .site-header :is(.nav-list, .header-call, .header-cta-desktop) { display: none !important; }
html.a11y-compact-header .site-header .menu-btn { display: inline-flex !important; }
html.a11y-compact-header .site-header .header-actions { margin-left: auto; }
/* Line spacing (WCAG 1.4.12 text spacing): text lines at 1.9 and headings at 1.5 (both at least 1.5 times the
   font size), and paragraph spacing of twice the font size. */
html.a11y-lh body > :not(.tdi-widgets):not(#wpadminbar) :is(p, li, dt, dd, td, th, blockquote, figcaption, label, summary) { line-height: 1.9 !important; }
html.a11y-lh body > :not(.tdi-widgets):not(#wpadminbar) :is(h1, h2, h3, h4, h5, h6) { line-height: 1.5 !important; }
html.a11y-lh body > :not(.tdi-widgets):not(#wpadminbar) p { margin-bottom: 2em !important; }
/* Letter spacing (WCAG 1.4.12): letters 0.12 and words 0.16 times the font size. */
html.a11y-ls body > :not(.tdi-widgets):not(#wpadminbar):not(.callbar) :is(p, li, dd, dt, td, th, blockquote, figcaption, label, a, button, summary, h1, h2, h3, h4, h5, h6) { letter-spacing: .12em !important; word-spacing: .16em !important; }
html.a11y-links body > :not(.tdi-widgets):not(#wpadminbar) a { text-decoration: underline !important; text-underline-offset: 3px; }
html.a11y-font body > :not(.tdi-widgets):not(#wpadminbar), html.a11y-font body > :not(.tdi-widgets):not(#wpadminbar) * { font-family: Verdana, Tahoma, "Segoe UI", sans-serif !important; }
/* Stop animations (WCAG 2.2.2 and 2.3.3): no animation, transitions or smooth scrolling. Turned on by itself when the
   device asks for reduced motion (set before the page paints by the inline script in inc/widgets.php). */
html.a11y-still, html.a11y-still *, html.a11y-still *::before, html.a11y-still *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
/* Higher contrast is applied by widgets.js (WCAG 2.2): text reaches 7:1, borders 3:1, form fields and buttons
   get a visible 3:1 edge, and gradient overlays behind text become solid. It starts on when the
   device asks for more contrast (prefers-contrast: more). Transitions pause while it measures colours. */
html.a11y-measuring *, html.a11y-measuring *::before, html.a11y-measuring *::after { transition: none !important; }
