/**
 * Revita: page header bands (.revita-page-header) and the 404 section.
 * Lavender honeycomb band with a soft honey hexagon, breadcrumbs, kicker, title,
 * lead and article meta. Variants: --center (pages, posts), --article (featured
 * image overlaps the band), --service (hexagon image on the band edge), --search.
 *
 * @package Revita
 */

:is(.revita-page-header, .revita-404) {
	position: relative;
	isolation: isolate;
	overflow-x: clip;
}

.wp-block-group.revita-page-header > * {
	position: relative;
	z-index: 1;
	margin-block: 0;
}

:is(.wp-block-group.revita-page-header, .revita-page-header__inner) > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

/* A large soft honey hexagon drifting off the inline end. It is sized by the band's height
 * too, so it never spills below a short band onto the white page. */
.revita-page-header::after {
	content: "";
	position: absolute;
	inset-block-start: 50%;
	inset-inline-end: -6vw;
	inline-size: auto;
	block-size: min(calc(clamp(11rem, 30vw, 26rem) / 1.1547), 92%);
	aspect-ratio: 1.1547;
	background: var(--wp--preset--gradient--honey);
	opacity: 0.18;
	transform: translateY(-50%) rotate(-8deg);
	-webkit-mask: url("../../images/hexagon.svg") center / contain no-repeat;
	mask: url("../../images/hexagon.svg") center / contain no-repeat;
	pointer-events: none;
}

/* Breadcrumbs. */
.revita-page-header .wp-block-breadcrumbs {
	font-weight: 600;
	letter-spacing: 0.02em;
}

.revita-page-header .wp-block-breadcrumbs a {
	padding-block: 0.375rem;
	margin-block: -0.375rem;
	color: var(--wp--preset--color--primary);
}

.revita-page-header .wp-block-breadcrumbs li:not(:last-child)::after {
	color: var(--wp--preset--color--accent-deep);
	opacity: 1;
}

.revita-page-header--center .wp-block-breadcrumbs ol {
	justify-content: center;
}

/* Phones: the trail stays on one line; long items end in an ellipsis. On posts and health
 * articles the current page is left out, because its title follows right below as the H1. */
@media (max-width: 781px) {
	.revita-page-header .wp-block-breadcrumbs ol {
		flex-wrap: nowrap;
	}

	.revita-page-header .wp-block-breadcrumbs li {
		min-inline-size: 0;
	}

	.revita-page-header .wp-block-breadcrumbs li:first-child,
	.revita-page-header .wp-block-breadcrumbs li::after {
		flex-shrink: 0;
	}

	.revita-page-header .wp-block-breadcrumbs li > :is(a, span) {
		min-inline-size: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	:is(.revita-page-header--article, .revita-page-header--service) .wp-block-breadcrumbs li:last-child:has(> [aria-current]) {
		display: none;
	}

	:is(.revita-page-header--article, .revita-page-header--service) .wp-block-breadcrumbs li:has(+ li:last-child > [aria-current])::after {
		content: none;
	}
}

/* Phones and touch screens: every link is a 44px target (THEME_SPEC section 16), with the text in the
 * middle; a short one ("Блог") is 44px wide too. The links still reach 0.375rem past the trail's row
 * above and below, inside the band's padding and the gap to the next line, so the row grows by
 * about 10px and never overlaps the kicker or the title below. Long items keep their ellipsis. */
@media (max-width: 781.98px), (pointer: coarse) {
	.revita-page-header .wp-block-breadcrumbs li > a {
		min-inline-size: 2.75rem;
		padding-block: calc((2.75rem - 1lh) / 2);
		text-align: center;
	}
}

/* Kicker: the shared .revita-kicker style is in global.css (cards use it too). */
.revita-page-header--center .revita-kicker {
	text-align: center;
}

/* Title, lead and meta. */
.revita-page-header__title {
	max-inline-size: 52rem;
	letter-spacing: -0.02em;
	text-wrap: balance;
}

.revita-page-header__lead {
	max-inline-size: 42rem;
	color: var(--wp--preset--color--muted);
	line-height: 1.55;
}

.revita-page-header__lead p {
	margin: 0;
}

.revita-page-header--center :is(.revita-page-header__title, .revita-page-header__lead) {
	margin-inline: auto;
}

.revita-page-header__lead:has(> .wp-block-post-excerpt__excerpt:empty) {
	display: none;
}

/* Page content that opens with a full-width section starts right under the band; the
 * section's own top padding is trimmed, so the white gap is about 48px on phones
 * (88px on wide screens) instead of 96 to 180px. */
.revita-page-header + .wp-block-post-content:has(> .wp-block-group.alignfull:first-child) {
	margin-block-start: 0 !important;
}

.revita-page-header + .wp-block-post-content > .wp-block-group.alignfull:first-child {
	padding-block-start: var(--wp--preset--spacing--70) !important;
}

/* The title and lead are never hidden by an entrance animation (they are the first thing
 * on screen and often the LCP element). They paint at once and only settle 0.3em upwards. */
@media (prefers-reduced-motion: no-preference) {
	body:not(.revita-motion-off) .revita-page-header :is(.revita-page-header__title, .revita-page-header__lead) {
		animation: revita-band-settle var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--easing--emphasized) both;
	}

	body:not(.revita-motion-off) .revita-page-header .revita-page-header__lead {
		animation-delay: 80ms;
	}
}

