/* Language selector (ES / EN / FR). Plain CSS on the theme variables from finly.css, so it follows light/dark. */

.lang-switch {
	position: relative;
	display: inline-flex;
}

.lang-switch__button {
	display: inline-flex;
	align-items: center;
	gap: 0.375rem;
	height: 2.25rem;
	padding: 0 0.625rem;
	border: 0;
	border-radius: 0.375rem;
	background: transparent;
	color: var(--foreground);
	font: inherit;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
	transition: background-color 150ms ease;
}

.lang-switch__button:hover {
	background: var(--muted);
}

.lang-switch__button:focus-visible,
.lang-switch__item:focus-visible,
.lang-segment__item:focus-visible,
.lang-footer__link:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px color-mix(in oklab, var(--outline) 50%, transparent);
}

.lang-switch__globe,
.lang-switch__chevron,
.lang-switch__check {
	width: 1rem;
	height: 1rem;
	flex: none;
}

.lang-switch__chevron {
	color: var(--muted-foreground);
	transition: transform 200ms ease;
}

.lang-switch__button[aria-expanded='true'] .lang-switch__chevron {
	transform: rotate(180deg);
}

.lang-switch__current {
	letter-spacing: 0.04em;
}

/* Mobile header bar: same pill look as the theme toggle / menu button next to it.
   Compact on purpose (code + small chevron, no globe) so the bar fits 390px with longer locales. */
.lang-switch[data-variant='bar'] .lang-switch__globe {
	display: none;
}

.lang-switch[data-variant='bar'] .lang-switch__chevron {
	width: 0.75rem;
	height: 0.75rem;
}

.lang-switch[data-variant='bar'] .lang-switch__button {
	height: 2.75rem;
	gap: 0.25rem;
	padding: 0 0.75rem;
	border: 1px solid var(--border);
	border-radius: 9999px;
	background: color-mix(in oklab, var(--accent) 80%, transparent);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

.lang-switch[data-variant='bar'] .lang-switch__button:hover {
	background: var(--muted);
}

.lang-switch__menu {
	position: absolute;
	top: calc(100% + 0.5rem);
	right: 0;
	z-index: 60;
	min-width: 11.5rem;
	margin: 0;
	padding: 0.25rem;
	list-style: none;
	border: 1px solid var(--border);
	border-radius: 0.75rem;
	background: var(--card);
	color: var(--card-foreground);
	box-shadow:
		0 12px 32px -12px rgb(0 0 0 / 0.28),
		0 4px 10px -6px rgb(0 0 0 / 0.16);
}

.lang-switch__menu[hidden] {
	display: none;
}

.lang-switch__item {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.625rem;
	border-radius: 0.5rem;
	color: var(--foreground);
	font-size: 0.875rem;
	line-height: 1.25rem;
	text-decoration: none;
}

.lang-switch__item:hover,
.lang-switch__item:focus-visible {
	background: var(--muted);
}

.lang-switch__code {
	display: inline-flex;
	width: 1.75rem;
	color: var(--muted-foreground);
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.06em;
}

.lang-switch__name {
	flex: 1;
}

.lang-switch__check {
	color: var(--primary);
	visibility: hidden;
}

.lang-switch__item[aria-checked='true'] {
	font-weight: 600;
}

.lang-switch__item[aria-checked='true'] .lang-switch__code {
	color: var(--foreground);
}

.lang-switch__item[aria-checked='true'] .lang-switch__check {
	visibility: visible;
}

/* Segmented control inside the mobile menu sheet. */
.lang-sheet {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.lang-sheet__label {
	padding: 0 0.75rem;
}

.lang-segment {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.25rem;
	padding: 0.25rem;
	border: 1px solid var(--border);
	border-radius: 9999px;
	background: var(--muted);
}

.lang-segment__item {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 2.5rem;
	border-radius: 9999px;
	color: var(--muted-foreground);
	font-size: 0.875rem;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-decoration: none;
	transition:
		background-color 150ms ease,
		color 150ms ease;
}

.lang-segment__item:hover {
	color: var(--foreground);
}

.lang-segment__item[aria-current='true'] {
	background: var(--card);
	color: var(--foreground);
	box-shadow:
		0 1px 2px rgb(0 0 0 / 0.14),
		0 0 0 1px var(--border);
}

/* Footer: plain links, works without JavaScript. */
.lang-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 0.75rem;
	margin-top: 1.25rem;
	color: var(--muted-foreground);
	font-size: 0.875rem;
}

.lang-footer ul {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.lang-footer__link {
	display: inline-block;
	padding: 0.25rem 0.5rem;
	border-radius: 0.375rem;
	color: inherit;
	text-decoration: none;
}

.lang-footer__link:hover {
	color: var(--foreground);
}

.lang-footer__link[aria-current='true'] {
	background: var(--muted);
	color: var(--foreground);
	font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
	.lang-switch__chevron,
	.lang-switch__button,
	.lang-segment__item {
		transition: none;
	}
}
