/* Evertongue language switcher
 * Self-contained, high-contrast, light/dark themeable.
 * Uses long "evertongue-switcher" names to avoid theme collisions.
 * Interactive elements use `all: unset` + explicit styles for maximum compatibility.
 */

.evertongue-switcher {
	font-family: var(--switcher-font, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: var(--switcher-font-size, 16px);
	line-height: 1.35;
	direction: ltr;
	unicode-bidi: isolate;

	/* Light theme (default) */
	--switcher-panel-bg: #ffffff;
	--switcher-panel-color: #111827;
	--switcher-panel-border: #e5e7eb;
	--switcher-panel-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.18), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
	--switcher-input-bg: #f3f4f6;
	--switcher-input-color: #111827;
	--switcher-input-border: #e5e7eb;
	--switcher-item-hover-bg: #f3f4f6;
	--switcher-item-current-bg: var(--switcher-item-hover-bg);
	--switcher-muted: #6b7280;
	--switcher-toggle-bg: #ffffff;
	--switcher-toggle-color: #111827;
	--switcher-toggle-border: #d1d5db;
	--switcher-toggle-shadow: none;
	--switcher-search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

.evertongue-switcher--theme-dark {
	--switcher-panel-bg: #111827;
	--switcher-panel-color: #f3f4f6;
	--switcher-panel-border: #374151;
	--switcher-panel-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.55);
	--switcher-input-bg: #1f2937;
	--switcher-input-color: #f3f4f6;
	--switcher-input-border: #4b5563;
	--switcher-item-hover-bg: #374151;
	--switcher-item-current-bg: #cfd3df;
	--switcher-muted: #9ca3af;
	--switcher-toggle-bg: #111827;
	--switcher-toggle-color: #f3f4f6;
	--switcher-toggle-border: #6b7280;
	--switcher-toggle-shadow: none;
	--switcher-search-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}

/* Shared pieces */
.evertongue-switcher__flag {
	display: inline-block;
	border-radius: 2px !important;
	overflow: hidden;
	flex-shrink: 0;
	position: relative;
	top: 1px;
}
.evertongue-switcher__english {
	display: inline;
}
.evertongue-switcher__native {
	display: inline;
	opacity: 0.75;
}

/* List style */
.evertongue-switcher--list {
	list-style: none;
	margin: 0;
	padding: 0;
	/* display: grid;
	grid-template-columns: repeat( auto-fill, minmax( 18rem, 1fr ) );
	gap: 3px 5px; */
	column-width: 18em;
	column-gap: 2rem;
}
.evertongue-switcher--list .evertongue-switcher__item a {
	all: unset;
	display: inline-flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 4px 6px;
	width: 100%;
	box-sizing: border-box;
	padding: 3px 6px;
	border-radius: 4px;
	text-decoration: none;
	color: inherit;
	cursor: pointer;
	direction: ltr;
	text-align: start;
	margin: 2px 0;
}
.evertongue-switcher--list .evertongue-switcher__item a:hover {
	background: rgba( 0, 0, 0, 0.06 );
}
.evertongue-switcher--list .evertongue-switcher__item.is-current a {
	font-weight: 700;
}

/* Combobox container */
.evertongue-switcher--combobox {
	position: relative;
	display: inline-block;
}

/* Combobox trigger button */
.evertongue-switcher button.evertongue-switcher__toggle {
	all: unset;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	background-color: var(--switcher-toggle-bg);
	color: var(--switcher-toggle-color);
	border: 1px solid var(--switcher-toggle-border);
	border-radius: 9999px;
	cursor: pointer;
	font: inherit;
	font-size: var(--switcher-font-size, 14px);
	line-height: 1;
	box-shadow: var(--switcher-toggle-shadow);
	box-sizing: border-box;
}

.evertongue-switcher--theme-light button.evertongue-switcher__toggle {
	background-color: #ffffff;
	color: #111827;
	border-color: #d1d5db;
}

.evertongue-switcher--theme-dark button.evertongue-switcher__toggle {
	background-color: #111827;
	color: #f3f4f6;
	border-color: #6b7280;
}

.evertongue-switcher button.evertongue-switcher__toggle::after {
	content: '';
	border-style: solid;
	border-width: 4px 4px 0 4px;
	border-color: currentColor transparent transparent transparent;
	margin-left: 6px;
	margin-top: 2px;
	opacity: 0.85;
}
.evertongue-switcher button.evertongue-switcher__toggle:hover {
	filter: brightness( 0.97 );
}
.evertongue-switcher button.evertongue-switcher__toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Dropdown panel */
.evertongue-switcher__panel {
	position: absolute;
	top: calc( 100% + 6px );
	left: 0;
	min-width: min( 100vw - 24px, 20rem );
	max-width: min( 100vw - 24px, 22rem );
	max-height: 340px;
	overflow: hidden;
	background: var(--switcher-panel-bg);
	color: var(--switcher-panel-color);
	border: 1px solid var(--switcher-panel-border);
	border-radius: 14px;
	box-shadow: var(--switcher-panel-shadow);
	padding: 8px;
	z-index: 100000;
	display: none;
	box-sizing: border-box;
}
.evertongue-switcher--combobox.is-open .evertongue-switcher__panel {
	display: flex;
	flex-direction: column;
}

