/* ==========================================================================
   Language button in the header (template-parts/language-switcher.php,
   inc/translate.php). A small globe pill that opens a panel with the 16
   languages; the panel drops under the button on a computer and fills the
   width on phones. Also hides Google Translate's own grey top bar so the
   site keeps its design.
   ========================================================================== */
.lang-switch { position: relative; flex-shrink: 0; }

.lang-toggle {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 14px;
	border: 1.5px solid var(--color-border);
	border-radius: 999px;
	background: var(--color-surface);
	color: var(--color-primary-dark);
	font-family: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
	transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.lang-current { letter-spacing: 0.04em; }

/* Every flag is the same size, on the button and in the list. */
.lang-flag {
	width: 24px;
	height: 18px;
	flex-shrink: 0;
	display: block;
	object-fit: contain;
	border-radius: 3px;
	border: 1px solid rgba(43, 38, 32, 0.15);
	background: var(--color-bg-alt);
}
.lang-flag-box { display: inline-flex; }
.lang-toggle:hover,
.lang-switch.is-open .lang-toggle { border-color: var(--color-primary); background: var(--color-bg-alt); }
.lang-toggle:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.lang-caret {
	width: 7px; height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	margin-top: -4px;
	transition: transform var(--transition);
}
.lang-switch.is-open .lang-caret { transform: rotate(225deg); margin-top: 3px; }

/* ---- The panel of languages ---- */
.lang-panel {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 1000;
	width: 420px;
	max-width: calc(100vw - 32px);
	padding: 16px;
	border-radius: var(--radius-md);
	border: 1px solid var(--color-border);
	background: var(--color-surface);
	box-shadow: var(--shadow-lg);
}
.lang-panel[hidden] { display: none; }
.lang-panel-title {
	margin: 0 0 12px;
	font-size: 0.74rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--color-secondary-dark);
}
.lang-list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 4px;
	max-height: 60vh;
	overflow-y: auto;
}
.lang-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	padding: 8px 10px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: transparent;
	font-family: inherit;
	text-align: left;
	cursor: pointer;
	transition: background var(--transition), border-color var(--transition);
}
.lang-item:hover,
.lang-item:focus-visible { background: var(--color-bg-alt); border-color: var(--color-border); outline: none; }

.lang-names { display: flex; flex-direction: column; min-width: 0; }
.lang-name { font-size: 0.92rem; font-weight: 600; color: var(--color-primary-dark); }
.lang-names small { font-size: 0.72rem; color: var(--color-text-light); }
.lang-tick { margin-left: auto; opacity: 0; color: var(--color-primary); }
.lang-tick svg { width: 16px; height: 16px; }
.lang-item.is-current { background: rgba(47, 93, 80, 0.09); border-color: rgba(47, 93, 80, 0.3); }
.lang-item.is-current .lang-tick { opacity: 1; }
.lang-note {
	margin: 12px 0 0;
	padding-top: 10px;
	border-top: 1px dashed var(--color-border);
	font-size: 0.72rem;
	color: var(--color-text-light);
}

/* ---- Phones and tablets: the button sits next to the ☰ menu ---- */
@media (max-width: 1240px) {
	.lang-toggle { padding: 7px 10px; font-size: 0.78rem; }
	.lang-flag { width: 22px; height: 16px; }
	.lang-panel { width: min(360px, calc(100vw - 24px)); padding: 14px; }
	.lang-list { grid-template-columns: 1fr; max-height: 56vh; }
}

/* Phones: globe only, so the logo and the ☰ button keep their room. */
@media (max-width: 640px) {
	/* A little less air either side so the logo, the globe and the ☰ button
	   all fit on a 360px phone. */
	.header-inner { gap: 8px; padding: 0 12px; }
	.lang-toggle { padding: 7px 9px; gap: 4px; }
	.lang-current { display: none; }
	/* The panel is pinned to the screen, not to the button: hanging it off
	   the button pushed its left side (flags and names) off the screen. */
	.lang-panel {
		position: fixed;
		top: calc(var(--header-h) + 8px);
		left: 12px;
		right: 12px;
		width: auto;
		max-width: none;
		max-height: calc(100vh - var(--header-h) - 24px);
		max-height: calc(100dvh - var(--header-h) - 24px);
		overflow-y: auto;
	}
	.lang-list { max-height: none; }
}

/* ---- Google's own widget: keep the page looking like ours ---- */
#sty-google-translate { display: none; }
.skiptranslate iframe, .goog-te-banner-frame, #goog-gt-tt, .goog-te-balloon-frame { display: none !important; }
body { top: 0 !important; }
.goog-text-highlight { background: none !important; box-shadow: none !important; }
