/**
 * Smart sticky header (Elementor header template 46).
 *
 * Every rule is scoped to .bl-sh, which smart-header.js adds, so without JS the header is unchanged.
 * --bl-promo-h       Promo bar height, set on the header by JS.
 * --bl-header-offset Height of the header currently covering the top of the viewport (0 when hidden), set on <html> by JS.
 */

.elementor-location-header.bl-sh {
	position: sticky;
	/* Negative offset: the promo bar scrolls away, the logo + nav row stays. Leaves room for the WP admin bar. */
	top: calc(var(--wp-admin--admin-bar--height, 0px) - var(--bl-promo-h, 0px));
	/* Keep the header and its mini-cart overlay (z-index 9998 inside it) above page content. */
	z-index: 9990;
	transition: transform .25s ease;
}

/* Phones: the admin bar scrolls with the page, so don't leave room for it. */
@media (max-width: 600px) {
	.admin-bar .elementor-location-header.bl-sh {
		top: calc(-1 * var(--bl-promo-h, 0px));
	}
}

/* Not translateY(0) when visible: any transform would trap the fixed mini-cart overlay inside the header. */
.elementor-location-header.bl-sh-hidden {
	transform: translateY(-100%);
}

/* Mobile menu: if it's taller than the screen, scroll inside it (the header is stuck, so the page can't reveal it). */
.elementor-location-header.bl-sh details[open] > .e-accordion-item-content-base {
	max-height: calc(100vh - var(--bl-sh-menu-top, 0px));
	max-height: calc(100dvh - var(--bl-sh-menu-top, 0px));
	overflow-y: auto;
	overscroll-behavior: contain;
}

/* Sticky elements below the header: keep them clear of it while it's showing. */
@media (min-width: 1025px) {
	/* Product archive filter sidebar (template 87). */
	body .elementor .e-6cea6775-90ba {
		top: calc(24px + var(--bl-header-offset, 0px));
		transition: top .25s ease;
	}
}

@media (min-width: 1024px) {
	/* Blog post table of contents (assets/blog/blog.css). */
	body .bl-blog .bl-toc {
		top: calc(var(--bl-sticky-top) + var(--bl-header-offset, 0px));
		transition: top .25s ease;
	}
}

@media (prefers-reduced-motion: reduce) {
	.elementor-location-header.bl-sh,
	body .elementor .e-6cea6775-90ba,
	body .bl-blog .bl-toc {
		transition: none;
	}
}
