/*
 * Language switcher, injected into the footer of every page by
 * Website/i18n/build.ps1. Colours follow the footer palette in site-footer.css
 * (#FA7316 accent on a dark ground) rather than the Elementor globals, so the
 * widget renders the same on pages that load a different Elementor kit.
 */

.cc-lang {
	display: flex;
	justify-content: center;
	width: 100%;
	/* The bottom margin is the gap between the button and whatever the footer
	   puts under it, so it is deliberately larger than the top one. */
	margin: 8px 0 24px;
	font-family: "Inter", sans-serif;
}

.cc-lang__wrap {
	position: relative;
}

.cc-lang__button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 14px;
	border: 1px solid rgba(255, 255, 255, .22);
	border-radius: 999px;
	background: rgba(255, 255, 255, .06);
	color: #FFFFFF;
	font: inherit;
	font-size: 14px;
	line-height: 1.2;
	cursor: pointer;
	transition: border-color .2s ease, background .2s ease;
}

.cc-lang__button:hover,
.cc-lang__button[aria-expanded="true"] {
	border-color: #FA7316;
	background: rgba(250, 115, 22, .12);
}

.cc-lang__button:focus-visible {
	outline: 2px solid #FA7316;
	outline-offset: 2px;
}

.cc-lang__list {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 8px);
	transform: translateX(-50%);
	z-index: 100;
	/* Three columns fit all 23 locales in eight short rows, so the popup opens
	   as one block; the rules at the bottom step down to two columns and then
	   one as the viewport narrows.

	   The explicit width is what keeps the popup off a horizontal scrollbar. An
	   absolutely positioned box shrink-to-fits, and its containing block here is
	   the button, so left to itself it settles at the *minimum* its tracks allow
	   while names like "Português (Portugal)" need half again that -- and the
	   overflow arrives as a scrollbar. Measured against max-content instead, the
	   fr tracks all come out at the longest label, which both fits every name and
	   keeps the three columns even. */
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	width: max-content;
	max-width: 92vw;
	gap: 1px 2px;
	max-height: 60vh;
	overflow-y: auto;
	/* A vertical scrollbar, once max-height bites, eats into that exact width and
	   would bring the horizontal one straight back; the trailing margin on the
	   last column is what it takes instead. */
	overflow-x: hidden;
	margin: 0;
	padding: 8px;
	list-style: none;
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: 12px;
	background: #1E1E21;
	box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
}

.cc-lang__list[hidden] {
	display: none;
}

.cc-lang__list li {
	/* Logical rather than margin-right so the Arabic and Hebrew pages, where the
	   whole popup runs right to left, get the gap on the correct side. */
	margin: 0;
	margin-inline-end: 14px;
	padding: 0;
	list-style: none;
}

.cc-lang__list a {
	display: flex;
	align-items: center;
	gap: 9px;
	/* Tight vertically, roomy horizontally: three columns of 23 languages want
	   to read as a compact block, not a long ladder. */
	padding: 4px 16px;
	border-radius: 6px;
	color: rgba(255, 255, 255, .8);
	font-size: 14px;
	line-height: 1.35;
	text-decoration: none;
	white-space: nowrap;
}

.cc-lang__list a:hover,
.cc-lang__list a:focus-visible {
	background: rgba(250, 115, 22, .16);
	color: #FFFFFF;
}

.cc-lang__list a.is-current {
	color: #FA7316;
	font-weight: 600;
}

/*
 * Flags come from assets/js/cc-flags.js. The inset ring stands the pale ones --
 * Japan, Israel, Poland -- off the dark panel, which they would otherwise bleed
 * into; overflow keeps the rounded corners on the artwork inside.
 */
.cc-lang__flag {
	flex: 0 0 auto;
	width: 21px;
	height: 14px;
	border-radius: 2px;
	overflow: hidden;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.cc-lang__flag svg {
	display: block;
	width: 100%;
	height: 100%;
}

/* Sized to their content the three columns come to about 640px, so the step
   down happens well before the popup could reach the edge of the window. */
@media (max-width: 820px) {
	.cc-lang__list {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 520px) {
	.cc-lang__list {
		grid-template-columns: 1fr;
		max-height: 55vh;
	}
}

/* Without JavaScript there is no switcher, so nothing should reserve space. */
.cc-lang:empty {
	display: none;
}
