/*
 * HD Header Glass (Nov 14, 2026): the sticky header as dark blurred glass, and a smooth change from the full header
 * to the sticky one. Applies only while <body> carries .hd-header-glass (header-glass.php decides).
 *
 * One number drives everything: --hdhg-p, 0 for the full header and 1 for the compact one. The bar's height, the
 * logo's width and the glass behind them are all worked out from it, so they always move together.
 *   - Where the browser can tie an animation to the scroll position, --hdhg-p follows the scroll over the first
 *     stretch of the page: the header eases down as you scroll and eases back up, with no moment where it switches.
 *   - Elsewhere, Avada's own switch (.fusion-sticky-transition) flips it and it glides there over half a second.
 * Avada's own sticky changes (a 0.1 s min-height step, the logo images swapped by display, a flat background)
 * are replaced below. header-cta.js keeps the menu where it is while the logo shrinks (it used to re-center it
 * against the smaller logo, which moved the items between rows).
 *
 * The glass is drawn on ::before, not on the container, so nothing fixed inside the header (dropdowns, the phone
 * menu) is affected by the backdrop filter. It sits inside the container's own stacking context (Avada gives the
 * container a position and a z-index), above its background and below its content.
 *
 * Assumes the standard and the sticky logo are the same picture (they are: hokedesigns_square_300px.webp).
 */
@property --hdhg-p { syntax: '<number>'; inherits: true; initial-value: 0; }

body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer) {
	--hdhg-p: 0;
	--hdhg-h0: var(--awb-min-height, 0px);
	--hdhg-h1: var(--awb-sticky-height, 0px);
	min-height: calc(var(--hdhg-h0) - (var(--hdhg-h0) - var(--hdhg-h1)) * var(--hdhg-p)) !important;
	transition: --hdhg-p .55s cubic-bezier(.22, .8, .26, 1) !important;
}
body.hd-header-glass .fusion-tb-header .fusion-sticky-container.fusion-sticky-transition:not(.fusion-sticky-spacer) { --hdhg-p: 1; }

/* The glass: the site's navy, mostly opaque, over a blur of the page behind it, with a hairline along the bottom.
   Old browsers (no color-mix): Avada's own backgrounds stay and the glass fades in over them. */
body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer)::before {
	content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
	background-color: rgba(0, 24, 60, .88);
	-webkit-backdrop-filter: blur(14px) saturate(1.4) brightness(.85); backdrop-filter: blur(14px) saturate(1.4) brightness(.85);
	box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .1);
	opacity: var(--hdhg-p);
}
/* Everyone else: the glass is the header's only background. It starts as the header's own color (none on wide
   screens, the navy on phones) and ends as the glass, so it never gets lighter on the way. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
	body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer) { background-color: transparent !important; }
	body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer)::before {
		opacity: 1;
		background-color: color-mix(in srgb, var(--awb-background-color, transparent) calc((1 - var(--hdhg-p)) * 100%), rgba(0, 24, 60, .88));
		-webkit-backdrop-filter: blur(calc(var(--hdhg-p) * 14px)) saturate(calc(1 + var(--hdhg-p) * .4)) brightness(calc(1 - var(--hdhg-p) * .15));
		backdrop-filter: blur(calc(var(--hdhg-p) * 14px)) saturate(calc(1 + var(--hdhg-p) * .4)) brightness(calc(1 - var(--hdhg-p) * .15));
		box-shadow: inset 0 -1px 0 rgba(255, 255, 255, calc(var(--hdhg-p) * .1));
	}
}

/* The logo: one picture that narrows, instead of two that swap. */
body.hd-header-glass .fusion-tb-header .fusion-sticky-container .fusion-image-element .fusion-imageframe {
	--hdhg-w0: min(100%, var(--awb-max-width, 100%));
	--hdhg-w1: var(--awb-sticky-max-width, var(--hdhg-w0));
	width: calc(var(--hdhg-w0) - (var(--hdhg-w0) - var(--hdhg-w1)) * var(--hdhg-p));
	max-width: var(--awb-max-width, 100%) !important;
	transition: none !important;
}
/* Above 640px Avada swaps the standard logo for the sticky one; below it, it shows the mobile logo and we leave that be. */
@media (min-width: 641px) {
	body.hd-header-glass .fusion-tb-header .fusion-sticky-container .fusion-imageframe.has-fusion-sticky-logo img.fusion-standard-logo { display: inline !important; }
	body.hd-header-glass .fusion-tb-header .fusion-sticky-container .fusion-imageframe.has-fusion-sticky-logo img.fusion-sticky-logo { display: none !important; }
}

/* Between 1401 and 1445px wide the full Support / Contact pill left the menu 2 to 31px short of one line, so it
   wrapped onto two rows (header-cta.css folds the pill at 1400px and under, and from about 1445px there is room).
   Tighten the gaps a little there so the menu stays on one line, the way header-cta.css does under 1240px. */
@media (min-width: 1401px) and (max-width: 1445px) {
	body.hd-header-glass .fusion-tb-header .fusion-builder-row:has(.hdcta) .awb-menu__main-ul > li { margin-right: 16px !important; }
}

/* Tied to the scroll where that is possible: the header is fully compact once the page has moved this far. */
@supports (animation-timeline: scroll()) {
	@media (prefers-reduced-motion: no-preference) {
		body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer) {
			transition: none !important;
			animation: hdhg-shrink linear both;
			animation-timeline: scroll(root block);
			animation-range: 30px 200px;
		}
	}
}
@keyframes hdhg-shrink { from { --hdhg-p: 0; } to { --hdhg-p: 1; } }

@media (prefers-reduced-motion: reduce) {
	body.hd-header-glass .fusion-tb-header .fusion-sticky-container:not(.fusion-sticky-spacer) { transition: none !important; }
}
