/*
 * websun-i18n — language bar.
 *
 * Self-contained on purpose: the bar is rendered at wp_body_open(), outside the
 * header part, so nothing here may depend on a header class name. The only
 * shared things are the theme's design tokens, read through var() with fallbacks
 * so a token rename degrades to a readable bar instead of an invisible one.
 *
 * Dark strip, because the header is near-white: a light bar on top of a light
 * header reads as a rendering artefact rather than as a control. `brand-dark`
 * keeps it in the palette.
 */

.wpb-lang-bar {
	background: var(--brand-dark, #3d2b1f);
	color: rgba(255, 255, 255, .78);
	font-size: 12px;
	line-height: 1;
}

.wpb-lang-bar-inner {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	min-height: 30px;
}

/* The theme sets `ul { padding-left: 20px }` globally; reset it here. */
.wpb-lang-list {
	display: flex;
	align-items: center;
	gap: 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.wpb-lang-list li {
	margin: 0;
	padding: 0;
}

.wpb-lang-list a,
.wpb-lang-list .is-current {
	display: inline-block;
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
	text-decoration: none;
	color: rgba(255, 255, 255, .72);
}

.wpb-lang-list a:hover,
.wpb-lang-list a:focus {
	color: #fff;
	text-decoration: none;
}

/* Current language: a rule under it rather than a different weight, so the line
   height of the bar does not change between languages. */
.wpb-lang-list .is-current {
	color: #fff;
	box-shadow: inset 0 -2px 0 var(--brand, #8a5a34);
	padding-bottom: 2px;
}

/* ---- dropdown form, used when a site has more than four languages ---- */

.wpb-lang-more {
	position: relative;
}

.wpb-lang-more > summary {
	list-style: none;
	cursor: pointer;
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
	color: #fff;
	box-shadow: inset 0 -2px 0 var(--brand, #8a5a34);
	padding-bottom: 2px;
}

.wpb-lang-more > summary::-webkit-details-marker {
	display: none;
}

.wpb-lang-more > summary::marker {
	content: none;
}

/* With the summary carrying the current language, the list repeats it as a
   non-link, which is correct: it is where the visitor already is. */
.wpb-lang-more > .wpb-lang-nav {
	position: absolute;
	right: 0;
	top: calc(100% + 8px);
	z-index: 120;
	display: none;
	min-width: 112px;
	background: var(--brand-dark, #3d2b1f);
	border: 1px solid rgba(255, 255, 255, .18);
	border-radius: var(--radius, 10px);
	box-shadow: var(--shadow-md, 0 12px 28px rgba(28, 26, 23, .10));
	padding: 12px 18px;
}

.wpb-lang-more[open] > .wpb-lang-nav {
	display: block;
}

/* The dropdown is a column; the inline form stays a row. */
.wpb-lang-more .wpb-lang-list {
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;
}

/* ===========================================================================
 * In-header switcher (placement marker).
 *
 * The bar above is a dark strip on a near-white page: it works because it is
 * its own block. Inside the header these rules would be a dark slab in a light
 * row, so the in-header forms get their own, header-native styling: no
 * background, the header's own text colour, and the same letter-spacing /
 * uppercase rhythm the nav links use.
 *
 * Names are prefixed `wpb-lang-` like the bar, but no class is shared with it -
 * the bar's rules must not leak into the header.
 * ======================================================================== */

/* ---- shared by both in-header forms ---- */

.wpb-lang-drop,
.wpb-lang-inline {
	font-size: 12px;
	line-height: 1;
}

.wpb-lang-drop {
	position: relative;
	align-self: center;
}

.wpb-lang-drop-list,
.wpb-lang-inline-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wpb-lang-drop-list a,
.wpb-lang-drop-list .is-current,
.wpb-lang-inline-list a,
.wpb-lang-inline-list .is-current {
	display: inline-block;
	font-weight: 600;
	letter-spacing: .1em;
	/* No text-transform: the code is already upper-cased in PHP, and the name
	   modes must print `English` / `中文` as written, not `ENGLISH`. */
	text-decoration: none;
	color: inherit;
}

.wpb-lang-inline-list {
	display: flex;
	align-items: center;
	gap: 16px;
	/* A third language at 375px overflows the drawer without this. */
	flex-wrap: wrap;
}

/* Current language: a rule underneath, so switching does not change the
   trigger's own height and the header never nudges. `text-decoration` rather
   than an inset box-shadow because the dropdown rows are blocks now - a
   box-shadow would paint one line across the full row width. */
.wpb-lang-drop-list .is-current,
.wpb-lang-inline-list .is-current {
	text-decoration: underline;
	text-decoration-color: var(--brand, #8a5a34);
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
}

/* ---- dropdown form (desktop nav) ---- */

.wpb-lang-trigger {
	appearance: none;
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	font: inherit;
	font-weight: 600;
	letter-spacing: .1em;
	color: inherit;
	opacity: .72;
}

.wpb-lang-trigger::after {
	content: "";
	display: inline-block;
	width: 5px;
	height: 5px;
	margin-left: 7px;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	transform: translateY(-2px) rotate(45deg);
	vertical-align: middle;
}

.wpb-lang-trigger:hover,
.wpb-lang-trigger:focus {
	opacity: 1;
}

/* Absolutely positioned: an open list must not widen the header row, or it
   would push the single-line breakpoint on its own. `display` is declared in
   the scoped rule further down, because a bare `.wpb-lang-drop-list` loses to
   the theme's `.site-nav ul { display: flex }`. */
.wpb-lang-drop-list {
	position: absolute;
	right: 0;
	top: calc(100% + 10px);
	z-index: 130;
	min-width: 84px;
	background: var(--surface, #fff);
	border: 1px solid rgba(28, 26, 23, .12);
	border-radius: var(--radius, 10px);
	box-shadow: var(--shadow-md, 0 12px 28px rgba(28, 26, 23, .10));
}

/* The 10px between the trigger and the panel is a gap the pointer crosses on
   its way down. Without a bridge the panel closes under the cursor and the
   second language is unreachable by mouse - the classic hover-menu trap. It
   covers empty header space and nothing else, so it cannot intercept a real
   control. */
.wpb-lang-drop::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	height: 10px;
}

/* Hover + focus-within, matching the theme's existing Products dropdown rather
   than introducing a second interaction model in the same flex row. Keyboard
   users reach it by tabbing to the trigger; the trigger never gains focus
   without the list being reachable because :focus-within covers both. */
.wpb-lang-drop:hover .wpb-lang-drop-list,
.wpb-lang-drop:focus-within .wpb-lang-drop-list {
	display: flex;
}

/* Panel box. Scoped to .wpb-lang-drop on purpose. Measured, not assumed: with
   the bare `.wpb-lang-drop-list { padding: 12px }` the panel rendered at 0px of
   padding while every other declaration in the same rule (gap, flex-direction,
   align-items) applied. It was not cascade order - deleting the zeroing rule
   live changed nothing, and re-appending the panel rule at EOF changed nothing
   either. Raising the selector's specificity is the only thing that made the
   padding stick, so the extra class is functional, not cosmetic: dropping it
   silently re-flattens the panel.
 *
 * `display: none` needs the same weight for the same reason, and that is the
 * 0.3.0 defect this fixes: the theme's `.site-nav ul { display: flex }` is
 * (0,1,1) against the bare class's (0,1,0), so the panel was open at rest on
 * every page. */
.wpb-lang-drop .wpb-lang-drop-list {
	display: none;
	flex-direction: column;
	/* stretch, so each row's anchor fills the panel instead of hugging its text */
	align-items: stretch;
	gap: 0;
	/* Vertical padding only: the rows bring their own horizontal padding, and
	   it is what makes the whole row clickable. */
	padding: 6px 0;
}

/* Rows are clickable end to end: a block anchor with its own padding, so the
   target is the row and not the 12px-wide text. Scoped rather than under
   `.site-nav`, because a marker may sit in a header that has no `.site-nav`. */
.wpb-lang-drop .wpb-lang-drop-list a,
.wpb-lang-drop .wpb-lang-drop-list .is-current {
	display: block;
	padding: 7px 14px;
}

/* The theme styles every anchor inside .site-nav (font-size 15px, weight 500,
   padding 6px 2px, plus its own scaleX underline) because it assumes they are
   menu labels. The panel's labels also live there, so re-assert our own row
   metrics at a specificity that wins without !important. */
.site-nav .wpb-lang-drop-list li {
	margin: 0;
}

.site-nav .wpb-lang-drop-list a,
.site-nav .wpb-lang-drop-list .is-current {
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
}

/* The theme also styles list containers inside .site-nav, so the 24px gap it
   uses between menu items reaches this list as well and wins on specificity.
   Zero here: rows are separated by their own padding, not by a gap. */
.site-nav .wpb-lang-drop-list {
	gap: 0;
}

.site-nav .wpb-lang-drop-list a::after {
	display: none;
}

/* ---- inline form (mobile drawer) ---- */

.wpb-lang-inline {
	padding: 0 0 12px;
}

.wpb-lang-inline-list {
	/* Column gap 20px as before; row gap 12px, which only matters once the list
	   wraps to a second line. */
	gap: 12px 20px;
}

@media (max-width: 600px) {
	.wpb-lang-trigger {
		font-size: 13px;
	}
}

@media print {
	.wpb-lang-drop,
	.wpb-lang-inline {
		display: none;
	}
}

@media print {
	.wpb-lang-bar {
		display: none;
	}
}
