/*
 * The language switcher on the public site: a row, a list, a dropdown or
 * pills, with or without flags. Colours and type come from the theme; only
 * the layout is set here, so a theme can restyle it by the classes.
 */

.aitr-switcher,
.aitr-switcher__list {
	box-sizing: border-box;
}

.aitr-switcher__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.25em 1em;
	margin: 0;
	padding: 0;
	list-style: none;
}

.aitr-switcher__item {
	margin: 0;
}

.aitr-switcher__link,
.aitr-switcher__current {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	text-decoration: none;
}

.aitr-switcher__item.is-current .aitr-switcher__link {
	font-weight: 700;
}

/* The flags. */
.aitr-flag {
	display: inline-block;
	flex: none;
	width: 1.35em;
	height: auto;
	vertical-align: -0.2em;
	object-fit: cover;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.aitr-flag--rounded {
	border-radius: 0.2em;
}

.aitr-flag--circle {
	width: 1.25em;
	aspect-ratio: 1;
	border-radius: 50%;
}

.aitr-language .aitr-flag,
.wp-block-navigation-item .aitr-flag {
	margin-inline-end: 0.4em;
}

.wp-block-navigation-item .aitr-flag + .wp-block-navigation-item__label {
	display: inline;
}

/* A list: one language under another. */
.aitr-switcher--list .aitr-switcher__list {
	flex-direction: column;
	align-items: flex-start;
	gap: 0.35em;
}

/* Pills: each language in a small rounded button. */
.aitr-switcher--pills .aitr-switcher__list {
	gap: 0.5em;
}

.aitr-switcher--pills .aitr-switcher__link {
	padding: 0.3em 0.85em;
	border: 1px solid currentColor;
	border-radius: 999px;
	line-height: 1.3;
}

.aitr-switcher--pills .aitr-switcher__item.is-current .aitr-switcher__link {
	background: currentColor;
}

.aitr-switcher--pills .aitr-switcher__item.is-current .aitr-switcher__name {
	color: #fff;
	mix-blend-mode: difference;
}

/* A dropdown: the language being viewed, the others behind it. It opens
   and closes without a script (details/summary). */
.aitr-switcher--dropdown {
	position: relative;
	display: inline-block;
}

.aitr-switcher__current {
	cursor: pointer;
	list-style: none;
	padding: 0.35em 0.6em;
	border: 1px solid currentColor;
	border-radius: 0.3em;
	line-height: 1.3;
}

.aitr-switcher__current::-webkit-details-marker {
	display: none;
}

.aitr-switcher__arrow {
	width: 0.45em;
	height: 0.45em;
	margin-inline-start: 0.2em;
	border: solid currentColor;
	border-width: 0 1.5px 1.5px 0;
	transform: translateY(-25%) rotate(45deg);
}

.aitr-switcher--dropdown[open] .aitr-switcher__arrow {
	transform: translateY(25%) rotate(-135deg);
}

.aitr-switcher__menu {
	position: absolute;
	inset-inline-start: 0;
	top: calc(100% + 0.3em);
	z-index: 30;
	min-width: 100%;
	/* No padding: a hovered row fills the menu to its edges, and the
	   rounded corners clip it. */
	padding: 0;
	overflow: hidden;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 0.3em;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.aitr-switcher--dropdown .aitr-switcher__list {
	flex-direction: column;
	align-items: stretch;
	gap: 0;
}

.aitr-switcher--dropdown .aitr-switcher__link {
	display: flex;
	padding: 0.55em 0.9em;
	color: inherit;
	white-space: nowrap;
}

.aitr-switcher--dropdown .aitr-switcher__link:hover,
.aitr-switcher--dropdown .aitr-switcher__link:focus-visible {
	background: rgba(0, 0, 0, 0.06);
}

/* The menu clips what sticks out of its rounded corners, so a focus ring
   drawn outside a row would be cut: it is drawn inside instead. */
.aitr-switcher--dropdown .aitr-switcher__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

/* The switcher in the corner of every page: bottom right unless another
   corner is picked on the Settings screen. The corners are the screen's,
   the same in a right-to-left language. */
.aitr-float {
	position: fixed;
	z-index: 9990;
	bottom: 16px;
	right: 16px;
	max-width: calc(100vw - 32px);
	color: #1e1e1e;
	font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	letter-spacing: normal;
	text-transform: none;
}

.aitr-float .aitr-switcher__current {
	padding: 8px 14px;
	border: 1px solid #d5d8dc;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
	font-weight: 600;
}

.aitr-float .aitr-switcher__menu {
	top: auto;
	bottom: calc(100% + 6px);
	left: auto;
	right: 0;
	min-width: 100%;
}

.aitr-float--bottom-left,
.aitr-float--top-left {
	right: auto;
	left: 16px;
}

.aitr-float--bottom-left .aitr-switcher__menu,
.aitr-float--top-left .aitr-switcher__menu {
	right: auto;
	left: 0;
}

.aitr-float--top-right,
.aitr-float--top-left {
	bottom: auto;
	top: 16px;
}

/* At the top the menu opens downwards. */
.aitr-float--top-right .aitr-switcher__menu,
.aitr-float--top-left .aitr-switcher__menu {
	bottom: auto;
	top: calc(100% + 6px);
}

/* Below the admin bar for a signed-in visitor. */
.admin-bar .aitr-float--top-right,
.admin-bar .aitr-float--top-left {
	top: 48px;
}

@media screen and (max-width: 782px) {
	.admin-bar .aitr-float--top-right,
	.admin-bar .aitr-float--top-left {
		top: 62px;
	}
}

.aitr-float .aitr-switcher__current:focus-visible,
.aitr-float .aitr-switcher__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

@media print {
	.aitr-float {
		display: none;
	}
}
