/**
 * Translate Switcher — front-end styles.
 * All colours flow from CSS custom properties set per-site in the admin,
 * so the switcher inherits the host theme's palette by default.
 */

.ts-switcher {
	display: inline-block;
	font-size: var(--ts-font-size, 14px);
	line-height: 1.3;
	position: relative;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.ts-dropdown {
	position: relative;
	min-width: var(--ts-min-width, 120px);
	cursor: pointer;
	user-select: none;
	border: 1px solid var(--ts-border, #ddd);
	border-radius: var(--ts-radius, 6px);
	background: var(--ts-bg, #fff);
	color: var(--ts-color, #333);
}
.ts-dropdown:focus-visible {
	outline: 2px solid var(--ts-active-bg, #0073aa);
	outline-offset: 2px;
}
.ts-selected {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: var(--ts-py, 8px) var(--ts-px, 12px);
	gap: 8px;
}
.ts-globe { font-size: 1.05em; line-height: 1; }
.ts-arrow {
	font-size: 10px;
	opacity: .6;
	transition: transform .2s ease;
}
.ts-dropdown[aria-expanded="true"] .ts-arrow { transform: rotate(180deg); }

.ts-menu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	min-width: 100%;
	margin: 0;
	padding: 4px;
	background: var(--ts-bg, #fff);
	border: 1px solid var(--ts-border, #ddd);
	border-radius: var(--ts-radius, 6px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
	overflow: hidden;
	z-index: 9999;
	list-style: none;
	opacity: 0;
	transform: translateY(-4px);
	visibility: hidden;
	transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}
.ts-dropdown[aria-expanded="true"] .ts-menu {
	opacity: 1;
	transform: translateY(0);
	visibility: visible;
	transition: opacity .16s ease, transform .16s ease;
}
.ts-option { display: block; margin: 0; padding: 0; }
.ts-switcher .ts-option-link {
	display: flex;
	align-items: center;
	padding: var(--ts-py, 8px) var(--ts-px, 12px);
	border-radius: max(calc(var(--ts-radius, 6px) - 2px), 3px);
	cursor: pointer;
	text-decoration: none;
	color: var(--ts-color, #333);
	transition: background .15s ease, color .15s ease;
}
.ts-option-link:hover,
.ts-option-link:focus-visible {
	background: var(--ts-hover-bg, #f0f0f0);
	color: var(--ts-hover-color, #000);
	outline: none;
}
.ts-option.ts-active .ts-option-link {
	background: var(--ts-active-bg, #0073aa);
	color: var(--ts-active-color, #fff);
}

/* Theme-proof base text colour: some themes force a global `a { color }`
   that would otherwise hijack the switcher's link text. */
.ts-switcher .ts-pill,
.ts-switcher .ts-minimal-item { color: var(--ts-color, #333); }

/* ── Flags only ───────────────────────────────────────────── */
.ts-flags-list { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ts-flag-item {
	display: inline-flex;
	align-items: center;
	padding: 4px;
	border-radius: var(--ts-radius, 6px);
	text-decoration: none;
	opacity: .6;
	transition: opacity .2s ease, transform .15s ease;
}
.ts-flag-item:hover,
.ts-flag-item:focus-visible { opacity: 1; transform: scale(1.08); outline: none; }
.ts-flag-item.ts-active { opacity: 1; }

/* ── Pills ────────────────────────────────────────────────── */
.ts-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ts-pill {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: var(--ts-py, 6px) var(--ts-px, 12px);
	border: 1px solid var(--ts-border, #ddd);
	border-radius: 999px;
	background: var(--ts-bg, #fff);
	color: var(--ts-color, #333);
	text-decoration: none;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.ts-pill:hover,
.ts-pill:focus-visible { background: var(--ts-hover-bg, #f0f0f0); color: var(--ts-hover-color, #000); outline: none; }
.ts-pill.ts-active {
	background: var(--ts-active-bg, #0073aa);
	color: var(--ts-active-color, #fff);
	border-color: var(--ts-active-bg, #0073aa);
}

/* ── Minimal ──────────────────────────────────────────────── */
.ts-minimal { display: flex; align-items: center; gap: 6px; }
.ts-minimal-item {
	text-decoration: none;
	color: var(--ts-color, #333);
	font-weight: 600;
	opacity: .55;
	transition: opacity .15s ease, color .15s ease;
}
.ts-minimal-item:hover,
.ts-minimal-item:focus-visible { opacity: 1; outline: none; }
.ts-minimal-item.ts-active { opacity: 1; color: var(--ts-active-bg, #0073aa); }
.ts-sep { color: var(--ts-border, #ccc); }

/* ── Flag element ─────────────────────────────────────────── */
.ts-flag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: var(--ts-flag-size, 20px);
	line-height: 1;
	vertical-align: middle;
}
.ts-flag-img img,
.ts-flag-img { width: calc(var(--ts-flag-size, 20px) * 1.35); height: var(--ts-flag-size, 20px); object-fit: cover; }
.ts-flag-circle.ts-flag-img img { border-radius: 50%; }

/* Bundled SVG flag pack */
.ts-flag-svg { overflow: hidden; }
.ts-flag-svg img { width: calc(var(--ts-flag-size, 20px) * 1.35); height: var(--ts-flag-size, 20px); object-fit: cover; display: block; }
.ts-flag-svg.ts-flag-circle { border-radius: 50%; }
.ts-flag-svg.ts-flag-circle img { width: var(--ts-flag-size, 20px); border-radius: 50%; }
.ts-flag-svg.ts-flag-square { border-radius: 3px; }
.ts-flag-svg.ts-flag-square img { width: var(--ts-flag-size, 20px); }
.ts-flag-svg.ts-flag-rectangle { border-radius: 2px; }

/* Text-chip fallback (Windows / no emoji flags / chip mode) */
.ts-flag-chip {
	font-size: calc(var(--ts-flag-size, 20px) * .5);
	font-weight: 700;
	letter-spacing: .5px;
	min-width: calc(var(--ts-flag-size, 20px) * 1.3);
	height: var(--ts-flag-size, 20px);
	padding: 0 4px;
	color: var(--ts-color, #333);
	background: color-mix(in srgb, var(--ts-border, #ddd) 45%, transparent);
	border: 1px solid var(--ts-border, #ddd);
}
.ts-flag-chip.ts-flag-circle { border-radius: 50%; }
.ts-flag-chip.ts-flag-square { border-radius: 3px; }
.ts-flag-chip.ts-flag-rectangle { border-radius: 2px; }

/* ── Label ────────────────────────────────────────────────── */
.ts-label { display: inline-flex; align-items: center; gap: 7px; }
.ts-text { line-height: 1.3; }
.ts-code-badge { font-size: .8em; opacity: .7; font-weight: 600; }

/* ── Floating + Block ─────────────────────────────────────── */
.ts-floating {
	position: fixed;
	z-index: 99999;
	box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
	border-radius: var(--ts-radius, 6px);
	max-width: calc(100vw - 16px);
}
.ts-floating.ts-pos-top-left { top: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-top, 0px)); left: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-left, 0px)); }
.ts-floating.ts-pos-top-center { top: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); }
.ts-floating.ts-pos-top-right { top: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-top, 0px)); right: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-right, 0px)); }
.ts-floating.ts-pos-middle-left { top: 50%; left: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-left, 0px)); transform: translateY(-50%); }
.ts-floating.ts-pos-middle-right { top: 50%; right: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-right, 0px)); transform: translateY(-50%); }
.ts-floating.ts-pos-bottom-left { bottom: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-bottom, 0px)); left: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-left, 0px)); }
.ts-floating.ts-pos-bottom-center { bottom: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); }
.ts-floating.ts-pos-bottom-right { bottom: calc(var(--ts-offset-y, 20px) + env(safe-area-inset-bottom, 0px)); right: calc(var(--ts-offset-x, 20px) + env(safe-area-inset-right, 0px)); }

/* Explicit mobile placement. The breakpoint is toggled by JS so the admin can
   configure it without generating a separate stylesheet. */
html.ts-mobile-active .ts-floating.ts-mobile-pos-hidden { display: none !important; }
html.ts-mobile-active .ts-floating.ts-mobile-pos-top-left,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-top-left,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-middle-left,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-bottom-left {
	top: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-top, 0px)); right: auto; bottom: auto;
	left: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-left, 0px)); transform: none;
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-top-center {
	top: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-top, 0px)); right: auto; bottom: auto; left: 50%; transform: translateX(-50%);
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-top-right,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-top-right,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-middle-right,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-bottom-right {
	top: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-top, 0px)); right: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-right, 0px)); bottom: auto; left: auto; transform: none;
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-middle-left {
	top: 50%; right: auto; bottom: auto; left: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-left, 0px)); transform: translateY(-50%);
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-middle-right {
	top: 50%; right: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-right, 0px)); bottom: auto; left: auto; transform: translateY(-50%);
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-bottom-left {
	top: auto; right: auto; bottom: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-bottom, 0px)); left: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-left, 0px)); transform: none;
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-bottom-center,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-top-center,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-bottom-center {
	top: auto; right: auto; bottom: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-bottom-right {
	top: auto; right: calc(var(--ts-mobile-offset-x, 12px) + env(safe-area-inset-right, 0px)); bottom: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-bottom, 0px)); left: auto; transform: none;
}

/* Auto-safe deliberately moves top/middle floating controls to the lower edge
   on mobile, away from the most common hamburger/menu-toggle zone. */
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-top-left,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-middle-left,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-bottom-left {
	top: auto; bottom: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-bottom, 0px));
}
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-top-right,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-middle-right,
html.ts-mobile-active .ts-floating.ts-mobile-pos-auto-safe.ts-pos-bottom-right {
	top: auto; bottom: calc(var(--ts-mobile-offset-y, 16px) + env(safe-area-inset-bottom, 0px));
}

