/**
 * WCAG toolbar — chrome and reader preferences.
 *
 * Two halves. The .wcag-* blocks draw the toolbar and are scoped like any other
 * component. The html.wcag-* rules are the preferences themselves, and those
 * carry !important on purpose: a reader who asks for bigger type has to win
 * against whatever the site's own stylesheet says, and no amount of specificity
 * beats arbitrary template CSS. It is the one place where the override is the
 * whole point.
 *
 * No @layer either: as a drop-in module the chrome must win against a host
 * template's unlayered base CSS, which would beat any layered rule regardless.
 */

.wcag,
.wcag *,
.wcag *::before,
.wcag *::after {
	box-sizing: border-box;
}

.wcag {
	--wcag-surface: #ffffff;
	--wcag-text: #1a1a1a;
	--wcag-muted: #555555;
	--wcag-btn-bg: #f4f4f6;
	--wcag-btn-bg-hover: #e9e9ee;
	--wcag-border: #d1d1d6;
	--wcag-backdrop: rgba(0, 0, 0, 0.4);
	--wcag-radius: 10px;
	--wcag-gap: 8px;
	--wcag-panel-inline: 380px;
	--wcag-trigger-size: 52px;
	--wcag-offset: 20px;
	--wcag-duration: 0.25s;
	--wcag-focus-width: 3px;
	--wcag-focus-offset: 2px;

	/* Above the site, below nothing: the toolbar is the last thing a reader
	   should lose behind a sticky header. */
	--wcag-z-guide: 2147483644;
	--wcag-z-backdrop: 2147483645;
	--wcag-z-trigger: 2147483646;
	--wcag-z-panel: 2147483647;
}

/* --- Trigger ----------------------------------------------------------- */

.wcag-trigger {
	position: fixed;
	z-index: var(--wcag-z-trigger);
	display: flex;
	align-items: center;
	justify-content: center;
	inline-size: var(--wcag-trigger-size);
	block-size: var(--wcag-trigger-size);
	padding: 0;
	border: 3px solid #ffffff;
	border-radius: 50%;
	background-color: var(--wcag-accent, #0054c8);
	color: #ffffff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	cursor: pointer;
	font: inherit;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wcag-trigger:hover {
	transform: scale(1.08);
}

.wcag-trigger:focus-visible {
	outline: var(--wcag-focus-width) solid #ffffff;
	outline-offset: var(--wcag-focus-offset);
	box-shadow: 0 0 0 calc(var(--wcag-focus-width) + var(--wcag-focus-offset) + 2px) #000000;
}

.wcag-trigger__icon {
	display: block;
	pointer-events: none;
}

.wcag-pos-bottom-right {
	inset-block-end: var(--wcag-offset);
	inset-inline-end: var(--wcag-offset);
}

.wcag-pos-bottom-left {
	inset-block-end: var(--wcag-offset);
	inset-inline-start: var(--wcag-offset);
}

.wcag-pos-top-right {
	inset-block-start: var(--wcag-offset);
	inset-inline-end: var(--wcag-offset);
}

.wcag-pos-top-left {
	inset-block-start: var(--wcag-offset);
	inset-inline-start: var(--wcag-offset);
}

/* --- Panel ------------------------------------------------------------- */

/**
 * Hidden rather than merely slid away. A panel parked off screen with
 * aria-hidden is still in the tab order, so the keyboard walks into controls
 * nobody can see. visibility takes it out of the tree and out of the tab order
 * at once, and still transitions.
 */
.wcag-panel {
	position: fixed;
	z-index: var(--wcag-z-panel);
	inset-block: 0;
	inset-inline-end: 0;
	display: flex;
	flex-direction: column;
	inline-size: min(var(--wcag-panel-inline), 92vw);
	background-color: var(--wcag-surface);
	color: var(--wcag-text);
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
	visibility: hidden;
	transform: translateX(100%);
	/**
	 * Visibility is not a gradual thing: given a duration it flips at the
	 * halfway mark, and a panel that is still hidden cannot be focused. So it
	 * waits for the slide to finish on the way out, and switches at once on the
	 * way in, where the keyboard is about to land.
	 */
	transition: transform var(--wcag-duration) ease, visibility 0s linear var(--wcag-duration);
	font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.wcag-panel--left {
	inset-inline-end: auto;
	inset-inline-start: 0;
	transform: translateX(-100%);
	box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.wcag-panel.is-open {
	visibility: visible;
	transform: translateX(0);
	transition: transform var(--wcag-duration) ease, visibility 0s linear 0s;
}

.wcag-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 18px 20px;
	background-color: var(--wcag-accent, #0054c8);
	color: #ffffff;
}

.wcag-head__title {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
}

.wcag-head__sub {
	margin: 2px 0 0;
	font-size: 13px;
	opacity: 0.9;
}

.wcag-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	inline-size: 36px;
	block-size: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background-color: rgba(255, 255, 255, 0.15);
	color: #ffffff;
	cursor: pointer;
}

.wcag-close:hover {
	background-color: rgba(255, 255, 255, 0.3);
}

.wcag-close:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: var(--wcag-focus-offset);
}

.wcag-body {
	flex: 1;
	padding: 16px 20px;
	overflow-y: auto;
}

.wcag-group + .wcag-group {
	margin-block-start: 22px;
}

.wcag-group__title {
	margin: 0 0 10px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--wcag-muted);
}

.wcag-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--wcag-gap);
}

