/*
 * header.css — Site header / navbar styles.
 *
 * Design tokens (from Figma)
 *   --greenova-header-bg      #FFFFFF   (white background, thin divider below)
 *   --greenova-header-height  72px      (fixed header height)
 *   --greenova-nav-color      #535768   (nav link text color)
 *   --greenova-dark           #2E2E2E   (button borders/backgrounds/text)
 *   --greenova-active-bg      #7FB04F   (active pill background)
 *   --greenova-active-text    #FFFFFF
 *
 * The Figma frame is 1920px wide; the header itself stays fluid/responsive
 * (100% width) and the inner content is centred with a max-width matched to
 * that frame at large viewports — see section 1 below.
 */

:root {
	--greenova-header-height: 72px;
	--greenova-nav-color:     #535768;
	--greenova-dark:          #2E2E2E;
}

/* =============================================================================
   1. Header Shell

   .site-header__inner replaces Bootstrap's .container for this header.
   Bootstrap's `.navbar > .container` is ALSO a 3-item flex/space-between box
   by default, but its max-width steps through Bootstrap's own breakpoints
   (540/720/960/1140/1320px) — none of which match a specific design's
   content width, and a too-wide box makes space-between's two (necessarily
   *equal*, by definition of space-between) gaps balloon into the oversized,
   "menu floating away from the logo" gap this was rebuilt to fix. One
   explicit max-width, used at every viewport size, replaces that stepping.

   NOTE: 1440px is a placeholder for the design's real content width — swap
   in the exact Figma value once available.
   ============================================================================= */

#masthead {
	background-color: #FFFFFF;
	border-bottom: 1px solid rgba(27, 37, 14, 0.08);

	/* Sits above page content; add position:sticky + top:0 to make it sticky */
	position: fixed;
	z-index: 1030;
	width: 100%;
}

#masthead .navbar {
	min-height:     var(--greenova-header-height); /* mobile-safe baseline — see the lg+ override below */
	padding-top:    0;
	padding-bottom: 0;
}

/* At lg and up, .navbar-collapse is always expanded inline (navbar-expand-lg
   never shows the mobile toggle here), so it's safe to pin the header to an
   exact 72px — every child (logo, nav links, buttons) is already capped
   below that. Below lg, min-height above lets the toggled mobile menu grow
   the bar without being clipped. */
@media ( min-width: 992px ) {
	#masthead .navbar {
		height: var(--greenova-header-height);
	}
}

.site-header__inner {
	position:        relative; /* anchors the mobile centered-logo override below */
	display:         flex;
	align-items:     center;
	justify-content: space-between;
	flex-wrap:       wrap; /* lets the mobile collapse menu drop to a new row */
	width:           100%;
	max-width:       1440px;
	margin-inline:   auto;
	padding-inline:  24px;
	box-sizing:      border-box;
}

/* =============================================================================
   2. Logo
   ============================================================================= */

.site-logo-link,
.site-logo-link:hover,
.site-logo-link:focus {
	display:        inline-flex;
	align-items:    center;
	text-decoration: none;
	flex-shrink: 0;
	padding: 0;     /* Override Bootstrap's default navbar-brand padding */
}

.site-logo-img {
	/* Constrained by height, not width — keeps the logo comfortably inside
	   the 72px bar (with room above/below) regardless of the uploaded
	   image's own aspect ratio, and keeps it visually in proportion with
	   the 40/41px-tall CTA buttons next to it. Width follows automatically. */
	height:      32px;
	width:       auto;
	max-width:   180px; /* Safety cap so it never overflows on very wide logos */
	object-fit:  contain;
	display:     block;

	/* Keep it crisp on HiDPI / retina displays */
	/* image-rendering: -webkit-optimize-contrast; */
	/* image-rendering: crisp-edges; */
}

/* Text fallback when no logo is uploaded */
.site-logo-fallback {
	font-size:   1.25rem;
	font-weight: 700;
	color:       #1B250E;
	letter-spacing: 0.02em;
}

/* =============================================================================
   3. Top-level Nav Links
   ============================================================================= */

