/* BP Header widget styles
 *
 * Scoped to .bp-header. Uses logical properties for LTR/RTL.
 * Tokens from tokens.css drive colors. Mirrors the approved
 * Barbary Plante mockup:
 *   - utility bar: compact 32px deep-green strip
 *   - main bar:    1200px inner, ~76px tall
 *   - logo:        ~120px visual width
 *   - CTA:         pill, deep green, white text
 *   - mobile:      compact, no duplicate FR | AR
 */

.bp-header {
	--bp-header-bg:         var(--bp-bg);
	--bp-header-utility-bg: var(--bp-primary);
	--bp-header-utility-fg: var(--bp-fg-on-green);
	--bp-header-border:     var(--bp-border-soft);
	--bp-header-inner-max:  1200px;
	--bp-header-pad-block:  14px;
	--bp-header-pad-inline: 24px;
	--bp-header-fg:         var(--bp-fg);
	--bp-header-cta-bg:     var(--bp-primary);
	--bp-header-cta-fg:     var(--bp-fg-on-green);
	--bp-header-cta-hover:  var(--bp-accent);
	--bp-header-accent:     var(--bp-accent);

	background: var(--bp-header-bg);
	color: var(--bp-header-fg);
	position: relative;
	z-index: 40;
	border-block-end: 1px solid var(--bp-header-border);
}

/* The .bp-header (parent) stays `position: relative` so the
 * green utility strip is non-sticky and scrolls away. The
 * white navigation bar (`.bp-header__main`) is NO LONGER
 * relying on `position: sticky`; a fixed-on-scroll behavior
 * is driven by `bp-sticky.js` via the `.is-fixed` class. The
 * legacy `.is-sticky` class is kept for backwards-compatible
 * hooks but no longer applies sticky positioning (v0.1.306). */
.bp-header__main {
	background: var(--bp-header-bg);
	box-shadow: 0 2px 8px rgba( 31, 42, 31, 0.04 );
	transition: box-shadow 200ms ease;
}

/* Fixed-on-scroll state applied by JS once the white bar
 * would otherwise leave the top of the viewport. */
.bp-header__main.is-fixed {
	position: fixed !important;
	inset-block-start: 0 !important;
	inset-inline-start: 0;
	inset-inline-end: 0;
	inline-size: 100%;
	z-index: 9999;
	background: var(--bp-header-bg);
	box-shadow: 0 4px 14px rgba( 31, 42, 31, 0.10 );
	animation: bp-header-slide-down 220ms ease;
}

@keyframes bp-header-slide-down {
	from { transform: translateY( -100% ); }
	to   { transform: translateY( 0 ); }
}

/* Spacer inserted by bp-sticky.js to prevent a content jump
 * when the white bar leaves the document flow. Zero height
 * until the bar is fixed. */
.bp-header-spacer {
	block-size: 0;
	pointer-events: none;
	visibility: hidden;
}

/* When the white bar is fixed, the mobile drawer (a sibling
 * of the bar inside .bp-header) must re-anchor to the
 * viewport just below the fixed bar, otherwise scrolling
 * pushes it off-screen. JS toggles `body.bp-header-fixed`
 * and writes the measured bar height into `--bp-header-main-h`.
 * Only apply when the drawer is actually open (`not([hidden])`)
 * so the closed state never intercepts clicks. */
body.bp-header-fixed .bp-header__drawer:not([hidden]) {
	position: fixed;
	inset-block-start: var(--bp-header-main-h, 60px);
	inset-inline-start: 0;
	inset-inline-end: 0;
	z-index: 9998;
	max-block-size: calc(100vh - var(--bp-header-main-h, 60px));
	overflow-y: auto;
}

/* ---------------- Inner container ---------------- */
.bp-header__inner {
	max-inline-size: var(--bp-header-inner-max);
	margin-inline: auto;
	padding-inline: var(--bp-header-pad-inline);
	display: flex;
	align-items: center;
	gap: 16px;
	min-block-size: 56px;
}