@keyframes revita-band-settle {
	from {
		translate: 0 0.3em;
	}
}

.revita-meta {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
}

.revita-meta > * {
	display: inline-flex;
	align-items: center;
	margin: 0;
}

.revita-meta > * + *::before {
	content: "";
	inline-size: 0.45em;
	block-size: 0.4em;
	margin-inline-end: var(--wp--preset--spacing--20);
	background-color: var(--wp--preset--color--accent-deep);
	clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}

/* Article: the featured image overlaps the bottom of the band. */
.wp-block-post-featured-image.revita-article__image {
	position: relative;
	z-index: 2;
	margin-block-start: calc(-1 * var(--wp--preset--spacing--70));
	border-radius: var(--wp--custom--radius--lg);
	box-shadow: var(--wp--preset--shadow--card);
	overflow: hidden;
}

/* Health article: hexagon image hangs over the band's lower edge. */
.revita-service-hero__media {
	display: flex;
	justify-content: center;
}

.revita-service-hero__image {
	inline-size: min(100%, 26rem);
}

@media (min-width: 782px) {
	.wp-block-post-featured-image.revita-service-hero__image {
		margin-block-end: calc(-1 * var(--wp--preset--spacing--80));
	}
}

.revita-service-hero:not(:has(.revita-service-hero__image)) > .revita-service-hero__text {
	flex-basis: 100% !important;
}

.revita-service-hero:not(:has(.revita-service-hero__image)) > .revita-service-hero__media {
	display: none;
}

/* Search band. */
.revita-page-header__search {
	max-inline-size: 36rem;
}

.revita-page-header__count {
	display: inline-flex;
	padding: 0.4em 1em;
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--soft);
	color: var(--wp--preset--color--primary-deep);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
}

:is(.revita-page-header, .revita-404) :focus-visible {
	outline: 2px solid var(--revita-focus, var(--wp--preset--color--primary-deep));
	outline-offset: 3px;
}

/* 404: the lost bee. */
.revita-404__art {
	inline-size: min(100%, 30rem);
	margin-inline: auto;
}

.revita-404__svg {
	display: block;
	inline-size: 100%;
	block-size: auto;
	overflow: visible;
}

.wp-block-column.revita-404__content > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

.revita-404__text {
	color: var(--wp--preset--color--muted);
}

.revita-404__search {
	max-inline-size: 30rem;
}

.revita-404 :is(.revita-404__bee, .revita-404__question, .revita-404__wing) {
	transform-box: fill-box;
	transform-origin: center;
}

.revita-404 .revita-404__wing {
	transform-origin: 50% 100%;
}

@media (prefers-reduced-motion: no-preference) {
	body:not(.revita-motion-off) .revita-404__path {
		animation: revita-404-trail 2.4s linear infinite;
	}

	body:not(.revita-motion-off) .revita-404__bee {
		animation: revita-404-hover 3.2s var(--wp--custom--motion--easing--honey) infinite alternate;
	}

	body:not(.revita-motion-off) .revita-404__question {
		animation: revita-404-wonder 2.6s var(--wp--custom--motion--easing--honey) infinite alternate;
	}

	body.revita-motion-full .revita-404__wing {
		animation: revita-404-flutter 0.16s linear infinite alternate;
	}
}

@keyframes revita-404-trail { to { stroke-dashoffset: -48; } }
@keyframes revita-404-hover { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-10px) rotate(4deg); } }
@keyframes revita-404-wonder { from { transform: rotate(-6deg); } to { transform: rotate(8deg) translateY(-3px); } }
@keyframes revita-404-flutter { to { transform: scaleY(0.55); } }

@media (max-width: 781px) {
	.revita-404__art { inline-size: min(78%, 20rem); }
	.revita-404__content { text-align: center; }
	.revita-404__actions { justify-content: center; }
	.revita-404__search { margin-inline: auto; }
}
