/**
 * Sélecteur de langue — Traduction Automatique.
 *
 * Le sélecteur reprend la police et la couleur de texte du thème. Le bouton
 * flottant a sa propre surface ; ses couleurs se personnalisent depuis le
 * thème via les variables ci-dessous, par exemple :
 *   .trad-auto-floating { --trad-auto-surface: #10233f; --trad-auto-ink: #fff; }
 */

.trad-auto-switcher {
	--trad-auto-surface: #ffffff;
	--trad-auto-ink: #1e2a3a;
	--trad-auto-muted: #5b6878;
	--trad-auto-line: #d5dae1;
	--trad-auto-hover: #eef2f7;
	--trad-auto-focus: #2f6feb;
	--trad-auto-radius: 10px;
	--trad-auto-gap: 0.5em;

	font: inherit;
	line-height: 1.3;
}

.trad-auto-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Liste et éléments communs ------------------------------------------- */

.trad-auto-switcher__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25em 1em;
	margin: 0;
	padding: 0;
	list-style: none;
}

.trad-auto-switcher__item {
	margin: 0;
	padding: 0;
}

.trad-auto-switcher__item::before,
.trad-auto-switcher__item::marker {
	content: none;
}

.trad-auto-switcher__link {
	display: inline-flex;
	align-items: center;
	gap: var(--trad-auto-gap);
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
}

a.trad-auto-switcher__link:hover .trad-auto-switcher__name,
a.trad-auto-switcher__link:hover .trad-auto-switcher__code {
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.trad-auto-switcher__item.is-current .trad-auto-switcher__link {
	font-weight: 600;
}

.trad-auto-switcher a:focus-visible,
.trad-auto-switcher summary:focus-visible {
	outline: 2px solid var(--trad-auto-focus);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Le drapeau : petit rectangle arrondi, filet intérieur pour les drapeaux clairs. */
.trad-auto-switcher__flag {
	display: block;
	flex: none;
	width: 1.25em;
	min-width: 18px;
	max-width: 24px;
	height: auto;
	aspect-ratio: 4 / 3;
	margin: 0;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(30, 42, 58, 0.18);
	object-fit: cover;
}

.trad-auto-switcher__code {
	font-size: 0.85em;
	font-weight: 600;
	letter-spacing: 0.04em;
}

.trad-auto-switcher--flag .trad-auto-switcher__flag {
	width: 1.5em;
	max-width: 28px;
}

/* Liste déroulante ----------------------------------------------------- */

.trad-auto-switcher--dropdown {
	position: relative;
	display: inline-block;
}

.trad-auto-switcher__details {
	position: relative;
}

.trad-auto-switcher__toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--trad-auto-gap);
	cursor: pointer;
	list-style: none;
	user-select: none;
	white-space: nowrap;
}

.trad-auto-switcher__toggle::-webkit-details-marker {
	display: none;
}

.trad-auto-switcher__chevron {
	flex: none;
	transition: transform 0.15s ease;
}

.trad-auto-switcher__details[open] .trad-auto-switcher__chevron {
	transform: rotate(180deg);
}

.trad-auto-switcher--dropdown .trad-auto-switcher__list {
	position: absolute;
	z-index: 1000;
	top: calc(100% + 6px);
	left: 0;
	display: block;
	min-width: max(100%, 11em);
	padding: 4px;
	color: var(--trad-auto-ink);
	background: var(--trad-auto-surface);
	border: 1px solid var(--trad-auto-line);
	border-radius: var(--trad-auto-radius);
	box-shadow: 0 1px 2px rgba(30, 42, 58, 0.08), 0 8px 24px rgba(30, 42, 58, 0.14);
}

.trad-auto-switcher--dropdown .trad-auto-switcher__link {
	display: flex;
	width: 100%;
	box-sizing: border-box;
	padding: 0.55em 0.75em;
	border-radius: calc(var(--trad-auto-radius) - 4px);
}

.trad-auto-switcher--dropdown a.trad-auto-switcher__link:hover {
	background: var(--trad-auto-hover);
}

.trad-auto-switcher--dropdown a.trad-auto-switcher__link:hover .trad-auto-switcher__name {
	text-decoration: none;
}

/* Langue affichée : coche à droite. */
.trad-auto-switcher--dropdown .is-current .trad-auto-switcher__link::after {
	content: "";
	width: 0.9em;
	height: 0.9em;
	margin-left: auto;
	padding-left: 0.75em;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right center / 0.9em no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.5 12 13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right center / 0.9em no-repeat;
}

/* Drapeau seul ou code : liste ajustée à son contenu, coche juste après le drapeau. */
.trad-auto-switcher--dropdown.trad-auto-switcher--flag .trad-auto-switcher__list,
.trad-auto-switcher--dropdown.trad-auto-switcher--code .trad-auto-switcher__list {
	width: max-content;
	min-width: 100%;
}

.trad-auto-switcher--dropdown.trad-auto-switcher--flag .trad-auto-switcher__link,
.trad-auto-switcher--dropdown.trad-auto-switcher--code .trad-auto-switcher__link {
	padding: 0.5em 0.65em;
}