/* ---------------- Utility bar ---------------- */
.bp-header__utility {
	background: var(--bp-header-utility-bg);
	color: var(--bp-header-utility-fg);
	font-family: var(--bp-font-body);
	font-size: 12px;
	line-height: 1.2;
	letter-spacing: 0.01em;
}

.bp-header__utility .bp-header__inner {
	min-block-size: 32px;
	gap: 14px;
	padding-block: 6px;
}

.bp-header__utility-start,
.bp-header__utility-end {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px 16px;
}

.bp-header__utility-start { margin-inline-end: auto; }
.bp-header__utility-end   { margin-inline-start: auto; }

.bp-header__util-link {
	color: inherit;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 2px 0;
	min-block-size: 28px;
	transition: color 150ms ease;
}

.bp-header__util-link:hover,
.bp-header__util-link:focus-visible {
	color: var(--bp-cream);
}

.bp-header__util-text {
	color: var(--bp-cream);
}

.bp-header__util-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--bp-cream);
}

.bp-header__util-text--pending {
	color: var(--bp-cream);
	opacity: 0.75;
	font-style: italic;
}

/* ---------------- Main desktop bar ---------------- */
.bp-header__main { background: var(--bp-header-bg); }

.bp-header__main .bp-header__inner {
	min-block-size: 76px;
	padding-block: var(--bp-header-pad-block);
	gap: 24px;
}

.bp-header__main.is-hidden { display: none; }

.bp-header__logo {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
	color: inherit;
	flex: 0 0 auto;
}

.bp-header__logo img {
	display: block;
	max-inline-size: 120px;
	block-size: auto;
	object-fit: contain;
}

.bp-header__logo-text {
	font-family: var(--bp-font-display);
	font-size: 22px;
	font-weight: 400;
	color: var(--bp-primary);
	letter-spacing: 0.01em;
}

/* ---------------- Primary menu (desktop) ---------------- */
.bp-header__nav {
	flex: 1 1 auto;
	display: flex;
	justify-content: center;
}

.bp-header__menu,
.bp-header__drawer-nav .bp-header__menu,
.bp-footer__menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 4px 22px;
	justify-content: center;
}

.bp-header__menu > li {
	position: relative;
}

.bp-header__menu > li > a,
.bp-header__drawer-nav .bp-header__menu > li > a,
.bp-footer__menu > li > a {
	display: inline-flex;
	align-items: center;
	padding: 10px 4px;
	text-decoration: none;
	color: var(--bp-fg);
	font-family: var(--bp-font-body);
	font-weight: 500;
	font-size: 15px;
	letter-spacing: 0.005em;
	position: relative;
	transition: color 150ms ease;
}

.bp-header__menu > li > a::after,
.bp-header__drawer-nav .bp-header__menu > li > a::after {
	content: "";
	position: absolute;
	inset-inline-start: 4px;
	inset-inline-end: 4px;
	inset-block-end: 4px;
	block-size: 2px;
	background: var(--bp-header-accent);
	opacity: 0;
	transform: scaleX(0.6);
	transform-origin: center;
	transition: opacity 150ms ease, transform 150ms ease;
}

.bp-header__menu > li > a:hover,
.bp-header__menu > li > a:focus-visible,
.bp-header__menu > li.current-menu-item > a,
.bp-header__menu > li.current_page_item > a,
.bp-header__drawer-nav .bp-header__menu > li > a:hover,
.bp-header__drawer-nav .bp-header__menu > li > a:focus-visible,
.bp-footer__menu > li > a:hover,
.bp-footer__menu > li > a:focus-visible {
	color: var(--bp-accent);
}

.bp-header__menu > li > a:hover::after,
.bp-header__menu > li > a:focus-visible::after,
.bp-header__menu > li.current-menu-item > a::after,
.bp-header__menu > li.current_page_item > a::after {
	opacity: 1;
	transform: scaleX(1);
}