.primary-nav {
	gap: 24px; /* the fixed inter-item gap — padding below is for the hover/active pill's own hit-box, not spacing */
}

.primary-nav .nav-link {
	font-family:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color:           var(--greenova-nav-color);
	font-size:       14px;
	font-weight:     300;
	line-height:     14px;
	letter-spacing:  0;
	text-align:      center;
	padding:         8px 10px;
	border-radius:   12px;           /* Pill shape ready for active state */
	white-space:     nowrap;
	text-decoration: none;
	transition:      background-color 0.2s ease, color 0.2s ease;
}

/* Hover — light tint of the brand blue */
.primary-nav .nav-link:hover {
	background-color: rgba(33, 159, 214, 0.10);
	color:            #1276a3;
	text-decoration:  none;
}

/* Active / current page — filled pill */
.primary-nav .nav-link.active,
.primary-nav .nav-item.current-menu-item    > .nav-link,
.primary-nav .nav-item.current_page_item    > .nav-link,
.primary-nav .nav-item.current-menu-parent  > .nav-link,
.primary-nav .nav-item.current-menu-ancestor > .nav-link {
	background-color: #7FB04F;
	color:            #ffffff !important;
	font-weight: 700;
}

/* Don't double-apply active styles to a dropdown-toggle parent that's not active */
.primary-nav .nav-item.dropdown:not(.current-menu-parent):not(.current-menu-ancestor) > .nav-link.active {
	background-color: #7FB04F;
	color: #ffffff !important;
}

/* =============================================================================
   4. Dropdown Caret (Bootstrap adds ::after via .dropdown-toggle — customise it)
   ============================================================================= */

.primary-nav .dropdown-toggle::after {
	display:       inline-block;
	margin-left:   0.35em;
	vertical-align: 0.15em;
	border-top:    0.32em solid currentColor;
	border-right:  0.32em solid transparent;
	border-bottom: 0;
	border-left:   0.32em solid transparent;
}

/* =============================================================================
   5. Dropdown Menu Panel
   ============================================================================= */

.primary-nav .dropdown-menu {
	background-color: #ffffff;
	border:           none;
	border-radius:    14px;
	box-shadow:       0 8px 32px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.06);
	padding:          0.5rem;
	min-width:        210px;
	margin-top:       0.5rem;

	/* Fade + slide-down animation on open */
	animation: greenovaDropdownIn 0.18s ease both;
}

@keyframes greenovaDropdownIn {
	from {
		opacity:   0;
		transform: translateY(-8px);
	}
	to {
		opacity:   1;
		transform: translateY(0);
	}
}

/* =============================================================================
   6. Dropdown Items
   ============================================================================= */

.primary-nav .dropdown-item {
	color:         #1B250E;
	font-size:     0.9rem;
	font-weight:   500;
	border-radius: 8px;
	padding:       0.6rem 1rem;
	transition:    background-color 0.15s ease, color 0.15s ease;
	white-space:   normal; /* Allow wrapping on long labels */
}

.primary-nav .dropdown-item:hover,
.primary-nav .dropdown-item:focus {
	background-color: rgba(33, 159, 214, 0.10);
	color:            #1276a3;
}

.primary-nav .dropdown-item.active,
.primary-nav .dropdown-item:active {
	background-color: #219FD6;
	color:            #ffffff;
}

/* =============================================================================
   7. CTA Buttons — "Request a Demo" + "Login"
   Both are only ever shown at the lg breakpoint and up (see site-header.php),
   so fixed pixel dimensions here are safe and won't cause overflow on small
   viewports.
   ============================================================================= */

.site-header-cta-demo,
.site-header-cta-login {
	font-family:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:       14px;
	font-weight:     500;
	line-height:     1;
	display:         inline-flex;
	align-items:     center;
	justify-content: center;
	gap:             10px;
	box-sizing:      border-box;
	white-space:     nowrap;
	text-decoration: none;
	transition:      opacity 0.15s ease;
}

.site-header-cta-demo:hover,
.site-header-cta-login:hover,
.site-header-cta-demo:focus,
.site-header-cta-login:focus {
	opacity:         0.85;
	text-decoration: none; /* a:hover in style.css otherwise wins this — see .mega-menu-link/.mega-menu-card for the same fix */
}

