/**
 * Entotox — country and language switchers.
 *
 * Two controls, not one: country moves between markets, language moves between
 * English and Arabic, and neither changes the other. They live in the navbar,
 * which is the part of the header the theme makes sticky, so they stay reachable
 * while reading. The mobile drawer gets its own stacked copy.
 *
 * Brand colours come from the logo (green #61C121, grey #5F5D5E), not the Bugro
 * demo palette. Directional rules use logical properties, so RTL mirrors itself
 * without a second set of rules.
 */

:root {
	--etx-sw-green: #61c121;
	--etx-sw-green-dark: #3d7d14;
	--etx-sw-ink: #2b2b2b;
	--etx-sw-muted: #5f5d5e;
	--etx-sw-line: rgba(95, 93, 94, 0.22);
}

.etx-switcher {
	position: relative;
	display: inline-flex;
	align-items: center;
	/* Both controls are inline-flex siblings, so by default they line up on
	   their text baselines — and a button holding a flag sits on a different
	   baseline from a span holding two links, which left the language pill 3px
	   below the country one. Aligning to the middle instead makes the pair
	   independent of whatever is inside them. */
	vertical-align: middle;
}

.etx-switcher .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---- flags --------------------------------------------------------------
   Sized explicitly: the theme stretches images inside the header otherwise. */

.etx-switcher .etx-switcher-flag {
	display: block;
	width: 20px;
	min-width: 20px;
	height: 14px;
	max-width: none;
	object-fit: cover;
	border: 1px solid rgba(95, 93, 94, 0.18);
	border-radius: 2px;
	flex: 0 0 auto;
}

/* ---- the country control ------------------------------------------------ */

.etx-switcher .etx-switcher-toggle {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	height: 34px;
	margin: 0;
	padding: 0 10px;
	border: 1px solid var(--etx-sw-line);
	border-radius: 8px;
	background: transparent;
	color: var(--etx-sw-muted);
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	cursor: pointer;
	transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}

.etx-switcher .etx-switcher-toggle:hover,
.etx-switcher .etx-switcher-toggle:focus-visible,
.etx-switcher.is-open .etx-switcher-toggle {
	border-color: var(--etx-sw-green);
	background: rgba(97, 193, 33, 0.1);
	color: var(--etx-sw-green-dark);
}

.etx-switcher-caret {
	width: 0;
	height: 0;
	margin-inline-start: 1px;
	border-inline-start: 4px solid transparent;
	border-inline-end: 4px solid transparent;
	border-top: 5px solid currentColor;
	opacity: 0.55;
	transition: transform 0.18s ease;
}

.etx-switcher.is-open .etx-switcher-caret {
	transform: rotate(180deg);
}

/* ---- the language control -----------------------------------------------
   A segmented pair rather than a dropdown: with two options the alternative is
   worth showing at all times, and it costs one click instead of two. */

.etx-switcher--language {
	margin-inline-start: 8px;
}

.etx-switcher-langs {
	display: inline-flex;
	align-items: center;
	height: 34px;
	padding: 3px;
	border: 1px solid var(--etx-sw-line);
	border-radius: 8px;
	background: transparent;
}

.etx-switcher-langs {
	transition: border-color 0.18s ease;
}

.etx-switcher-langs:hover {
	border-color: var(--etx-sw-green);
}

.etx-switcher .etx-switcher-lang {
	position: relative;
	display: inline-flex;
	align-items: center;
	height: 26px;
	padding: 0 9px;
	border-radius: 6px;
	color: var(--etx-sw-muted);
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.18s ease, transform 0.18s ease;
}

/* The fill is a pseudo-element that scales up rather than a background that
   snaps on. The control only ever has two states and the page reloads when you
   pick one, so without this the thing never moves and reads as decoration
   rather than something you can press. */
.etx-switcher .etx-switcher-lang::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: 6px;
	background: rgba(97, 193, 33, 0.16);
	opacity: 0;
	transform: scale(0.82);
	transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.etx-switcher .etx-switcher-lang:hover::before,
.etx-switcher .etx-switcher-lang:focus-visible::before {
	opacity: 1;
	transform: scale(1);
}

.etx-switcher .etx-switcher-lang:hover,
.etx-switcher .etx-switcher-lang:focus-visible {
	color: var(--etx-sw-green-dark);
	transform: translateY(-1px);
}

.etx-switcher .etx-switcher-lang:active {
	transform: translateY(0) scale(0.96);
}

.etx-switcher .etx-switcher-lang.is-current {
	background: var(--etx-sw-green);
	color: #fff;
	box-shadow: 0 1px 4px rgba(97, 193, 33, 0.45);
}

/* The active side is where you already are — it should not invite a press. */
.etx-switcher .etx-switcher-lang.is-current:hover {
	color: #fff;
	transform: none;
}

.etx-switcher .etx-switcher-lang.is-current::before {
	content: none;
}

