/**
 * Storefront language selector — plugin default skin.
 *
 * One black capsule, white type, white inline icons. The sheet loads on
 * every storefront page of a multi-language region and must not leak, so
 * every rule is scoped to .ebw-lang-switcher.
 *
 * Colors, type size, padding, radius, and the menu shadow are --ebw-ls-*
 * properties pinned on the component. Each use site passes a direct
 * fallback (var(--ebw-ls-bg, #111)), so a theme that never sets the
 * properties still paints the capsule. A later stylesheet restyles the
 * capsule by overriding the properties on .ebw-lang-switcher. A :root
 * token does not wash the default out, because the properties are set
 * on the component itself.
 *
 *   --ebw-ls-bg            capsule and menu background          (#111)
 *   --ebw-ls-bg-hover      hover / open background              (#2a2a2a)
 *   --ebw-ls-color         text and inline icons                (#fff)
 *   --ebw-ls-border        currency rule and menu edge          (white 25%)
 *   --ebw-ls-font-size     capsule type                         (14px)
 *   --ebw-ls-radius        capsule corner                       (999px)
 *   --ebw-ls-menu-radius   menu corner                          (12px)
 *   --ebw-ls-padding-y     vertical padding                     (8px)
 *   --ebw-ls-padding-x     horizontal padding                   (14px)
 *   --ebw-ls-shadow        menu shadow
 *   --ebw-ls-option-hover  menu row hover                       (white 14%)
 *
 * The painted control is a button plus a listbox. Icons are inline SVG
 * (currentColor), never a background-image or an icon font. The native
 * select stays in the form for the change → submit path and is clipped
 * out of sight: a visible <select> is what the theme paints as a gray
 * chip, and text-overflow on it is what ate the language name.
 *
 * Width is the content. min-width: 0 / overflow: hidden / a fixed width
 * are not used on the name, the trigger, or the currency.
 */

