/*!
 * MM Babel — front-end stylesheet
 *
 * Provides minimal, theme-agnostic styling for the language switcher
 * shortcode and its widget wrapper. Uses BEM-like class names, scoped
 * under `.mm-babel-switcher`, so themes can override individual hooks
 * without resorting to !important.
 *
 * Inherits color and font from the surrounding context where possible.
 */

.mm-babel-switcher {
	display: inline-block;
	font-size: 0.95em;
	line-height: 1.4;
}

.mm-babel-switcher__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em 0.75em;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mm-babel-switcher__item {
	margin: 0;
	padding: 0;
}

.mm-babel-switcher__item a {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	padding: 0.25em 0.6em;
	border: 1px solid transparent;
	border-radius: 4px;
	color: inherit;
	text-decoration: none;
	transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.mm-babel-switcher__item a:hover,
.mm-babel-switcher__item a:focus {
	background-color: rgba(0, 0, 0, 0.05);
	border-color: rgba(0, 0, 0, 0.1);
	text-decoration: none;
}

.mm-babel-switcher__item a:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.mm-babel-switcher__item.is-current a {
	font-weight: 600;
	background-color: rgba(0, 0, 0, 0.04);
	border-color: rgba(0, 0, 0, 0.08);
	cursor: default;
}

.mm-babel-switcher__flag {
	display: inline-flex;
	align-items: center;
	font-size: 1.1em;
	line-height: 1;
}

.mm-babel-switcher__name {
	display: inline-block;
}

.mm-babel-switcher__slug {
	font-variant: small-caps;
	letter-spacing: 0.05em;
	font-weight: 500;
}

/* Style variants — inline (default) leaves the list horizontal. */

.mm-babel-switcher--flags-only .mm-babel-switcher__list {
	gap: 0.25em 0.4em;
}

.mm-babel-switcher--flags-only .mm-babel-switcher__item a {
	padding: 0.2em 0.4em;
}

/* In flags-only mode the visible language name is removed so the header
   reads as a compact row of flags. The name is preserved in the DOM and
   hidden via the standard visually-hidden pattern (WCAG 2.1 SC 1.3.1) so
   screen readers still announce the destination of each link. */
.mm-babel-switcher--flags-only .mm-babel-switcher__name {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Bump the flag glyph size slightly when it stands alone so the tap target
   stays comfortable on touch devices (~24px equivalent). */
.mm-babel-switcher--flags-only .mm-babel-switcher__flag {
	font-size: 1.35em;
}

/* The dropdown variant is markup-compatible with the inline variant —
   themes may layer their own dropdown JS on top without breaking the
   accessible <nav> structure. The CSS just tightens the spacing. */
.mm-babel-switcher--dropdown .mm-babel-switcher__list {
	flex-direction: column;
	gap: 0;
}

.mm-babel-switcher--dropdown .mm-babel-switcher__item a {
	display: flex;
	width: 100%;
	border-radius: 0;
	padding: 0.4em 0.75em;
}

/* ─── Globe + dropdown variant ───────────────────────────────────────
   Compact "🌐 PT ▾" trigger that opens a listbox with flag + name per
   language. Block 20.0 (v0.9.0). */

.mm-babel-switcher--globe {
	position: relative;
	display: inline-block;
}

.mm-babel-switcher__trigger {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 10px;
	font: inherit;
	font-size: 0.85em;
	line-height: 1;
	color: inherit;
	background-color: transparent;
	border: 1px solid currentColor;
	border-radius: 999px;
	border-color: rgba(0, 0, 0, 0.18);
	cursor: pointer;
	transition: background-color 120ms ease, border-color 120ms ease;
}

.mm-babel-switcher__trigger:hover,
.mm-babel-switcher__trigger:focus {
	background-color: rgba(0, 0, 0, 0.05);
	border-color: rgba(0, 0, 0, 0.3);
}

.mm-babel-switcher__trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.mm-babel-switcher__globe,
.mm-babel-switcher__chevron {
	flex-shrink: 0;
}

.mm-babel-switcher__current {
	font-weight: 500;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.mm-babel-switcher__chevron {
	opacity: 0.7;
	transition: transform 150ms ease;
}

.mm-babel-switcher__trigger[aria-expanded="true"] .mm-babel-switcher__chevron {
	transform: rotate(180deg);
}

.mm-babel-switcher__dropdown {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 180px;
	margin: 0;
	padding: 6px 0;
	list-style: none;
	background-color: #fff;
	color: #1a1a1a;
	border: 1px solid rgba(0, 0, 0, 0.1);
	border-radius: 8px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
	z-index: 9999;
}

.mm-babel-switcher__dropdown[hidden] {
	display: none;
}

.mm-babel-switcher--globe .mm-babel-switcher__item {
	margin: 0;
	padding: 0;
}

.mm-babel-switcher--globe .mm-babel-switcher__item a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 14px;
	color: inherit;
	text-decoration: none;
	border: 0;
	border-radius: 0;
	font-size: 0.9em;
	white-space: nowrap;
	transition: background-color 100ms ease;
}

.mm-babel-switcher--globe .mm-babel-switcher__item a:hover,
.mm-babel-switcher--globe .mm-babel-switcher__item a:focus {
	background-color: rgba(0, 0, 0, 0.06);
	text-decoration: none;
}

.mm-babel-switcher--globe .mm-babel-switcher__item.is-current a {
	font-weight: 500;
	background-color: rgba(0, 0, 0, 0.04);
	cursor: default;
}

.mm-babel-switcher--globe .mm-babel-switcher__flag {
	flex-shrink: 0;
	display: inline-flex;
	width: 22px;
	height: 15px;
	overflow: hidden;
	border-radius: 2px;
	box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.15);
}

.mm-babel-switcher--globe .mm-babel-switcher__flag svg {
	width: 100%;
	height: 100%;
	display: block;
}

.mm-babel-switcher--globe .mm-babel-switcher__name {
	flex: 1;
}

/* Mobile breakpoint — bigger tap targets, dropdown anchors to the
   right edge of the viewport so it doesn't overflow on small screens. */
@media (max-width: 480px) {
	.mm-babel-switcher__dropdown {
		right: -8px;
		min-width: 200px;
	}
	.mm-babel-switcher--globe .mm-babel-switcher__item a {
		padding: 12px 16px;
	}
}

/* Reduced-motion: drop the chevron rotation transition. */
@media (prefers-reduced-motion: reduce) {
	.mm-babel-switcher__chevron,
	.mm-babel-switcher__trigger,
	.mm-babel-switcher--globe .mm-babel-switcher__item a {
		transition: none;
	}
}

/* Note on colour scheme: prefers-color-scheme is intentionally NOT used.
   The switcher follows the site's own theme — colours and surfaces are
   driven by `color: inherit` on text and explicit defaults (white
   dropdown, dark text) for the panel. Themes that ship a dark palette
   override the dropdown surface via their own CSS rather than fighting
   the OS preference, which previously caused the dropdown to render
   dark on top of a light site whenever the visitor's OS was in dark
   mode. Removed in 0.9.1 after the chaodarelva live test. */
