/**
 * Navigation Header — frontend styles.
 */

.wb-nav-header {
	--wb-nav-brand: #1a5fe0;

	/*
	 * Rows align to the theme's wide content width rather than a fixed
	 * value, so the wordmark and departments line up with page content.
	 * The gutter is added on top so the content edge lands exactly on the
	 * theme's wide size.
	 */
	--wb-nav-gutter: 32px;
	--wb-nav-wide: var(--wp--style--global--wide-size, 1260px);
	--wb-nav-row-width: calc(var(--wb-nav-wide) + 64px);
	--wb-nav-foreground: #16181d;
	--wb-nav-muted: #6b7280;
	--wb-nav-border: #e4e7ec;

	/* The strip's ground in every state; only its contents change. */
	--wb-nav-utility-bg: #16181d;

	/* The bar's own drop shadow, and the accent it shares with the panels. */
	--wb-nav-accent: var(--wb-nav-brand);
	--wb-nav-bar-shadow: 0 6px 16px -10px rgba(20, 30, 50, 0.25);

	position: sticky;
	top: 0;
	z-index: 100;
	background: #fff;
}

/*
 * Rows are inner blocks, so they opt in to collapse behaviour by class.
 * Anything not marked stays in the collapsed bar.
 */

/*
 * The header's three rows are sibling stacking contexts, and each one traps
 * whatever it contains: a positioned descendant's own z-index, however
 * high, can never win against a sibling context it is trapped inside, and
 * two contexts that tie are decided by DOM order alone. So the rows are
 * ordered here, deliberately, and everything that pops out of one inherits
 * that order:
 *
 *   utility 42 — the location strip's panel, which has to cover the
 *                wordmark and the cart in the row below it
 *   tools    41 — the search field's suggestions, which have to cover the
 *                department row below them
 *   drawer   40 — the department row and its panels (departments/style.css)
 *
 * All three clear the department scrim at 30, so the header stays clickable
 * while a panel is open.
 *
 * Tools used to tie with the department drawer at 40, and the department row
 * comes later in the DOM — so the nav links painted straight through the
 * open search dropdown, a word of "Garden & landscape" lying across the
 * suggestions. The band's own background sits lower again (its element is
 * unpositioned), which is why the panel covered the grey but not the words.
 */
.wb-nav-header__utility {
	position: relative;
	z-index: 42;
	background: var(--wb-nav-utility-bg);
	color: #fff;
	font-size: 12px;
}

/*
 * 48px on desktop: 9px of padding around the strip's 30px capsule. The
 * location cluster on the left is what truncates when the row is tight;
 * the help offer on the right is pinned and never wraps.
 */
.wb-nav-header__utility > .wp-block-group {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	max-width: var(--wb-nav-row-width);
	min-height: 48px;
	margin: 0 auto;
	padding: 0 var(--wb-nav-gutter);
}

.wb-nav-header__utility .wb-locations-strip {
	min-width: 0;
}

/*
 * WooCommerce's block-theme stylesheet gives every label on a shop page a
 * 0.7em bottom margin (`.woocommerce-page label`). The location strip's order
 * type toggle and panel fields are labels, so on shop, product, cart and
 * category pages the toggle grew taller than on every other page. The header
 * must look the same everywhere, so its labels opt out.
 */
.wb-nav-header__utility .wb-locations-strip label {
	margin-bottom: 0;
}

.wb-nav-header__utility p {
	margin: 0;
	font-size: 12px;
}

.wb-nav-header__utility a {
	color: inherit;
}

/*
 * The help offer that follows the editable location block. Authored as one
 * paragraph: the question itself is the link to the contact page, and one
 * Call us button dials. The number is never printed — the button carries
 * the `tel:` link, so a phone dials it in one tap and a desktop visitor is
 * not reading a string they cannot click. At phone width the question
 * shortens to the one word that still means it: Contact.
 */
.wb-nav-header__actions {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 14px;
	white-space: nowrap;
}

/*
 * Muted, and lighter than the controls around it: it is an offer, not an
 * instruction. It is still a link, so it takes the hover underline.
 *
 * Scoped to the row rather than left as a bare class: the row sets
 * `.wb-nav-header__utility a { color: inherit }`, two selectors against
 * this one, so a bare class here loses at every width and the offer reads
 * as white as the controls it is meant to sit behind.
 */
.wb-nav-header__utility .wb-nav-header__contact {
	color: #b0b7bf;
	font-size: 12px;
	font-weight: 400;
	text-decoration: none;
}

