/**
 * Container Header integration -- Phase 1 of the v2 header rebuild.
 *
 * Styles the sticky/pill behavior attached to Elementor's own native
 * Container element (see includes/integrations/class-container-header.php).
 * Ported from assets/css/widgets/header.css's own Sticky Header rules,
 * adapted so the Container itself (`{{WRAPPER}}`) IS the sticky element --
 * no separate inner `.granpai-header` div the way the old widget needed,
 * since here the "wrapper" and the "thing that sticks" are the same node.
 */

.granpai-container-header {
	--granpai-sticky: 1;
	--granpai-sticky-offset: 0px;
	--granpai-glass: 0;
	--granpai-glass-blur: 12px;
	--granpai-account-admin-bar: 1;
	--granpai-pill-margin: 16px;
	--granpai-pill-radius: 999px;
	--granpai-pill-max-width: none;
	/* NOT a literal `position: relative`, deliberately -- Elementor's own
	   Container base CSS already drives every Container's `position` off
	   its own `--position` custom property (default `relative`, or
	   whatever the author picked on Advanced > Position: Absolute/Fixed,
	   e.g. for a header meant to overlay a hero from page load -- see the
	   "Overlay a Hero" panel notice in class-container-header.php). A
	   literal `position: relative` here has the exact same (0,1,0)
	   specificity as Elementor's own rule, so whichever stylesheet
	   happened to print last in <head> would silently win and could
	   clobber the author's own Position choice back to `relative` --
	   fighting Elementor's own Advanced > Position control is a known
	   anti-pattern this codebase avoids elsewhere too. Referencing the
	   same variable instead means both rules always resolve to the exact
	   identical value, so load order stops mattering. The `relative`
	   fallback only matters outside a real Elementor Container (where
	   `--position` would never be set at all). */
	position: var(--position, relative);
	z-index: 100;
	/* Explicit, not assumed -- Max Width (below) clamps the CONTENT-box
	   width per spec, and this Container's own padding is user-set
	   (Elementor's Advanced > Padding), so without this a configured
	   Max Width of e.g. 1200px would silently render wider by however
	   much padding is set. Elementor's own frontend CSS already does
	   this site-wide in practice, but setting it here too means this
	   rule is correct on its own, not dependent on that. */
	box-sizing: border-box;
	/* Position itself is deliberately not transitioned -- see header.css's
	   identical note. Shape (margin/radius) IS transitioned here, unlike
	   the old widget, since Floating Pill's edges visibly move inward on
	   stick and a hard snap there reads as a glitch rather than a shape
	   change. */
	transition: background-color 0.25s ease, box-shadow 0.25s ease, backdrop-filter 0.25s ease, border-radius 0.25s ease, left 0.25s ease, right 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
	.granpai-container-header {
		transition: none;
	}
}

/* ---- Sticky (JS-driven, see assets/js/integrations/container-header.js)
   Unlike the old widget, the sentinel/spacer are NOT server-rendered --
   Elementor's Container render hooks only wrap the element from the
   outside (no clean hook to inject sibling markup around a core element),
   so frontend.js inserts both as DOM siblings at runtime instead. */

.granpai-container-header-sticky-sentinel {
	height: 0;
	width: 100%;
}

.granpai-container-header-sticky-spacer {
	height: 0;
	width: 100%;
}

.granpai-container-header.is-stuck {
	position: fixed;
	top: var(--granpai-sticky-offset, 0px);
	left: 0;
	right: 0;
	z-index: 999;
	-webkit-backdrop-filter: blur(calc(var(--granpai-glass, 0) * var(--granpai-glass-blur, 12px)));
	backdrop-filter: blur(calc(var(--granpai-glass, 0) * var(--granpai-glass-blur, 12px)));
}

/* Floating Pill shape -- only once stuck; pre-stuck it looks like whatever
   the Container's own normal Style-tab controls already made it look
   like (same "sticky-only" philosophy as the Sticky-Only Background/
   Border/Shadow controls in class-container-header.php).
   `left`/`right` act as the MINIMUM gutter from the viewport edges (so the
   pill never touches them on any screen size); `max-width` + auto margins
   are what let it stop growing and center itself once the available
   width (viewport minus those two gutters) exceeds the cap -- without
   `max-width`/auto-margins, `left`+`right` alone stretch a `width: auto`
   fixed-position box to fill 100% of the space between them with no way
   to cap it, which was the reported bug (pill always full-width,
   Max Width had no effect because the control didn't exist yet). */