.ebw-lang-switcher {
	--ebw-ls-bg: #111;
	--ebw-ls-bg-hover: #2a2a2a;
	--ebw-ls-color: #fff;
	--ebw-ls-border: rgba(255, 255, 255, 0.25);
	--ebw-ls-font-size: 14px;
	--ebw-ls-radius: 999px;
	--ebw-ls-menu-radius: 12px;
	--ebw-ls-padding-y: 8px;
	--ebw-ls-padding-x: 14px;
	--ebw-ls-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
	--ebw-ls-option-hover: rgba(255, 255, 255, 0.14);
	position: relative;
	z-index: 30;
	display: flex;
	flex-wrap: nowrap;
	align-items: stretch;
	justify-content: flex-start;
	gap: 0;
	box-sizing: border-box;
	width: max-content;
	min-width: max-content;
	max-width: none;
	min-height: 0;
	margin: 12px 16px;
	padding: 0;
	border: 0;
	border-radius: var(--ebw-ls-radius, 999px);
	background-color: var(--ebw-ls-bg, #111);
	background-image: none;
	box-shadow: none;
	color: var(--ebw-ls-color, #fff);
	color-scheme: dark;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans SC", "Noto Sans TC", sans-serif;
	font-size: var(--ebw-ls-font-size, 14px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0;
	text-align: start;
	text-transform: none;
	white-space: nowrap;
	-webkit-font-smoothing: antialiased;
}

.ebw-lang-switcher--shortcode {
	align-self: center;
	margin: 0;
}

.ebw-lang-switcher:hover,
.ebw-lang-switcher.is-open {
	background-color: var(--ebw-ls-bg-hover, #2a2a2a);
}

.ebw-lang-switcher.is-open {
	z-index: 100000;
}

.ebw-lang-switcher,
.ebw-lang-switcher *,
.ebw-lang-switcher *::before,
.ebw-lang-switcher *::after {
	box-sizing: border-box;
}

.ebw-lang-switcher__lang {
	position: relative;
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	min-width: max-content;
	max-width: none;
	margin: 0;
	padding: 0;
	overflow: visible;
	color: var(--ebw-ls-color, #fff);
	white-space: nowrap;
}

form.ebw-lang-switcher button.ebw-lang-switcher__trigger,
form.ebw-lang-switcher button.ebw-lang-switcher__option {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	width: auto;
	min-width: max-content;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: none;
	background-color: transparent;
	background-image: none;
	box-shadow: none;
	color: var(--ebw-ls-color, #fff);
	font: inherit;
	font-size: var(--ebw-ls-font-size, 14px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0;
	text-align: start;
	text-decoration: none;
	text-transform: none;
	text-overflow: clip;
	white-space: nowrap;
	overflow: visible;
	cursor: pointer;
}

form.ebw-lang-switcher button.ebw-lang-switcher__trigger {
	padding: var(--ebw-ls-padding-y, 8px) var(--ebw-ls-padding-x, 14px);
	border-radius: var(--ebw-ls-radius, 999px) 0 0 var(--ebw-ls-radius, 999px);
}

form.ebw-lang-switcher button.ebw-lang-switcher__trigger:focus-visible,
form.ebw-lang-switcher button.ebw-lang-switcher__option:focus-visible {
	outline: 2px solid var(--ebw-ls-color, #fff);
	outline-offset: 2px;
}

.ebw-lang-switcher__name {
	display: inline-block;
	flex: 0 0 auto;
	width: auto;
	min-width: min-content;
	max-width: none;
	overflow: visible;
	color: var(--ebw-ls-color, #fff);
	font-size: var(--ebw-ls-font-size, 14px);
	line-height: 1.2;
	text-overflow: clip;
	white-space: nowrap;
}

.ebw-lang-switcher__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.ebw-lang-switcher__icon,
.ebw-lang-switcher__chevron {
	display: block;
	flex: 0 0 auto;
	max-width: none;
	overflow: visible;
	fill: currentColor;
	color: var(--ebw-ls-color, #fff);
}

.ebw-lang-switcher__icon {
	width: 16px;
	height: 16px;
}

.ebw-lang-switcher__chevron {
	width: 12px;
	height: 12px;
	transition: transform 160ms ease;
}

.ebw-lang-switcher.is-open .ebw-lang-switcher__chevron {
	transform: rotate(180deg);
}

/* The native select only exists so change still submits. It must not paint.
   !important holds the clip against a theme `select { width, appearance }`
   rule — that chrome is what drew the gray chip and clipped the name. */
form.ebw-lang-switcher select.ebw-lang-switcher__select {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	min-width: 0 !important;
	max-width: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	clip-path: inset(50%) !important;
	white-space: nowrap !important;
	border: 0 !important;
	appearance: none !important;
	-webkit-appearance: none !important;
	pointer-events: none !important;
	background: none !important;
	color: transparent !important;
}

.ebw-lang-switcher__menu {
	position: fixed;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	gap: 2px;
	width: max-content;
	min-width: 0;
	max-width: none;
	margin: 0;
	padding: 6px;
	border: 1px solid var(--ebw-ls-border, rgba(255, 255, 255, 0.25));
	border-radius: var(--ebw-ls-menu-radius, 12px);
	background-color: var(--ebw-ls-bg, #111);
	background-image: none;
	box-shadow: var(--ebw-ls-shadow, 0 10px 28px rgba(0, 0, 0, 0.35));
	color: var(--ebw-ls-color, #fff);
	white-space: nowrap;
}

.ebw-lang-switcher__menu[hidden] {
	display: none !important;
}

form.ebw-lang-switcher button.ebw-lang-switcher__option {
	align-self: stretch;
	width: auto;
	min-width: max-content;
	padding: 8px 12px;
	border-radius: 8px;
	font-weight: 500;
}

form.ebw-lang-switcher button.ebw-lang-switcher__option:hover,
form.ebw-lang-switcher button.ebw-lang-switcher__option:focus-visible,
form.ebw-lang-switcher button.ebw-lang-switcher__option[aria-selected="true"] {
	background-color: var(--ebw-ls-option-hover, rgba(255, 255, 255, 0.14));
	color: var(--ebw-ls-color, #fff);
}

.ebw-lang-switcher__currency {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	align-self: stretch;
	gap: 6px;
	min-width: max-content;
	max-width: none;
	margin: 0;
	padding: var(--ebw-ls-padding-y, 8px) var(--ebw-ls-padding-x, 14px);
	border: 0;
	border-left: 1px solid var(--ebw-ls-border, rgba(255, 255, 255, 0.25));
	background: transparent;
	background-image: none;
	color: var(--ebw-ls-color, #fff);
	font: inherit;
	font-size: var(--ebw-ls-font-size, 14px);
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.04em;
	text-decoration: none;
	white-space: nowrap;
	overflow: visible;
	cursor: default;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
}

.ebw-lang-switcher__currency-symbol,
.ebw-lang-switcher__currency-code {
	color: var(--ebw-ls-color, #fff);
	white-space: nowrap;
}

.ebw-lang-switcher__currency-code {
	font-weight: 500;
	letter-spacing: 0.06em;
}

.ebw-lang-switcher.is-pending {
	opacity: 0.55;
}

@media (max-width: 768px) {
	.ebw-lang-switcher {
		width: max-content;
		min-width: max-content;
		max-width: none;
		flex-wrap: nowrap;
		white-space: nowrap;
	}

	.ebw-lang-switcher__lang,
	.ebw-lang-switcher__name,
	.ebw-lang-switcher__trigger,
	.ebw-lang-switcher__currency,
	.ebw-lang-switcher__option {
		white-space: nowrap;
		max-width: none;
		overflow: visible;
	}

	form.ebw-lang-switcher button.ebw-lang-switcher__trigger,
	.ebw-lang-switcher__currency {
		padding: var(--ebw-ls-padding-y, 8px) var(--ebw-ls-padding-x, 14px);
	}
}

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

@media (forced-colors: active) {
	.ebw-lang-switcher {
		border: 1px solid CanvasText;
		background-color: Canvas;
		color: CanvasText;
	}

	.ebw-lang-switcher__currency {
		border-color: CanvasText;
		color: CanvasText;
	}

	.ebw-lang-switcher__menu {
		background-color: Canvas;
		color: CanvasText;
		border-color: CanvasText;
		box-shadow: none;
	}

	form.ebw-lang-switcher button.ebw-lang-switcher__trigger:focus-visible,
	form.ebw-lang-switcher button.ebw-lang-switcher__option:focus-visible {
		outline: 2px solid Highlight;
	}
}

@media print {
	.ebw-lang-switcher {
		display: none !important;
	}
}