.wb-nav-header__utility .wb-nav-header__contact:hover {
	color: #fff;
	text-decoration: underline;
}

/* The rule between the offer and the button. */
.wb-nav-header__separator {
	display: inline-block;
	width: 1px;
	height: 20px;
	background: rgba(255, 255, 255, 0.28);
}

/* The one filled control on this side, the same white as the strip's. */
.wb-nav-header__call {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 5px 13px;
	border-radius: 999px;
	background: #fff;
	color: var(--wb-nav-foreground) !important;
	font-size: 12px;
	font-weight: 700;
	text-decoration: none;
}

.wb-nav-header__call:hover {
	background: #e9ebef;
}

/* The phone glyph, drawn from the current colour so it follows the text. */
.wb-nav-header__call::before {
	width: 14px;
	height: 14px;
	background: currentcolor;
	content: "";
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6A19.79 19.79 0 0 1 2.12 4.18 2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z'/%3E%3C/svg%3E");
	mask-position: center;
	mask-repeat: no-repeat;
	mask-size: contain;
}

@media (min-width: 901px) {
	/*
	 * The strip does not scroll away on desktop: the collapsed bar keeps
	 * the utility row, and only the department row goes.
	 */
	.wb-nav-header--collapsible.is-collapsed .wb-nav-header__utility {
		display: block;
	}
}

/*
 * The question is what desktop and tablet read; only a phone shortens it
 * to the one word that still means it. Its own breakpoint, below the
 * 900px layout switch, because a tablet has room for the words even once
 * the bar has gone compact.
 */
.wb-nav-header__short {
	display: none;
}

@media (max-width: 600px) {
	.wb-nav-header__long {
		display: none;
	}

	.wb-nav-header__short {
		display: inline;
	}

	/*
	 * At one word it is a control, not an aside, so it reads as one. Same
	 * scoping as the base rule above, and placed after it: equal
	 * specificity is decided by source order, and this block used to come
	 * first, so none of it applied.
	 */
	.wb-nav-header__utility .wb-nav-header__contact {
		color: #fff;
		font-size: 10.5px;
		font-weight: 700;
	}
}

/* Text wordmark, per the design's 23px/800 specification. */
.wb-nav-header__wordmark {
	margin: 0;
	color: var(--wb-nav-foreground);
	font-size: 23px;
	font-weight: 800;
	letter-spacing: -0.01em;
	line-height: 1;
}

.wb-nav-header__wordmark a {
	color: inherit;
	text-decoration: none;
}

/* The search field takes the middle of the tools row, capped per the spec. */
.wb-nav-header__tools .wp-block-workbench-hero-search {
	flex: 1 1 auto;
	max-width: 460px;
	margin: 0;
}

/* See the note above the utility row for why this outranks the drawer. */
.wb-nav-header__tools {
	position: relative;
	z-index: 41;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	max-width: var(--wb-nav-row-width);
	margin: 0 auto;

	/*
	 * The brand row carries the wordmark and the cart and nothing else, so
	 * its height is set by this padding rather than by its contents. At 12px
	 * the row was 56px and read as a strip rather than a header band.
	 */
	padding: 20px var(--wb-nav-gutter);
}

.wb-nav-header__expand {
	display: none;
}

/*
 * The search field, closed. It sits in the brand row between the wordmark
 * and the icon that opens it, and spends almost all of its life at zero
 * width — `display: none` would be simpler but cannot be animated, and the
 * field opening is the only thing that says the icon did something.
 *
 * The field itself is what narrows, not a window over a field held at full
 * size. A clip revealed a field with a flat cut for a left edge for most of
 * the 260ms — no corner, no border, and the leading magnifier sliced in half
 * — because the field's own left edge did not enter the clip until the last
 * few frames. Narrowing the field keeps it a whole rounded box at every
 * width, and its submit button, which is pinned to its right edge, rides
 * along at the far end from the first frame.
 *
 * `visibility` rather than width alone carries the other half of hidden: a
 * zero-width field is still in the tab order, and a keyboard visitor should
 * not have to tab through a search box nobody can see.
 */
.wb-nav-header__search {
	--wb-nav-search-width: min(420px, 38vw);

	display: flex;
	align-items: center;
	flex: 0 0 auto;
	width: 0;
	visibility: hidden;
	transition:
		width 260ms cubic-bezier(0.4, 0, 0.2, 1),
		visibility 0s linear 260ms;
}

