/*
 * Accessibility panel (inc/a11y.php) and the settings it applies to <html>:
 * data-jw-fs (1-3), data-jw-contrast="high", data-jw-motion="reduce".
 * Loaded after dark.css so high contrast also works in dark mode.
 */

/* Text size */
html[data-jw-fs="1"] { --jw-fs: 1.12; }
html[data-jw-fs="2"] { --jw-fs: 1.25; }
html[data-jw-fs="3"] { --jw-fs: 1.4; }

html[data-jw-fs] {
	font-size: calc(100% * var(--jw-fs));
}

html[data-jw-fs] body,
html[data-jw-fs] button,
html[data-jw-fs] input,
html[data-jw-fs] select,
html[data-jw-fs] textarea {
	font-size: calc(17px * var(--jw-fs));
}

/* High contrast */
html[data-jw-contrast="high"] {
	--jw-text: #000;
	--jw-text-muted: #1f2937;
	--jw-border: #000;
	--jw-surface: #fff;
	--jw-bg: #fff;
	--jw-red: #9b0d14;
	--jw-red-dark: #6e090e;
	--jw-red-tint: #fff;
}

html[data-theme="dark"][data-jw-contrast="high"] {
	--jw-text: #fff;
	--jw-text-muted: #f3f4f6;
	--jw-border: #fff;
	--jw-surface: #000;
	--jw-bg: #000;
	--jw-red-tint: #000;
	--jw-link: #ffc2c5;
}

html[data-jw-contrast="high"] .entry-content a,
html[data-jw-contrast="high"] .jw-footer a,
html[data-jw-contrast="high"] .comment-content a {
	text-decoration: underline;
	text-underline-offset: 3px;
}

html[data-jw-contrast="high"] :focus-visible {
	outline: 3px solid currentColor !important;
	outline-offset: 2px;
}

html[data-jw-contrast="high"] img {
	filter: none;
}

/* Reduced motion */
html[data-jw-motion="reduce"],
html[data-jw-motion="reduce"] *,
html[data-jw-motion="reduce"] *::before,
html[data-jw-motion="reduce"] *::after {
	animation-duration: .001ms !important;
	animation-iteration-count: 1 !important;
	transition-duration: .001ms !important;
	scroll-behavior: auto !important;
}

/* The button in the top bar */
.jw-a11y {
	position: relative;
	display: inline-flex;
}

.jw-a11y-btn {
	display: inline-grid;
	place-items: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: var(--jw-radius-pill);
	background: rgba(255, 255, 255, .14);
	color: #fff;
	cursor: pointer;
}

.jw-a11y-btn:hover,
.jw-a11y-btn:focus-visible,
.jw-a11y-btn[aria-expanded="true"] {
	background: #fff;
	color: var(--jw-red);
}

/* The panel */
.jw-a11y-panel {
	position: absolute;
	top: calc(100% + 8px);
	inset-inline-end: 0;
	z-index: 200;
	display: grid;
	gap: .6rem;
	width: 260px;
	padding: 14px;
	border: 1px solid var(--jw-border);
	border-radius: var(--jw-radius);
	background: var(--jw-bg);
	color: var(--jw-text);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
	font-size: .9rem;
	line-height: 1.5;
}

.jw-a11y-panel[hidden] {
	display: none;
}

.jw-a11y-title {
	margin: 0;
	font-weight: 700;
}

.jw-a11y-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: .5rem;
}

.jw-a11y-panel button {
	font: inherit;
	color: inherit;
	cursor: pointer;
}

.jw-a11y-fs,
.jw-a11y-seg {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--jw-border);
	border-radius: var(--jw-radius-pill);
	overflow: hidden;
}

.jw-a11y-fs button,
.jw-a11y-seg button {
	min-width: 40px;
	min-height: 32px;
	padding: 0 10px;
	border: 0;
	background: transparent;
}

.jw-a11y-fs button:disabled {
	opacity: .35;
	cursor: default;
}

.jw-a11y-fs output {
	min-width: 3.2em;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.jw-a11y-seg button[aria-pressed="true"] {
	background: var(--jw-red);
	color: #fff;
}

.jw-a11y-fs button:not(:disabled):hover,
.jw-a11y-seg button[aria-pressed="false"]:hover {
	background: var(--jw-surface);
}

.jw-a11y-switch {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	min-height: 32px;
	padding: 0;
	border: 0;
	background: none;
	text-align: start;
}

.jw-a11y-switch i {
	position: relative;
	width: 38px;
	height: 22px;
	border-radius: 11px;
	background: #8a919c;
	flex: none;
}

.jw-a11y-switch i::after {
	content: "";
	position: absolute;
	top: 3px;
	inset-inline-start: 3px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #fff;
	transition: inset-inline-start .15s;
}

.jw-a11y-switch[aria-checked="true"] i {
	background: var(--jw-red);
}

.jw-a11y-switch[aria-checked="true"] i::after {
	inset-inline-start: 19px;
}

.jw-a11y-reset {
	justify-self: start;
	padding: 0;
	border: 0;
	background: none;
	color: var(--jw-text-muted) !important;
	text-decoration: underline;
	font-size: .85rem !important;
}

.jw-a11y-panel button:focus-visible {
	outline: 2px solid var(--jw-red);
	outline-offset: 2px;
}

@media (max-width: 768px) {
	.jw-a11y {
		position: static;
	}

	.jw-a11y-panel {
		position: absolute;
		inset-inline: 12px;
		width: auto;
	}

	.jw-topbar-inner {
		position: relative;
	}
}

/* Archive header band and chips: plain panel with a clear edge. */
html[data-jw-contrast="high"] .jw-archive-head.jw-news-head { --jw-band: var(--jw-bg); --jw-band-muted: var(--jw-text-muted); }
html[data-jw-contrast="high"] .jw-news-band { border: 1px solid var(--jw-border); border-inline-start-width: 4px; }
html[data-jw-contrast="high"] .jw-news-count { border: 1px solid var(--jw-border); }
