/*
 * STAAK Accessibility for Multisite - page adjustments.
 *
 * Each feature is a class on <html>: .sa11y-<feature>.
 * The widget lives in a shadow root on #staak-a11y-root, so every rule here
 * excludes that host and nothing in this file reaches the widget itself.
 * Text size is applied by widget.js as inline styles, not here.
 */

/* ---------- Content ---------- */

html.sa11y-line-height body *:not(#staak-a11y-root) {
	line-height: var(--sa11y-line-height, 1.6) !important;
}

html.sa11y-letter-spacing body *:not(#staak-a11y-root) {
	letter-spacing: var(--sa11y-letter-spacing, 0.05em) !important;
	word-spacing: var(--sa11y-word-spacing, 0.16em) !important;
}

/* Icon fonts are left alone so glyphs do not turn into letters. */
html.sa11y-readable-font body *:not(#staak-a11y-root):not(i):not([class*="icon"]):not([class*="fa-"]):not([class^="fa"]):not([class*="dashicons"]):not(.material-icons) {
	font-family: "Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", Arial, sans-serif !important;
}

html.sa11y-highlight-links body a:not(#staak-a11y-root),
html.sa11y-highlight-links body [role="link"] {
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: 3px !important;
	outline: 3px solid #ffbf47 !important;
	outline-offset: 2px !important;
}

html.sa11y-highlight-headings body :is(h1, h2, h3, h4, h5, h6, [role="heading"]) {
	outline: 3px solid #1d70b8 !important;
	outline-offset: 4px !important;
}

/* Element being read aloud. */
html body .sa11y-speaking {
	outline: 3px solid #ffbf47 !important;
	outline-offset: 3px !important;
	background-color: rgba(255, 191, 71, 0.25) !important;
}

/* ---------- Colour and contrast ---------- */

/*
 * Filters go on the direct children of <body>, never on <html> or <body>.
 * A filter on an ancestor would break position: fixed inside it and would
 * also recolour the widget. preload.js/widget.js build --sa11y-filter.
 */
html.sa11y-filter body > *:not(#staak-a11y-root) {
	filter: var(--sa11y-filter) !important;
}

html.sa11y-dark-contrast body,
html.sa11y-dark-contrast body *:not(#staak-a11y-root) {
	background-color: #000 !important;
	background-image: none !important;
	color: #fff !important;
	border-color: #fff !important;
	text-shadow: none !important;
	box-shadow: none !important;
}

html.sa11y-dark-contrast body a:not(#staak-a11y-root),
html.sa11y-dark-contrast body a *:not(#staak-a11y-root) {
	color: #ffd400 !important;
}

html.sa11y-dark-contrast body :is(button, input, select, textarea) {
	border: 2px solid #fff !important;
}

html.sa11y-dark-contrast body svg {
	fill: currentColor;
}

html.sa11y-light-contrast body,
html.sa11y-light-contrast body *:not(#staak-a11y-root) {
	background-color: #fff !important;
	background-image: none !important;
	color: #000 !important;
	border-color: #000 !important;
	text-shadow: none !important;
	box-shadow: none !important;
}

html.sa11y-light-contrast body a:not(#staak-a11y-root),
html.sa11y-light-contrast body a *:not(#staak-a11y-root) {
	color: #0b3d91 !important;
}

html.sa11y-light-contrast body :is(button, input, select, textarea) {
	border: 2px solid #000 !important;
}

/*
 * Site logos are usually dark artwork on a light page. On black they all but
 * disappear, so Dark contrast shows them as white shapes.
 */
html.sa11y-dark-contrast body :is(.custom-logo, .custom-logo-link img, .site-logo img, .logo-wrapper img, .navbar-brand img, header [class*="logo"] img, .nh-landing-bar img):not(#staak-a11y-root) {
	background-color: transparent !important;
	filter: brightness(0) invert(1) !important;
}

/*
 * Images keep their own colours in both contrast modes. :not() matches the
 * ID weight of the catch-all rules above, which otherwise win.
 */
html.sa11y-dark-contrast body :is(img, video, picture, iframe):not(#staak-a11y-root),
html.sa11y-light-contrast body :is(img, video, picture, iframe):not(#staak-a11y-root) {
	background-color: transparent !important;
}

/* ---------- Navigation ---------- */

html.sa11y-big-cursor,
html.sa11y-big-cursor body *:not(#staak-a11y-root) {
	cursor: url("../img/cursor.svg") 3 2, auto !important;
}

html.sa11y-big-cursor body :is(a, button, [role="button"], label, summary, select, input[type="checkbox"], input[type="radio"], input[type="submit"], input[type="button"]) {
	cursor: url("../img/pointer.svg") 17 5, pointer !important;
}

html.sa11y-big-cursor body :is(input:not([type]), input[type="text"], input[type="email"], input[type="search"], input[type="tel"], input[type="url"], input[type="number"], input[type="password"], textarea, [contenteditable="true"]) {
	cursor: text !important;
}

html.sa11y-stop-animations *:not(#staak-a11y-root),
html.sa11y-stop-animations *::before,
html.sa11y-stop-animations *::after {
	animation-duration: 0.001ms !important;
	animation-delay: 0s !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0.001ms !important;
	transition-delay: 0s !important;
	scroll-behavior: auto !important;
}

html.sa11y-hide-images body :is(img, picture, video, svg image, [role="img"]):not(#staak-a11y-root) {
	visibility: hidden !important;
}

html.sa11y-hide-images body *:not(#staak-a11y-root) {
	background-image: none !important;
}

html.sa11y-focus-highlight body *:focus,
html.sa11y-focus-highlight body *:focus-visible {
	outline: 3px solid #ffbf47 !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px #0b0c0c !important;
}

/* Hide the launcher for printing. */
@media print {
	#staak-a11y-root {
		display: none !important;
	}
}
