/**
 * Grovidex site chrome (child-theme owned, site-wide).
 *
 * Styles the Grovidex header, footer and mobile bottom navigation
 * rendered by the shared chrome partials (template-parts/chrome/):
 * on the static front page via the homepage templates, and on every
 * other route via the astra_header/astra_footer hook swap in
 * inc/chrome.php. No Astra Header Builder selectors are used or
 * required. The shared search-form skin (.gvx-search-form) lives in
 * header-footer.css so any Astra-rendered fallback search uses the
 * identical treatment.
 *
 * Breakpoint: 922px, matching the site's established header breakpoint
 * and the sticky-offset media queries in header-footer.css (which also
 * provide html scroll-padding-top and per-target scroll-margin-top
 * site-wide).
 */

/* ------------------------------------------------------------------
 * Scoped box model (base.css scopes to .gvx-section only).
 * ------------------------------------------------------------------ */

.gvx-site-header,
.gvx-site-header *,
.gvx-site-header *::before,
.gvx-site-header *::after,
.gvx-site-footer,
.gvx-site-footer *,
.gvx-site-footer *::before,
.gvx-site-footer *::after,
.gvx-bottom-nav,
.gvx-bottom-nav *,
.gvx-bottom-nav *::before,
.gvx-bottom-nav *::after {
	box-sizing: border-box;
}

/* ------------------------------------------------------------------
 * Skip link — visually hidden until keyboard focus.
 * ------------------------------------------------------------------ */

.gvx-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
}

