/* All colours meet WCAG AAA contrast (at least 7:1) against the background in both schemes. */
:root {
	color-scheme: light dark;
	--bg: light-dark(#fdfdfc, #17171b);
	--text: light-dark(#1b1b1f, #ededf0);
	--muted: light-dark(#45454d, #b9b9c2);
	--link: light-dark(#1a44b8, #9ec3ff);
	--visited: light-dark(#6b21a8, #d2b4fe);
	--rule: light-dark(#d4d4da, #3a3a42);
	/* Minimum size of links outside running text (WCAG 2.5.5, 44 CSS pixels). */
	--target: 2.75rem;

	font-family: system-ui, sans-serif;
	line-height: 1.5;
	background: var(--bg);
	color: var(--text);
	overflow-wrap: break-word;
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body {
	margin: 0;
	padding-inline: 1rem;
}

header,
main,
footer {
	/* Keep lines under 80 characters (WCAG 1.4.8). Prose averages narrower characters than "0", which ch measures. */
	max-inline-size: 55ch;
	margin-inline: auto;
}

header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 1.5rem;
	padding-block: 0.5rem;
	border-block-end: thin solid var(--rule);
}

header > a {
	font-weight: 700;
	font-size: 1.25rem;
}

nav ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0 1rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

header a,
header a:visited {
	color: var(--link);
	display: inline-flex;
	align-items: center;
	min-block-size: var(--target);
	min-inline-size: var(--target);
	text-decoration: none;
}

header a:hover,
header a[aria-current="page"] {
	text-decoration: underline;
	text-decoration-thickness: 0.125em;
}

main {
	padding-block: 1rem 3rem;
}

h1,
h2 {
	line-height: 1.2;
	text-wrap: balance;
}

h1 {
	font-size: 2rem;
	margin-block: 1rem;
}

h2 {
	font-size: 1.5rem;
	margin-block: 2rem 0.5rem;
}

/* Paragraph spacing at least 1.5 times the line spacing (WCAG 1.4.8). */
p,
ol > li {
	margin-block: 0 1em;
}

a {
	color: var(--link);
	text-underline-offset: 0.15em;
}

a:visited {
	color: var(--visited);
}

a:focus-visible {
	outline: 0.1875rem solid var(--link);
	outline-offset: 0.125rem;
	border-radius: 0.125rem;
}

/* Alphabetical index: flow words into as many columns as fit. */
.words {
	columns: 10rem;
	column-gap: 1.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.words a {
	display: inline-flex;
	align-items: center;
	min-block-size: var(--target);
	min-inline-size: var(--target);
	/* Break long words rather than overflowing narrow screens. */
	overflow-wrap: anywhere;
}

footer {
	padding-block: 1rem;
	border-block-start: thin solid var(--rule);
	color: var(--muted);
}

/* Set the smaller size here rather than on footer, so footer's ch-based width matches header and main. */
footer p {
	margin: 0;
	font-size: 0.875rem;
}
