/* =====================================================================
 * UNIVERSAL CONTAINERS — Site header
 *
 * Markup:  template-parts/layout/header-content.php
 * Design:  Figma "All New Designs" → Header (mobile), node 244:3240
 *
 * Plain CSS for now, like footer.css. Desktop (≥ 1024px) is still styled
 * by the Tailwind utilities in style.css; only the logo height lives here.
 * ===================================================================== */

/* Logo height. WooCommerce's ".woocommerce-page img { height: auto }"
   outranks the Tailwind height utilities on shop/cart/checkout/account
   pages, so the height is pinned here with an ID selector. */
#masthead .site-logo {
	height: 62px;
}

@media (max-width: 1023.98px) {
	/* Fixed header: the bar stays pinned to the top of the screen on mobile.
	   The body is padded by the same height so content starts below it on
	   load (no jump), and in-page anchor links stop below it too. */
	:root {
		--uc-header-h: 64px;
		--uc-header-top: 0px;
		--uc-cta-h: 60px;
	}

	html {
		scroll-padding-top: var(--uc-header-h);
	}

	/* Stop the sideways "bounce" when dragging the page left/right. Mobile
	   only: on desktop the same gesture is the trackpad swipe back/forward,
	   which this would disable. Vertical scrolling is unaffected. */
	html,
	body {
		overscroll-behavior-x: none;
	}

	body {
		padding-top: var(--uc-header-h);
		/* Room for the fixed bottom bar (.uc-mobile-cta) so the footer isn't hidden. */
		padding-bottom: var(--uc-cta-h);
	}

	#masthead {
		position: fixed;
		top: var(--uc-header-top);
		left: 0;
		right: 0;
	}

	/* The menu opens below the fixed bar, so it scrolls inside itself when
	   it is taller than the screen. */
	#masthead .mobile-menu {
		max-height: calc(100vh - var(--uc-header-h) - var(--uc-header-top) - var(--uc-cta-h));
		max-height: calc(100dvh - var(--uc-header-h) - var(--uc-header-top) - var(--uc-cta-h));
		overflow-y: auto;
		overscroll-behavior: contain;
	}

	/* Logged in: sit below the WordPress admin bar (46px under 783px, 32px
	   above). */
	body.admin-bar {
		--uc-header-top: 46px;
	}

	/* WordPress makes the admin bar scroll away under 601px, which left a
	   46px gap above the fixed header once scrolled. Keep it fixed instead
	   so the admin bar and header stay stacked at the top. */
	html body.admin-bar #wpadminbar {
		position: fixed;
	}

	/* Bar: 64px tall, 16px side padding */
	#masthead .uc-header-main {
		padding: 0 16px;
	}

	#masthead .uc-header-row {
		min-height: 64px;
	}

	#masthead .uc-header-group {
		gap: 14px;
	}

	#masthead .site-logo {
		height: 32px;
		width: auto;
		max-width: 123px;
	}

	/* Burger: shows the menu icon, swaps to a close icon while open.
	   script.min.js toggles .menu-active on #mobile-menu-open. */
	#masthead .uc-menu-toggle {
		display: flex;
		align-items: center;
		justify-content: center;
		width: 24px;
		height: 24px;
		padding: 0;
		background: none;
		border: 0;
		cursor: pointer;
	}

	#masthead .uc-menu-toggle img {
		width: 24px;
		height: 24px;
	}

	#masthead .uc-menu-toggle__close,
	#masthead .uc-menu-toggle.menu-active .uc-menu-toggle__open {
		display: none;
	}

	#masthead .uc-menu-toggle.menu-active .uc-menu-toggle__close {
		display: block;
	}

	/* Call: 40px yellow circle with an 18px phone icon */
	#masthead .uc-header-call {
		width: 40px;
		height: 40px;
		flex-shrink: 0;
	}

	#masthead .uc-header-call img {
		width: 18px;
		height: 18px;
	}

	/* Basket: 22px icon */
	#masthead .uc-header-basket img {
		width: 22px;
		height: 22px;
	}

	/* Item count badge, top-right of the basket. Same yellow-green as the
	   call button (theme primary, .bg-primary). */
	#masthead .uc-header-basket__count {
		position: absolute;
		top: -10px;
		right: -10px;
		min-width: 18px;
		height: 18px;
		padding: 0 5px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		border-radius: 9999px;
		background: #e1ff2c;
		color: #0a0a0a;
		font-size: 11px;
		font-weight: 700;
		line-height: 1;
	}
}

/* Admin bar is 32px tall from 783px; the header is fixed up to 1023px. */
@media (min-width: 783px) and (max-width: 1023.98px) {
	body.admin-bar {
		--uc-header-top: 32px;
	}
}

/* =====================================================================
 * Mobile bottom bar (< 1024px): Call us + Get a quote
 *
 * Markup:  header.php (.uc-mobile-cta)
 * Design:  Figma "All New Designs", node 276:150 (fonts swapped for the
 *          site's AktivGrotesk). Replaces the rotated side "Quick quote"
 *          button on mobile; desktop keeps the side button.
 * ===================================================================== */