.site-header-cta {
	gap: 16px;
}

.site-header-cta-demo {
	width:         139px;
	height:        40px;
	padding:       10px 16px;
	border:        1px solid var(--greenova-dark);
	border-radius: 80px;
	background-color: #FFFFFF;
	color:         var(--greenova-dark);
}

.site-header-cta-login {
	width:         93px;
	height:        41px;
	padding:       11px 16px;
	border:        1px solid var(--greenova-dark);
	border-radius: 160px;
	background-color: var(--greenova-dark);
	color:         #FFFFFF;
}

.site-header-cta-icon {
	display:     inline-flex;
	align-items: center;
	line-height: 0;
}

.site-header-cta-icon svg {
	width:  14px;
	height: 14px;
}

/* =============================================================================
   8. Mobile — Hamburger Toggle Button
   ============================================================================= */

.site-navbar-toggler {
	border:           1.5px solid rgba(27, 37, 14, 0.25);
	border-radius:    10px;
	padding:          0.375rem 0.625rem;
	background-color: transparent;
	line-height:      1;
	cursor:           pointer;
	transition:       background-color 0.2s ease, border-color 0.2s ease;
}

.site-navbar-toggler:hover {
	background-color: rgba(33, 159, 214, 0.10);
	border-color:     rgba(33, 159, 214, 0.5);
}

.site-navbar-toggler:focus {
	outline:    none;
	box-shadow: 0 0 0 3px rgba(33, 159, 214, 0.3);
}

/* =============================================================================
   9. Mega Menu — "Resources" (see inc/nav-walker.php for the "mega-menu-{slug}"
   class convention; this styles the "resources" panel specifically, since
   its dimensions/cards are per this Figma spec).

   Desktop only (lg+) — opened via .is-open (JS, mouse — see custom.js) or
   :focus-within (keyboard, no JS required). Collapses to a plain stacked
   list on mobile; see the responsive section below.
   ============================================================================= */

.nav-item--mega {
	position: relative;
}

.mega-menu-panel {
	position:       absolute;
	top:            calc(100% + 8px);
	left:           0; /* Left-aligned under the trigger, not centered — matches Figma. */
	transform:      translateY(-8px);
	width:          660px;
	min-height:     297px; /* A floor, not a hard cap — see .mega-menu-card__title for why. */
	background:     #FFFFFF;
	border-radius:  18px;
	box-shadow:     0 10px 40px 10px rgba(0, 0, 0, 0.25);
	opacity:        0;
	visibility:     hidden;
	pointer-events: none;
	transition:     opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
	z-index:        1040;
}

.nav-item--mega:focus-within .mega-menu-panel,
.nav-item--mega.is-open .mega-menu-panel {
	opacity:        1;
	visibility:     visible;
	transform:      translateY(0);
	pointer-events: auto;
}

.mega-menu-panel__inner {
	display:    flex;
	padding:    24px;
	gap:        24px;
	box-sizing: border-box;
}

/* --- Left column: submenu links --- */

.mega-menu-panel__left {
	flex:          0 0 160px;
	box-sizing:    border-box;
	border-right:  1px solid #E5E5E5;
	padding-right: 20px;
}

.mega-menu-links {
	display:        flex;
	flex-direction: column;
	gap:            24px;
	list-style:     none;
	margin:         0;
	padding:        0;
}

.mega-menu-link {
	display:         block;
	font-family:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:       14px;
	font-weight:     300;
	line-height:     14px;
	letter-spacing:  0;
	color:           var(--greenova-nav-color);
	padding:         6px 10px;
	border-radius:   8px;
	text-decoration: none;
	background-color: transparent;
	transition:      background-color 0.15s ease, color 0.15s ease;
}

.mega-menu-link:hover,
.mega-menu-link:focus {
	background-color: rgba(33, 159, 214, 0.10);
	color:            #1276a3;
	text-decoration:  none;
}

.mega-menu-link.active {
	background-color: rgba(33, 159, 214, 0.12);
	color:            #1276a3;
}

/* --- Right column: featured cards --- */