.gvx-skip-link:focus {
	position: fixed;
	left: var(--gvx-space-3);
	top: calc(var(--gvx-space-3) + var(--wp-admin--admin-bar--height, 0px));
	z-index: calc(var(--gvx-z-header) + 1);
	padding: var(--gvx-space-2) var(--gvx-space-4);
	background-color: var(--gvx-surface);
	color: var(--gvx-teal);
	font-family: var(--gvx-font-sans);
	font-size: var(--gvx-text-sm);
	font-weight: 600;
	border-radius: var(--gvx-radius-md);
	box-shadow: var(--gvx-shadow-md);
	outline: 2px solid var(--gvx-teal);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Sticky header band — one sticky element covering both mobile rows,
 * so the search bar is permanently visible and there is no sibling
 * coordination and no layout shift.
 * ------------------------------------------------------------------ */

.gvx-site-header {
	position: sticky;
	/* WordPress core sets --wp-admin--admin-bar--height (32px, 46px at
	   <=782px) whenever the admin bar renders; logged-out visitors get
	   the 0px fallback. */
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: var(--gvx-z-header);
	background-color: var(--gvx-surface);
	border-bottom: 1px solid var(--gvx-border);
	font-family: var(--gvx-font-sans);
	/* Device cutout / safe-area protection. */
	padding-left: env(safe-area-inset-left);
	padding-right: env(safe-area-inset-right);
}

/* Below 600px core makes the admin bar position:absolute (it scrolls
   away), so the sticky header docks to the true viewport top. */
@media (max-width: 600px) {
	body.admin-bar .gvx-site-header {
		top: 0;
	}
}

/* WooCommerce checkout keeps a conservative, non-sticky presentation —
   full Grovidex branding without a persistent bar over the payment
   flow. */
body.woocommerce-checkout .gvx-site-header {
	position: static;
}

/* Scrolled-state shadow: progressive enhancement via CSS scroll-driven
   animation; browsers without support keep the static bottom border. */
@supports (animation-timeline: scroll()) {
	@keyframes gvx-home-header-shadow {
		to {
			box-shadow: var(--gvx-shadow-md);
		}
	}

	.gvx-site-header {
		animation: gvx-home-header-shadow linear both;
		animation-timeline: scroll();
		animation-range: 0 120px;
	}

	@media (prefers-reduced-motion: reduce) {
		.gvx-site-header {
			animation: none;
		}
	}
}

/* ------------------------------------------------------------------
 * Header layout. Mobile-first: two rows —
 *   row 1: logo | account/cart;  row 2: full-width search.
 * One search-form instance is repositioned via grid areas.
 * Height budget at mobile: 8 + 44 + 4 + 44 + 8 = 108px (<=112px).
 * ------------------------------------------------------------------ */

.gvx-site-header__inner {
	display: grid;
	grid-template-areas:
		"logo actions"
		"search search";
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	column-gap: var(--gvx-space-4);
	row-gap: var(--gvx-space-1);
	padding-top: var(--gvx-space-2);
	padding-bottom: var(--gvx-space-2);
}

.gvx-site-header__logo {
	grid-area: logo;
	display: flex;
	align-items: center;
	min-height: 44px;
	min-width: 0;
}

.gvx-site-header__search {
	grid-area: search;
	min-width: 0;
}

.gvx-site-header__actions {
	grid-area: actions;
	display: flex;
	align-items: center;
	gap: var(--gvx-space-2);
}

@media (min-width: 922px) {
	.gvx-site-header__inner {
		grid-template-areas: "logo search actions";
		grid-template-columns: auto minmax(0, 1fr) auto;
		column-gap: var(--gvx-space-5);
		min-height: var(--gvx-header-h-desktop, 72px);
	}

	/* Dominant centered search on desktop. */
	.gvx-site-header__search {
		width: 100%;
		max-width: 640px;
		margin-inline: auto;
	}
}

/* Track Order is desktop-only in the site header. */
@media (max-width: 921px) {
	.gvx-site-header .gvx-track-order {
		display: none;
	}
}

/* Mobile search targets: field stays >=44px, never icon-only. */
@media (max-width: 921px) {
	.gvx-site-header .gvx-search-field {
		height: 44px;
	}

	.gvx-site-header .gvx-search-submit {
		height: 44px;
		width: 48px;
	}
}

/* ------------------------------------------------------------------
 * Logo — original artwork, original proportions, capped height only.
 * ------------------------------------------------------------------ */

.gvx-site-header__logo .custom-logo-link {
	display: inline-flex;
	align-items: center;
}

/* A definite height (not max-height) is load-bearing: the desktop
   logo track is `auto`-sized, and an SVG logo with width:auto +
   height:auto + a percentage max-width creates a cyclic sizing
   dependency there — the track and image both resolve to 0 and the
   logo disappears. Fixing the height gives the image a definite
   intrinsic-ratio width, so the track sizes to it in both layouts.
   The fixed (non-percentage) max-width caps very wide artwork without
   re-introducing the cycle; object-fit keeps the drawing undistorted
   if that cap ever engages. */
.gvx-site-header__logo .custom-logo {
	height: 44px;
	width: auto;
	max-width: 220px;
	max-height: 44px;
	object-fit: contain;
}

/* Site-title fallback when no custom logo exists. */
.gvx-site-header__title {
	font-size: var(--gvx-text-lg);
	font-weight: 700;
	color: var(--gvx-ink);
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gvx-site-header__title:hover {
	color: var(--gvx-teal);
}

/* ------------------------------------------------------------------
 * Account / cart actions — 44px targets, ink icons, teal hover.
 * ------------------------------------------------------------------ */

.gvx-site-header__action {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	color: var(--gvx-ink);
	border-radius: var(--gvx-radius-sm);
	transition: color var(--gvx-duration) var(--gvx-ease);
}

.gvx-site-header__action:hover {
	color: var(--gvx-teal);
}

.gvx-site-header__cart-count {
	position: absolute;
	top: 2px;
	right: 0;
	min-width: 18px;
	padding: 0 4px;
	background-color: var(--gvx-gold);
	color: var(--gvx-ink);
	font-size: var(--gvx-text-xs);
	font-weight: 600;
	line-height: 18px;
	text-align: center;
	border-radius: var(--gvx-radius-pill);
}

/* Focus visibility inside the header — never removed, never clipped. */
.gvx-site-header a:focus-visible,
.gvx-site-header button:focus-visible,
.gvx-site-header input:focus-visible {
	outline: 2px solid var(--gvx-teal);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Footer — deep teal, premium bookstore treatment.
 * ------------------------------------------------------------------ */

.gvx-site-footer {
	background-color: var(--gvx-teal);
	color: var(--gvx-ink-on-dark);
	font-family: var(--gvx-font-sans);
	font-size: var(--gvx-text-sm);
	line-height: var(--gvx-leading-body);
	padding-top: var(--gvx-space-7);
	padding-bottom: var(--gvx-space-5);
}

.gvx-site-footer__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--gvx-space-6);
}

@media (min-width: 600px) {
	.gvx-site-footer__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.gvx-site-footer__grid {
		grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
	}
}

/* Brand column — the original logo sits on a light chip so the
   artwork stays visible on the teal ground without recoloring it. */
.gvx-site-footer__logo {
	display: inline-flex;
	align-items: center;
	padding: var(--gvx-space-2) var(--gvx-space-3);
	background-color: var(--gvx-surface);
	border-radius: var(--gvx-radius-md);
	margin: 0 0 var(--gvx-space-3);
}

/* Definite height for the same auto-sizing reason as the header logo:
   the chip shrink-wraps, so a percentage max-width would collapse an
   SVG logo to 0 width. */
.gvx-site-footer__logo .custom-logo {
	height: 40px;
	width: auto;
	max-width: 200px;
	max-height: 40px;
	object-fit: contain;
}

.gvx-site-footer__name {
	margin: 0 0 var(--gvx-space-2);
	font-size: var(--gvx-text-lg);
	font-weight: 700;
	color: var(--gvx-ink-on-dark);
}

.gvx-site-footer__desc {
	margin: 0;
	max-width: 40ch;
	opacity: 0.85;
}

/* Navigation columns. */
.gvx-site-footer__heading {
	margin: 0 0 var(--gvx-space-3);
	font-size: var(--gvx-text-sm);
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--gvx-gold);
}