@media (prefers-reduced-motion: reduce) {
	.etx-switcher *,
	.etx-switcher-panel {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}

	.etx-switcher .etx-switcher-lang:hover {
		transform: none;
	}
}

/* ---- the country panel -------------------------------------------------- */

/* Three flags in a row rather than a stacked list: with the names gone a
   vertical list would be a tall thin strip of pictures. Each target is 44x34,
   comfortably above the 24px minimum for a pointer target. */
.etx-switcher-panel {
	position: absolute;
	top: calc(100% + 8px);
	inset-inline-end: 0;
	z-index: 1001;
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px;
	border: 1px solid rgba(95, 93, 94, 0.1);
	border-radius: 10px;
	background: #fff;
	box-shadow: 0 10px 30px rgba(31, 31, 31, 0.14);
}

.etx-switcher-panel[hidden] {
	display: none;
}

/* ---- opening on hover ---------------------------------------------------
   On a pointer device the country panel opens by hovering; the click handler
   stays for touch and for keyboard, where :focus-within does the same job.

   Restricted to hover-capable pointers so a tap on a phone does not fire a
   phantom hover and leave the panel stuck open. */

@media (hover: hover) and (min-width: 992px) {
	/* !important is not decoration here: Bootstrap's reboot ships
	   `[hidden] { display: none !important }`, which no amount of specificity
	   can outrank. The click handler works by removing the attribute, which is
	   why that path never hit this. */
	.etx-switcher--country:hover .etx-switcher-panel,
	.etx-switcher--country:focus-within .etx-switcher-panel {
		display: flex !important;
		animation: etx-switcher-in 0.16s ease-out;
	}

	/* The panel sits 8px below the button; without something spanning that gap
	   the pointer leaves the control on the way down and the panel shuts. */
	.etx-switcher--country .etx-switcher-panel::before {
		content: "";
		position: absolute;
		inset-inline: 0;
		top: -10px;
		height: 10px;
	}

	.etx-switcher--country:hover .etx-switcher-toggle,
	.etx-switcher--country:focus-within .etx-switcher-toggle {
		border-color: var(--etx-sw-green);
		background: rgba(97, 193, 33, 0.1);
		color: var(--etx-sw-green-dark);
	}

	.etx-switcher--country:hover .etx-switcher-caret,
	.etx-switcher--country:focus-within .etx-switcher-caret {
		transform: rotate(180deg);
	}
}