.bp-header__menu .sub-menu,
.bp-header__drawer-nav .sub-menu {
	list-style: none;
	margin: 0;
	padding: 8px 0;
	min-inline-size: 200px;
	background: var(--bp-bg);
	border: 1px solid var(--bp-border-soft);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba( 31, 42, 31, 0.08 );
	position: absolute;
	inset-block-start: 100%;
	inset-inline-start: 0;
	z-index: 50;
}

.bp-header__menu .sub-menu li a,
.bp-header__drawer-nav .sub-menu li a {
	display: block;
	padding: 8px 14px;
	color: var(--bp-fg);
	font-size: 14px;
}

/* ---------------- Actions column (CTA + burger) ---------------- */
.bp-header__actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-inline-start: auto;
	flex: 0 0 auto;
}

/* CTA button. */
.bp-header__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: var(--bp-header-cta-bg);
	color: var(--bp-header-cta-fg);
	padding: 11px 22px;
	border-radius: 999px;
	font-family: var(--bp-font-body);
	font-weight: 600;
	font-size: 14px;
	letter-spacing: 0.01em;
	text-decoration: none;
	transition: background-color 150ms ease, color 150ms ease;
	min-block-size: 44px;
	white-space: nowrap;
	border: 0;
}

.bp-header__cta:hover,
.bp-header__cta:focus-visible {
	background: var(--bp-header-cta-hover);
	color: var(--bp-fg);
}

/* Burger. */
.bp-header__burger {
	display: none;
	background: transparent;
	border: 0;
	padding: 10px;
	cursor: pointer;
	flex-direction: column;
	gap: 4px;
	min-block-size: 44px;
	min-inline-size: 44px;
	align-items: center;
	justify-content: center;
}

.bp-header__burger-line {
	display: block;
	inline-size: 22px;
	block-size: 2px;
	background: var(--bp-fg);
	border-radius: 2px;
	transition: transform 200ms ease, opacity 200ms ease;
}

.bp-header__burger[aria-expanded="true"] .bp-header__burger-line:nth-child(1) {
	transform: translateY(6px) rotate(45deg);
}
.bp-header__burger[aria-expanded="true"] .bp-header__burger-line:nth-child(2) {
	opacity: 0;
}
.bp-header__burger[aria-expanded="true"] .bp-header__burger-line:nth-child(3) {
	transform: translateY(-6px) rotate(-45deg);
}

/* ---------------- Mobile drawer ---------------- */
.bp-header__drawer {
	background: var(--bp-bg);
	border-block-start: 1px solid var(--bp-header-border);
	padding: 16px 20px 24px;
}

.bp-header__drawer[hidden] { display: none; }

.bp-header__drawer-nav {
	display: block;
}

.bp-header__drawer-nav .bp-header__menu {
	flex-direction: column;
	gap: 0;
	align-items: stretch;
}

.bp-header__drawer-nav .bp-header__menu > li > a {
	padding: 14px 4px;
	font-size: 16px;
	border-block-end: 1px solid var(--bp-header-border);
}

.bp-header__cta--drawer {
	margin-block-start: 16px;
	inline-size: 100%;
}

.bp-header__drawer-link {
	display: block;
	margin-block-start: 12px;
	color: var(--bp-fg);
	text-decoration: none;
	font-weight: 500;
	padding: 12px 0;
	border-block-end: 1px solid var(--bp-header-border);
}

.bp-header__drawer-lang {
	margin-block-start: 16px;
	color: var(--bp-fg);
}

/* ---------------- Responsive ---------------- */
@media ( max-width: 1024px ) {
	.bp-header__nav,
	.bp-header__lang--desktop {
		display: none;
	}
	.bp-header__burger { display: inline-flex; }
	.bp-header__actions { gap: 8px; }
	.bp-header__main .bp-header__inner { gap: 12px; }
}