.gvx-site-footer__menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: var(--gvx-space-2);
}

.gvx-site-footer__menu a,
.gvx-site-footer__policy-menu a {
	color: var(--gvx-ink-on-dark);
	text-decoration: none;
}

.gvx-site-footer__menu a:hover,
.gvx-site-footer__policy-menu a:hover {
	color: var(--gvx-gold);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* Bottom row — copyright + optional policies menu. */
.gvx-site-footer__bottom {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--gvx-space-3);
	margin-top: var(--gvx-space-6);
	padding-top: var(--gvx-space-4);
	border-top: 1px solid rgba(246, 249, 248, 0.2);
}

.gvx-site-footer__copyright {
	margin: 0;
	opacity: 0.85;
}

.gvx-site-footer__policy-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: var(--gvx-space-2) var(--gvx-space-4);
}

/* Focus visibility on the dark ground — gold ring, matching the
   established .gvx-on-dark convention. */
.gvx-site-footer a:focus-visible {
	outline: 2px solid var(--gvx-gold);
	outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Mobile bottom navigation — Home / Shop / Track Order / Cart.
 * Rendered by inc/chrome.php on wp_footer; never on single product
 * pages (Grovidex Sticky Cart owns that edge) or checkout — those
 * routes also omit the body class, so no space is reserved. Search
 * and Account are absent by design: both live in the sticky mobile
 * header. Mobile-only; zero JavaScript.
 * ------------------------------------------------------------------ */

.gvx-bottom-nav {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	/* One step below the sticky header so an open skip link / header
	   focus ring is never covered; still above page content. */
	z-index: calc(var(--gvx-z-header) - 1);
	display: flex;
	align-items: stretch;
	background-color: var(--gvx-surface);
	border-top: 1px solid var(--gvx-border);
	font-family: var(--gvx-font-sans);
	padding-bottom: env(safe-area-inset-bottom);
	padding-left: env(safe-area-inset-left);
	padding-right: env(safe-area-inset-right);
}

/* Reserve room above the bar so page content and the footer are never
   hidden behind it. Applied via body class only when the bar renders. */
body.gvx-has-bottom-nav {
	padding-bottom: calc(var(--gvx-bottom-nav-h) + env(safe-area-inset-bottom));
}

/* Phase 12AN: the Support AI floating launcher (fixed bottom-right,
   positioned by its own plugin stylesheet — production confirmed no
   inline styles, so plain higher-specificity CSS wins without
   !important) collided with the fixed bottom navigation on phones.
   While the bar renders (<922px + the body class), lift the launcher
   above the bar's reserved height + safe-area with deliberate
   clearance. Presentation-only: plugin markup/logic and the desktop
   position are untouched, and the launcher is never hidden here. */
@media (max-width: 921px) {
	body.gvx-has-bottom-nav .gsai-widget {
		bottom: calc(var(--gvx-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
	}
}

.gvx-bottom-nav__item {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 2px;
	min-height: 56px;
	padding: var(--gvx-space-2) var(--gvx-space-1);
	color: var(--gvx-ink-muted);
	text-decoration: none;
	transition: color var(--gvx-duration) var(--gvx-ease);
}

.gvx-bottom-nav__item:hover,
.gvx-bottom-nav__item[aria-current="page"] {
	color: var(--gvx-teal);
}

.gvx-bottom-nav__label {
	font-size: var(--gvx-text-xs);
	font-weight: 500;
	line-height: 1.2;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.gvx-bottom-nav__icon-wrap {
	position: relative;
	display: inline-flex;
}

.gvx-bottom-nav__count {
	position: absolute;
	top: -6px;
	right: -10px;
	min-width: 16px;
	padding: 0 4px;
	background-color: var(--gvx-gold);
	color: var(--gvx-ink);
	font-size: var(--gvx-text-xs);
	font-weight: 600;
	line-height: 16px;
	text-align: center;
	border-radius: var(--gvx-radius-pill);
}

.gvx-bottom-nav a:focus-visible {
	outline: 2px solid var(--gvx-teal);
	outline-offset: -2px;
}

/* Desktop: the bar and its reserved space disappear entirely. */
@media (min-width: 922px) {
	.gvx-bottom-nav {
		display: none;
	}

	body.gvx-has-bottom-nav {
		padding-bottom: 0;
	}
}
