/* Accessibility options: the floating button, its panel, and what each option changes. */

/* ---------- Button and panel ---------- */

.a11y {
	position: fixed;
	right: var(--s2);
	bottom: var(--s2);
	z-index: 60;
}

html:not(.js) .a11y {
	display: none;
}

.a11y-toggle {
	display: grid;
	place-items: center;
	width: 56px;
	height: 56px;
	padding: 0;
	border: 3px solid #ffffff;
	border-radius: 50%;
	background: #1f4fd8;
	color: #ffffff;
	box-shadow: var(--shadow);
	cursor: pointer;
}

.a11y-toggle svg {
	width: 32px;
	height: 32px;
}

.a11y-toggle:hover,
.a11y-toggle[aria-expanded="true"] {
	background: #163aa6;
}

.a11y-panel {
	position: absolute;
	right: 0;
	bottom: calc(100% + var(--s1));
	width: min(320px, 100vw - 2 * var(--s2));
	max-height: calc(100vh - 120px);
	padding: var(--s2);
	overflow-y: auto;
	border: 2px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--ink);
	box-shadow: var(--shadow);
}

.a11y-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: var(--s1);
}

.a11y-head h2 {
	margin: 0;
	font-size: 1.25rem;
}

.a11y-panel button {
	border: 2px solid var(--line);
	border-radius: var(--radius-sm);
	background: var(--bg);
	color: var(--ink);
	font: 700 1rem var(--font-body);
	cursor: pointer;
}

.a11y-panel button:hover {
	border-color: var(--primary);
}

.a11y-close {
	width: 40px;
	height: 40px;
	padding: 0;
	font-size: 1.5rem !important;
	line-height: 1;
}

.a11y-size {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--s1);
	margin-bottom: var(--s1);
	font-weight: 700;
}

.a11y-size div {
	display: flex;
	align-items: center;
	gap: var(--s1);
}

.a11y-size button {
	min-width: 48px;
	height: 44px;
}

.a11y-size output {
	min-width: 3.2em;
	text-align: center;
}

.a11y-options {
	display: grid;
	gap: var(--s1);
	margin: 0 0 var(--s1);
	padding: 0;
	list-style: none;
}

.a11y-options li {
	margin: 0;
}

.a11y-options button {
	display: flex;
	align-items: center;
	gap: var(--s1);
	width: 100%;
	min-height: 44px;
	padding: 8px 12px;
	text-align: left;
}

/* A tick box drawn in front of each option. */
.a11y-options button::before {
	content: "";
	flex: none;
	width: 20px;
	height: 20px;
	border: 2px solid currentColor;
	border-radius: 5px;
}

.a11y-options button[aria-pressed="true"] {
	border-color: var(--primary);
	background: var(--primary);
	color: var(--on-primary);
}

.a11y-options button[aria-pressed="true"]::before {
	background: currentColor;
	box-shadow: inset 0 0 0 3px var(--primary);
}

.a11y-reset {
	width: 100%;
	min-height: 44px;
}

/* ---------- What the options do ---------- */

/* High contrast: black page, white text, yellow links and buttons. */
:root.a11y-contrast,
:root.a11y-contrast[data-theme] {
	--brand: #000000;
	--on-brand: #ffffff;
	--primary: #ffe600;
	--on-primary: #000000;
	--red: #ff6b6b;
	--leaf: #6dff9c;
	--accent: #ffe600;
	--bg: #000000;
	--surface: #000000;
	--ink: #ffffff;
	--muted: #ffffff;
	--line: #ffffff;
	--tint: #1a1a1a;
	--tint-warm: #1a1a1a;
	--shadow: 0 0 0 2px #ffffff;
}

.a11y-contrast main a,
.a11y-contrast .site-footer a {
	text-decoration: underline;
}

/* Plain font. */
.a11y-font body,
.a11y-font body * {
	font-family: Verdana, Tahoma, Arial, sans-serif !important;
}

/* More space. */
.a11y-spacing body,
.a11y-spacing body * {
	line-height: 1.9 !important;
	letter-spacing: 0.06em !important;
	word-spacing: 0.14em !important;
}

/* Links stand out. */
.a11y-links main a,
.a11y-links .site-footer a,
.a11y-links .site-nav a,
.a11y-links .topbar a {
	outline: 2px solid #000000;
	outline-offset: 1px;
	background: #ffe600 !important;
	color: #000000 !important;
	text-decoration: underline !important;
}

/* Large pointer. */
.a11y-cursor,
.a11y-cursor * {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4 2l15 11h-7l4 8-3 1.500-4-8-5 5z' fill='%23000' stroke='%23fff' stroke-width='1.500' stroke-linejoin='round'/%3E%3C/svg%3E") 8 4, auto !important;
}

/* Nothing moves. The announcement can be scrolled sideways instead. */
.a11y-motion *,
.a11y-motion *::before,
.a11y-motion *::after {
	animation: none !important;
	transition: none !important;
	scroll-behavior: auto !important;
}

.a11y-motion .intro {
	display: none;
}

.a11y-motion .brand-shine,
.a11y-motion .announce-card::after,
.a11y-motion .announce::before {
	display: none;
}

/* Grayscale. */
:root.a11y-gray {
	filter: grayscale(1);
}