@media ( max-width: 768px ) {
	.bp-header__utility { display: none; }
	.bp-header__main .bp-header__inner {
		min-block-size: 64px;
		gap: 8px;
		padding-inline: 16px;
	}
	.bp-header__logo img { max-inline-size: 110px; }
	/* On phone-width, the header bar only carries logo + burger.
	   CTA moves to the mobile drawer to avoid overflow. */
	.bp-header__main .bp-header__cta { display: none; }
	.bp-header__actions { gap: 0; margin-inline-start: auto; }
	.bp-header__burger { display: inline-flex; }
}

@media ( max-width: 480px ) {
	.bp-header__main .bp-header__inner { padding-inline: 14px; }
	.bp-header__logo img { max-inline-size: 100px; }
}

@media ( max-width: 380px ) {
	.bp-header__logo img { max-inline-size: 92px; }
	.bp-header__main .bp-header__inner { padding-inline: 12px; gap: 6px; }
}

/* ============================================================
   Arabic header overrides (html[lang="ar"])
   Scoped RTL + click-safety. Never touches base .bp-header.
   ============================================================ */
html[lang="ar"] .bp-header {
	direction: rtl;
}

/* The drawer's [hidden] must beat any third-party override
   (e.g. Elementor boxed container styles) so a closed drawer
   can never intercept clicks on the page below it. */
html[lang="ar"] .bp-header__drawer[hidden] {
	display: none !important;
}

/* When the drawer is open, lift it above page content and
   keep its links on the top stacking layer. */
html[lang="ar"] .bp-header__drawer:not([hidden]) {
	position: relative;
	z-index: 41;
}

/* Every interactive element stays clickable in Arabic. */
html[lang="ar"] .bp-header a,
html[lang="ar"] .bp-header button {
	pointer-events: auto;
	position: relative;
	z-index: 1;
}

/* Decorative pseudo-elements / icon wrappers must never
   intercept clicks. */
html[lang="ar"] .bp-header__menu > li > a::after,
html[lang="ar"] .bp-header__drawer-nav .bp-header__menu > li > a::after,
html[lang="ar"] .bp-header__util-icon,
html[lang="ar"] .bp-header__burger-line {
	pointer-events: none;
}

/* Arabic drawer: natural RTL text + tap targets. */
html[lang="ar"] .bp-header__drawer {
	text-align: right;
}

html[lang="ar"] .bp-header__drawer-nav .bp-header__menu > li > a {
	min-block-size: 44px;
	text-align: right;
	justify-content: flex-end;
}

html[lang="ar"] .bp-header__drawer-lang {
	text-align: right;
}

/* Constrain the header so it never overflows the viewport
   on narrow Arabic screens. */
html[lang="ar"] .bp-header,
html[lang="ar"] .bp-header__main,
html[lang="ar"] .bp-header__main .bp-header__inner,
html[lang="ar"] .bp-header__utility,
html[lang="ar"] .bp-header__utility .bp-header__inner,
html[lang="ar"] .bp-header__drawer {
	width: 100%;
	max-width: 100%;
	min-width: 0;
	box-sizing: border-box;
}

/* Desktop Arabic: natural RTL flex order already yields
   [actions(left) | nav(center) | logo(right)]; only nudge
   the actions to the visual end of the bar so they never
   collide with the nav. */
@media ( min-width: 1025px ) {
	html[lang="ar"] .bp-header__actions {
		margin-inline-start: auto;
	}
	html[lang="ar"] .bp-header__nav {
		justify-content: center;
	}
}

/* Mobile Arabic: keep the desktop nav hidden, burger and
   logo sized so the row never overflows. */
@media ( max-width: 1024px ) {
	html[lang="ar"] .bp-header__nav {
		display: none;
	}
	html[lang="ar"] .bp-header__burger {
		display: inline-flex;
	}
}

@media ( max-width: 767px ) {
	html[lang="ar"] .bp-header__main .bp-header__cta {
		display: none;
	}
	html[lang="ar"] .bp-header__actions {
		gap: 0;
		margin-inline-start: auto;
	}
}

/* Reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.bp-header *,
	.bp-header *::before,
	.bp-header *::after {
		animation-duration: 0.001ms !important;
		transition-duration: 0.001ms !important;
	}
}