.trad-auto-switcher--dropdown.trad-auto-switcher--flag .is-current .trad-auto-switcher__link::after,
.trad-auto-switcher--dropdown.trad-auto-switcher--code .is-current .trad-auto-switcher__link::after {
	padding-left: 0;
	margin-left: 0;
}

/* Liens sans coche : même largeur que la ligne cochée, drapeaux alignés. */
.trad-auto-switcher--dropdown.trad-auto-switcher--flag .trad-auto-switcher__item:not(.is-current) .trad-auto-switcher__link::after,
.trad-auto-switcher--dropdown.trad-auto-switcher--code .trad-auto-switcher__item:not(.is-current) .trad-auto-switcher__link::after {
	content: "";
	width: 0.9em;
	margin-left: 0;
}

.trad-auto-switcher__details[open] > .trad-auto-switcher__list {
	animation: trad-auto-open 0.14s ease-out;
}

@keyframes trad-auto-open {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
}

/* Bouton flottant ------------------------------------------------------ */

.trad-auto-floating {
	position: fixed;
	z-index: 99990;
	font-size: 15px;
}

.trad-auto-floating--bottom-right {
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
}

.trad-auto-floating--bottom-left {
	left: max(16px, env(safe-area-inset-left));
	bottom: max(16px, env(safe-area-inset-bottom));
}

.trad-auto-floating--top-right {
	top: max(16px, env(safe-area-inset-top));
	right: max(16px, env(safe-area-inset-right));
}

.trad-auto-floating--top-left {
	top: max(16px, env(safe-area-inset-top));
	left: max(16px, env(safe-area-inset-left));
}

body.admin-bar .trad-auto-floating--top-right,
body.admin-bar .trad-auto-floating--top-left {
	top: calc(max(16px, env(safe-area-inset-top)) + 32px);
}

.trad-auto-floating .trad-auto-switcher__toggle {
	min-height: 44px;
	box-sizing: border-box;
	padding: 0.5em 0.9em 0.5em 0.8em;
	color: var(--trad-auto-ink);
	background: var(--trad-auto-surface);
	border: 1px solid var(--trad-auto-line);
	border-radius: 999px;
	box-shadow: 0 1px 2px rgba(30, 42, 58, 0.1), 0 6px 18px rgba(30, 42, 58, 0.16);
}

.trad-auto-floating .trad-auto-switcher__toggle:hover {
	background: var(--trad-auto-hover);
}

.trad-auto-floating .trad-auto-switcher__details[open] .trad-auto-switcher__toggle {
	border-color: var(--trad-auto-muted);
}

/* La liste s'ouvre vers l'intérieur de l'écran. */
.trad-auto-floating--bottom-right .trad-auto-switcher__list,
.trad-auto-floating--bottom-left .trad-auto-switcher__list {
	top: auto;
	bottom: calc(100% + 8px);
}

.trad-auto-floating--bottom-right .trad-auto-switcher__list,
.trad-auto-floating--top-right .trad-auto-switcher__list {
	right: 0;
	left: auto;
}

.trad-auto-floating--bottom-right .trad-auto-switcher__details[open] > .trad-auto-switcher__list,
.trad-auto-floating--bottom-left .trad-auto-switcher__details[open] > .trad-auto-switcher__list {
	animation-name: trad-auto-open-up;
}

@keyframes trad-auto-open-up {
	from {
		opacity: 0;
		transform: translateY(4px);
	}
}

/* Barre de pied de page ------------------------------------------------ */

.trad-auto-footer-bar {
	display: flex;
	justify-content: center;
	padding: 14px 16px;
	font-size: 0.95em;
	border-top: 1px solid rgba(127, 127, 127, 0.25);
}

/* Menus ---------------------------------------------------------------- */

.trad-auto-menu-item > a,
.trad-auto-menu-item .sub-menu a {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
}

.trad-auto-menu-item .trad-auto-switcher__flag {
	display: block;
	width: 20px;
	height: auto;
	aspect-ratio: 4 / 3;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(30, 42, 58, 0.18);
}

.trad-auto-nav-item .trad-auto-switcher--dropdown .trad-auto-switcher__list {
	right: 0;
	left: auto;
}

/* Thèmes RTL. */
[dir="rtl"] .trad-auto-switcher--dropdown .trad-auto-switcher__list {
	right: 0;
	left: auto;
}

[dir="rtl"] .trad-auto-switcher--dropdown .is-current .trad-auto-switcher__link::after {
	margin-right: auto;
	margin-left: 0;
	padding-right: 0.75em;
	padding-left: 0;
}

@media (max-width: 480px) {
	.trad-auto-floating {
		font-size: 14px;
	}

	.trad-auto-floating .trad-auto-switcher--flag-name .trad-auto-switcher__toggle .trad-auto-switcher__name {
		max-width: 9em;
		overflow: hidden;
		text-overflow: ellipsis;
	}
}

@media (prefers-reduced-motion: reduce) {
	.trad-auto-switcher__chevron {
		transition: none;
	}

	.trad-auto-switcher__details[open] > .trad-auto-switcher__list {
		animation: none;
	}
}

@media print {
	.trad-auto-floating,
	.trad-auto-footer-bar {
		display: none !important;
	}
}