@keyframes etx-switcher-in {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.etx-switcher .etx-switcher-option {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 34px;
	padding: 0;
	border-radius: 7px;
	text-decoration: none;
	transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.etx-switcher .etx-switcher-option:hover,
.etx-switcher .etx-switcher-option:focus-visible {
	background: rgba(97, 193, 33, 0.14);
}

/* The active market gets a ring. A tick or a filled block would crowd a tile
   this size, and the ring still reads at a glance. */
.etx-switcher .etx-switcher-option.is-current {
	box-shadow: inset 0 0 0 2px var(--etx-sw-green);
}

/* Arabic needs the brand Arabic face here: on the English markets the panel
   sits inside an English header and cannot inherit body.rtl. */
.etx-switcher [lang="ar"],
.etx-switcher-option:lang(ar) {
	font-family: 'Tajawal', 'Montserrat', 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- inside the navbar --------------------------------------------------
   The navbar lays its three zones out with flex-shrink, and the right-hand zone
   lost: its contents needed 485px and it was squeezed to 273, so the search icon
   and the quotation button dropped onto a second row. The menu in the middle has
   room to give instead. */

@media (min-width: 992px) {
	/* The row must not wrap, or the whole right-hand zone drops below the menu.
	 *
	 * The top bar is included because it has the same fault, and had it before
	 * this control moved: its middle zone is empty yet still claims 819px, which
	 * wrapped the phone number, the social heading and the social icons onto
	 * three separate lines and made a 49px bar 97px tall. */
	.header-navbar .container-fluid,
	.header-topbar .container-fluid {
		flex-wrap: nowrap;
	}

	.header-topbar .topbar-ul.pull-center {
		flex: 1 1 auto;
		min-width: 0;
	}

	/* Its right zone is pinned to the logo zone's width as well, so the social
	   heading and the icons beside it wrapped against each other. */
	.header-topbar .topbar-ul.pull-right {
		flex: 0 0 auto;
		width: auto;
		max-width: none;
		flex-wrap: nowrap;
	}

	/* The top bar writes its zones in the order left, right, centre — the old
	   stretched widths hid that. Once they size to their contents the social
	   block lands next to the phone number, so state the visual order. */
	.header-topbar .topbar-ul.element-left {
		order: 1;
	}

	.header-topbar .topbar-ul.pull-center {
		order: 2;
	}

	.header-topbar .topbar-ul.pull-right {
		order: 3;
	}

	/* The two outer zones take equal shares of whatever the middle does not
	   need, which puts the middle on the bar's midpoint. They still refuse to
	   go narrower than their own contents, so nothing is ever squashed — with
	   the switchers moved into the middle those contents are the logo (~195px)
	   and search plus the quotation button (~241px), close enough that each
	   side settles on the same width. */
	.header-navbar .navbar-ul.element-left,
	.header-navbar .navbar-ul.pull-right {
		flex: 1 1 0;
		width: auto;
		max-width: none;
		min-width: max-content;
		flex-wrap: nowrap;
	}

	.header-navbar .navbar-ul.pull-right {
		gap: 0;
	}

	/* The middle must not grow: if it absorbs the spare room the outer zones
	   stay at their own widths and the balancing above never happens. It still
	   refuses to shrink past its contents, so the menu cannot be squeezed. */
	.header-navbar .navbar-ul.pull-center {
		flex: 0 1 auto;
		min-width: max-content;
	}
}

/* ---- centring the menu --------------------------------------------------
   Left deliberately alone, and worth recording why.

   The right-hand cluster (two controls, search, quotation button) measures
   about 412px against a 195px logo. Centring the menu means reserving the
   same 412px on the logo side, which leaves roughly 600px for a menu that
   needs 700 — so at 1440px the menu wraps onto a second row, and pinning it
   to the bar's midpoint instead makes it run underneath the controls.

   Both were measured and reverted. Centring needs about 100px taken out of
   the right-hand cluster first — a shorter button label, a smaller button, or
   dropping the search icon — which is a design decision, not a CSS one. */

.header-navbar .navbar-ul.pull-right > li {
	display: flex;
	align-items: center;
}

.header-navbar .etx-switcher {
	margin-inline-end: 4px;
}

/* The sticky bar is white where the resting one is pale green, and its type is
   darker — follow it so the controls do not look pasted on. */
.header-sticky .etx-switcher .etx-switcher-toggle,
.header-sticky .etx-switcher .etx-switcher-langs {
	border-color: rgba(40, 36, 31, 0.2);
}

.header-sticky .etx-switcher .etx-switcher-toggle {
	color: #28241f;
}

/* Between the theme's mobile breakpoint (991px) and about 1260px the navbar
   cannot hold the logo, five menu items, both controls, search and the
   quotation button on one line — the menu wrapped and the header became two
   rows. Three small savings in that band add up to enough:
   the market name gives way to its flag, the controls tighten, and the menu
   items halve their side padding. */

/* Between the theme's mobile breakpoint (991px) and about 1200px the navbar is
   still tight: the logo, five menu items, both controls, search and the
   quotation button only just fit. Two small savings cover it.

   Dropping the country names freed roughly 70px, which is why the menu padding
   and the logo no longer have to shrink here as well. */
@media (min-width: 992px) and (max-width: 1199px) {
	.header-navbar .etx-switcher .etx-switcher-toggle {
		padding: 0 8px;
	}

	.header-navbar .etx-switcher .etx-switcher-lang {
		padding: 0 5px;
	}

	/* The last 12px come from the gaps around the two controls. */
	.header-navbar .etx-switcher {
		margin-inline-end: 2px;
	}

	.header-navbar .etx-switcher--language {
		margin-inline-start: 4px;
	}

	/* Dropping the country names did not help at this width — the name was
	   already hidden here, so that saving only shows above 1200px. These two
	   reductions are what actually make the row fit.

	   The menu rule matches the RTL sweep's own
	   `.rtl .header-navbar ul.nav.wp-menu > li`, which sets all four sides;
	   only the inline axis is touched. */
	.header-navbar ul.nav.wp-menu > li,
	.rtl .header-navbar ul.nav.wp-menu > li {
		padding-inline: 8px;
	}

	.header-navbar .site-logo {
		max-width: 150px;
	}
}

/* ---- inside the mobile drawer -------------------------------------------
   The drawer is a plain stacked list, so the panel becomes part of the flow
   rather than an overlay that the drawer's own scrolling would clip. */

@media (max-width: 991px) {
	.wp-menu.mobile-menu .etx-switcher {
		display: flex;
		width: 100%;
		padding: 8px 0;
	}

	.wp-menu.mobile-menu .etx-switcher--language {
		margin-inline-start: 0;
	}

	/* Not full width. With the name gone that would be a wide pill holding one
	   small flag and a caret at the far end. */
	.wp-menu.mobile-menu .etx-switcher-toggle {
		width: auto;
		justify-content: flex-start;
	}

	/* The panel opens in the flow rather than as an overlay the drawer's own
	   scrolling would clip. */
	.wp-menu.mobile-menu .etx-switcher-panel {
		position: static;
		min-width: 0;
		margin-top: 8px;
		box-shadow: none;
		border-color: var(--etx-sw-line);
	}
}
