/*
 * The header and footer this plugin draws.
 *
 * Its own file, loaded only when the shop has asked this plugin to draw them, because a visitor
 * on a site using its theme's header should not download a stylesheet for one it never sees.
 *
 * NOT ONE LITERAL COLOUR. Every value is a setting, exactly as the product page is, so the same
 * light/dark switch and the same per-screen overrides reach the header for free.
 */

.wpp-nav {
	background: var(--wpp-nav-bg);
	color: var(--wpp-nav-ink);
	/* Stated, not inherited. A header rendered at the very top of the body does not reliably
	   sit inside whatever the theme set its typeface on. */
	font-family: var(--wpp-nav-font);
	position: relative;
	z-index: 9010;
	border-bottom: var(--wpp-nav-edge-width) solid var(--wpp-nav-edge);
}

/* Sticky is a class on the body, so a shop can turn it off without this file knowing why. */
.wpp-nav-sticky .wpp-nav {
	position: sticky;
	top: 0;
	transition: transform 0.22s ease, box-shadow 0.22s ease;
}

/*
 * What it does once you start scrolling.
 *
 * --wpp-nav-barh is written by the script from the bar's REAL height, so condensing lifts the
 * header by exactly the top row and leaves the navigation band sitting on the top edge. A fixed
 * number here would be wrong at every width but one, and wrong in a way that shows: a sliver of
 * the bar left behind, or the navigation pulled half off the screen.
 */
