/*
 * Bayes Studio Multilingual — front-end styles.
 *
 * Enqueued only on pages where a switcher, an AI tag or a fallback notice
 * actually renders. Colours come from the theme's presets with hard fallbacks
 * so the components hold up with any theme active.
 */

/*
 * Tokens live on every root the switcher renders — the dropdown's <nav> and the
 * overlay switch beside it. The switch is a sibling of that <nav>, not a child,
 * so tokens set only on .bsml-switcher were undefined there: the selected
 * segment's var(--bsml-accent) fell back to transparent while its hard-coded
 * dark text stayed, and the chosen language rendered dark-on-navy, looking
 * disabled.
 */
.bsml-switcher,
.bsml-switcher__switch {
	--bsml-edge: rgba(0, 32, 68, 0.22);
	--bsml-ink: var(--wp--preset--color--harbour, #002044);
	--bsml-accent: var(--wp--preset--color--mint, #58e9d4);
	--bsml-wash: var(--wp--preset--color--mint-wash, #eafbf8);
	--bsml-hairline: var(--wp--preset--color--hairline, #e2e4ea);
}

.bsml-switcher {
	font: inherit;
	position: relative;
	color: inherit;
}

/* ---------------------------------------------------------------- dropdown */

.bsml-switcher--dropdown {
	display: inline-block;
	vertical-align: middle;
}

.bsml-switcher__details {
	position: relative;
}

/*
 * A real disclosure widget: it opens, closes and takes keyboard focus with the
 * stylesheet alone, so the switcher still works with scripting off. The script
 * only adds hover-to-open and click-away-to-close on top.
 */
.bsml-switcher__trigger {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	list-style: none;
	cursor: pointer;
	box-sizing: border-box;
	min-height: 34px;
	padding: 0.4em 0.6em;
	border: 1px solid var(--bsml-edge);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	transition: border-color 0.15s ease, background-color 0.15s ease;
}

.bsml-switcher__trigger::-webkit-details-marker {
	display: none;
}

.bsml-switcher__trigger::marker {
	content: "";
}

.bsml-switcher__globe {
	flex: none;
	opacity: 0.8;
}

.bsml-switcher__value {
	white-space: nowrap;
}

.bsml-switcher__caret {
	flex: none;
	opacity: 0.75;
	transition: transform 0.15s ease;
}

.bsml-switcher__details[open] .bsml-switcher__caret {
	transform: rotate(180deg);
}

.bsml-switcher__trigger:hover,
.bsml-switcher__details[open] > .bsml-switcher__trigger {
	border-color: var(--bsml-accent);
	background: rgba(0, 32, 68, 0.05);
}

.bsml-switcher__trigger:focus-visible {
	outline: 2px solid var(--bsml-accent);
	outline-offset: 2px;
}

.bsml-switcher__menu {
	position: absolute;
	top: calc(100% + 0.4rem);
	right: 0;
	z-index: 100;
	min-width: 12rem;
	margin: 0;
	padding: 0.3rem;
	list-style: none;
	border: 1px solid var(--bsml-hairline);
	border-radius: 10px;
	background: #fff;
	color: var(--bsml-ink);
	box-shadow: 0 12px 30px rgba(0, 32, 68, 0.18);
	text-align: left;
}

.bsml-switcher__option {
	margin: 0;
	list-style: none;
}

.bsml-switcher__option .bsml-switcher__link {
	display: grid;
	grid-template-columns: 1.05em 1fr auto;
	align-items: center;
	gap: 0.55em;
	box-sizing: border-box;
	width: 100%;
	padding: 0.5em 0.6em;
	border: 0;
	border-radius: 6px;
	color: var(--bsml-ink);
	text-decoration: none;
	font-size: 0.875rem;
	font-weight: 500;
	line-height: 1.25;
	white-space: nowrap;
}

.bsml-switcher__tick {
	width: 1.05em;
	height: 1.05em;
}

.bsml-switcher__option.is-current .bsml-switcher__tick::after {
	content: "";
	display: block;
	width: 0.3em;
	height: 0.6em;
	margin: 0.02em 0 0 0.36em;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
}

.bsml-switcher__code {
	font-size: 0.6875rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	opacity: 0.5;
}

.bsml-switcher__option .bsml-switcher__link:hover,
.bsml-switcher__option .bsml-switcher__link:focus-visible {
	background: rgba(0, 32, 68, 0.06);
	color: var(--bsml-ink);
}

.bsml-switcher__option .bsml-switcher__link:focus-visible {
	outline: 2px solid var(--bsml-accent);
	outline-offset: -2px;
}

.bsml-switcher__option.is-current .bsml-switcher__link {
	background: var(--bsml-wash);
	font-weight: 700;
}

.bsml-switcher__option.is-unavailable .bsml-switcher__link {
	opacity: 0.55;
}

/* ------------------------------------------------- segmented mobile switch */

/*
 * The Navigation block renders one list for the desktop bar and the mobile
 * overlay alike, so both presentations ship in the markup and the theme's own
 * overlay state class decides which one is shown. Hidden means display:none,
 * so only one of the two is ever in the accessibility tree.
 *
 * It borrows the overlay's own vocabulary: the current page there is marked by
 * mint text, the one solid mint shape is the demo button, and the quiet link
 * is white at 72%. So the chosen language is a mint-tinted segment with mint
 * text — clearly the one selected, and never mistaken for a second button.
 */
.bsml-switcher__switch {
	display: none;
}

.wp-block-navigation__responsive-container.is-menu-open .bsml-switcher--dropdown {
	display: none;
}

.wp-block-navigation__responsive-container.is-menu-open .bsml-switcher__item {
	width: 100%;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.wp-block-navigation__responsive-container.is-menu-open .bsml-switcher__switch {
	display: block;
	width: 100%;
	container: bsml-switch / inline-size;
}

.bsml-switcher__switch-label {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 12px;
	color: rgba(255, 255, 255, 0.6);
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.12em;
	line-height: 1;
	text-transform: uppercase;
}

.bsml-switcher__switch-label .bsml-switcher__globe {
	width: 14px;
	height: 14px;
	opacity: 1;
}

.bsml-switcher__track {
	display: flex;
	gap: 4px;
	box-sizing: border-box;
	width: 100%;
	padding: 4px;
	border: 1px solid rgba(255, 255, 255, 0.14);
	border-radius: 10px;
	background: rgba(255, 255, 255, 0.03);
}

/*
 * Two classes deep on purpose: the navigation's own link rules
 * (`:root :where(.wp-block-navigation a…)`) come later at one class and would
 * otherwise repaint every segment white.
 */
.bsml-switcher__track .bsml-switcher__segment {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	box-sizing: border-box;
	min-height: 44px;
	padding: 0 10px;
	border-radius: 6px;
	background: transparent;
	color: rgba(255, 255, 255, 0.72);
	font-size: 0.9375rem;
	font-weight: 500;
	line-height: 1.2;
	text-decoration: none;
	white-space: nowrap;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.bsml-switcher__segment-name {
	overflow: hidden;
	text-overflow: ellipsis;
}

.bsml-switcher__segment-code {
	display: none;
	letter-spacing: 0.06em;
}

.bsml-switcher__track .bsml-switcher__segment:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
}

.bsml-switcher__track .bsml-switcher__segment:focus-visible {
	outline: 2px solid var(--bsml-accent, #58e9d4);
	outline-offset: 2px;
}

.bsml-switcher__track .bsml-switcher__segment.is-current,
.bsml-switcher__track .bsml-switcher__segment.is-current:hover {
	background: rgba(88, 233, 212, 0.14);
	background: color-mix(in srgb, var(--bsml-accent, #58e9d4) 14%, transparent);
	box-shadow: inset 0 0 0 1px rgba(88, 233, 212, 0.6);
	box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bsml-accent, #58e9d4) 60%, transparent);
	color: var(--bsml-accent, #58e9d4);
	font-weight: 600;
}

/* A shape as well as a colour, so the choice does not rest on hue alone. */
.bsml-switcher__track .bsml-switcher__segment.is-current::before {
	content: "";
	flex: none;
	width: 0.3em;
	height: 0.6em;
	margin: -0.15em 0.1em 0 0;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
}

.bsml-switcher__track .bsml-switcher__segment.is-unavailable:not(.is-current) {
	color: rgba(255, 255, 255, 0.5);
}

/*
 * Narrow phones. Equal thirds of a 280px track leave about 87px a segment, and
 * the chosen one needs its tick and its bolder name to fit in that — so the
 * padding and the type come down a step. On a track under 260px — a Galaxy
 * Fold's 280px cover screen, less the gutters — three names cannot fit at
 * all, so the codes stand in. Two languages keep their names at any width.
 */
@container bsml-switch (max-width: 340px) {
	.bsml-switcher__track .bsml-switcher__segment {
		gap: 4px;
		padding: 0 4px;
		font-size: 0.875rem;
	}
}

@container bsml-switch (max-width: 260px) {
	.bsml-switcher__track:has(> :nth-child(3)) .bsml-switcher__segment-name {
		display: none;
	}

	.bsml-switcher__track:has(> :nth-child(3)) .bsml-switcher__segment-code {
		display: inline;
	}
}

/* ------------------------------------------------------- horizontal list */

.bsml-switcher__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.25rem 0.75rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.bsml-switcher__item {
	margin: 0;
	list-style: none;
}

.bsml-switcher--list .bsml-switcher__link {
	color: inherit;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	border-bottom: 1px solid transparent;
	padding-bottom: 0.1em;
}

.bsml-switcher--list .bsml-switcher__link:hover,
.bsml-switcher--list .bsml-switcher__link:focus-visible {
	border-bottom-color: currentColor;
}

.bsml-switcher--list .bsml-switcher__link:focus-visible {
	outline: 2px solid var(--bsml-accent);
	outline-offset: 3px;
}

.bsml-switcher--list .bsml-switcher__link.is-current {
	font-weight: 600;
	border-bottom-color: var(--bsml-accent);
}

.bsml-switcher--list .bsml-switcher__link.is-unavailable {
	opacity: 0.55;
}

.bsml-switcher__badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.75em;
	padding: 0.2em 0.45em;
	border: 1px solid currentColor;
	border-radius: 4px;
	font-size: 0.72em;
	font-weight: 700;
	letter-spacing: 0.04em;
	line-height: 1.2;
	text-transform: uppercase;
}

.bsml-switcher__name {
	line-height: 1.2;
}

/* ------------------------------------------ inside the header navigation */

.bsml-switcher--in-nav {
	display: block;
}

.wp-block-navigation .bsml-switcher {
	--bsml-edge: rgba(255, 255, 255, 0.3);
	color: inherit;
}

.wp-block-navigation .bsml-switcher__trigger {
	color: #fff;
}

.wp-block-navigation .bsml-switcher__trigger:hover,
.wp-block-navigation .bsml-switcher__details[open] > .bsml-switcher__trigger {
	border-color: var(--bsml-accent);
	background: rgba(255, 255, 255, 0.12);
}

/* The header forces light link colours; the panel sits on white. */
.wp-block-navigation .bsml-switcher__menu,
.wp-block-navigation .bsml-switcher__menu a,
.wp-block-navigation-item .bsml-switcher__menu a {
	color: var(--bsml-ink) !important;
}


@media (prefers-reduced-motion: reduce) {
	.bsml-switcher__trigger,
	.bsml-switcher__caret,
	.bsml-switcher__segment {
		transition: none;
	}
}

.bsml-disclosure {
	border: 1px solid var(--wp--preset--color--hairline, #e2e4ea);
	border-left: 4px solid var(--wp--preset--color--mint, #58e9d4);
	background: var(--wp--preset--color--mint-wash, #eafbf8);
	color: var(--wp--preset--color--body, #29334a);
	padding: 0.85rem 1.1rem;
	margin: 2rem auto;
	max-width: var(--wp--style--global--content-size, 1140px);
	font-size: 0.9375rem;
	line-height: 1.55;
	border-radius: 2px;
}

.bsml-disclosure p {
	margin: 0;
}

.bsml-disclosure p + p {
	margin-top: 0.35rem;
	opacity: 0.85;
}

.bsml-disclosure a {
	color: var(--wp--preset--color--harbour, #002044);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.bsml-disclosure a:focus-visible {
	outline: 2px solid var(--wp--preset--color--mint, #58e9d4);
	outline-offset: 2px;
}

.bsml-ai-tag {
	margin: 1.25rem 0;
	font-size: 0.75rem;
	line-height: 1.2;
}

.bsml-ai-tag__label {
	display: inline-block;
	padding: 0.2em 0.55em;
	border: 1px solid var(--wp--preset--color--hairline, #e2e4ea);
	border-radius: 999px;
	background: var(--wp--preset--color--mint-wash, #eafbf8);
	color: var(--wp--preset--color--harbour, #002044);
	letter-spacing: 0.02em;
	font-weight: 600;
}

/*
 * Dismissable card, out of document flow. Sits just below the sticky/fixed
 * header so it never covers the logo and nav the way an in-content box did
 * on hero templates.
 */
.bsml-fallback-notice {
	position: fixed;
	z-index: 1000;
	top: calc(var(--bsi--sticky-offset, calc(var(--bsi--admin-bar, 0px) + var(--bsi--header-height, 96px))) + 0.75rem);
	right: max(1.25rem, env(safe-area-inset-right));
	left: auto;
	box-sizing: border-box;
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: start;
	gap: 0.15rem 0.65rem;
	width: min(22rem, calc(100vw - 2.5rem));
	margin: 0;
	padding: 0.9rem 0.85rem 0.9rem 1.05rem;
	border: 1px solid var(--wp--preset--color--hairline, #e2e4ea);
	border-left: 4px solid var(--wp--preset--color--mint, #58e9d4);
	border-radius: 2px;
	background: var(--wp--preset--color--mint-wash, #eafbf8);
	color: var(--wp--preset--color--body, #29334a);
	box-shadow: 0 10px 28px rgba(0, 32, 68, 0.18);
	font-size: 0.875rem;
	line-height: 1.45;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.bsml-fallback-notice p {
	margin: 0;
	padding-top: 0.15rem;
}

.bsml-fallback-notice[hidden] {
	display: none !important;
}

.bsml-fallback-notice__dismiss {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	margin: -0.25rem -0.2rem 0 0;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: transparent;
	color: var(--wp--preset--color--harbour, #002044);
	cursor: pointer;
}

.bsml-fallback-notice__dismiss svg {
	width: 14px;
	height: 14px;
	stroke: currentColor;
	fill: none;
	stroke-width: 1.75;
	stroke-linecap: round;
}

.bsml-fallback-notice__dismiss:hover,
.bsml-fallback-notice__dismiss:focus-visible {
	background: color-mix(in srgb, var(--wp--preset--color--mint, #58e9d4) 35%, transparent);
}

.bsml-fallback-notice__dismiss:focus-visible {
	outline: 2px solid var(--wp--preset--color--mint, #58e9d4);
	outline-offset: 2px;
}

.bsml-fallback-notice.is-dismissing {
	opacity: 0;
	transform: translateY(-0.4rem);
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.bsml-fallback-notice {
		transition: none;
	}

	.bsml-fallback-notice.is-dismissing {
		transform: none;
	}
}