.wb-nav-header.is-search-open .wb-nav-header__search {
	width: var(--wb-nav-search-width);

	/* Visible from the first frame on the way out, and not until the last on
	   the way back, so the field is never a ghost over the closing gap. */
	visibility: visible;
	transition:
		width 260ms cubic-bezier(0.4, 0, 0.2, 1),
		visibility 0s;
}

.wb-nav-header__search .wb-hero-search {
	width: 100%;
	min-width: 0;
	margin: 0;
}

/*
 * The field's own rounded box does the clipping, so what it holds is cut to
 * the same corners it has rather than to a rectangle a few pixels outside
 * them. Its dropdown is `position: fixed` and is not caught by this.
 */
.wb-nav-header__search .wb-hero-search__form {
	overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
	.wb-nav-header__search,
	.wb-nav-header.is-search-open .wb-nav-header__search {
		transition: none;
	}
}

/*
 * Search and account sit against the cart, not midway across the row. The
 * brand row is `space-between`, so without the auto margin the free space
 * would be shared out around them and the cluster would float in the middle
 * of the bar. The tighter gap applies only where these controls are present,
 * so a header composed without them keeps the wider rhythm it was drawn for.
 */
.wb-nav-header__tools:has(.wb-nav-header-actions) {
	gap: 6px;
}

.wb-nav-header__tools .wb-nav-header-actions {
	margin-left: auto;
}

/*
 * With a search field in the row the free space belongs in front of it, not
 * in front of the icons: the field's right edge has to be the thing that
 * stays put while it opens, and an auto margin between the field and the
 * icons would instead pin the field's left edge and grow it rightward,
 * shoving the cart along the bar as it went. So the space is banked against
 * the wordmark and everything after it is packed to the right.
 */
.wb-nav-header__tools:has(.wb-nav-header__search) .wb-nav-header__wordmark {
	margin-right: auto;
}

.wb-nav-header__tools:has(.wb-nav-header__search) .wb-nav-header-actions {
	margin-left: 0;
}

/*
 * The cart, drawn one way at every width. The block ships a 24px glyph in a
 * 32px button with an 18px badge and a 13px total, and this brought that down
 * — but only inside the mobile breakpoint, so a desktop or tablet visitor got
 * the shipped size and the control changed shape as the window narrowed. It
 * is the same control wherever it appears.
 *
 * This matches the drawer's copy too: the drawer sits inside the header, so
 * the selector reaches both.
 */
.wb-nav-header .cc-mini-cart {
	gap: 4px;
}

.wb-nav-header .cc-mini-cart__button {
	width: 26px;
	height: 26px;
	padding: 3px;
}

.wb-nav-header .cc-mini-cart__icon {
	width: 18px;
	height: 18px;
}

.wb-nav-header .cc-mini-cart__badge {
	top: -2px;
	right: -3px;
	min-width: 13px;
	height: 13px;
	padding: 0 3px;
	font-size: 8.5px;
}

/* Smaller than the wordmark beside it: a fact, not a heading. */
.wb-nav-header .cc-mini-cart__subtotal {
	color: var(--wb-nav-foreground);
	font-size: 11px;
	font-weight: 700;
}

/* ---------------------------------------------------------- Collapsed */

@media (min-width: 901px) {
	.wb-nav-header--collapsible.is-collapsed .wb-nav-departments {
		display: none;
	}
}

/*
 * Below the breakpoint the strip scrolls with the page and the compact
 * sticky bar takes over. On desktop it stays — see the min-width block
 * above the wordmark.
 */
@media (max-width: 900px) {
	.wb-nav-header--collapsible.is-collapsed .wb-nav-header__utility {
		display: none;
	}
}

/*
 * Below the breakpoint the department strip is just the hamburger, and the
 * collapsed bar has to keep it: hiding it would leave no way into the
 * navigation at all for most of a session.
 */
@media (max-width: 900px) {
	.wb-nav-header--collapsible.is-collapsed .wb-nav-departments__row,
	.wb-nav-header--collapsible.is-collapsed .wb-nav-departments__panels {
		display: none;
	}

	/*
	 * Except while the drawer is open. The collapsed bar hides the row and
	 * the panels because neither belongs in a 56px bar, but the drawer is
	 * built from exactly those two elements, so opening it from the collapsed
	 * state would otherwise show an empty sheet.
	 */
	.wb-nav-departments.is-drawer-open .wb-nav-departments__row {
		display: flex;
	}

	.wb-nav-departments.is-drawer-open .wb-nav-departments__panels {
		display: block;
	}
}

.wb-nav-header--collapsible.is-collapsed .wb-nav-header__tools {
	min-height: 60px;
	padding-top: 0;
	padding-bottom: 0;
}

