/*
 * WBS Header — wraps the logo, WPML language switcher, and the mega menu
 * nav (assets/css/megamenu.css) into a single bar: the floating rounded
 * pill at >=768px, a flush-top full-width bar with a hamburger toggle
 * below it. Both breakpoints share header.js's sticky pin() behaviour.
 */

.wbs-header {
	--wbs-header-accent: #6054e8;
	--wbs-header-text: #181d27;
	--wbs-header-shadow: 0 20px 40px rgba(20, 20, 31, 0.12);
	--wbs-header-font: 'Inter', sans-serif;

	font-family: var(--wbs-header-font);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

@media (min-width: 768px) {
	.wbs-header {
		display: flex;
		/*
		 * stretch, not center: the trigger buttons/logo are shorter than
		 * this 75px bar, so centering them would leave a dead strip below
		 * each trigger (still visually inside the white bar) that's outside
		 * every trigger's own hoverable box. A slow pointer moving straight
		 * down from trigger text into that strip would drop the :hover
		 * chain before ever reaching the dropdown panel below. Stretching
		 * each column to the bar's full height (and re-centering content
		 * one level down — see .wbs-header__logo/__lang/.wbs-header
		 * .wbs-megamenu) closes that gap entirely.
		 */
		align-items: stretch;
		justify-content: space-between;
		gap: 16px;
		height: 75px;
		background: #fff;
		border-radius: 12px;
		box-shadow: none;
		transition: box-shadow 0.15s ease;
		/*
		 * Horizontal padding only. Vertical padding would sit outside the
		 * stretched content box above (align-items: stretch only fills the
		 * content box, never padding), leaving a slice of the bar's own top
		 * and bottom edge that's part of .wbs-header's painted area but not
		 * a descendant of any trigger <li> — the last dead strip in the
		 * hover chain. Height is fixed and children are centered one level
		 * down, so dropping vertical padding here doesn't move anything
		 * visually; it just lets the stretch reach the bar's real edges.
		 */
		padding: 0 16px;
		box-sizing: border-box;
		/*
		 * Positioning context for the mega-columns dropdown panel (see
		 * .wbs-header .wbs-megamenu__panel below) whether or not JS has
		 * pinned this yet — relative/fixed both establish one the same way.
		 */
		position: relative;
	}

	/*
	 * Matches --wbs-mm-shadow on .wbs-megamenu (megamenu.css) — the same
	 * shadow the dropdown panels use, applied to the bar itself on hover.
	 */
	.wbs-header:hover {
		box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
	}

	/*
	 * header.js applies this immediately on page load (not on scroll —
	 * that was an earlier approach here that caused a real vanish-then-
	 * pop-back flicker under fast/momentum scrolling, since a JS scroll
	 * handler can lag visibly behind actual scroll position; switching to
	 * fixed once, up front, before the user has scrolled at all, sidesteps
	 * that entirely — matches the proven `.smart-sticky-header` pattern
	 * already used elsewhere on this site). left/width are set inline by
	 * header.js, captured from wherever this would have naturally
	 * rendered in the surrounding Elementor container's normal flow, so
	 * this file doesn't need to hardcode that container's content-width
	 * setting — unlike .smart-sticky-header, this element IS the visible
	 * rounded pill (not an outer full-width wrapper around a separately
	 * boxed inner container), so it can't just be width: 100%.
	 */
	.wbs-header.wbs-header--fixed {
		position: fixed !important;
		top: 12px !important;
		/*
		 * Max 32-bit z-index — third-party widgets (chat bubbles etc.) tend
		 * to self-assign something similarly enormous (observed: 2147483645
		 * from a live one on this site) specifically so they always render
		 * on top. .wbs-header creates its own stacking context here, so
		 * this one value is enough to keep everything nested inside it
		 * (lang panel, the mobile overlay below) above such a widget too,
		 * regardless of their own smaller z-index values.
		 */
		z-index: 2147483647;
		transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
	}

	.wbs-header.wbs-header--fixed.wbs-header--hidden {
		transform: translateY(calc(-100% - 24px));
	}

	/*
	 * A panel open via :hover doesn't know the header it's anchored to just
	 * scrolled off — scrolling alone never fires the mouse events that
	 * would make the browser re-check :hover, so without this it's left
	 * floating in its old on-screen position after the bar itself is gone.
	 * Force it closed outright the instant the header is hidden, regardless
	 * of hover/focus/aria-expanded state.
	 */
	.wbs-header.wbs-header--hidden .wbs-megamenu__panel,
	.wbs-header.wbs-header--hidden .wbs-header__lang-panel {
		opacity: 0 !important;
		visibility: hidden !important;
	}

	/* WP admin bar (logged-in users only) sits fixed at the very top —
	 * 32px tall at desktop widths, 46px at the admin bar's own <=782px
	 * breakpoint. Clear it instead of sliding under it. */
	body.admin-bar .wbs-header.wbs-header--fixed {
		top: 44px !important;
	}

	@media screen and (max-width: 782px) {
		body.admin-bar .wbs-header.wbs-header--fixed {
			top: 58px !important;
		}
	}

	.wbs-header__logo {
		display: flex;
		align-items: center;
		flex-shrink: 0;
	}

	.wbs-header__logo img {
		display: block !important;
		height: 52px !important;
		width: auto !important;
		max-width: none !important;
	}

	/*
	 * Groups the language switcher and the mega menu nav into a single row
	 * (matching the Figma "List" container) so they share one flex context
	 * pinned to the header's right edge, instead of each fighting for space
	 * independently.
	 */
	.wbs-header__nav-group {
		display: flex;
		align-items: stretch;
		gap: 0;
		flex: 1;
		min-width: 0;
		justify-content: flex-end;
	}

	/*
	 * Carries the full-height stretch down into the nav itself so its <ul>
	 * (and in turn each trigger <li> — see .wbs-megamenu__top /
	 * .wbs-megamenu__top-item in megamenu.css) spans the bar's full 75px,
	 * closing the dead strip described above.
	 */
	.wbs-header .wbs-megamenu {
		display: flex;
		align-items: stretch;
	}

	/*
	 * The mega-columns dropdown panel is normally positioned relative to
	 * its own trigger <li> (see megamenu.css) so [wbs_mega_menu] works
	 * standalone. Wrapped in the header, the reference design anchors it to
	 * the whole header bar's width instead — cancel the trigger's own
	 * positioning context so the panel's absolute positioning resolves
	 * against .wbs-header above. Scoped to just the columns trigger (:has)
	 * — the simple/cards dropdowns (e.g. "For companies") and the language
	 * switcher should stay centered under their own narrow trigger, not
	 * anchored to the whole header's width, so their <li>/wrapper needs to
	 * keep its own positioning context.
	 */
	.wbs-header .wbs-megamenu__top-item:has(> .wbs-megamenu__panel--columns) {
		position: static;
	}

	.wbs-header .wbs-megamenu__panel--columns {
		left: 0;
		right: 0;
		width: auto;
	}

	.wbs-header__lang {
		position: relative;
		flex-shrink: 0;
		display: flex;
		align-items: center;
	}

	/*
	 * The hamburger/close toggle only exists for the mobile overlay below.
	 * !important: without it, the site's global button style (see the note
	 * on .wbs-header__lang-trigger above) wins and the raw <button> shows
	 * through as its default black pill.
	 */
	.wbs-header__mobile-toggle {
		display: none !important;
	}

	/*
	 * !important + explicit width/height/flex-direction resets: this site
	 * has a global button style (observed elsewhere as a black circular
	 * icon-button) that otherwise forces a fixed circular size onto any
	 * bare <button>, which stacks this trigger's flag+code content instead
	 * of showing them inline. See the matching note in megamenu.css.
	 */
	.wbs-header__lang-trigger {
		display: inline-flex !important;
		flex-direction: row !important;
		align-items: center !important;
		gap: 8px !important;
		width: auto !important;
		height: 30px !important;
		aspect-ratio: auto !important;
		white-space: nowrap;
		background: none !important;
		border: none !important;
		box-shadow: none !important;
		border-radius: 8px !important;
		min-width: 0 !important;
		line-height: normal !important;
		cursor: pointer;
		font: inherit;
		font-family: var(--wbs-header-font) !important;
		font-size: 14px !important;
		font-weight: 600;
		color: var(--wbs-header-text) !important;
		padding: 6px 12px !important;
		box-sizing: border-box;
	}

	.wbs-header__lang-trigger img {
		display: block;
	}

	.wbs-header__lang-trigger::after {
		content: "";
		display: inline-block;
		flex-shrink: 0;
		width: 10px;
		height: 6px;
		background-color: currentColor;
		-webkit-mask-image: url(../img/icons/chevron-down.svg);
		mask-image: url(../img/icons/chevron-down.svg);
		-webkit-mask-repeat: no-repeat;
		mask-repeat: no-repeat;
		-webkit-mask-size: contain;
		mask-size: contain;
		-webkit-mask-position: center;
		mask-position: center;
		transition: transform 0.15s ease;
	}

	/*
	 * Rotates on hover/focus as well as [aria-expanded="true"] — see the
	 * matching comment on .wbs-megamenu__trigger in megamenu.css.
	 */
	.wbs-header__lang:hover > .wbs-header__lang-trigger::after,
	.wbs-header__lang:focus-within > .wbs-header__lang-trigger::after,
	.wbs-header__lang-trigger[aria-expanded="true"]::after {
		transform: rotate(180deg);
	}

	/*
	 * Same gap-bridging split as .wbs-megamenu__panel in megamenu.css: this
	 * outer box has zero top offset and is fully transparent, so the
	 * invisible padding-top area stays part of the hover chain. The visible
	 * white panel lives on the nested -inner element, offset down by that
	 * padding.
	 */
	.wbs-header__lang-panel {
		position: absolute;
		top: 100%;
		left: 50%;
		transform: translateX(-50%);
		z-index: 100;
		padding-top: 8px;
		min-width: 160px;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.15s ease, visibility 0.15s;
	}

	.wbs-header__lang-panel-inner {
		background: #fff;
		border-radius: 12px;
		box-shadow: var(--wbs-header-shadow);
		border: 1px solid #ebebf2;
		transform: translateY(4px);
		transition: transform 0.15s ease;
	}

	.wbs-header__lang:hover > .wbs-header__lang-panel,
	.wbs-header__lang:focus-within > .wbs-header__lang-panel,
	.wbs-header__lang-trigger[aria-expanded="true"] + .wbs-header__lang-panel {
		opacity: 1;
		visibility: visible;
	}

	.wbs-header__lang:hover > .wbs-header__lang-panel .wbs-header__lang-panel-inner,
	.wbs-header__lang:focus-within > .wbs-header__lang-panel .wbs-header__lang-panel-inner,
	.wbs-header__lang-trigger[aria-expanded="true"] + .wbs-header__lang-panel .wbs-header__lang-panel-inner {
		transform: translateY(0);
	}

	.wbs-header__lang-panel ul {
		margin: 0;
		padding: 6px;
		list-style: none;
	}

	.wbs-header__lang-panel a {
		display: flex;
		align-items: center;
		/*
		 * Centered horizontally too — unlike the other dropdown panels,
		 * this one's content is just a flag + short code, and with so
		 * little content the panel's own min-width (160px) otherwise
		 * leaves it looking off-balance stuck to the left edge.
		 */
		justify-content: center;
		gap: 8px;
		padding: 8px 10px;
		border-radius: 8px;
		font-family: var(--wbs-header-font) !important;
		font-size: 14px !important;
		text-decoration: none;
		color: var(--wbs-header-text);
		font-size: 14px;
	}

	.wbs-header__lang-panel a:hover {
		background: #f5f5fa;
	}
}

/*
 * Mobile (<768px): a flush, full-width bar (no floating pill) with a
 * hamburger toggle that reveals the nav as a full-screen accordion overlay
 * below it — see `.wbs-header .wbs-megamenu` / `.wbs-header--menu-open`
 * below and the open/close controller in header.js.
 */
@media (max-width: 767.98px) {
	.wbs-header {
		position: relative;
		width: 100%;
		height: 72px;
		background: #fff;
		padding: 0 16px;
		box-sizing: border-box;
	}

	.wbs-header.wbs-header--fixed {
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		right: 0 !important;
		width: 100% !important;
		/* See the matching desktop rule above for why this is the max
		   32-bit value rather than a modest round number. */
		z-index: 2147483647;
		box-shadow: 0px 2px 2px -1px rgba(10, 13, 18, 0.04), 0px 4px 6px -2px rgba(10, 13, 18, 0.03);
		transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
	}

	.wbs-header.wbs-header--fixed.wbs-header--hidden {
		transform: translateY(-100%);
	}

	/* WP admin bar is 46px tall at its own <=782px breakpoint — comfortably
	   covers this component's 767.98px mobile range. */
	body.admin-bar .wbs-header.wbs-header--fixed {
		top: 46px !important;
	}

	.wbs-header__logo img {
		display: block !important;
		height: 35px !important;
		width: auto !important;
		max-width: none !important;
	}

	.wbs-header__nav-group {
		display: flex;
		align-items: center;
		gap: 4px;
	}

	.wbs-header__lang {
		position: relative;
		display: flex;
		align-items: center;
	}

	.wbs-header__lang-trigger {
		display: inline-flex !important;
		flex-direction: row !important;
		align-items: center !important;
		gap: 8px !important;
		width: auto !important;
		height: 30px !important;
		aspect-ratio: auto !important;
		white-space: nowrap;
		background: none !important;
		border: none !important;
		box-shadow: none !important;
		border-radius: 8px !important;
		min-width: 0 !important;
		line-height: normal !important;
		cursor: pointer;
		font: inherit;
		font-family: var(--wbs-header-font) !important;
		font-size: 14px !important;
		font-weight: 600;
		color: var(--wbs-header-text) !important;
		padding: 6px 12px !important;
		box-sizing: border-box;
	}

	.wbs-header__lang-trigger img {
		display: block;
	}

	.wbs-header__lang-trigger::after {
		content: "";
		display: inline-block;
		flex-shrink: 0;
		width: 10px;
		height: 6px;
		background-color: currentColor;
		-webkit-mask-image: url(../img/icons/chevron-down.svg);
		mask-image: url(../img/icons/chevron-down.svg);
		-webkit-mask-repeat: no-repeat;
		mask-repeat: no-repeat;
		-webkit-mask-size: contain;
		mask-size: contain;
		-webkit-mask-position: center;
		mask-position: center;
		transition: transform 0.15s ease;
	}

	.wbs-header__lang-trigger[aria-expanded="true"]::after {
		transform: rotate(180deg);
	}

	.wbs-header__lang-panel {
		position: absolute;
		top: 100%;
		left: 50%;
		right: auto;
		transform: translateX(-50%);
		z-index: 1001;
		padding-top: 8px;
		min-width: 160px;
		opacity: 0;
		visibility: hidden;
		transition: opacity 0.15s ease, visibility 0.15s;
	}

	.wbs-header__lang-trigger[aria-expanded="true"] + .wbs-header__lang-panel {
		opacity: 1;
		visibility: visible;
	}

	.wbs-header__lang-panel-inner {
		background: #fff;
		border-radius: 12px;
		box-shadow: var(--wbs-header-shadow);
		border: 1px solid #ebebf2;
	}

	.wbs-header__lang-panel ul {
		margin: 0;
		padding: 6px;
		list-style: none;
	}

	.wbs-header__lang-panel a {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 8px;
		padding: 8px 10px;
		border-radius: 8px;
		font-family: var(--wbs-header-font) !important;
		font-size: 14px !important;
		text-decoration: none;
		color: var(--wbs-header-text);
	}

	.wbs-header__lang-panel a:hover {
		background: #f5f5fa;
	}

	.wbs-header__mobile-toggle {
		display: flex !important;
		align-items: center;
		justify-content: center;
		flex-shrink: 0;
		width: 40px;
		height: 40px;
		padding: 8px;
		background: none !important;
		border: none !important;
		box-shadow: none !important;
		border-radius: 8px !important;
		cursor: pointer;
		box-sizing: border-box;
	}

	/*
	 * Hamburger -> X morph: three plain bars (see render_mobile_toggle() in
	 * class-wbs-header.php) rather than a two-icon swap, so the outer two
	 * can rotate into an X and the middle one can fade out instead of a
	 * hard cut between two unrelated glyphs.
	 */
	.wbs-header__mobile-toggle-bars {
		position: relative;
		display: block;
		width: 24px;
		height: 24px;
	}

	.wbs-header__mobile-toggle-bar {
		position: absolute;
		left: 0;
		width: 24px;
		height: 2px;
		border-radius: 1px;
		background: var(--wbs-header-text);
		transition: top 0.2s ease, transform 0.2s ease, opacity 0.15s ease;
	}

	.wbs-header__mobile-toggle-bar:nth-child(1) {
		top: 6px;
	}

	.wbs-header__mobile-toggle-bar:nth-child(2) {
		top: 11px;
	}

	.wbs-header__mobile-toggle-bar:nth-child(3) {
		top: 16px;
	}

	.wbs-header__mobile-toggle[aria-expanded="true"] .wbs-header__mobile-toggle-bar:nth-child(1) {
		top: 11px;
		transform: rotate(45deg);
	}

	.wbs-header__mobile-toggle[aria-expanded="true"] .wbs-header__mobile-toggle-bar:nth-child(2) {
		opacity: 0;
	}

	.wbs-header__mobile-toggle[aria-expanded="true"] .wbs-header__mobile-toggle-bar:nth-child(3) {
		top: 11px;
		transform: rotate(-45deg);
	}

	/*
	 * Hidden until the hamburger opens it — header.js toggles
	 * .wbs-header--menu-open. Kept in the layout (not display:none) so
	 * opacity/transform can transition; visibility + pointer-events still
	 * keep it fully inert and out of the tab order while closed. Standalone
	 * [wbs_mega_menu] usage (no .wbs-header ancestor) is untouched by this
	 * and stays in-flow, always expanded, per megamenu.css.
	 */
	.wbs-header .wbs-megamenu {
		position: fixed;
		top: 72px;
		left: 0;
		right: 0;
		bottom: 0;
		/*
		 * display: flex; flex-direction: column — lets .wbs-megamenu__top
		 * (its only child) use flex: 1 to fill this box's full height even
		 * when the accordion content alone is shorter than the screen, so
		 * a trailing CTA item can be pushed to the true bottom edge via
		 * margin-top: auto rather than just trailing off wherever the
		 * (short) content happens to end — see megamenu.css.
		 */
		display: flex;
		flex-direction: column;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		z-index: 999;
		background: var(--wbs-mm-panel-bg, #fff);
		box-shadow: 0px 12px 16px -4px rgba(10, 13, 18, 0.08), 0px 4px 6px -2px rgba(10, 13, 18, 0.03), 0px 2px 2px -1px rgba(10, 13, 18, 0.04);
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transform: translateY(-8px);
		transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	}

	.wbs-header.wbs-header--menu-open .wbs-megamenu {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		transform: translateY(0);
	}

	body.admin-bar .wbs-header .wbs-megamenu {
		top: 118px;
	}

	/* Locks page scroll behind the overlay while it's open — the list
	   itself still scrolls internally via overflow-y above. */
	body.wbs-menu-open {
		overflow: hidden;
	}

	@media (prefers-reduced-motion: reduce) {
		.wbs-header__mobile-toggle-bar,
		.wbs-header .wbs-megamenu {
			transition: none !important;
		}
	}
}