.mega-menu-panel__right {
	flex:      1 1 auto;
	min-width: 0;
}

.mega-menu-cards {
	display: flex;
	gap:     24px;
}

/*
 * Per-submenu-link content swap (see inc/nav-walker.php's "mega-submenu-{key}"
 * class convention and assets/js/custom.js's hover/focus listener). A block
 * carrying data-mega-submenu is hidden until its ".nav-item--mega" ancestor
 * gets a matching "is-showing-{key}" class, at which point it replaces the
 * default (no-attribute) block. Add one more override pair per key as more
 * submenu-specific content blocks are introduced.
 */
.mega-menu-cards[data-mega-submenu] {
	display: none;
}

.nav-item--mega.is-showing-case-studies .mega-menu-cards--default {
	display: none;
}

.nav-item--mega.is-showing-case-studies .mega-menu-cards[data-mega-submenu="case-studies"] {
	display: flex;
}

.mega-menu-empty {
	display:         flex;
	align-items:     center;
	justify-content: center;
	height:          100%;
	min-height:      195px;
	text-align:      center;
	color:           #8A939B;
	font-family:     'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:       13px;
	line-height:     1.5;
	padding:         0 20px;
}

.mega-menu-card,
.mega-menu-card:hover,
.mega-menu-card:focus {
	display:         flex;
	flex-direction:  column;
	width:           195px;
	flex-shrink:     0;
	text-decoration: none;
	color:           inherit;
}

.mega-menu-card__image-wrap {
	position:      relative;
	width:         195px;
	height:        195px;
	flex-shrink:   0;
	margin-bottom: 12px;
}

.mega-menu-card__image,
.mega-menu-card__image--placeholder {
	width:         195px;
	height:        195px;
	border-radius: 8px;
	object-fit:    cover;
	display:       block;
}

.mega-menu-card__image--placeholder {
	background-color: #F1F2F4;
}

.mega-menu-card__badge {
	position:         absolute;
	top:               10px;
	left:              10px;
	display:           inline-flex;
	align-items:       center;
	gap:               10px;
	background-color: var(--greenova-dark);
	color:             #FFFFFF;
	border-radius:     21.5px;
	padding:           4px 12px;
	font-family:       'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:         8px;
	font-weight:       600;
	line-height:       24px;
	white-space:       nowrap;
}

.mega-menu-card__badge-icon {
	font-size: 8px;
	line-height: 1;
}

.mega-menu-card__title {
	font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:   14px;
	font-weight: 400;
	line-height: 16px;
	color:       #000000;
	margin:      0 0 8px;

	/* Titles are real post titles and vary in length — clamp to 3 lines
	   so an unusually long one can't blow out the panel's height and
	   overlap page content below it (rather than a hard-clipping fixed
	   height, which broke on longer titles). */
	display:            -webkit-box;
	-webkit-box-orient:  vertical;
	-webkit-line-clamp:  3;
	line-clamp:          3;
	overflow:            hidden;
}

.mega-menu-card__meta {
	display:        flex;
	align-items:    center;
	gap:            6px;
	font-family:    'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size:      10px;
	font-weight:    400;
	line-height:    20px;
	letter-spacing: 0.02em; /* 2% */
	text-transform: uppercase;
	color:          #8A939B;
	margin:         0;
}

/* =============================================================================
   10. Responsive — Mobile / Tablet (< lg breakpoint, 992px)
   ============================================================================= */