.wpp-nav-sticky .wpp-nav[data-scroll="condense"].is-shifted {
	transform: translateY(calc(-1 * var(--wpp-nav-barh, 0px)));
}
.wpp-nav-sticky .wpp-nav[data-scroll="hide"].is-shifted {
	transform: translateY(-100%);
}
.wpp-nav[data-shadow="1"].is-scrolled {
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

@media (prefers-reduced-motion: reduce) {
	.wpp-nav-sticky .wpp-nav { transition: none; }
}

.wpp-nav__inner {
	max-width: var(--wpp-nav-max);
	margin: 0 auto;
	padding: 0 var(--wpp-nav-pad);
	display: flex;
	align-items: center;
	gap: 2rem;
}

/* ------------------------------------------------------------------ the strip above */

.wpp-nav__utility {
	background: var(--wpp-nav-utility-bg);
	font-size: 0.78rem;
}
.wpp-nav__utility .wpp-nav__inner {
	min-height: 2.4rem;
	gap: 1.2rem;
	justify-content: center;
}
.wpp-nav__note { margin: 0; }

/* ------------------------------------------------------------------------- the bar */

.wpp-nav__bar .wpp-nav__inner {
	min-height: var(--wpp-nav-height);
	padding-top: 0.85rem;
	padding-bottom: 0.85rem;
	position: relative;   /* the wordmark is centred against this on a phone */
}

/*
 * Equal flanks, so the search lands on the page centre however wide the logo happens to be.
 *
 * flex-basis 0 on both sides is what does it. Without a floor under the logo the cell is free
 * to collapse to nothing, and a wordmark that has been told to scale then disappears rather
 * than overflowing - which is worse, because nothing looks broken.
 */
.wpp-nav__side {
	flex: 1 1 0;
	display: flex;
	align-items: center;
	gap: 1.5rem;
	min-width: 0;
}
.wpp-nav__side--end { justify-content: flex-end; }

.wpp-nav__logo { display: block; flex: 0 1 auto; min-width: 0; }
.wpp-nav__logo img {
	height: var(--wpp-nav-logo-height);
	width: auto;
	max-width: 100%;
	object-fit: contain;
	object-position: left center;
	display: block;
}
.wpp-nav__logo--text {
	font-family: var(--wpp-nav-logo-font);
	font-weight: 800;
	font-size: 1.1rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
}

/* ---- search ---- */

.wpp-nav__search {
	flex: 2 1 22rem;
	display: flex;
	align-items: stretch;
	min-width: 0;
	border: var(--wpp-nav-edge-width) solid var(--wpp-nav-edge);
	border-radius: var(--wpp-radius-control);
	overflow: hidden;
	background: transparent;
}
.wpp-nav__search input[type="search"] {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	padding: 0.7rem 1rem;
	outline-offset: -3px;
}
.wpp-nav__search input::placeholder { color: inherit; opacity: 0.55; }
.wpp-nav__search button {
	flex: 0 0 auto;
	border: 0;
	background: var(--wpp-nav-edge);
	color: var(--wpp-nav-bg);
	cursor: pointer;
	padding: 0 0.9rem;
	display: inline-flex;
	align-items: center;
}

/* ---- account and basket ---- */

.wpp-nav__action {
	color: inherit;
	text-decoration: none;
	font-size: 0.74rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	font-weight: 700;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
}
.wpp-nav__action:hover { opacity: 0.6; }
.wpp-nav__count { font-weight: 700; }

/* ------------------------------------------------------------- the navigation band */

/*
 * A band of its own, with the same heavy rule above it as the one under the whole header, so it
 * reads as its own row rather than as something tacked onto the bottom of the logo bar.
 */
.wpp-nav__menu { border-top: var(--wpp-nav-edge-width) solid var(--wpp-nav-edge); }
.wpp-nav__menu .wpp-nav__inner {
	gap: 0.25rem;
	align-items: stretch;
	/* Sideways rather than wrapping to two rows, which would eat a third of a phone screen
	   before any content. */
	overflow-x: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
}
.wpp-nav__menu .wpp-nav__inner::-webkit-scrollbar { display: none; }

.wpp-nav__ulist {
	display: flex;
	align-items: stretch;
	gap: 0.25rem;
	list-style: none;
	margin: 0;
	padding: 0;
	/*
	 * Centred when the row fits, scrolling from the LEFT when it does not.
	 *
	 * auto margins do this properly: they take the spare space when there is some and collapse
	 * to zero when there is not. justify-content:center centres it too, but once the row
	 * overflows it pushes the first item off the left edge where it cannot be scrolled back to.
	 */
	margin-inline: auto;
}
.wpp-nav__ulist li { margin: 0; }
.wpp-nav__ulist a {
	display: inline-flex;
	align-items: center;
	font-family: var(--wpp-nav-menu-font);
	padding: 0.62rem 0.95rem;
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
	font-size: var(--wpp-nav-menu-size);
	letter-spacing: var(--wpp-nav-menu-spacing);
	font-weight: var(--wpp-nav-menu-weight);
	text-transform: var(--wpp-nav-menu-case);
	border-bottom: var(--wpp-nav-edge-width) solid transparent;
}
.wpp-nav__ulist a:hover { opacity: 0.55; }
/* Where you are, marked by the rule under it rather than by a colour. WordPress puts these
   classes on the item itself, so the anchor is reached through its parent. */
.wpp-nav__ulist .current-menu-item > a,
.wpp-nav__ulist .current-menu-ancestor > a,
.wpp-nav__ulist .current_page_item > a {
	border-bottom-color: currentColor;
}

/* The utility strip's list is a plain row, not a set of tabs. */
.wpp-nav__utility .wpp-nav__ulist a {
	padding: 0.2rem 0;
	border: 0;
	font-size: inherit;
	letter-spacing: normal;
	text-transform: none;
	font-weight: 400;
	text-decoration: underline;
}

/* ----------------------------------------------------------------------- the phone */

.wpp-nav__burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 4px;
	width: 2.4rem;
	height: 2.4rem;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	cursor: pointer;
}
.wpp-nav__burger span {
	display: block;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

.wpp-nav__drawer {
	border-top: 1px solid var(--wpp-nav-edge);
	padding: 0.4rem var(--wpp-nav-pad) 1rem;
}
.wpp-nav__drawer .wpp-nav__ulist {
	flex-direction: column;
	align-items: stretch;
	gap: 0;
	margin-inline: 0;
}
.wpp-nav__drawer .wpp-nav__ulist a {
	padding: 0.7rem 0;
	border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
	width: 100%;
}

/* What the bar had no room for: the account link, and whatever the shop put in the slot. */
.wpp-nav__drawer-rest { padding-top: 0.6rem; }
.wpp-nav__drawer-link {
	display: block;
	padding: 0.7rem 0;
	color: inherit;
	text-decoration: none;
	font-size: 0.74rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	font-weight: 700;
	border-bottom: 1px solid color-mix(in srgb, currentColor 14%, transparent);
}
.wpp-nav__drawer-extra { padding-top: 0.9rem; }
.wpp-nav__drawer-extra select { max-width: 100%; }

@media (max-width: 900px) {
	.wpp-nav__inner { gap: 0.6rem; }
	.wpp-nav__bar .wpp-nav__inner { flex-wrap: wrap; }
	.wpp-nav__burger { display: flex; }
	.wpp-nav__side { flex: 1 1 0; min-width: 0; }

	/*
	 * THE WORDMARK IS CENTRED ON THE BAR, NOT ON WHAT IS LEFT OVER.
	 *
	 * In the flow it sat beside the burger, so it centred itself in whatever space the burger
	 * and the basket happened to leave - which is never the middle, and it read as pushed to
	 * the right. Out of the flow and pinned to 50% it is actually central at every width.
	 *
	 * Pinned to the FIRST ROW, not to the box: the search wraps below, so centring vertically
	 * on the whole inner would drop the wordmark between the two rows.
	 */
	.wpp-nav__logo {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		top: 0.85rem;                     /* the inner's own padding-top */
		height: 2.4rem;                   /* the burger's height, so it shares that row */
		display: flex;
		align-items: center;
		max-width: calc(100% - 10rem);    /* never under the burger or the basket */
	}
	.wpp-nav__logo img { object-position: center; }

	/*
	 * Account leaves the bar and turns up in the drawer.
	 *
	 * It was wrapping onto a second row with the basket, which reads as an accident rather
	 * than a design. The basket stays because it carries a count somebody is watching.
	 */
	.wpp-nav__side--end .wpp-nav__action:not(.wpp-nav__cart) { display: none; }

	.wpp-nav__search { order: 3; flex: 1 1 100%; }

	/* The band goes; every item is in the drawer, and two scrolling rows on a phone is one
	   too many. */
	.wpp-nav__menu { display: none; }
}

/* -------------------------------------------------------------------------- footer */

.wpp-footer {
	background: var(--wpp-footer-bg);
	color: var(--wpp-footer-ink);
	font-family: var(--wpp-footer-font);
}
.wpp-footer__inner {
	max-width: var(--wpp-container);
	margin: 0 auto;
	padding: 0 var(--wpp-nav-pad);
}

/*
 * The promises row, styled for the footer.
 *
 * The product page's version of this is scoped to `.wpp .wpp-product`, and the footer is not
 * inside either - so it arrived as four stacked blocks 5,688px tall. A shared component being
 * styled only where it was first used is exactly the trap this plugin exists to avoid, so the
 * footer states its own layout rather than the product page loosening its scope and repainting
 * something it cannot see.
 */
.wpp-footer .wpp-promises {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	background: var(--wpp-footer-strip-bg);
	color: var(--wpp-footer-strip-ink);
	margin: 0;
	border: 0;
	border-radius: 0;
	overflow: hidden;
}
.wpp-footer .wpp-promise {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.55rem;
	padding: 0.95rem 1rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: inherit;
	text-align: center;
	/* A divider that is not there on the first of a row: one side only, and the strip clips
	   the leftmost one away. */
	box-shadow: -1px 0 0 0 color-mix(in srgb, currentColor 22%, transparent);
}
.wpp-footer .wpp-promise__icon {
	flex: 0 0 auto;
	width: 1.15em;
	height: 1.15em;
	opacity: 0.85;
}

.wpp-footer__cols .wpp-footer__inner {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	gap: 1.6rem 2rem;
	padding-top: 2.6rem;
	padding-bottom: 2.6rem;
}
.wpp-footer__h {
	margin: 0 0 0.6rem;
	color: var(--wpp-footer-head-ink);
	font-size: 0.72rem;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	font-weight: 800;
}
.wpp-footer__col ul { list-style: none; margin: 0; padding: 0; }
.wpp-footer__col li { margin: 0 0 0.42rem; }
.wpp-footer__col a {
	color: inherit;
	text-decoration: none;
	font-size: 0.88rem;
	line-height: 1.5;
}
.wpp-footer__col a:hover { color: var(--wpp-footer-head-ink); text-decoration: underline; }

.wpp-footer__base .wpp-footer__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	flex-wrap: wrap;
	padding-top: 1.2rem;
	padding-bottom: 1.6rem;
	border-top: 1px solid color-mix(in srgb, currentColor 16%, transparent);
	font-size: 0.8rem;
}
.wpp-footer__mark {
	font-family: var(--wpp-footer-mark-font);
	color: var(--wpp-footer-head-ink);
	font-weight: 800;
	letter-spacing: 0.18em;
	text-transform: uppercase;
}
