/**
 * Revita: header parts (header.html, header-compact.html).
 * Purple honeycomb top bar, gradient navigation bar, one-row compact layout,
 * brand fallback (site title as a honey wordmark until a logo is set), phone,
 * account and cart icons, and the white compact header. Animated scroll states
 * and the sticky wrapper belong to the motion system (components/header-motion.css);
 * menus are in navigation.css.
 *
 * Desktop layout from 1100px wide (and taller than 500px): top bar plus the full menu.
 * Below that, and on short landscape screens, one 60px bar: logo, account, cart and the
 * menu button. The same switch is used in navigation.css.
 *
 * @package Revita
 */

.revita-header {
	position: relative;
	z-index: var(--wp--custom--z--header, 50);
}

/* Top bar: every background layer tiles, so a honeycomb drift never shows a seam. */
.revita-header .revita-header__top {
	background-color: var(--wp--preset--color--primary);
	background-image: url("../../images/honeycomb-dense.svg"), linear-gradient(90deg, var(--wp--preset--color--primary-deep), var(--wp--preset--color--primary) 50%, var(--wp--preset--color--primary-deep));
	background-size: 48px 28px, 100% 100%;
	color: var(--wp--preset--color--base);
}

.revita-header :is(.revita-header__top-inner, .revita-header__bar-inner),
.revita-header .revita-header__nav-inner {
	align-items: center;
}

.revita-header .revita-header__top-inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.revita-header__social { justify-self: start; }
.revita-header__top-inner > .revita-header__brand { justify-self: center; align-items: center; }
.revita-header__contact { justify-self: end; }

.revita-header .revita-header__social .wp-social-link a {
	display: grid;
	place-items: center;
	inline-size: 2.25rem;
	block-size: 2.25rem;
	padding: 0;
	border-radius: 50%;
}

.revita-header .revita-header__social .wp-social-link a:hover {
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 16%, transparent);
	color: var(--wp--preset--color--accent);
}

/* Brand. The desktop logo sits in a picture that skips the download in the compact layout
 * (inc/setup.php); the picture box itself takes no part in the layout. */
.revita-header .wp-block-site-logo picture {
	display: contents;
}

.revita-header .wp-block-site-logo img {
	display: block;
	block-size: auto;
}

.revita-header__top .wp-block-site-logo img {
	filter: drop-shadow(0 8px 16px color-mix(in srgb, var(--wp--preset--color--primary-dark) 40%, transparent));
}

/* The site title is the brand only while no logo is set: then it is a one-line honey wordmark
 * that never wraps and, when the name is long, ends in an ellipsis instead of pushing the
 * account, cart and menu buttons out of the bar. */
.revita-header__title {
	min-inline-size: 0;
	max-inline-size: 100%;
	margin: 0;
	overflow: hidden;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 800;
	line-height: 1.1;
	letter-spacing: -0.02em;
	text-overflow: ellipsis;
	text-transform: lowercase;
	white-space: nowrap;
	color: var(--wp--preset--color--accent);
}

.revita-header--compact .revita-header__brand {
	flex: 0 1 auto;
	min-inline-size: 0;
}

.revita-header--compact .revita-header__title {
	font-size: var(--wp--preset--font-size--large);
	color: var(--wp--preset--color--primary);
}

@media (max-width: 599.98px) {
	.revita-header--compact .revita-header__title {
		font-size: var(--wp--preset--font-size--medium);
	}
}

/* With a logo, the logo names the brand at every width: its home link is called
 * "<site title>" (the logo's alt text), so the title would only repeat it for screen readers
 * and has no room beside the 46px logo and three buttons on a 360px phone. */
.revita-header__brand:has(.wp-block-site-logo img) .revita-header__title {
	display: none;
}

/* Phone: a bound button reset to a text link with a honey call badge. */
:is(.revita-header, .revita-footer-minimal) .revita-phone-link .wp-block-button__link {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 0.65em;
	box-sizing: border-box;
	min-block-size: 2.75rem;
	padding: 0;
	border-radius: 0;
	background: none;
	color: inherit;
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
}

.revita-phone-link .wp-block-button__link::before {
	content: "";
	inline-size: 2.25rem;
	block-size: 2.25rem;
	border-radius: 50%;
	background-color: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--wp--preset--color--accent) 22%, transparent);
}

.revita-phone-link .wp-block-button__link::after {
	content: "";
	position: absolute;
	inset-inline-start: 0.5625rem;
	inset-block-start: calc(50% - 0.5625rem);
	inline-size: 1.125rem;
	block-size: 1.125rem;
	background-color: var(--wp--preset--color--primary-deep);
	-webkit-mask: url("../../images/icons/phone.svg") center / contain no-repeat;
	mask: url("../../images/icons/phone.svg") center / contain no-repeat;
}

.revita-phone-link .wp-block-button__link:hover::before {
	background-color: var(--wp--preset--color--base);
}