@media ( max-width: 991.98px ) {

	/*
	 * The expanded mobile menu — full-width panel below the logo/hamburger
	 * row, with its own top divider separating it from that row.
	 *
	 * #masthead is position:fixed with no corresponding push-down of the
	 * page's own content (no padding-top reserving space for it), which is
	 * fine at the collapsed ~72px height, but this panel's content (nav
	 * links + the mobile CTA buttons below) can easily need more height
	 * than that. Without a cap, the expanded menu just kept growing behind
	 * the fixed header, uncontained, so the tail end of it visually
	 * overlapped/blended into the page's own hero content sitting
	 * underneath at the SAME screen position — max-height + its own
	 * scrollbar keeps the whole expanded header within the viewport
	 * instead, however long the menu's content gets.
	 */
	#primaryNavigation {
		width:       100%;
		max-height:  calc(100vh - var(--greenova-header-height) - 16px);
		overflow-y:  auto;
		-webkit-overflow-scrolling: touch;
		border-top:  1px solid rgba(27, 37, 14, 0.08);
		margin-top:  16px;
		padding-top: 8px;
		padding-bottom: 16px;
		box-sizing:  border-box;
	}

	.primary-nav {
		width: 100%;
		gap:   0; /* Each .nav-link below carries its own 24px via margin-bottom instead of gap, so the Resources accordion's indented sub-items don't inherit the same rhythm. */
	}

	.primary-nav > .nav-item {
		width: 100%;
	}

	.primary-nav > .nav-item:not(:last-child) {
		margin-bottom: 15px;
	}

	.primary-nav .nav-link {
		display:     block;
		width:       100%;
		text-align:  left;
		padding:     10px 24px;
		border-radius: 0;
	}

	/* Standard (non-mega) dropdown items — plain stacked sub-list, indented. */
	.primary-nav .dropdown-menu {
		position:      static;
		display:       block;
		box-shadow:    none;
		border-radius: 0;
		background-color: transparent;
		border:        none;
		padding:       4px 0 0;
		margin-top:    8px;
		animation:     none; /* No slide-in animation on mobile */
	}

	.primary-nav .dropdown-item {
		padding: 8px 24px 8px 40px;
	}

	/* --- Resources mega menu → mobile accordion --- */

	/* Rotate the caret when the accordion is open (mouse .is-open or
	   keyboard :focus-within — matches how the panel itself opens). */
	.nav-item--mega.is-open > .nav-link.dropdown-toggle::after,
	.nav-item--mega:focus-within > .nav-link.dropdown-toggle::after {
		transform: rotate(180deg);
	}

	.mega-menu-panel {
		position:       static;
		width:          100%;
		min-height:     0;
		transform:      none;
		opacity:        1;
		visibility:     visible;
		pointer-events: auto;
		box-shadow:     none;
		border-radius:  0;
		background-color: transparent;
		margin-top:     8px;
		display:        none; /* toggled by .is-open, same mechanism as the desktop panel */
	}

	.nav-item--mega.is-open .mega-menu-panel,
	.nav-item--mega:focus-within .mega-menu-panel {
		display: block;
	}

	.mega-menu-panel__inner {
		display: block;
		padding: 0;
	}

	.mega-menu-panel__left {
		width:         100%;
		border-right:  none;
		padding-right: 0;
	}

	.mega-menu-links {
		gap: 4px; /* the 24px desktop rhythm is too loose for a compact accordion sub-list */
	}

	.mega-menu-link {
		padding: 8px 24px 8px 40px;
	}

	/* Cards are a desktop-only enhancement — too heavy for a mobile submenu. */
	.mega-menu-panel__right {
		display: none;
	}

	/*
	 * Mobile CTA buttons — the second copy rendered inside #primaryNavigation
	 * (see site-header.php), shown via Bootstrap's d-lg-none utility already
	 * on the wrapper. Full-width and stacked, unlike the desktop pair's
	 * fixed 139px/93px inline sizing, with its own divider echoing the one
	 * separating the logo row from the nav list above it.
	 */
	.site-header-cta--mobile {
		display:        flex;
		flex-direction: column;
		gap:            12px;
		width:          100%;
		margin-top:     16px;
		padding-top:    16px;
		border-top:     1px solid rgba(27, 37, 14, 0.08);
	}

	.site-header-cta--mobile .site-header-cta-demo,
	.site-header-cta--mobile .site-header-cta-login {
		width:  100%;
		height: 44px;
	}
}

/* =============================================================================
   11. Sticky Header Utility Class
   Add class="site-header sticky-header" to <header> in PHP to enable.
   ============================================================================= */

.site-header.sticky-header {
	position: sticky;
	top:      0;
}

/* Subtle shadow when page is scrolled (toggled via JS body.scrolled) */
body.scrolled .site-header {
	box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
}
