/* ARYF i18n — language switcher
 *
 * Layout (matches design reference):
 *   Toggle:  [ globe ] [ EN ] [ ▾ ]                    pill capsule
 *   Menu item: [ EN ]  English      ✓                  chip + label + check
 *
 * The chip is the short code (Latin "EN"/"ES" for Latin langs, leading CJK
 * char for Chinese/Korean, first Abjad letter for Arabic/Persian). Comes
 * from languages.php → 'code' field.
 *
 * Colors are scoped to the site theme via --aryf-lang-* tokens at the top
 * so the switcher can be retinted from a single place.
 * ------------------------------------------------------------------------- */

.aryf-lang-switcher {
	--aryf-lang-fg:           #f1f3f8;
	--aryf-lang-fg-muted:     rgba(241, 243, 248, 0.72);
	--aryf-lang-toggle-bg:    rgba(255, 255, 255, 0.06);
	--aryf-lang-toggle-bg-h:  rgba(255, 255, 255, 0.12);
	--aryf-lang-toggle-bdr:   rgba(255, 255, 255, 0.16);
	--aryf-lang-menu-bg:      rgba(10, 14, 32, 0.96);
	--aryf-lang-menu-bdr:     rgba(255, 255, 255, 0.08);
	--aryf-lang-item-h:       rgba(255, 255, 255, 0.06);
	--aryf-lang-item-current: rgba(93, 177, 255, 0.14);  /* var(--c-blue) at 14% */
	--aryf-lang-accent:       #5db1ff;                    /* var(--c-blue) */
	--aryf-lang-chip-bg:      rgba(255, 255, 255, 0.06);
	--aryf-lang-chip-bg-cur:  rgba(93, 177, 255, 0.22);
	--aryf-lang-chip-fg-cur:  #93c5fd;

	position: relative;
	display: inline-flex;
	align-items: center;
	font-size: 0.9rem;
	line-height: 1;
	margin-inline-start: 0.5em;
	color: var(--aryf-lang-fg);
}

/* ----- Toggle pill ----- */
.aryf-lang-switcher__toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.5em 0.85em;
	background: var(--aryf-lang-toggle-bg);
	color: inherit;
	border: 1px solid var(--aryf-lang-toggle-bdr);
	border-radius: 999px;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.02em;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.aryf-lang-switcher__toggle:hover,
.aryf-lang-switcher__toggle:focus-visible,
.aryf-lang-switcher[data-aryf-lang-open] .aryf-lang-switcher__toggle {
	background-color: var(--aryf-lang-toggle-bg-h);
	border-color: rgba(255, 255, 255, 0.22);
	outline: none;
}

.aryf-lang-switcher__globe {
	flex: 0 0 auto;
	opacity: 0.85;
}

.aryf-lang-switcher__current {
	white-space: nowrap;
	font-size: 0.95em;
}

.aryf-lang-switcher__chev {
	flex: 0 0 auto;
	opacity: 0.7;
	margin-inline-start: -0.1em;
	transition: transform 0.15s ease;
}

.aryf-lang-switcher[data-aryf-lang-open] .aryf-lang-switcher__chev {
	transform: rotate(180deg);
}

/* ----- Dropdown menu ----- */
.aryf-lang-switcher__menu {
	position: absolute;
	top: calc(100% + 8px);
	inset-inline-end: 0;
	min-width: 200px;
	margin: 0;
	padding: 6px;
	list-style: none;
	background: var(--aryf-lang-menu-bg);
	color: var(--aryf-lang-fg);
	border: 1px solid var(--aryf-lang-menu-bdr);
	border-radius: 14px;
	box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
	z-index: 9999;
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
}

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

.aryf-lang-switcher__menu li {
	margin: 0;
	padding: 0;
	list-style: none;
}
.aryf-lang-switcher__menu li + li {
	margin-top: 2px;
}

/* ----- Menu item: chip + label + checkmark ----- */
.aryf-lang-switcher__item {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 0.7em;
	padding: 0.5em 0.65em;
	color: inherit;
	text-decoration: none;
	font-size: 0.92rem;
	white-space: nowrap;
	border-radius: 10px;
	transition: background-color 0.12s ease;
}

.aryf-lang-switcher__item:hover,
.aryf-lang-switcher__item:focus-visible {
	background-color: var(--aryf-lang-item-h);
	color: inherit;
	text-decoration: none;
	outline: none;
}

.aryf-lang-switcher__item.is-current {
	background-color: var(--aryf-lang-item-current);
	color: var(--aryf-lang-accent);
}

/* Chip — short language code in a rounded square */
.aryf-lang-switcher__chip {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 30px;
	height: 26px;
	padding: 0 0.4em;
	background: var(--aryf-lang-chip-bg);
	color: var(--aryf-lang-fg);
	border-radius: 7px;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1;
}