/* Right-side alignment for right floating positions */
.evertongue-switcher--floating--top-right .evertongue-switcher__panel,
.evertongue-switcher--floating--bottom-right .evertongue-switcher__panel {
	left: auto;
	right: 0;
}

/* Upward panel for bottom floating positions */
.evertongue-switcher--floating--bottom-left .evertongue-switcher__panel,
.evertongue-switcher--floating--bottom-right .evertongue-switcher__panel {
	top: auto;
	bottom: calc( 100% + 6px );
}

.evertongue-switcher--floating--bottom-left button.evertongue-switcher__toggle::after,
.evertongue-switcher--floating--bottom-right button.evertongue-switcher__toggle::after {
	border-width: 0 4px 4px 4px;
	border-color: transparent transparent currentColor transparent;
	margin-top: 0;
	margin-bottom: 0;
}

/* Search input: icon as background-image, text starts after padding-left */
.evertongue-switcher input.evertongue-switcher__search[type="search"] {
	box-sizing: border-box;
	display: block;
	width: 100%;
	min-height: 34px;
	margin: 0 0 6px;
	padding: 7px 10px 7px 2.65rem;
	border: 1px solid var(--switcher-input-border);
	border-radius: 6px;
	font-family: inherit;
	font-size: var(--switcher-font-size, 14px);
	line-height: 1.35;
	color: var(--switcher-input-color);
	background: var(--switcher-input-bg) var(--switcher-search-icon) no-repeat 10px center / 18px 18px;
	-webkit-appearance: none;
	appearance: none;
}

.evertongue-switcher input.evertongue-switcher__search[type="search"]::-webkit-search-decoration,
.evertongue-switcher input.evertongue-switcher__search[type="search"]::-webkit-search-cancel-button,
.evertongue-switcher input.evertongue-switcher__search[type="search"]::-webkit-search-results-button,
.evertongue-switcher input.evertongue-switcher__search[type="search"]::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
	display: none;
}

.evertongue-switcher input.evertongue-switcher__search[type="search"]::placeholder {
	color: var(--switcher-muted);
	opacity: 0.9;
}

.evertongue-switcher input.evertongue-switcher__search[type="search"]:focus {
	outline: none;
	border-color: var(--switcher-panel-border);
}

/* Hide icon and reclaim left padding once the user starts typing */
.evertongue-switcher input.evertongue-switcher__search[type="search"].has-value {
	padding-left: 10px;
	background: var(--switcher-input-bg);
}

/* Language options list */
.evertongue-switcher__options {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow-y: auto;
	max-height: 260px;
}
.evertongue-switcher__option a {
	all: unset;
	display: inline-flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 6px 8px;
	width: 100%;
	box-sizing: border-box;
	padding: 6px 10px;
	border-radius: 5px;
	text-decoration: none;
	color: var(--switcher-panel-color);
	cursor: pointer;
	direction: ltr;
	text-align: start;
}
.evertongue-switcher__option a:hover,
.evertongue-switcher__option a:focus {
	background: var(--switcher-item-hover-bg);
}
.evertongue-switcher__option.is-current a {
	background: var(--switcher-item-current-bg);
	font-weight: 600;
}
.evertongue-switcher__option[hidden] {
	display: none;
}

/* Always-visible combobox (no toggle, panel always shown) */
.evertongue-switcher--combobox-open {
	position: relative;
	display: block;
	max-width: min( 100vw - 24px, 22rem );
}
.evertongue-switcher--combobox-open .evertongue-switcher__panel {
	position: static;
	display: flex;
	flex-direction: column;
	min-width: 0;
	max-height: none;
	overflow: visible;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.08 );
	padding: 8px;
}

/* Floating button container */
.evertongue-switcher--floating {
	position: fixed;
	z-index: 999999;
}
.evertongue-switcher--floating--top-left {
	top: 16px;
	left: 16px;
}
.evertongue-switcher--floating--top-right {
	top: 16px;
	right: 16px;
}
.evertongue-switcher--floating--bottom-left {
	bottom: 16px;
	left: 16px;
}
.evertongue-switcher--floating--bottom-right {
	bottom: 16px;
	right: 16px;
}

/* Subtle lift for floating button only */
.evertongue-switcher--floating.evertongue-switcher--theme-light button.evertongue-switcher__toggle {
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.12 );
}

.evertongue-switcher--floating.evertongue-switcher--theme-dark button.evertongue-switcher__toggle {
	box-shadow: 0 2px 10px rgba( 0, 0, 0, 0.35 );
}

/* Automatic footer language list */
.evertongue-switcher-footer {
	margin: 1.25rem 0 0.5rem;
	font-size: 12px;
	text-align: center;
	opacity: 0.9;
}
.evertongue-switcher-footer .evertongue-switcher--list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 2px 10px;
	grid-template-columns: none;
}