.ts-header-mount { display: inline-flex; align-items: center; min-width: 0; }
.ts-switcher.ts-auto-shift { transform: translateX(var(--ts-auto-shift-x, 0)) !important; }
.ts-switcher.ts-collision-compact .ts-text,
.ts-switcher.ts-collision-compact .ts-globe { display: none !important; }
.ts-switcher.ts-collision-compact .ts-dropdown { min-width: 0; }
.ts-switcher.ts-collision-compact .ts-selected { padding-left: max(8px, var(--ts-px, 12px)); padding-right: max(8px, var(--ts-px, 12px)); }

.ts-block.aligncenter { display: flex; justify-content: center; }
.ts-block.alignright { display: flex; justify-content: flex-end; }

/* ── RTL ──────────────────────────────────────────────────── */
.ts-rtl .ts-switcher,
.ts-switcher[dir="rtl"] { direction: rtl; }

/* ── Switching state ──────────────────────────────────────── */
.ts-switcher.ts-switching { opacity: .55; pointer-events: none; }

/* ── Browser-language suggestion bar ──────────────────────── */
.ts-lang-bar {
	position: fixed;
	left: 0;
	right: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	flex-wrap: wrap;
	padding: 10px 18px;
	background: #1f2430;
	color: #fff;
	font-size: 14px;
	box-shadow: 0 2px 18px rgba(0, 0, 0, .25);
}
.ts-lang-bar-top { top: 0; }
.ts-lang-bar-bottom { bottom: 0; }
.ts-lang-bar-text { display: inline-flex; align-items: center; gap: 8px; }
.ts-lang-bar-globe { font-size: 1.1em; }
.ts-lang-bar-actions { display: inline-flex; align-items: center; gap: 10px; }
.ts-lang-bar-yes {
	background: #2f80ed;
	color: #fff;
	text-decoration: none;
	padding: 6px 16px;
	border-radius: 6px;
	font-weight: 600;
	transition: background .15s ease;
}
.ts-lang-bar-yes:hover { background: #1f6fe0; color: #fff; }
.ts-lang-bar-no {
	background: transparent;
	color: #c9d1e0;
	border: 1px solid #3a4153;
	padding: 6px 14px;
	border-radius: 6px;
	cursor: pointer;
	font: inherit;
}
.ts-lang-bar-no:hover { color: #fff; border-color: #5a6377; }

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.ts-arrow,
	.ts-menu,
	.ts-flag-item,
	.ts-pill,
	.ts-option-link,
	.ts-minimal-item,
	.ts-lang-bar-yes { transition: none; }
}

/* ── Switcher inside a theme nav menu ─────────────────────── */
.ts-menu-switcher {
	display: flex;
	align-items: center;
	list-style: none;
	min-width: 0;
}
.ts-menu-switcher > .ts-switcher { margin: 0; max-width: 100%; }
html.ts-mobile-active .ts-menu-switcher {
	max-width: 100%;
	min-width: 0;
	z-index: 1;
}
html.ts-mobile-active .ts-menu-switcher .ts-dropdown { max-width: min(100%, calc(100vw - 16px)); }