.aryf-lang-switcher__item.is-current .aryf-lang-switcher__chip {
	background: var(--aryf-lang-chip-bg-cur);
	color: var(--aryf-lang-chip-fg-cur);
}

.aryf-lang-switcher__label {
	font-weight: 500;
}

.aryf-lang-switcher__item.is-current .aryf-lang-switcher__label {
	font-weight: 600;
}

.aryf-lang-switcher__mark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 18px;
	height: 18px;
	color: var(--aryf-lang-accent);
}

/* Pages where a language has no real translation — keep the chip visible but
 * mute the row slightly. */
.aryf-lang-switcher__item.is-fallback .aryf-lang-switcher__chip,
.aryf-lang-switcher__item.is-fallback .aryf-lang-switcher__label {
	opacity: 0.75;
}

/* When the switcher lives inside a nav <li>, neutralize inherited link styles */
li.aryf-lang-switcher-item {
	list-style: none;
}
li.aryf-lang-switcher-item > .aryf-lang-switcher {
	display: inline-flex;
}

/* ----- Footer variant — opens upward, centered ----- */
.aryf-lang-switcher-item--footer {
	margin: 0 auto;
	text-align: center;
}
.aryf-lang-switcher-item--footer .aryf-lang-switcher {
	margin-inline: auto;
}
.aryf-lang-switcher-item--footer .aryf-lang-switcher__toggle {
	padding: 0.4em 0.75em;
	font-size: 0.85rem;
}
.aryf-lang-switcher-item--footer .aryf-lang-switcher__menu {
	bottom: calc(100% + 8px);
	top: auto;
	inset-inline-end: auto;
	left: 50%;
	transform: translateX(-50%);
	min-width: 200px;
	max-width: 90vw;
}

/* ----- Mobile drawer (Elementor popup) -----
 * The dropdown approach is fragile inside Elementor's popup (z-index
 * fights, overflow clipping, click-handler re-binding). Render the
 * languages INLINE instead — toggle button hidden, menu always visible
 * as a row of full-width chip+label rows. Push the whole switcher to
 * the bottom of the drawer so it sits below the menu items in its own
 * dedicated zone, not interleaved with them. */
.dialog-widget.elementor-popup-modal .aryf-lang-switcher-item {
	display: block;
	width: 100%;
	margin: 1.5em 0 0;
	padding-top: 1.25em;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
	order: 999;        /* push below regular menu items if parent is flex */
}
.dialog-widget.elementor-popup-modal .aryf-lang-switcher-item > .aryf-lang-switcher {
	display: block;
	width: 100%;
	margin: 0;
}
/* Hide the toggle button — no dropdown in the popup. */
.dialog-widget.elementor-popup-modal .aryf-lang-switcher__toggle {
	display: none;
}
/* Force the menu open (overrides [hidden]) and reflow it inline as a
 * static block, not an absolute-positioned dropdown. */
.dialog-widget.elementor-popup-modal .aryf-lang-switcher__menu,
.dialog-widget.elementor-popup-modal .aryf-lang-switcher__menu[hidden] {
	display: block;
	position: static;
	transform: none;
	left: auto;
	top: auto;
	bottom: auto;
	inset-inline-end: auto;
	min-width: 0;
	max-width: none;
	width: 100%;
	margin: 0;
	padding: 4px 0;
	background: transparent;
	border: 0;
	box-shadow: none;
	backdrop-filter: none;
	-webkit-backdrop-filter: none;
}
.dialog-widget.elementor-popup-modal .aryf-lang-switcher__item {
	padding: 0.85em 0;
	font-size: 1.05rem;
	border-radius: 8px;
}
.dialog-widget.elementor-popup-modal .aryf-lang-switcher__chip {
	min-width: 36px;
	height: 32px;
	font-size: 0.85rem;
}

/* Hide the menu's "Donate" item inside the mobile drawer popup — The7's
 * header CTA already renders a Donate button, having a duplicate menu
 * item is visual noise. Match by URL since the label may be translated. */
.dialog-widget.elementor-popup-modal a[href$="/donate/"],
.dialog-widget.elementor-popup-modal a[href$="/zh/donate/"] {
	display: none !important;
}
/* The7's CTA button widget uses an Elementor button-wrapper that we want
 * to keep, so restore it explicitly. */
.dialog-widget.elementor-popup-modal .elementor-button-wrapper a[href$="/donate/"],
.dialog-widget.elementor-popup-modal .elementor-button-wrapper a[href$="/zh/donate/"] {
	display: inline-flex !important;
}

/* RTL is automatic via logical properties; no extra rules needed. */
