/**
 * Accessibility panel.
 *
 * State lives as attributes on <html> so every rule here is a plain attribute
 * selector and nothing depends on JavaScript having rewritten the page. The
 * panel itself is the only markup this file styles; the adjustments apply to
 * whatever the template rendered.
 */

:root {
	--a11y-line: normal;
	--a11y-letter: normal;
	--a11y-word: normal;
	--a11y-accent: var(--teal-600, #0f7f76);
	--a11y-panel-w: 480px;
	--a11y-launcher-x: 1.25rem;
	--a11y-launcher-y: 1.25rem;
}

/* ── Launcher ────────────────────────────────────────────────────────────── */

/*
 * The corner is set by two classes rather than one of four, so the panel can
 * keep taking its side from the same horizontal half. The two distances are
 * separate variables on purpose: pinned to the top of a site with a floating
 * header the button has to be pushed down past it, and one shared offset would
 * drag it in from the side by the same amount.
 */
.a11y-launcher {
	position: fixed;
	z-index: 1200;
	width: 3.25rem;
	height: 3.25rem;
	border: 0;
	border-radius: 50%;
	background: var(--a11y-accent);
	color: #fff;
	display: grid;
	place-items: center;
	box-shadow: 0 10px 28px -8px rgb(3 25 46 / 45%);
	cursor: pointer;
}

.a11y-launcher.is-left {
	inset-inline-start: var(--a11y-launcher-x);
}

.a11y-launcher.is-right {
	inset-inline-end: var(--a11y-launcher-x);
}

.a11y-launcher.is-top {
	top: var(--a11y-launcher-y);
}

.a11y-launcher.is-bottom {
	bottom: var(--a11y-launcher-y);
}

.a11y-launcher:hover,
.a11y-launcher:focus-visible {
	background: var(--navy-800, #0a3059);
}

.a11y-launcher svg {
	width: 1.9rem;
	height: 1.9rem;
}

/* ── Panel ───────────────────────────────────────────────────────────────── */

.a11y-panel {
	position: fixed;
	z-index: 1210;
	top: 0;
	bottom: 0;
	inset-inline-start: 0;
	width: min(var(--a11y-panel-w), 92vw);
	background: #fff;
	color: var(--ink-900, #0d1c2b);
	box-shadow: 0 0 60px -10px rgb(3 25 46 / 45%);
	display: flex;
	flex-direction: column;
	transform: translateX(-102%);
	transition: transform 0.22s ease, visibility 0.22s;
	font-size: 0.9rem;

	/*
	 * visibility, not the hidden attribute. It keeps the panel out of the
	 * accessibility tree and out of the tab order while closed, animates, and
	 * needs no frame callback to open — a panel that only appears once
	 * requestAnimationFrame fires is a panel that stays shut in a background
	 * tab.
	 */
	visibility: hidden;
}

.a11y-panel.is-right {
	inset-inline-start: auto;
	inset-inline-end: 0;
	transform: translateX(102%);
}

.a11y-panel.is-open {
	transform: translateX(0);
	visibility: visible;
}

.a11y-backdrop {
	position: fixed;
	inset: 0;
	z-index: 1205;
	background: rgb(0 19 34 / 45%);
}

.a11y-backdrop[hidden] {
	display: none;
}

.a11y-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.7rem 0.9rem;
	background: var(--a11y-accent);
	color: #fff;
}

.a11y-head h2 {
	font-size: 1.02rem;
	margin: 0;
	color: #fff;
}

.a11y-close {
	width: 2rem;
	height: 2rem;
	border: 0;
	border-radius: 50%;
	background: rgb(255 255 255 / 18%);
	color: #fff;
	display: grid;
	place-items: center;
	cursor: pointer;
	flex: none;
}

.a11y-close:hover {
	background: rgb(255 255 255 / 34%);
}

.a11y-close svg {
	width: 1rem;
	height: 1rem;
}

.a11y-body {
	overflow-y: auto;
	padding: 0.8rem 0.9rem 0.9rem;
	flex: 1;
}

.a11y-group + .a11y-group {
	margin-top: 0.7rem;
}

.a11y-group > h3 {
	font-size: 0.66rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--ink-500, #5f7488);
	margin: 0 0 0.4rem;
}

/* ── Tiles ───────────────────────────────────────────────────────────────── */

/*
 * Profiles, colour modes and tools are all the same tile, in one auto-filling
 * grid. A row of labelled switches pushed the panel past two screens; icons in
 * a grid put the whole thing in view, which for a panel a visitor may be
 * opening precisely because reading is hard is the point of it.
 */
.a11y-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(4.6rem, 1fr));
	gap: 0.4rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.a11y-tile {
	width: 100%;
	height: 100%;
	min-height: 3.6rem;
	border: 1px solid var(--line, #e2e8ee);
	border-radius: 11px;
	background: #fff;
	color: inherit;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.22rem;
	padding: 0.4rem 0.2rem;
	font: inherit;
	font-size: 0.68rem;
	line-height: 1.15;
	text-align: center;
	cursor: pointer;
	hyphens: auto;
}

.a11y-tile svg {
	width: 1.3rem;
	height: 1.3rem;
	flex: none;
	color: var(--a11y-accent);
}

.a11y-tile:hover {
	border-color: var(--a11y-accent);
}

/* Pressed state carries no text: aria-pressed is what a screen reader reads. */
.a11y-tile[aria-pressed="true"] {
	border-color: var(--a11y-accent);
	background: var(--teal-100, #e0f5f2);
	font-weight: 700;
}

.a11y-tile[aria-pressed="true"] svg {
	color: var(--teal-600, #0f7f76);
}

/* ── Steppers ────────────────────────────────────────────────────────────── */

.a11y-grid-steps {
	grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
}

.a11y-step {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.2rem;
	padding: 0.4rem 0.3rem;
	border: 1px solid var(--line, #e2e8ee);
	border-radius: 11px;
	min-height: 3.6rem;
	justify-content: center;
}

.a11y-step svg {
	width: 1.15rem;
	height: 1.15rem;
	color: var(--a11y-accent);
}

.a11y-step-label {
	font-size: 0.66rem;
	line-height: 1.15;
	text-align: center;
}

.a11y-step-controls {
	display: flex;
	align-items: center;
	gap: 0.2rem;
	flex: none;
}

.a11y-step button {
	width: 1.5rem;
	height: 1.5rem;
	border: 1px solid var(--line, #e2e8ee);
	border-radius: 7px;
	background: var(--sand-50, #f6f8fa);
	color: inherit;
	font: inherit;
	font-size: 0.8rem;
	font-weight: 700;
	cursor: pointer;
	line-height: 1;
	padding: 0;
}

.a11y-step button:hover {
	background: var(--a11y-accent);
	border-color: var(--a11y-accent);
	color: #fff;
}

.a11y-step output {
	min-width: 2.6rem;
	text-align: center;
	font-size: 0.7rem;
	font-variant-numeric: tabular-nums;
}

.a11y-foot {
	margin-top: 0.85rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.a11y-reset {
	padding: 0.5rem 1rem;
	border: 1px solid var(--line, #e2e8ee);
	border-radius: 100px;
	background: #fff;
	color: inherit;
	font: inherit;
	font-weight: 700;
	font-size: 0.84rem;
	cursor: pointer;
}

.a11y-reset:hover {
	background: var(--navy-800, #0a3059);
	border-color: var(--navy-800, #0a3059);
	color: #fff;
}

.a11y-statement {
	text-align: center;
	font-size: 0.8rem;
	color: var(--teal-600, #0f7f76);
	text-decoration: underline;
}

@media (max-width: 480px) {
	.a11y-grid,
	.a11y-grid-steps {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* ══════════════════════════════════════════════════════════════════════════
   The adjustments themselves
   ══════════════════════════════════════════════════════════════════════════ */

/* Text metrics. The panel is exempt so its own controls stay usable. */
html[data-a11y-line] body :not(.a11y-panel):not(.a11y-panel *) {
	line-height: var(--a11y-line);
}

html[data-a11y-letter] body :not(.a11y-panel):not(.a11y-panel *) {
	letter-spacing: var(--a11y-letter);
	word-spacing: var(--a11y-word);
}

/* A face with wide apertures and distinct letterforms, from what is installed. */
html[data-a11y-font="readable"] body :not(.a11y-panel):not(.a11y-panel *) {
	font-family: "Atkinson Hyperlegible", "Comic Sans MS", Verdana, Tahoma, sans-serif !important;
}

html[data-a11y-align="left"] body :not(.a11y-panel):not(.a11y-panel *) {
	text-align: start !important;
}

/* Link and heading emphasis, for anyone who cannot rely on colour alone. */
html[data-a11y-links="on"] body a:not(.a11y-panel a) {
	text-decoration: underline !important;
	text-underline-offset: 3px;
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

html[data-a11y-headings="on"] body :is(h1, h2, h3, h4, h5, h6):not(.a11y-panel *) {
	outline: 2px dashed var(--orange-500, #f0913f);
	outline-offset: 4px;
}

/*
 * High contrast.
 *
 * Implemented here rather than left to the template. The panel sets
 * data-a11y-contrast on <html>, and a template that has never heard of this
 * plugin has no rules for it — which is exactly what happened when the panel
 * moved off its original template and onto a Helix one: the switch lit up and the
 * page did not change.
 *
 * A forced black-on-white-text palette rather than a nudge to the existing one,
 * because the existing one is unknown. It is blunt by design; everything is
 * !important because it has to beat whatever the template asserts.
 */
html[data-a11y-contrast="on"] body,
html[data-a11y-contrast="on"] body * {
	background-color: #000 !important;
	background-image: none !important;
	color: #fff !important;
	border-color: #fff !important;
	text-shadow: none !important;
	box-shadow: none !important;
}

html[data-a11y-contrast="on"] body a {
	color: #ff0 !important;
	text-decoration: underline !important;
}

html[data-a11y-contrast="on"] body :is(button, input, select, textarea) {
	border: 1px solid #fff !important;
}

/* Photographs stay, but lift them off the black so edges remain findable. */
html[data-a11y-contrast="on"] body :is(img, video) {
	outline: 1px solid #fff;
	background: #000 !important;
}

html[data-a11y-contrast="on"] body :is(svg, svg *) {
	fill: currentColor !important;
	stroke: currentColor !important;
	background: none !important;
}

/*
 * The panel itself is exempt, or its own controls become unreadable at the
 * moment they are most needed. These come after the block above and carry an
 * extra class, so they win on both order and specificity.
 */
html[data-a11y-contrast="on"] .a11y-panel,
html[data-a11y-contrast="on"] .a11y-panel * {
	background-color: #fff !important;
	color: #000 !important;
	border-color: #000 !important;
}

html[data-a11y-contrast="on"] .a11y-panel :is(.a11y-head, .a11y-head *) {
	background-color: #000 !important;
	color: #fff !important;
}

html[data-a11y-contrast="on"] .a11y-panel .a11y-tile[aria-pressed="true"] {
	background-color: #000 !important;
	color: #fff !important;
}

html[data-a11y-contrast="on"] .a11y-panel a {
	color: #00006b !important;
}

html[data-a11y-contrast="on"] .a11y-launcher,
html[data-a11y-contrast="on"] .a11y-launcher * {
	background-color: #000 !important;
	color: #fff !important;
	border: 2px solid #fff !important;
}

/* Colour filters. Media is inverted back so photographs stay readable. */
html[data-a11y-filter="invert"] {
	filter: invert(1) hue-rotate(180deg);
	background: #fff;
}

html[data-a11y-filter="invert"] img,
html[data-a11y-filter="invert"] video,
html[data-a11y-filter="invert"] iframe,
html[data-a11y-filter="invert"] svg image {
	filter: invert(1) hue-rotate(180deg);
}

html[data-a11y-filter="mono"] {
	filter: grayscale(1);
}

html[data-a11y-filter="lowsat"] {
	filter: saturate(0.5);
}

html[data-a11y-filter="highsat"] {
	filter: saturate(1.8);
}

/* The panel must not be filtered, or its own controls become unreadable. */
html[data-a11y-filter] .a11y-panel,
html[data-a11y-filter] .a11y-launcher {
	filter: none;
}

html[data-a11y-cursor="on"] body,
html[data-a11y-cursor="on"] body * {
	cursor:
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M8 4 38 22 24 25 30 40 24 43 18 28 8 36Z' fill='%23fff' stroke='%23000' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E")
		4 2, auto;
}

html[data-a11y-motion="off"] body *,
html[data-a11y-motion="off"] body *::before,
html[data-a11y-motion="off"] body *::after {
	animation: none !important;
	transition: none !important;
	scroll-behavior: auto !important;
}

html[data-a11y-images="off"] body :is(img, picture, video):not(.a11y-panel *) {
	visibility: hidden !important;
}

html[data-a11y-images="off"] body :is(.hero-bg, .site-footer::before) {
	display: none !important;
}

/* Read mode strips the decorative bands back to the content. */
html[data-a11y-read="on"] body :is([data-a11y-decorative], .hero-bg,
	[class*="-s-gallery"], [class*="-s-agencies"], [class*="-s-gateways"]) {
	display: none !important;
}

html[data-a11y-read="on"] body :is([class*="card"], .cta-banner, .service-feature) {
	box-shadow: none !important;
	background: #fff !important;
	color: #111 !important;
	border: 1px solid #767676 !important;
}

/* Reading guide and mask follow the pointer; the JS sets --a11y-y. */
.a11y-guide,
.a11y-mask-top,
.a11y-mask-bottom {
	position: fixed;
	inset-inline: 0;
	z-index: 1150;
	pointer-events: none;
}

.a11y-guide {
	top: calc(var(--a11y-y, 50vh) - 2px);
	height: 4px;
	background: var(--orange-500, #f0913f);
	box-shadow: 0 0 0 1px rgb(0 0 0 / 35%);
}

.a11y-mask-top {
	top: 0;
	height: calc(var(--a11y-y, 50vh) - 70px);
	background: rgb(0 19 34 / 72%);
}

.a11y-mask-bottom {
	top: calc(var(--a11y-y, 50vh) + 70px);
	bottom: 0;
	background: rgb(0 19 34 / 72%);
}

/* Hearing: flag anything that carries sound, since the page cannot caption it. */
html[data-a11y-media="on"] body :is(video, audio, iframe) {
	outline: 3px solid var(--orange-500, #f0913f);
	outline-offset: 3px;
}

.a11y-media-note {
	display: block;
	margin: 0.4rem 0 1rem;
	padding: 0.5rem 0.75rem;
	border-inline-start: 4px solid var(--orange-500, #f0913f);
	background: var(--orange-100, #fdead8);
	color: #3a2a17;
	font-size: 0.82rem;
}

/* Motor: bigger hit areas and an unmissable focus ring. */
html[data-a11y-targets="on"] body :is(a, button, input, select, [role="button"]):not(.a11y-panel *) {
	min-height: 44px;
	min-width: 44px;
}

html[data-a11y-targets="on"] body :focus-visible {
	outline: 4px solid var(--orange-500, #f0913f) !important;
	outline-offset: 3px !important;
}

@media print {
	.a11y-launcher,
	.a11y-panel,
	.a11y-backdrop,
	.a11y-guide,
	.a11y-mask-top,
	.a11y-mask-bottom {
		display: none !important;
	}
}

/* ── Reading aloud ───────────────────────────────────────────────────────── */

/*
 * The block currently being spoken. Marked with an outline and a tint rather
 * than a colour swap, so it stays legible under every colour mode above —
 * including high contrast, where it picks up the forced palette's own colours.
 */
.a11y-speaking {
	outline: 3px solid var(--orange-500, #f0913f) !important;
	outline-offset: 3px;
	background-color: var(--orange-100, #fdead8) !important;
}

/*
 * Click-to-read gives every readable block a pointer, so it is obvious the
 * page has changed mode and what will respond to a click.
 */
html[data-a11y-speech="on"] body :is(p, li, h1, h2, h3, h4, h5, h6, td, th, dd, dt, figcaption, blockquote) {
	cursor: pointer;
}

/* A browser with no speech synthesis gets no controls for it. */
html[data-a11y-speechless] .a11y-group-speech {
	display: none;
}
