/* Babel language switcher — modern, accessible, theme-agnostic. */

.babel-switcher {
	position: relative;
	display: inline-block;
	font-size: 14px;
	line-height: 1.2;
	--babel-bg: #ffffff;
	--babel-fg: #1e2430;
	--babel-muted: #5b6472;
	--babel-border: rgba(0, 0, 0, 0.1);
	--babel-hover: rgba(0, 0, 0, 0.05);
	--babel-accent: #2f6bff;
	--babel-radius: 10px;
	--babel-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
}

.babel-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 12px;
	margin: 0;
	background: var(--babel-bg);
	color: var(--babel-fg);
	border: 1px solid var(--babel-border);
	border-radius: var(--babel-radius);
	cursor: pointer;
	font: inherit;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.babel-toggle:hover {
	border-color: var(--babel-accent);
}

.babel-toggle:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.35);
}

.babel-flag {
	width: 22px;
	height: 16px;
	border-radius: 3px;
	flex: 0 0 auto;
	box-shadow: inset 0 0 0 1px var(--babel-border);
	display: block;
}

.babel-name {
	white-space: nowrap;
}

.babel-caret {
	width: 11px;
	height: 8px;
	margin-left: 2px;
	color: var(--babel-muted);
	transition: transform 0.2s ease;
}

.babel-switcher.is-open .babel-caret {
	transform: rotate(180deg);
}

.babel-menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	min-width: 190px;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--babel-bg);
	border: 1px solid var(--babel-border);
	border-radius: var(--babel-radius);
	box-shadow: var(--babel-shadow);
	opacity: 0;
	transform: translateY(-6px) scale(0.98);
	transform-origin: top right;
	pointer-events: none;
	transition: opacity 0.18s ease, transform 0.18s ease;
	z-index: 9999;
}

.babel-switcher.is-open .babel-menu {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.babel-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 10px;
	border-radius: 7px;
	color: var(--babel-fg);
	text-decoration: none;
	transition: background 0.15s ease;
}

.babel-option:hover,
.babel-option:focus-visible {
	background: var(--babel-hover);
	outline: none;
}

.babel-option.is-current {
	font-weight: 600;
	color: var(--babel-accent);
}

/* Inline (flat, no dropdown) variant. */
.babel-style-inline .babel-toggle {
	display: none;
}
.babel-style-inline .babel-menu {
	position: static;
	opacity: 1;
	transform: none;
	pointer-events: auto;
	box-shadow: none;
	border: none;
	display: flex;
	gap: 4px;
	padding: 0;
	min-width: 0;
}

/* --- Floating switcher (fixed to a page corner) --- */
.babel-floating {
	position: fixed;
	z-index: 99990;
}
.babel-floating.babel-pos-bottom-right { bottom: 20px; right: 20px; }
.babel-floating.babel-pos-bottom-left  { bottom: 20px; left: 20px; }
.babel-floating.babel-pos-top-right    { top: 20px; right: 20px; }
.babel-floating.babel-pos-top-left     { top: 20px; left: 20px; }

/* Bottom-anchored floats open their menu upward. */
.babel-floating[class*="bottom"] .babel-menu {
	top: auto;
	bottom: calc(100% + 8px);
	transform-origin: bottom right;
}
.babel-floating.babel-pos-bottom-left .babel-menu,
.babel-floating.babel-pos-top-left .babel-menu {
	right: auto;
	left: 0;
	transform-origin: top left;
}
.babel-floating[class*="bottom"].babel-pos-bottom-left .babel-menu {
	transform-origin: bottom left;
}
.babel-floating .babel-toggle {
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.16);
}

/* --- Presets (applied to the floating wrapper) --- */
.babel-preset-dark .babel-switcher {
	--babel-bg: #1b1f27;
	--babel-fg: #f0f2f6;
	--babel-muted: #9aa4b2;
	--babel-border: rgba(255, 255, 255, 0.16);
	--babel-hover: rgba(255, 255, 255, 0.09);
}
.babel-preset-border .babel-toggle {
	border-width: 2px;
	border-color: var(--babel-accent);
}
.babel-preset-transparent .babel-toggle {
	background: transparent;
	border-color: transparent;
	box-shadow: none;
}
.babel-preset-transparent .babel-toggle:hover {
	background: var(--babel-hover);
}

@media (prefers-reduced-motion: reduce) {
	.babel-toggle,
	.babel-caret,
	.babel-menu,
	.babel-option {
		transition: none;
	}
}

@media (prefers-color-scheme: dark) {
	.babel-switcher {
		--babel-bg: #1b1f27;
		--babel-fg: #e8ebf0;
		--babel-muted: #9aa4b2;
		--babel-border: rgba(255, 255, 255, 0.14);
		--babel-hover: rgba(255, 255, 255, 0.08);
		--babel-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
	}
}
