/*
 * Reset, typography and the accessibility primitives.
 *
 * Mobile-first throughout: every rule here is the small-screen rule, and layout.css adds
 * the wider ones. NF-02 requires the whole site to work from 320px without sideways
 * scrolling, which is a promise that is far easier to keep by starting there than by
 * retrofitting breakpoints onto a desktop layout.
 */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}

body {
	margin: 0;
	background: var(--slf-bg);
	color: var(--slf-text);
	font-family: var(--slf-font);
	font-size: var(--slf-text-base);
	line-height: 1.6;
	/*
	 * The last line of defence for NF-02. A single wide element — a pasted URL in a
	 * question, a table in an answer — would otherwise widen the whole document and give
	 * every page on the site a horizontal scrollbar at 320px.
	 */
	overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
	margin: 0 0 var(--slf-space-3);
	line-height: 1.25;
	font-weight: 650;
	color: var(--slf-text);
}

h1 {
	font-size: var(--slf-text-2xl);
}

h2 {
	font-size: var(--slf-text-xl);
}

h3 {
	font-size: var(--slf-text-lg);
}

p {
	margin: 0 0 var(--slf-space-4);
}

a {
	color: var(--slf-accent-text);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
}

a:hover {
	color: var(--slf-text);
}

img,
svg,
video {
	max-width: 100%;
	height: auto;
}

/*
 * One visible focus ring for everything, and it must survive both themes — WCAG 2.1 AA
 * (NF-03) fails on a keyboard user who cannot see where they are. `:focus-visible` keeps
 * it off mouse clicks, so nothing here is a reason for anyone to remove it later.
 */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--slf-focus);
	outline-offset: 2px;
	border-radius: 3px;
}

/* Screen-reader-only text that becomes visible when focused (the skip link). */
.slf-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.slf-skip-link {
	position: absolute;
	top: var(--slf-space-2);
	left: var(--slf-space-2);
	z-index: 100;
	padding: var(--slf-space-2) var(--slf-space-4);
	background: var(--slf-accent);
	color: var(--slf-on-accent);
	border-radius: var(--slf-radius);
	transform: translateY(-200%);
}

.slf-skip-link:focus {
	transform: translateY(0);
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

/* Utilities used across templates. */
.slf-muted {
	color: var(--slf-text-muted);
}

.slf-small {
	font-size: var(--slf-text-sm);
}

.slf-stack > * + * {
	margin-top: var(--slf-space-4);
}

.slf-hide {
	display: none !important;
}