.granpai-container-header--floating-pill.is-stuck {
	left: var(--granpai-pill-margin, 16px);
	right: var(--granpai-pill-margin, 16px);
	width: auto;
	max-width: var(--granpai-pill-max-width, none);
	margin-left: auto;
	margin-right: auto;
	border-radius: var(--granpai-pill-radius, 999px);
	overflow: hidden;
}

/* Same WP admin-bar accounting as header.css -- see that file's own note
   for why 32px/46px aren't guesses (WP core's own two fixed admin-bar
   heights, 782px being WP's own breakpoint between them). */
body.admin-bar .granpai-container-header.is-stuck {
	top: calc(var(--granpai-sticky-offset, 0px) + (var(--granpai-account-admin-bar, 1) * 32px));
}

@media screen and (max-width: 782px) {
	body.admin-bar .granpai-container-header.is-stuck {
		top: calc(var(--granpai-sticky-offset, 0px) + (var(--granpai-account-admin-bar, 1) * 46px));
	}
}

/* Pill first, full viewport bar after scrolling; children keep their Elementor layout. */
.granpai-container-header.granpai-container-header--pill-expand {
 width:min(var(--gp-expand-width,1140px),calc(100% - 2 * var(--gp-expand-gutter,16px)))!important;
 max-width:none!important;margin-left:auto!important;margin-right:auto!important;
 margin-top:var(--gp-expand-gap,16px)!important;border-radius:var(--gp-expand-radius,32px)!important;
 transition:width var(--gp-expand-duration,500ms) cubic-bezier(.22,1,.36,1),border-radius var(--gp-expand-duration,500ms) ease,margin-top var(--gp-expand-duration,500ms) ease,background-color .25s ease,box-shadow .25s ease;
}
.granpai-container-header.granpai-container-header--pill-expand:not(.is-stuck) {background-color:var(--gp-expand-bg,#101b30)}
.granpai-container-header.granpai-container-header--pill-expand.is-stuck {left:0;right:0;position:fixed!important;width:var(--gp-expand-full-width,100vw)!important;max-width:none!important;margin-top:0!important;border-radius:0!important;}
@media(prefers-reduced-motion:reduce){.granpai-container-header.granpai-container-header--pill-expand{transition:none!important}}

/* Both states overlay the hero; no header row is reserved above it. */
.granpai-container-header.granpai-container-header--pill-expand {position:fixed!important;left:0;right:0;top:var(--granpai-sticky-offset,0px);z-index:999;}
.granpai-container-header.granpai-container-header--pill-expand.gp-expand-scroll-away {position:absolute!important;}
body.admin-bar .granpai-container-header.granpai-container-header--pill-expand {top:calc(var(--granpai-sticky-offset,0px) + var(--granpai-account-admin-bar,1) * 32px);}
@media(max-width:782px){body.admin-bar .granpai-container-header.granpai-container-header--pill-expand{top:calc(var(--granpai-sticky-offset,0px) + var(--granpai-account-admin-bar,1) * 46px);}}

/* Individual translate preserves Elementor transforms and pill expansion. */
.granpai-container-header[data-gp-scroll-visibility=up]{transition:translate .3s ease,opacity .2s ease,visibility .3s}
.granpai-container-header[data-gp-scroll-visibility=up].gp-scroll-hidden.is-stuck{translate:0 calc(-100% - var(--granpai-sticky-offset,0px) - 64px);opacity:0;visibility:hidden;pointer-events:none}
.granpai-container-header--pill-expand[data-gp-scroll-visibility=up]{transition:translate .3s ease,opacity .2s ease,visibility .3s,width var(--gp-expand-duration,500ms) cubic-bezier(.22,1,.36,1),border-radius var(--gp-expand-duration,500ms) ease,margin-top var(--gp-expand-duration,500ms) ease,background-color .25s ease,box-shadow .25s ease}
@media(prefers-reduced-motion:reduce){.granpai-container-header[data-gp-scroll-visibility=up]{transition:none!important}}