/* Account and cart icons. */
.revita-header :is(.wc-block-customer-account__link, .wc-block-mini-cart__button) {
	display: inline-grid;
	place-items: center;
	inline-size: 2.75rem;
	block-size: 2.75rem;
	padding: 0;
	border-radius: 50%;
	color: inherit;
	text-decoration: none;
}

.revita-header .wc-block-customer-account__link svg {
	inline-size: 1.5rem;
	block-size: 1.5rem;
}

.revita-header :is(.wc-block-customer-account__link, .wc-block-mini-cart__button):hover {
	background-color: color-mix(in srgb, currentColor 14%, transparent);
}

.revita-header .wc-block-mini-cart__badge {
	background-color: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--primary-deep);
	font-weight: 700;
}

/* Navigation bar (positioned: the scrolled glass layer is its ::before). */
.revita-header .revita-header__nav {
	position: relative;
	background: linear-gradient(90deg, var(--wp--preset--color--primary-deep), var(--wp--preset--color--primary));
	color: var(--wp--preset--color--base);
}

.revita-header .revita-header__nav-inner {
	min-block-size: var(--wp--custom--header--height-compact, 60px);
}

/* Compact header: white row; glass when scrolled, painted on ::before so the
 * fixed mobile menu inside never gets a filtered ancestor. */
.revita-header--compact .revita-header__bar {
	position: relative;
	isolation: isolate;
	color: var(--wp--preset--color--primary-deep);
}

.revita-header--compact .revita-header__bar::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-block-end: 1px solid var(--wp--preset--color--border);
	background-color: var(--wp--preset--color--base);
}

.revita-header--compact.is-scrolled .revita-header__bar::before {
	border-block-end-color: transparent;
	background-color: color-mix(in srgb, var(--wp--preset--color--base) 78%, transparent);
	box-shadow: var(--wp--preset--shadow--soft);
	-webkit-backdrop-filter: blur(14px) saturate(140%);
	backdrop-filter: blur(14px) saturate(140%);
}

.revita-header--compact .revita-header__bar-inner {
	min-block-size: calc(var(--wp--custom--header--height, 76px) - 1rem);
}

/* Desktop: menu in the middle column, actions at the end. The bar's own account icon is
 * for the compact layout only (the top bar has one), and so is its small logo, until the
 * sticky header has tucked the top bar away (motion system): then it fills the start column. */
@media (min-width: 1100px) and (min-height: 501px) {
	.revita-header :is(.revita-header__nav-inner, .revita-header__bar-inner) {
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
	}

	.revita-header .revita-header__menu { grid-column: 2; }
	.revita-header .revita-header__actions { grid-column: 3; justify-self: end; }

	.revita-header__nav .revita-header__actions .wp-block-woocommerce-customer-account,
	.revita-header:not(.is-scrolled) .revita-header__nav .revita-header__mobile-logo,
	body:not(.revita-sticky-header) .revita-header__nav .revita-header__mobile-logo {
		display: none;
	}

	.revita-header .revita-header__nav .revita-header__mobile-logo {
		grid-column: 1;
		justify-self: start;
	}
}

/* Compact (phones, landscape phones, tablets, small laptops): no top bar; logo left;
 * account, cart and menu button right. */
@media (max-width: 1099.98px), (max-height: 500px) {
	.revita-header .revita-header__top { display: none; }
	.revita-header .revita-header__mobile-logo { margin-inline-end: auto; }
	.revita-header .revita-header__actions { order: 1; margin-inline-start: auto; }
	.revita-header .revita-header__menu { order: 2; }
}

/* Expandable search (compact header): the field floats under the button. */
.revita-header__search {
	position: relative;
}

.revita-header__search .wp-block-search__button {
	inline-size: 2.75rem;
	block-size: 2.75rem;
	margin: 0;
	padding: 0;
	border-radius: 50%;
	background: none;
	color: inherit;
}

.revita-header__search .wp-block-search__button:hover {
	background-color: var(--wp--preset--color--lavender);
}

.revita-header__search:not(.wp-block-search__searchfield-hidden) .wp-block-search__input {
	position: absolute;
	inset-block-start: calc(100% + 0.5rem);
	inset-inline-end: 0;
	z-index: var(--wp--custom--z--floating, 60);
	inline-size: min(20rem, 86vw);
	box-shadow: var(--wp--preset--shadow--card);
}

/* Focus: the theme ring (global.css) takes its colours from the surface: Honey Cream on the
 * purple bars, Deep Purple on the white compact bar. */

/* A little phone "ring" on hover. */
@media (prefers-reduced-motion: no-preference) {
	body:not(.revita-motion-off) .revita-phone-link .wp-block-button__link:hover::after {
		animation: revita-ring 0.6s var(--wp--custom--motion--easing--honey);
	}
}

@keyframes revita-ring {
	25% { transform: rotate(-14deg); }
	50% { transform: rotate(12deg); }
	75% { transform: rotate(-8deg); }
}