.wb-nav-header--collapsible.is-collapsed .wb-nav-header__expand {
	position: absolute;
	top: 50%;
	left: var(--wb-nav-gutter, 32px);
	display: block;
	padding: 8px 14px;
	border: 1px solid var(--wb-nav-border);
	border-radius: 6px;
	background: #fff;
	color: var(--wb-nav-foreground);
	font: inherit;
	font-size: 13px;
	font-weight: 700;
	transform: translateY(-50%);
	cursor: pointer;
}

.wb-nav-header--collapsible.is-collapsed .wb-nav-header__expand:hover,
.wb-nav-header--collapsible.is-collapsed .wb-nav-header__expand:focus-visible {
	border-color: var(--wb-nav-brand);
	color: var(--wb-nav-brand);
}

@media (max-width: 900px) {
	.wb-nav-header {
		/*
		 * The page's own gutter, so the burger's glyph and the wordmark share
		 * a left edge with the breadcrumb and heading beneath them. At 20px
		 * the header sat 4px inside the content it belongs to, which reads as
		 * a misalignment rather than a margin.
		 */
		--wb-nav-gutter: 14px;

		/*
		 * The department row does not fit at this width, so the only nav
		 * control is the hamburger and it belongs beside the wordmark rather
		 * than on a row of its own. The departments block owns that button,
		 * so the header becomes a grid and places that block's strip in the
		 * same row as the tools. Its drawer and scrim are fixed, so they
		 * escape the grid untouched.
		 */

		/*
		 * One bar, four things: burger, wordmark, search, cart. The search
		 * used to take a full-width row of its own underneath them, spending
		 * a third of a phone's first screen on chrome while 180px sat empty
		 * between the wordmark and the cart.
		 *
		 * `display: contents` on the tools group is what allows it: the
		 * wordmark and the cart are its children and the search is a sibling
		 * of the group, so the three cannot share a row until the group stops
		 * being a box. The collapsed bar then needs no grid of its own —
		 * hiding the utility strip and the wordmark leaves exactly burger,
		 * search and cart.
		 */
		display: grid;
		grid-template-areas:
			"utility utility utility utility utility"
			"burger brand search actions cart";
		grid-template-columns: auto auto 1fr auto auto;

		/*
		 * The brand row's own height. `display: contents` on the tools group
		 * leaves it no box, so its padding cannot set this — without a row
		 * size the band collapsed onto the burger's 44px target.
		 *
		 * A property rather than a literal because the drawer covers this row
		 * while it is open and puts its own wordmark in the same place. The
		 * departments block inherits this and sizes its title bar from it, so
		 * the two cannot drift.
		 */
		--wb-nav-brand-row: 60px;

		grid-template-rows: auto minmax(var(--wb-nav-brand-row), auto);
		align-items: center;
	}

	/*
	 * Doubled class, the same technique the panels use: the group carries
	 * WordPress's own `.wp-block-group.is-layout-flex { display: flex }`,
	 * which is two classes and outranks a single one.
	 */
	.wb-nav-header .wb-nav-header__tools.wb-nav-header__tools {
		display: contents;
	}

	.wb-nav-header__wordmark {
		grid-area: brand;
		margin: 0;
		font-size: 16px;
	}

	/*
	 * Both carts, the header's and the drawer's — the drawer sits inside the
	 * header, so this matches its copy too. They were carrying separate
	 * rules of equal specificity and whichever came last in the file won for
	 * both, which is why the total sat 8px off the glyph in one place and
	 * 4px in the other while claiming two different sizes.
	 */
	.wb-nav-header .cc-mini-cart {
		grid-area: cart;
		margin-right: var(--wb-nav-gutter);
	}

	/*
	 * A grid cell of its own rather than a flex child: the tools group is
	 * `display: contents` at this width, so these controls are laid out by
	 * the header's own grid alongside the burger, the wordmark and the cart.
	 * The auto margin the brand row needs above the breakpoint has nothing
	 * to push against here and is dropped.
	 */
	.wb-nav-header .wb-nav-header-actions {
		grid-area: actions;
		margin-left: 0;
		margin-right: 6px;
	}

	.wb-nav-header__utility {
		grid-area: utility;
	}

	.wb-nav-header .wb-nav-departments {
		grid-area: burger;
		align-self: center;
	}

	/*
	 * Never drawn at this width, in either state. The search block answers
	 * the focus this element exists to receive by moving itself to the body
	 * as a full-screen sheet, so anything painted here would be a field that
	 * flashed into the bar and left again. Out of flow and transparent, it
	 * can still take the cursor, which is all it is for — and out of flow it
	 * leaves the grid's `search` column empty, which is what holds the cart
	 * against the right edge.
	 */
	.wb-nav-header__search {
		position: absolute;
		top: 0;
		left: 0;
		width: 1px;
		min-width: 0;
		height: 1px;
		margin: 0;
		padding: 0;
		opacity: 0;
		transition: none;
	}

	.wb-nav-header.is-search-open .wb-nav-header__search {
		width: 1px;
		padding: 0;
		visibility: visible;
	}

	.wb-nav-header__search .wb-hero-search {
		width: 100%;
	}

	/*
	 * The same 40px band as the desktop strip. The handover draws it at 33,
	 * but the "Change" pill inside it stands 23px on its own, which left five
	 * pixels of air above and below it — tight enough that the bar read as
	 * something clipped rather than something sized.
	 */
	.wb-nav-header__utility > .wp-block-group {
		min-height: 40px;
		gap: 7px;
		padding: 0 14px;
		white-space: nowrap;
	}

	/*
	 * The strip sizes itself for this width in its own stylesheet; the
	 * header only has to let it shrink so the contact controls stay pinned
	 * to the right, and the readout is what truncates.
	 */
	.wb-nav-header__utility .wb-locations-strip {
		flex: 1 1 auto;
		min-width: 0;
	}

	.wb-nav-header__utility p {
		font-size: 10.5px;
	}

	/* The offer and the button stay pinned to the right at every width. */
	.wb-nav-header__actions {
		gap: 7px;
	}

	/* One word and a button need no rule between them. */
	.wb-nav-header__separator {
		display: none;
	}

	.wb-nav-header__call {
		gap: 5px;
		padding: 4px 8px;
		font-size: 10.5px;
	}

	.wb-nav-header__call::before {
		width: 12px;
		height: 12px;
	}

	/*
	 * The expand button was the only route back to the departments once the
	 * header collapsed. The bar now carries the burger, so it would be a
	 * second control for the same thing, sitting on top of the cart.
	 */
	.wb-nav-header--collapsible.is-collapsed .wb-nav-header__expand {
		display: none;
	}

	/*
	 * The collapsed bar is one 56px row: burger, wordmark, cart. Three rows
	 * of chrome is most of a phone's first screen, and the one that goes is
	 * the location strip — a first-visit nudge rather than something a
	 * returning visitor reads on every scroll.
	 *
	 * The free space sits between the wordmark and the cart, in the column
	 * the search field used to occupy. It is empty on purpose: the burger is
	 * two centimetres away and opens the search that has the suggestions
	 * attached, so a second field here would be a third place to type the
	 * same query.
	 */
	.wb-nav-header--collapsible.is-collapsed {
		/*
		 * Fixed, not sticky. Sticky is confined to its containing block, and
		 * this header's is the template-part wrapper — only as tall as the
		 * header, so it sticks for its own height and then leaves. view.js
		 * reserves that height on the wrapper so taking it out of flow does
		 * not pull the page up, and publishes the admin bar's measured live
		 * bottom edge rather than assuming its height.
		 */
		position: fixed;
		top: var(--wb-nav-header-top, 0);
		right: 0;
		left: 0;

		/*
		 * The grid row sets the compact bar's exact height. It matches the
		 * brand row above it on purpose, now that the wordmark stays put
		 * through the collapse — at 56 against the expanded 60 it shifted two
		 * pixels as the bar appeared.
		 */
		grid-template-rows: auto 60px;
		box-shadow: var(--wb-nav-bar-shadow);
	}

	/*
	 * The subtotal is the first thing to go when the row is tight: the badge
	 * already says there is a cart, and the amount is one tap away.
	 */
	@media (max-width: 390px) {
		.wb-nav-header--collapsible.is-collapsed .cc-mini-cart__subtotal {
			display: none;
		}
	}
}

/* Focus rings last, so they are not outranked by the rules they sit over. */

.wb-nav-header__wordmark a:focus-visible,
.wb-nav-header--collapsible.is-collapsed .wb-nav-header__expand:focus-visible {
	border-radius: 4px;
	outline: 2px solid var(--wb-nav-brand);
	outline-offset: 3px;
}

/* ------------------------------------------------------ Focus rings */

/*
 * A white ring, because this strip is near-black and the brand blue does not
 * carry enough contrast against it.
 */
.wb-nav-header__utility a:focus-visible {
	border-radius: 4px;
	outline: 2px solid #fff;
	outline-offset: 2px;
}