.wcag-btn {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	min-block-size: 78px;
	padding: 12px 10px;
	border: 2px solid transparent;
	border-radius: var(--wcag-radius);
	background-color: var(--wcag-btn-bg);
	color: var(--wcag-text);
	font: inherit;
	text-align: center;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.wcag-btn:hover {
	background-color: var(--wcag-btn-bg-hover);
}

.wcag-btn:focus-visible {
	outline: 2px solid var(--wcag-accent, #0054c8);
	outline-offset: var(--wcag-focus-offset);
}

.wcag-btn[aria-pressed="true"] {
	background-color: var(--wcag-accent, #0054c8);
	border-color: var(--wcag-accent, #0054c8);
	color: #ffffff;
}

.wcag-btn__icon {
	display: block;
	flex-shrink: 0;
	pointer-events: none;
}

.wcag-btn__label {
	font-size: 13px;
	line-height: 1.25;
}

.wcag-btn__level {
	font-size: 11px;
	opacity: 0.75;
}

.wcag-foot {
	display: flex;
	flex-direction: column;
	gap: var(--wcag-gap);
	padding: 14px 20px;
	border-block-start: 1px solid #eeeeee;
	background-color: #fafafa;
}

.wcag-reset {
	padding: 10px;
	border: 2px solid var(--wcag-border);
	border-radius: 8px;
	background-color: var(--wcag-surface);
	color: var(--wcag-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.wcag-reset:hover {
	background-color: var(--wcag-btn-bg);
}

.wcag-reset:focus-visible {
	outline: 2px solid var(--wcag-accent, #0054c8);
	outline-offset: var(--wcag-focus-offset);
}

.wcag-meta {
	margin: 0;
	font-size: 11px;
	color: var(--wcag-text);
	text-align: center;
}

.wcag-meta__link {
	color: var(--wcag-accent, #0054c8);
}

.wcag-backdrop {
	position: fixed;
	z-index: var(--wcag-z-backdrop);
	inset: 0;
	background-color: var(--wcag-backdrop);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

.wcag-backdrop.is-open {
	opacity: 1;
	pointer-events: auto;
}

/* --- Skip link --------------------------------------------------------- */

.wcag-skip {
	position: fixed;
	z-index: var(--wcag-z-panel);
	inset-block-start: -100px;
	inset-inline-start: 10px;
	padding: 10px 16px;
	border-radius: 0 0 8px 8px;
	background-color: var(--wcag-accent, #0054c8);
	color: #ffffff;
	font-weight: 600;
	text-decoration: none;
	transition: inset-block-start 0.2s ease;
}

.wcag-skip:focus {
	inset-block-start: 0;
	outline: var(--wcag-focus-width) solid #ffffff;
	outline-offset: var(--wcag-focus-offset);
}

/* --- Reading guide ----------------------------------------------------- */

/* The script feeds the pointer's height in through the token, never a style attribute. */
.wcag-guide {
	position: fixed;
	z-index: var(--wcag-z-guide);
	inset-inline: 0;
	inset-block-start: var(--wcag-guide-y, -100px);
	block-size: 40px;
	background-color: rgba(255, 235, 59, 0.35);
	border-block: 2px solid #f9a825;
	pointer-events: none;
	display: none;
}

html.wcag-guide-on .wcag-guide {
	display: block;
}

@media (max-width: 480px) {
	.wcag-panel {
		inline-size: 100vw;
	}
}

/* --- Reader preferences ------------------------------------------------ */
/*
 * Everything below overrides the site on the reader's orders. Hence !important.
 *
 * And every one of them steps around the toolbar itself, through
 * :not(.wcag, .wcag *). The panel is the instrument, not the page: let dyslexia
 * spacing or a dark scheme land on it and the reader is left adjusting a
 * control they can no longer read. Big cursor and paused motion are the
 * exceptions on purpose — those should reach everything, this panel included.
 */

html.wcag-fs-n2 body { font-size: 0.9em !important; }
html.wcag-fs-n1 body { font-size: 0.95em !important; }
html.wcag-fs-1 body { font-size: 1.1em !important; }
html.wcag-fs-2 body { font-size: 1.2em !important; }
html.wcag-fs-3 body { font-size: 1.3em !important; }
html.wcag-fs-4 body { font-size: 1.45em !important; }
html.wcag-fs-5 body { font-size: 1.6em !important; }

html.wcag-lh-1 body, html.wcag-lh-1 body *:not(.wcag, .wcag *) { line-height: 1.5 !important; }
html.wcag-lh-2 body, html.wcag-lh-2 body *:not(.wcag, .wcag *) { line-height: 2 !important; }
html.wcag-lh-3 body, html.wcag-lh-3 body *:not(.wcag, .wcag *) { line-height: 2.5 !important; }

html.wcag-ls-1 body, html.wcag-ls-1 body *:not(.wcag, .wcag *) { letter-spacing: 0.05em !important; }
html.wcag-ls-2 body, html.wcag-ls-2 body *:not(.wcag, .wcag *) { letter-spacing: 0.12em !important; }

html.wcag-readable body, html.wcag-readable body *:not(.wcag, .wcag *) {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/**
 * Whatever the reader has installed comes first. The font is not shipped and
 * not fetched from a third party: a stranger's CDN on every page view is not
 * ours to sign the visitor up for.
 */
html.wcag-dyslexia body, html.wcag-dyslexia body *:not(.wcag, .wcag *) {
	font-family: "OpenDyslexic", "Open Dyslexic", "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif !important;
	letter-spacing: 0.05em !important;
	word-spacing: 0.1em !important;
}

html.wcag-hl-links a:not(.wcag *),
html.wcag-hl-links a:visited:not(.wcag *) {
	text-decoration: underline !important;
	text-underline-offset: 3px !important;
	background-color: #fff8a8 !important;
	color: #003366 !important;
	box-shadow: 0 0 0 2px #fff8a8 !important;
}

html.wcag-hl-headings :is(h1, h2, h3, h4, h5, h6):not(.wcag *) {
	outline: 2px dashed var(--wcag-accent, #0054c8) !important;
	outline-offset: 4px !important;
}

html.wcag-cm-dark body { background-color: #111111 !important; color: #eeeeee !important; }
html.wcag-cm-dark body :is(p, h1, h2, h3, h4, h5, h6, li, td, th, span, div, article, section, header, footer, nav, aside):not(.wcag, .wcag *) {
	background-color: transparent !important;
	color: #eeeeee !important;
}
html.wcag-cm-dark body a:not(.wcag *) { color: #6ab0ff !important; }

html.wcag-cm-light body { background-color: #ffffff !important; color: #111111 !important; }
html.wcag-cm-light body :is(p, h1, h2, h3, h4, h5, h6, li, td, th, span, div, article, section, header, footer, nav, aside):not(.wcag, .wcag *) {
	background-color: transparent !important;
	color: #111111 !important;
}

html.wcag-cm-hc body { background-color: #000000 !important; color: #ffffff !important; }
html.wcag-cm-hc body :is(p, h1, h2, h3, h4, h5, h6, li, td, th, span, div, article, section, header, footer, nav, aside):not(.wcag, .wcag *) {
	background-color: transparent !important;
	color: #ffffff !important;
}
html.wcag-cm-hc body :is(a, button):not(.wcag *) { color: #ffeb3b !important; text-decoration: underline !important; }

/**
 * The filter goes on the root element, never on the body. A filter makes its
 * element the containing block for fixed positioned descendants — except on the
 * root, which the spec exempts. Put it on body and every fixed thing on the page
 * tears loose and scrolls away, this toolbar's own button included.
 */
html.wcag-cm-invert { filter: invert(1) hue-rotate(180deg) !important; }
html.wcag-cm-grayscale { filter: grayscale(1) !important; }

/**
 * Inverted twice is upright again. Artwork keeps its own colours, and so does
 * the toolbar, which would otherwise be a photo negative of itself while the
 * reader is trying to use it.
 *
 * Each fixed element is listed on its own: filtering the .wcag wrapper instead
 * would make that wrapper the containing block for the fixed children inside it,
 * and they would land wherever its empty box happens to sit.
 */
html.wcag-cm-invert :is(img, video, iframe),
html.wcag-cm-invert .wcag-trigger,
html.wcag-cm-invert .wcag-panel,
html.wcag-cm-invert .wcag-skip,
html.wcag-cm-invert .wcag-guide {
	filter: invert(1) hue-rotate(180deg) !important;
}

html.wcag-big-cursor,
html.wcag-big-cursor * {
	cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='black' stroke='white' stroke-width='1.5' d='M3 2l7 18 2-8 8-2z'/></svg>") 0 0, auto !important;
}

html.wcag-big-cursor :is(a, button, [role="button"]) {
	cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='black' stroke='white' stroke-width='1.5' d='M9 2v8H4l8 12 8-12h-5V2z'/></svg>") 24 24, pointer !important;
}

html.wcag-no-anim *,
html.wcag-no-anim *::before,
html.wcag-no-anim *::after {
	animation: none !important;
	transition: none !important;
	scroll-behavior: auto !important;
}

html.wcag-no-anim video { animation-play-state: paused !important; }

/* The toolbar's own artwork stays put: hiding it would hide the way out. */
html.wcag-no-img :is(img, picture, video, [style*="background-image"]):not(.wcag *) {
	visibility: hidden !important;
}
