/*
 * Dark mode switch – styles.
 *
 * Styles the markup from Busol_Darkmode::switch_markup() in busol-darkmode.php: a pill-shaped
 * radio group (.bdm-switch) with three icon buttons and a sliding thumb (.bdm-thumb) whose
 * position comes from the CSS variable --bdm-i set by darkmode.js. Colours fall back to fixed
 * values when the theme busol does not provide its variables (--bg-alt, --muted, --surface,
 * --brand, --line, --ink). The compact mode at the end depends on the html class .nav-narrow
 * set by the theme's header script.
 */
.bdm-switch {
	--bdm-bg: var(--bg-alt, #eef2f7);
	--bdm-fg: var(--muted, #5d6878);
	--bdm-on: var(--surface, #fff);
	--bdm-ink: var(--brand, #1b569e);
	position: relative;
	display: inline-flex;
	padding: 3px;
	gap: 0;
	border-radius: 999px;
	background: var(--bdm-bg);
	box-shadow: inset 0 0 0 1px var(--line, #e1e7ef);
}
.bdm-switch button {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 32px;
	height: 30px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--bdm-fg);
	cursor: pointer;
	transition: color 0.3s;
}
.bdm-switch button svg {
	width: 17px;
	height: 17px;
	transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.bdm-switch button[aria-checked="true"] {
	color: var(--bdm-ink);
}
.bdm-switch button[aria-checked="true"] svg {
	transform: rotate(-20deg) scale(1.08);
}
.bdm-switch button:hover {
	color: var(--ink, #142033);
}
.bdm-switch button:focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px var(--bdm-ink);
}
.bdm-thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 32px;
	height: 30px;
	border-radius: 999px;
	background: var(--bdm-on);
	box-shadow: 0 2px 8px -2px rgba(15, 35, 66, 0.25);
	transform: translateX(calc(var(--bdm-i, 0) * 32px));
	transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}
/* Tooltip from data-tip, shown below the button after a short delay. */
.bdm-switch button::after {
	content: attr(data-tip);
	position: absolute;
	top: calc(100% + 10px);
	left: 50%;
	transform: translate(-50%, -4px);
	white-space: nowrap;
	padding: 6px 10px;
	border-radius: 8px;
	background: #0d2342;
	color: #fff;
	font:
		500 12px/1.2 system-ui,
		sans-serif;
	pointer-events: none;
	opacity: 0;
	transition:
		opacity 0.2s,
		transform 0.25s;
	z-index: 5;
}
.bdm-switch button:hover::after,
.bdm-switch button:focus-visible::after {
	opacity: 1;
	transform: translate(-50%, 0);
	transition-delay: 0.35s;
}
/* Fallback for themes without the header hook: fixed at the bottom left, tooltip above. */
.bdm-switch--floating {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 90;
	box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35);
}
.bdm-switch--floating button::after {
	top: auto;
	bottom: calc(100% + 10px);
}
@media (max-width: 420px) {
	.bdm-switch button {
		width: 28px;
	}
	.bdm-thumb {
		width: 28px;
		transform: translateX(calc(var(--bdm-i, 0) * 28px));
	}
}
@media (prefers-reduced-motion: reduce) {
	.bdm-thumb,
	.bdm-switch button svg {
		transition: none;
	}
}
/* Compact (little room in the header): only the active icon is shown, a click cycles to the next mode (darkmode.js). */
.nav-narrow .site-header .bdm-switch .bdm-thumb {
	transform: none;
}
.nav-narrow .site-header .bdm-switch button[aria-checked="false"] {
	display: none;
}
.nav-narrow .site-header .bdm-switch button[aria-checked="true"] svg {
	transform: none;
}
