/**
 * Reading Comfort Panel — styles.
 *
 * Themes can override every --rcpanel-* variable on :root (use `html:root { … }`
 * to win over these defaults) and refine the effects of the <html> classes
 * documented in readme.txt.
 */

:root {
	--rcpanel-bg: #ffffff;
	--rcpanel-text: #1c1917;
	--rcpanel-muted: #57534e;
	--rcpanel-accent: #1c1917;
	--rcpanel-accent-text: #ffffff;
	--rcpanel-border: #a8a29e;
	--rcpanel-focus: #1d4ed8;
	--rcpanel-radius: 6px;
	--rcpanel-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	--rcpanel-readable-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	--rcpanel-z: 100000;
}

/* ------------------------------------------------------------- Dialog */
.rcpanel-dialog {
	box-sizing: border-box;
	width: min(420px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	overflow: auto;
	border: 1px solid var(--rcpanel-border);
	border-radius: var(--rcpanel-radius);
	background: var(--rcpanel-bg);
	color: var(--rcpanel-text);
	font-family: var(--rcpanel-font);
	font-size: 16px;
	line-height: 1.45;
	letter-spacing: normal;
	word-spacing: normal;
	text-align: left;
	box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

.rcpanel-dialog::backdrop {
	background: rgba(0, 0, 0, 0.4);
}

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

.rcpanel-dialog__body {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin: 0;
	padding: 20px;
}

.rcpanel-dialog__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.rcpanel-dialog__title {
	margin: 0;
	color: inherit;
	font: 600 1.15em/1.3 var(--rcpanel-font);
	letter-spacing: normal;
	text-transform: none;
}

.rcpanel-dialog__intro {
	margin: 0;
	color: var(--rcpanel-muted);
	font-size: 0.875em;
}

.rcpanel-dialog__close {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--rcpanel-border);
	border-radius: var(--rcpanel-radius);
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.rcpanel-sizes {
	margin: 0;
	padding: 0;
	border: 0;
}

.rcpanel-sizes legend {
	margin-bottom: 8px;
	padding: 0;
	font-weight: 600;
}

.rcpanel-size {
	display: inline-flex;
	margin: 0 6px 6px 0;
	cursor: pointer;
}

.rcpanel-size input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.rcpanel-size span {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 14px;
	border: 1px solid var(--rcpanel-border);
	border-radius: var(--rcpanel-radius);
}

.rcpanel-size input:checked + span {
	border-color: var(--rcpanel-accent);
	background: var(--rcpanel-accent);
	color: var(--rcpanel-accent-text);
}

.rcpanel-size input:focus-visible + span {
	outline: 3px solid var(--rcpanel-focus);
	outline-offset: 2px;
}

.rcpanel-option {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px;
	border: 1px solid var(--rcpanel-border);
	border-radius: var(--rcpanel-radius);
	cursor: pointer;
}

.rcpanel-option input {
	flex: none;
	width: 22px;
	height: 22px;
	margin: 1px 0 0;
	accent-color: var(--rcpanel-accent);
}

.rcpanel-option__text {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.rcpanel-option__label {
	font-weight: 600;
}

.rcpanel-option__help {
	color: var(--rcpanel-muted);
	font-size: 0.85em;
}

.rcpanel-dialog__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.rcpanel-dialog__reset {
	min-height: 44px;
	padding: 0 16px;
	border: 1px solid var(--rcpanel-text);
	border-radius: var(--rcpanel-radius);
	background: transparent;
	color: inherit;
	font: 500 0.9em/1 var(--rcpanel-font);
	cursor: pointer;
}

.rcpanel-dialog__link {
	color: inherit;
	font-size: 0.9em;
	text-decoration: underline;
}

.rcpanel-status {
	min-height: 1.4em;
	margin: 0;
	color: var(--rcpanel-muted);
	font-size: 0.85em;
}

.rcpanel-dialog :focus-visible,
.rcpanel-open-button:focus-visible {
	outline: 3px solid var(--rcpanel-focus);
	outline-offset: 2px;
}

/* ------------------------------------------------------ Open buttons */
.rcpanel-open-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 16px;
	border: 1px solid var(--rcpanel-border);
	border-radius: var(--rcpanel-radius);
	background: var(--rcpanel-bg);
	color: var(--rcpanel-text);
	font: 500 15px/1 var(--rcpanel-font);
	cursor: pointer;
}

.rcpanel-open-button__icon {
	flex: none;
}

.rcpanel-floating {
	position: fixed;
	bottom: 16px;
	z-index: var(--rcpanel-z);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.rcpanel-floating--bottom-left {
	left: 16px;
}

.rcpanel-floating--bottom-right {
	right: 16px;
}

@media (max-width: 600px) {
	.rcpanel-floating .rcpanel-open-button__label {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
	}

	.rcpanel-floating {
		width: 48px;
		height: 48px;
		justify-content: center;
		padding: 0;
		border-radius: 50%;
	}
}

/* ------------------------------------------- Effects of the preferences */

/* Text size: zoom fallback, unless the theme scales its text from --rcpanel-scale. */
html[data-rcpanel-text]:not(.rcpanel-theme-scale) body {
	zoom: var(--rcpanel-scale, 1);
}

html.rcpanel-contrast a:not(.rcpanel-open-button) {
	text-decoration: underline !important;
	text-underline-offset: 0.2em;
}

html.rcpanel-contrast :focus-visible {
	outline: 3px solid var(--rcpanel-focus) !important;
	outline-offset: 2px !important;
}

html.rcpanel-contrast ::placeholder {
	color: var(--rcpanel-muted) !important;
	opacity: 1 !important;
}

html.rcpanel-reduce-motion *,
html.rcpanel-reduce-motion *::before,
html.rcpanel-reduce-motion *::after {
	scroll-behavior: auto !important;
	transition-duration: 0.001ms !important;
	animation-duration: 0.001ms !important;
	animation-iteration-count: 1 !important;
}

/* Text spacing: values of WCAG 2.2 success criterion 1.4.12. */
html.rcpanel-spacing body :where(p, li, dd, dt, td, th, blockquote, figcaption, label, a, span, h1, h2, h3, h4, h5, h6):not(.rcpanel-dialog *) {
	line-height: 1.5 !important;
	letter-spacing: 0.12em !important;
	word-spacing: 0.16em !important;
}

html.rcpanel-spacing body :where(p):not(.rcpanel-dialog *) {
	margin-bottom: 2em !important;
}

html.rcpanel-readable-font body :where(*:not(svg, svg *)) {
	font-family: var(--rcpanel-readable-font) !important;
}

@media (prefers-reduced-motion: reduce) {
	.rcpanel-dialog,
	.rcpanel-open-button {
		transition: none;
	}
}
