/*
 * Accessibility and UX fixes.
 *
 * Plain CSS, no build step. Enqueued in functions.php after style.css
 * (the compiled theme stylesheet), so rules here win at equal specificity.
 * One block per audit item, each labelled with the item it closes.
 */

/*
 * 1. Pages must not scroll in two dimensions on small screens (WCAG 1.4.10 Reflow).
 * Long unbroken strings (bare URLs, emails) were wider than a 320px viewport, e.g. the
 * SurveyMonkey link on /online-survey-listening-to-the-nation/ and the contact email on /about/.
 * Set site-wide: break-word only breaks a word when it can't fit its line, and unlike
 * `anywhere` it doesn't change min-content sizing, so tables, flex items and normal text
 * are unchanged.
 */
body {
	overflow-wrap: break-word;
}

/*
 * 2. Controls must change appearance when they receive focus (WCAG 2.4.7 Focus Visible).
 * _normalize.scss removes every outline (*:focus and input/textarea:focus { outline: none }).
 * This restores a ring for keyboard users only (:focus-visible, so mouse clicks stay clean).
 * Two-tone: white inner band plus a softly blurred black ring, so it shows on white, the
 * orange buttons and the image-backed hero and footer alike. Drawn with box-shadow (an
 * outline can't blur); the transparent outline stays so Windows High Contrast mode, which
 * drops shadows, still draws a ring. element:focus-visible matches the specificity of the
 * old input:focus rule and loads later, so it wins without touching style.css.
 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid transparent;
	outline-offset: 2px;
	box-shadow: 0 0 0 2px #fff, 0 0 3px 4px rgba(0, 0, 0, 0.9);
}

/*
 * 1b. Wide tables scroll inside their own box instead of widening the page.
 * The .table-scroll wrapper is added around every content table by the acp mu-plugin
 * (acp_wrap_content_tables). Tables that fit never show a scrollbar.
 */
.table-scroll {
	max-width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	margin-bottom: 1.5em;
}

.table-scroll > table {
	margin-bottom: 0;
}

.table-scroll:focus-visible {
	outline: 2px solid transparent;
	box-shadow: 0 0 0 2px #fff, 0 0 3px 4px rgba(0, 0, 0, 0.9);
}

/*
 * 1c. Video embeds shrink to fit narrow screens.
 * YouTube/Vimeo iframes are pasted with fixed width="560" height="315", which pushed
 * pages to ~580px wide on phones. Capping the width and deriving the height from 16:9
 * keeps them whole; where 560px fits (desktop) they render exactly as before.
 */
iframe[src*="youtube.com"],
iframe[src*="youtube-nocookie.com"],
iframe[src*="player.vimeo.com"] {
	max-width: 100%;
	height: auto;
	aspect-ratio: 16 / 9;
}

/*
 * 4. Skip to content link (WCAG 2.4.1 Bypass Blocks).
 * The link is output first in header.php and points at #content, which every template has.
 * It stays off-screen until it gets keyboard focus, then shows in the top-left corner.
 * #content has tabindex="-1" so focus moves there; it never needs a visible ring.
 */
.skip-link {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 100000;
	padding: 12px 18px;
	background: #fff;
	color: #000;
	font-family: Montserrat, sans-serif;
	font-weight: 600;
	font-size: 16px;
	text-decoration: none;
	transform: translateY(-200%);
}

.skip-link:focus {
	transform: none;
}

#content:focus {
	outline: none;
}

/*
 * 5. Screen-reader-only text must reach screen readers.
 * style.css had .screen-reader-text { display: none }, which hides it from assistive tech
 * too (e.g. the search field's "Search for:" label). Standard visually-hidden pattern instead.
 */
.screen-reader-text {
	display: block;
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/*
 * 3. Text must stay visible while webfonts load (font-display).
 * Montserrat and Lora: fixed in header.php by adding &display=swap to the Google Fonts URLs.
 * Font Awesome 5.1.0 comes from use.fontawesome.com, whose CSS has no font-display and
 * can't be edited. These faces repeat its three @font-face rules (same family, weight and
 * files) with font-display: swap. This file loads after the CDN stylesheet (wp_head() comes
 * after it in header.php), so these definitions are the ones the browser uses.
 */
@font-face {
	font-family: "Font Awesome 5 Brands";
	font-style: normal;
	font-weight: normal;
	font-display: swap;
	src: url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-brands-400.woff2) format("woff2"),
		url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-brands-400.woff) format("woff");
}

@font-face {
	font-family: "Font Awesome 5 Free";
	font-style: normal;
	font-weight: 400;
	font-display: swap;
	src: url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-regular-400.woff2) format("woff2"),
		url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-regular-400.woff) format("woff");
}

@font-face {
	font-family: "Font Awesome 5 Free";
	font-style: normal;
	font-weight: 900;
	font-display: swap;
	src: url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-solid-900.woff2) format("woff2"),
		url(https://use.fontawesome.com/releases/v5.1.0/webfonts/fa-solid-900.woff) format("woff");
}
