/**
 * Modern WordPress Lingua Front-end Switcher Styles.
 *
 * Provides clean, lightweight, standards-compliant, multi-theme styling
 * adhering strictly to WCAG 2.2 Level AA accessibility and W3C HTML5 semantics.
 *
 * @package ModernWordPress\Lingua
 */

.mwp-lingua-switcher {
	display: inline-flex;
	align-items: center;
	vertical-align: middle;
	font-family: inherit;
	box-sizing: border-box;
}

/* Semantic list reset */
.mwp-lingua-list,
.mwp-lingua-toggle-group {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 0;
	margin: 0;
	list-style: none;
	flex-wrap: wrap;
	box-sizing: border-box;
}

.mwp-lingua-item {
	display: inline-flex;
	margin: 0;
	padding: 0;
	list-style: none;
	box-sizing: border-box;
}

/* Interactive language toggle link/button */
.mwp-lingua-toggle-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	min-width: 32px;
	min-height: 32px;
	padding: 2px;
	border-radius: 50%;
	background: transparent;
	border: 2px solid transparent;
	color: inherit;
	text-decoration: none;
	box-sizing: border-box;
	cursor: pointer;
	position: relative;
	transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Ensure accessible 44x44px touch target geometry via pseudo-element without enlarging the visible circle */
.mwp-lingua-toggle-btn::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	min-width: 44px;
	min-height: 44px;
	width: 100%;
	height: 100%;
}

.mwp-lingua-toggle-btn:has(.mwp-lingua-name) {
	width: auto;
	min-width: 44px;
	border-radius: 16px;
	padding: 2px 10px 2px 2px;
}

.mwp-lingua-toggle-btn:hover {
	background-color: rgba(0, 0, 0, 0.05);
	border-color: rgba(0, 0, 0, 0.15);
}

.mwp-lingua-toggle-btn:active {
	background-color: rgba(0, 0, 0, 0.1);
}

/* WCAG 2.2 AA Focus Visibility */
.mwp-lingua-toggle-btn:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
	border-radius: 50%;
}

/* Active language state: solid contrast border + subtle tint (WCAG 1.4.1 non-color indicator) */
.mwp-lingua-toggle-btn.is-active,
.mwp-lingua-toggle-btn[aria-current="page"] {
	border-color: currentColor;
	background-color: rgba(0, 0, 0, 0.06);
}

/* Circular flag icon styling with contrast boundary (WCAG 1.4.11 Non-text Contrast) */
.mwp-lingua-flag-img,
.mwp-lingua-flag-icon {
	display: block;
	width: 24px;
	height: 24px;
	object-fit: cover;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.2);
	box-sizing: border-box;
	pointer-events: none;
	overflow: hidden;
}

.mwp-lingua-flag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	font-size: 1.125rem;
	line-height: 1;
	pointer-events: none;
	overflow: hidden;
}

/* Optional text label */
.mwp-lingua-name {
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1;
	margin-left: 6px;
	color: inherit;
}

/* Visually hidden screen reader utility */
.mwp-lingua-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Dark mode support */
:root[data-theme="dark"] .mwp-lingua-toggle-btn:hover,
.is-dark-theme .mwp-lingua-toggle-btn:hover {
	background-color: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.25);
}

:root[data-theme="dark"] .mwp-lingua-toggle-btn.is-active,
.is-dark-theme .mwp-lingua-toggle-btn.is-active,
:root[data-theme="dark"] .mwp-lingua-toggle-btn[aria-current="page"],
.is-dark-theme .mwp-lingua-toggle-btn[aria-current="page"] {
	border-color: currentColor;
	background-color: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] .mwp-lingua-flag-img,
.is-dark-theme .mwp-lingua-flag-img {
	border-color: rgba(255, 255, 255, 0.25);
}

/* Reduced motion invariant */
@media (prefers-reduced-motion: reduce) {
	.mwp-lingua-toggle-btn {
		transition: none !important;
	}
}
