/* Aipogeo Context Translate - front-end language switcher
 *
 * Every rule is scoped to the switcher's own id. The switcher lands inside
 * someone else's theme, so a generic theme rule such as
 * .some-menu a { display: block } must not be able to break it. To restyle it,
 * use the same id, or pick "My own CSS" / "No styles" under Switcher styles.
 *
 * Stable class names: .apgt-switcher-btn, .apgt-switcher-current,
 * .apgt-switcher-caret, .apgt-switcher-menu, .apgt-switcher-item,
 * .apgt-switcher-flag; states .is-active, .is-docked, .is-open, .is-flipped.
 */

#apgt-language-switch {
	position: fixed;
	top: 12px;
	right: 12px;
	z-index: 99999;
	font-size: 13px;
	line-height: 1.4;
	text-align: start;
	cursor: move;
	user-select: none;
}

#apgt-language-switch[hidden] {
	display: none;
}

/* Docked into a theme element: no longer floats. relative rather than static,
   so the menu is positioned against the switcher itself */
#apgt-language-switch.is-docked {
	position: relative;
	top: auto;
	right: auto;
	cursor: default;
	display: inline-block;
}

#apgt-language-switch .apgt-switcher-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: auto;
	margin: 0;
	padding: 7px 12px;
	border: 1px solid rgba(0, 0, 0, .12);
	border-radius: 4px;
	background: #fff;
	color: #1d2327;
	font: inherit;
	line-height: 1.4;
	text-align: start;
	text-transform: none;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

#apgt-language-switch.is-docked .apgt-switcher-btn {
	box-shadow: none;
}

#apgt-language-switch .apgt-switcher-btn:hover {
	background: #f6f7f7;
}

#apgt-language-switch .apgt-switcher-caret {
	font-size: 10px;
	opacity: .6;
}

/* Flags keep their aspect ratio; flags differ in height */
#apgt-language-switch .apgt-switcher-flag {
	display: inline-block;
	width: 22px;
	height: auto;
	max-width: none;
	margin: 0;
	padding: 0;
	vertical-align: middle;
	border: 0;
	border-radius: 2px;
	box-shadow: none;
	flex: 0 0 auto;
}

/* The menu needs its own z-index inside theme stacking contexts */
#apgt-language-switch .apgt-switcher-menu {
	display: none;
	position: absolute;
	z-index: 99999;
	top: calc(100% + 4px);
	/* Aligned with the button's left edge */
	left: 0;
	/* As wide as the longest item; max-width caps extreme cases */
	width: max-content;
	min-width: 100%;
	max-width: min(280px, calc(100vw - 24px));
	max-height: 320px;
	overflow-x: hidden;
	overflow-y: auto;
	/* Reserve room for a classic scrollbar so it does not cause a
	   horizontal one */
	scrollbar-gutter: stable;
	margin: 0;
	padding: 0;
	list-style: none;
	background: #fff;
	border: 1px solid rgba(0, 0, 0, .12);
	border-radius: 4px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

#apgt-language-switch.is-open .apgt-switcher-menu {
	display: block;
}

/* Not enough room on the right: align right and open towards the left */
#apgt-language-switch.is-flipped .apgt-switcher-menu {
	left: auto;
	right: 0;
}

#apgt-language-switch .apgt-switcher-item {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	/* Same padding and gap as the button, so items line up with it */
	gap: 6px;
	width: auto;
	margin: 0;
	padding: 8px 12px;
	color: #1d2327;
	font: inherit;
	text-align: start;
	text-decoration: none;
	text-transform: none;
	white-space: nowrap;
	border: 0;
}

/* Long language names end in an ellipsis instead of scrolling */
#apgt-language-switch .apgt-switcher-item > span {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

#apgt-language-switch .apgt-switcher-item:hover,
#apgt-language-switch .apgt-switcher-item:focus {
	background: #f0f0f1;
	color: #135e96;
	text-decoration: none;
}

#apgt-language-switch .apgt-switcher-item.is-active {
	font-weight: 600;
	background: #f6f7f7;
}

/* Right-to-left pages: float in the top left corner instead */
[dir="rtl"] #apgt-language-switch:not(.is-docked) {
	right: auto;
	left: 12px;
}

@media screen and (max-width: 768px) {
	/* Small screens: pinned to a corner, not draggable */
	#apgt-language-switch:not(.is-docked) {
		top: auto !important;
		left: auto !important;
		right: 10px !important;
		bottom: 10px;
		cursor: default;
	}

	#apgt-language-switch:not(.is-docked) .apgt-switcher-menu {
		top: auto;
		bottom: calc(100% + 4px);
	}
}

@media screen and (max-width: 768px) {
	[dir="rtl"] #apgt-language-switch:not(.is-docked) {
		right: auto !important;
		left: 10px !important;
	}
}
