/**
 * Mobile Language + Currency Switcher
 *
 * A sticky bar pinned to the bottom of WoodMart's mobile drawer, plus two
 * bottom sheets. Everything is styled with WoodMart's own design tokens
 * (--brdcolor-gray-300, --bgcolor-white, --wd-primary-color, …) with literal
 * fallbacks so it degrades gracefully under any other theme.
 *
 * The bar is revealed by CSS alone, keyed off the drawer's own open-state
 * class: `.mobile-nav.wd-opened ~ .wcmp-ms-bar`. No JS touches its visibility.
 */

/* ---------------------------------------------------------------- Bar ---- */

/* Width must match the drawer exactly. `--wd-side-hidden-w` is declared ON
   `.wd-side-hidden`, and this bar is a SIBLING (not a descendant), so the
   variable is not inherited — the theme's values are mirrored here instead:
     default              → 340px            (style.css:1450)
     @media ≤1024px       → min(300px, 80vw) (style.css:22088)
   Override `--wcmp-ms-w` if the drawer width is customised. */
.wcmp-ms-bar {
	--wcmp-ms-w: 340px;
	position: fixed;
	bottom: 0;
	z-index: 501; /* above .wd-side-hidden (500) */
	display: flex;
	width: min(var(--wcmp-ms-w), 100vw);
	margin: 0;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	background-color: var(--bgcolor-white, #fff);
	border-top: 1px solid var(--brdcolor-gray-300, rgba(0, 0, 0, .105));
	box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
	/* Hidden until the drawer opens — matches the drawer's own easing. */
	visibility: hidden;
	transform: translateY(100%);
	transition: transform .5s cubic-bezier(.19, 1, .22, 1), visibility .5s;
}

.mobile-nav.wd-opened ~ .wcmp-ms-bar {
	visibility: visible;
	transform: none;
}

.mobile-nav.wd-left.wd-opened ~ .wcmp-ms-bar {
	left: 0;
	right: auto;
}

.mobile-nav.wd-right.wd-opened ~ .wcmp-ms-bar {
	right: 0;
	left: auto;
}

/* Keep the last menu row reachable above the bar. */
.mobile-nav.wd-opened {
	padding-bottom: 64px;
}

.wcmp-ms-btn {
	flex: 1 1 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	min-height: 52px;
	margin: 0;
	padding: 5px 12px;
	border: 0;
	border-radius: 0;
	background-color: rgba(var(--color-black-rgb, 0, 0, 0), .04);
	color: var(--color-gray-800, #333);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
	text-transform: uppercase;
	cursor: pointer;
	transition: background-color .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.wcmp-ms-btn + .wcmp-ms-btn {
	border-inline-start: 1px solid var(--brdcolor-gray-300, rgba(0, 0, 0, .105));
}

.wcmp-ms-btn:hover,
.wcmp-ms-btn:focus-visible,
.wcmp-ms-btn[aria-expanded="true"] {
	background-color: rgba(var(--color-black-rgb, 0, 0, 0), .09);
}

.wcmp-ms-btn:focus-visible {
	outline: 2px solid var(--wd-primary-color, #83b735);
	outline-offset: -2px;
}

.wcmp-ms-chevron {
	flex: 0 0 auto;
	opacity: .5;
	transition: transform .25s ease;
}

.wcmp-ms-btn[aria-expanded="true"] .wcmp-ms-chevron {
	transform: rotate(180deg);
}

.wcmp-ms-label {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ------------------------------------------------------------- Sheets ---- */

.wcmp-ms-backdrop {
	position: fixed;
	inset: 0;
	z-index: 510;
	background-color: rgba(0, 0, 0, .5);
	opacity: 0;
	transition: opacity .28s ease;
}

.wcmp-ms-backdrop[hidden] {
	display: none;
}

.wcmp-ms-backdrop.is-open {
	opacity: 1;
}

.wcmp-ms-sheet {
	position: fixed;
	inset-inline: 0;
	bottom: 0;
	z-index: 511;
	max-height: 80vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding-bottom: env(safe-area-inset-bottom, 0px);
	background-color: var(--bgcolor-white, #fff);
	border-radius: 16px 16px 0 0;
	box-shadow: 0 -4px 24px rgba(0, 0, 0, .18);
	transform: translateY(100%);
	transition: transform .28s cubic-bezier(.19, 1, .22, 1);
}

.wcmp-ms-sheet[hidden] {
	display: none;
}

.wcmp-ms-sheet.is-open {
	transform: none;
}

.wcmp-ms-handle {
	width: 40px;
	height: 4px;
	margin: 10px auto 6px;
	border-radius: 2px;
	background-color: var(--brdcolor-gray-400, rgba(0, 0, 0, .12));
}

.wcmp-ms-title {
	margin: 0;
	padding: 8px 20px 14px;
	color: var(--color-gray-900, #242424);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
}

.wcmp-ms-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.wcmp-ms-list > li {
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Rows follow WoodMart's mobile nav metrics: 52px tall, 20px side padding,
   a single hairline divider. */
.wcmp-ms-row {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 52px;
	padding: 8px 20px;
	border-bottom: 1px solid var(--brdcolor-gray-300, rgba(0, 0, 0, .105));
	color: var(--color-gray-800, #333);
	font-size: 14px;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color .15s ease;
}

.wcmp-ms-list > li:last-child .wcmp-ms-row {
	border-bottom: 0;
}

.wcmp-ms-row:hover,
.wcmp-ms-row:focus-visible {
	background-color: rgba(var(--color-black-rgb, 0, 0, 0), .04);
	color: var(--color-gray-900, #242424);
}

.wcmp-ms-row.is-active {
	color: var(--wd-primary-color, #83b735);
	font-weight: 600;
}

.wcmp-ms-name {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wcmp-ms-code {
	flex: 0 0 auto;
	color: var(--color-gray-500, #767676);
	font-size: 12px;
	font-weight: 400;
	letter-spacing: .02em;
}

.wcmp-ms-row.is-active .wcmp-ms-code {
	color: inherit;
}

/* Checkmark drawn in CSS so no icon font is required. */
.wcmp-ms-check {
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	opacity: 0;
}

.wcmp-ms-row.is-active .wcmp-ms-check {
	position: relative;
	opacity: 1;
}

.wcmp-ms-row.is-active .wcmp-ms-check::after {
	content: "";
	position: absolute;
	top: 1px;
	left: 5px;
	width: 5px;
	height: 10px;
	border: solid currentColor;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

/* ------------------------------------------------------------- Glyphs ---- */

.wcmp-ms-flag {
	flex: 0 0 auto;
	width: 24px;
	height: 18px;
	max-height: 18px;
	border-radius: 2px;
	object-fit: cover;
}

.wcmp-ms-bar .wcmp-ms-flag {
	width: 20px;
	height: 15px;
}

.wcmp-ms-flag-empty {
	background-color: var(--bgcolor-gray-200, #f1f1f1);
}

.wcmp-ms-sym {
	flex: 0 0 auto;
	font-weight: 600;
}

.wcmp-ms-sym-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background-color: rgba(var(--color-black-rgb, 0, 0, 0), .06);
	color: var(--color-gray-700, #555);
	font-size: 12px;
}

.wcmp-ms-row.is-active .wcmp-ms-sym-badge {
	background-color: var(--wd-primary-color, #83b735);
	color: #fff;
}

/* --------------------------------------------------- Scope & a11y ------- */

/* Mirrors `.wd-side-hidden { --wd-side-hidden-w: min(300px, 80vw) }`
   at the same breakpoint (style.css:22071/22088). */
@media (max-width: 1024px) {
	.wcmp-ms-bar {
		--wcmp-ms-w: min(300px, 80vw);
	}
}

/* Desktop: never shown — matches WoodMart's own toolbar breakpoint. */
@media (min-width: 1025px) {
	.wcmp-ms-bar,
	.wcmp-ms-sheet,
	.wcmp-ms-backdrop {
		display: none !important;
	}

	.mobile-nav.wd-opened {
		padding-bottom: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.wcmp-ms-bar,
	.wcmp-ms-sheet,
	.wcmp-ms-backdrop,
	.wcmp-ms-chevron,
	.wcmp-ms-row {
		transition: none !important;
	}
}