.uc-mobile-cta {
	display: none;
}

@media (max-width: 1023.98px) {
	.uc-side-quote {
		display: none;
	}

	.uc-mobile-cta {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 60;
		display: grid;
		grid-template-columns: 1fr 1fr;
		/* Fixed height, no safe-area padding: iOS Safari changes
		   env(safe-area-inset-bottom) as its toolbar shows/hides, which made
		   the bar grow when scrolling back up. The site doesn't use
		   viewport-fit=cover, so Safari already keeps it clear of the home bar. */
		height: var(--uc-cta-h);
		box-sizing: border-box;
		overflow: hidden;
		background: #e1ff2c;
		color: #090a0a;
		font-family: AktivGrotesk, "Helvetica Neue", Arial, sans-serif;
		/* Hidden until the visitor scrolls down; hidden again when they
		   scroll up. html.uc-cta-visible is toggled by assets/js/uc-pages.js.
		   visibility keeps the hidden buttons out of the tab order; it flips
		   after the slide-out so the animation still shows. */
		transform: translateY(100%);
		visibility: hidden;
		transition: transform 0.25s ease, visibility 0s linear 0.25s;
	}

	html.uc-cta-visible .uc-mobile-cta,
	.uc-mobile-cta:focus-within {
		transform: none;
		visibility: visible;
		transition: transform 0.25s ease, visibility 0s;
	}

	@media (prefers-reduced-motion: reduce) {
		.uc-mobile-cta,
		html.uc-cta-visible .uc-mobile-cta {
			transition: none;
		}
	}

	.uc-mobile-cta--quote-only {
		grid-template-columns: 1fr;
	}

	.uc-mobile-cta__item {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 11px;
		min-width: 0;
		height: var(--uc-cta-h);
		padding: 0 16px;
		margin: 0;
		background: none;
		border: 0;
		color: inherit;
		font: inherit;
		text-align: left;
		text-decoration: none;
		cursor: pointer;
		-webkit-tap-highlight-color: transparent;
		transition: background-color 0.2s ease;
	}

	.uc-mobile-cta__item:hover,
	.uc-mobile-cta__item:active {
		background-color: #c0d825;
	}

	.uc-mobile-cta__item:focus-visible {
		outline: 2px solid #090a0a;
		outline-offset: -4px;
	}

	.uc-mobile-cta__item--call {
		border-right: 1px solid rgba(9, 10, 10, 0.2);
	}

	/* Bottom edge line, matching the divider, so the divider doesn't run
	   straight into the yellow Safari (iOS 26) tints its toolbar with. */
	.uc-mobile-cta__item {
		box-sizing: border-box;
		border-bottom: 1px solid rgba(9, 10, 10, 0.2);
	}

	.uc-mobile-cta__icon {
		flex-shrink: 0;
		width: 18px;
		height: 18px;
	}

	.uc-mobile-cta__text {
		display: flex;
		flex-direction: column;
		min-width: 0;
	}


	.uc-mobile-cta__title {
		font-size: 13px;
		font-weight: 700;
		line-height: 1.2;
		text-transform: uppercase;
		white-space: nowrap;
	}

	.uc-mobile-cta__arrow {
		flex-shrink: 0;
		width: 18px;
		height: 12px;
	}
}

/* HubSpot chat: lift the launcher above the bottom bar while the chat is
   closed and the bar is showing. html.uc-hs-chat-closed is toggled by assets/js/uc-pages.js; when
   the chat opens the class is removed and HubSpot's own position applies.
   !important because HubSpot positions the box with its own styles. */
@media (max-width: 1023.98px) {
	html.uc-hs-chat-closed.uc-cta-visible #hubspot-messages-iframe-container {
		bottom: var(--uc-cta-h) !important;
	}
}

/* Quick Quote modal (header.php): the Tailwind max-h-[90vh] uses the
   *largest* viewport, so on iOS Safari with its toolbars showing the modal
   was taller than the visible screen and the close button sat off the top.
   svh is the viewport with all browser bars showing, so it always fits;
   the inner panel scrolls instead. vh line is the fallback. */
#quick-quote-modal {
	max-height: 90vh;
	max-height: 90svh;
	max-width: 100vw;
	background: rgba(47, 50, 56, 1.0);
	color: white;
}

#quick-quote-modal > .overflow-y-auto {
	max-height: 100%;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

/* Logged in on mobile: keep the top clear of the fixed admin bar. */
@media (max-width: 1023.98px) {
	body.admin-bar #quick-quote-modal {
		max-height: calc(100vh - 2 * (var(--uc-header-top) + 8px));
		max-height: calc(100svh - 2 * (var(--uc-header-top) + 8px));
	}
}

/* Very narrow phones (e.g. 320px): tighten so both halves fit. */
@media (max-width: 374.98px) {
	.uc-mobile-cta__item {
		gap: 8px;
		padding: 0 10px;
	}
}
