/**
 * Sticky header + compact blog/single page bar.
 * Offsets are driven by CSS variables set from sticky-navigation.js.
 */

:root {
	--ssa-admin-bar-h: 0px;
	--ssa-header-h: 72px;
	--ssa-pagebar-h: 0px;
	--ssa-sticky-top: var(--ssa-admin-bar-h);
	--ssa-pagebar-top: calc(var(--ssa-admin-bar-h) + var(--ssa-header-h));
	--ssa-scroll-offset: calc(var(--ssa-admin-bar-h) + var(--ssa-header-h) + var(--ssa-pagebar-h) + 12px);
	--ssa-sticky-z-header: 1000;
	--ssa-sticky-z-pagebar: 999;
}

body.admin-bar {
	--ssa-admin-bar-h: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar {
		--ssa-admin-bar-h: 46px;
	}
}

@media screen and (max-width: 600px) {
	body.admin-bar {
		--ssa-admin-bar-h: 0px;
	}
}

/* ---- Main sticky header (Elementor + theme fallback) ---- */
.elementor-location-header,
.site-header {
	position: sticky;
	top: var(--ssa-sticky-top);
	z-index: var(--ssa-sticky-z-header);
	background-color: #ffffff;
	background: #ffffff;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
	border-bottom: 1px solid transparent;
	width: 100%;
}

.elementor-location-header.is-scrolled,
.site-header.is-scrolled,
body.ssa-header-scrolled .elementor-location-header,
body.ssa-header-scrolled .site-header {
	border-bottom-color: var(--ssa-border, #E1E8ED);
	box-shadow: 0 1px 0 rgba(38, 34, 97, 0.04), 0 6px 18px rgba(38, 34, 97, 0.08);
}

/* Compact padding when scrolled (desktop) */
@media (min-width: 1025px) {
	body.ssa-header-scrolled .elementor-location-header .e-con.e-parent,
	body.ssa-header-scrolled .elementor-location-header > .elementor-element {
		padding-top: 6px !important;
		padding-bottom: 6px !important;
	}

	body.ssa-header-scrolled .elementor-location-header .elementor-widget-image img,
	body.ssa-header-scrolled .elementor-location-header img[src*="study-logo"] {
		max-height: 56px;
	}

	body.ssa-header-scrolled .site-header .header-inner {
		min-height: 60px;
	}

	body.ssa-header-scrolled .site-header .site-logo {
		height: 44px;
	}
}

/* Ensure Elementor sticky effects do not invent a second header */
.elementor-sticky--active.elementor-location-header {
	/* location itself is sticky; avoid nested sticky clones jumping */
}

/* Admin bar must sit above sticky chrome */
#wpadminbar {
	z-index: 99999 !important;
}

/* ---- Compact sticky page bar (brand navy — matches Team hero) ---- */
.ssa-sticky-pagebar {
	position: fixed;
	inset-inline: 0;
	top: var(--ssa-pagebar-top);
	z-index: var(--ssa-sticky-z-pagebar);
	background: #262261;
	border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	transform: translateY(-110%);
	opacity: 0;
	pointer-events: none;
	visibility: hidden;
	transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
	max-height: min(72px, 18vh);
	color: #ffffff;
	font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif;
}

.ssa-sticky-pagebar.is-visible {
	transform: translateY(0);
	opacity: 1;
	pointer-events: auto;
	visibility: visible;
}

.ssa-sticky-pagebar__inner {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 0.15rem;
	padding-block: 0.45rem 0.5rem;
	min-height: 0;
}

.ssa-sticky-pagebar .ssa-breadcrumbs {
	margin: 0;
}

.ssa-sticky-pagebar .ssa-breadcrumbs__list {
	color: rgba(245, 247, 250, 0.82);
	flex-wrap: nowrap;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	max-width: 100%;
}

.ssa-sticky-pagebar .ssa-breadcrumbs a,
.ssa-sticky-pagebar .ssa-breadcrumbs span {
	color: inherit;
}

.ssa-sticky-pagebar .ssa-breadcrumbs__item {
	flex: 0 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ssa-sticky-pagebar .ssa-breadcrumbs__item.is-current {
	flex: 0 1 auto;
	max-width: 45%;
}

.ssa-sticky-pagebar .ssa-breadcrumbs__item:not(:last-child)::after {
	content: "‹";
	margin-inline-start: 0.45rem;
	opacity: 0.65;
}

.ssa-sticky-pagebar__title {
	margin: 0;
	font-size: var(--ssa-fs-sm, 0.9375rem);
	font-weight: 700;
	line-height: 1.3;
	color: #ffffff;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

/* Mobile: keep bar compact; drop title if breadcrumbs alone are enough on archive */
@media (max-width: 767px) {
	.ssa-sticky-pagebar {
		max-height: min(64px, 20vh);
	}

	.ssa-sticky-pagebar__inner {
		padding-block: 0.35rem 0.4rem;
		gap: 0.1rem;
	}

	.ssa-sticky-pagebar__title {
		font-size: var(--ssa-fs-xs, 0.8125rem);
	}

	.ssa-sticky-pagebar .ssa-breadcrumbs__list {
		font-size: 0.75rem;
	}
}

@media (max-width: 390px) {
	.ssa-sticky-pagebar--single .ssa-breadcrumbs__item:not(.is-current):not(:first-child) {
		/* keep home + current; middle crumbs still present for a11y but can shrink */
		max-width: 4.5rem;
	}
}

/* Sidebar sticky sits below header + pagebar */
.ssa-blog-sidebar {
	top: calc(var(--ssa-pagebar-top) + var(--ssa-pagebar-h) + 12px) !important;
}

/* Heading clearance for TOC / in-page anchors */
.ssa-article__content h2[id],
.ssa-article__content h3[id],
.ssa-article__content h2 span[id],
.ssa-article__content h3 span[id],
.ssa-post-content h2[id],
.ssa-post-content h3[id],
.ssa-post-content h2 span[id],
.ssa-post-content h3 span[id],
.entry-content h2[id],
.entry-content h3[id],
.entry-content h2 span[id],
.entry-content h3 span[id],
.ssa-page-body h2[id],
.ssa-page-body h3[id],
.front-hero,
.front-services,
.front-abstracthub,
.front-methodology,
.front-trust,
.front-rfp,
.front-final-cta {
	scroll-margin-top: var(--ssa-scroll-offset);
}

@media (prefers-reduced-motion: reduce) {
	.elementor-location-header,
	.site-header,
	.ssa-sticky-pagebar {
		transition: none;
	}
}
