/**
 * Revita: card grids (hidden-post-grid, hidden-post-card, health-article cards).
 * White post cards with an image that zooms on hover and the title link stretched
 * over the card (honeycomb placeholder without an image; the newest post becomes a
 * wide feature card on the blog index), hexagon health-article cards, section
 * titles, pagination and the empty state.
 *
 * @package Revita
 */

.wp-block-query:is(.revita-post-grid, .revita-service-archive) {
	margin-block-start: var(--wp--preset--spacing--60);
}

.wp-block-heading.revita-section-title {
	margin-block-end: var(--wp--preset--spacing--50);
}

/* Shared card surface. */
:is(.revita-post-card, .revita-service-card) {
	position: relative;
	block-size: 100%;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--lg);
	background-color: var(--wp--preset--color--base);
	box-shadow: var(--wp--preset--shadow--soft);
	transition: transform var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing--honey);
}

/* The lifted shadow fades in on its own layer (only opacity animates). */
:is(.revita-post-card, .revita-service-card)::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: var(--wp--preset--shadow--lifted);
	opacity: 0;
	transition: opacity var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing--standard);
	pointer-events: none;
}

:is(.revita-post-card, .revita-service-card):hover::after {
	opacity: 1;
}

/* Post card. */
.revita-post-card {
	display: flex;
	flex-direction: column;
	padding: var(--wp--preset--spacing--30);
}

.wp-block-post-featured-image.revita-post-card__media {
	margin: 0 0 var(--wp--preset--spacing--30);
	border-radius: var(--wp--custom--radius--md);
	background-color: var(--wp--preset--color--lavender);
	overflow: hidden;
}

.revita-post-card__media img {
	display: block;
	border-radius: inherit;
	transition: transform var(--wp--custom--motion--duration--slow) var(--wp--custom--motion--easing--honey);
}

.revita-post-card:not(:has(.revita-post-card__media))::before {
	content: "";
	aspect-ratio: 3 / 2;
	margin-block-end: var(--wp--preset--spacing--30);
	border-radius: var(--wp--custom--radius--md);
	background: url("../../images/revita-bee.svg") center / 24% auto no-repeat, url("../../images/honeycomb-purple.svg") 0 0 / 84px 48px, var(--wp--preset--gradient--sunrise);
}

.revita-post-card__body {
	flex: 1;
}

.revita-post-card__body > * {
	margin: 0;
}

.revita-post-card__kicker {
	position: relative;
	z-index: 2;
}

.revita-post-card__title {
	line-height: 1.25;
	text-wrap: balance;
}

.revita-post-card__title a {
	color: var(--wp--preset--color--primary-deep);
	text-decoration: none;
}

.revita-post-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	border-radius: var(--wp--custom--radius--lg);
}

.revita-post-card:hover .revita-post-card__title a {
	color: var(--wp--preset--color--primary);
}

:is(.revita-post-card__excerpt, .revita-service-card__excerpt) {
	color: var(--wp--preset--color--muted);
}

:is(.revita-post-card__excerpt, .revita-service-card__excerpt) p {
	margin: 0;
}

.revita-post-card__date {
	margin-block-start: auto;
	padding-block-start: var(--wp--preset--spacing--20);
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
}

/* Search results: products show their category, price, stock and order button instead of a date.
 * The row sits above the stretched title link, so the button stays clickable. */
.revita-post-card__shop {
	position: relative;
	z-index: 2;
	margin-block-start: auto;
	padding-block-start: var(--wp--preset--spacing--20);
}

.revita-post-card__shop:not(:has(*)) {
	display: none;
}

.revita-post-card__price {
	color: var(--wp--preset--color--primary-deep);
	font-family: var(--wp--preset--font-family--heading);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
}

.revita-post-card__stock {
	flex-basis: 100%;
	order: 3;
	margin: 0;
	font-size: var(--wp--preset--font-size--small);
}

.wp-block-post.type-product .revita-post-card__date {
	display: none;
}

/* Product packshots whole on cream, as on the shop cards (no 3:2 crop of cans and sachets).
 * The featured-image block prints "aspect-ratio:3/2;object-fit:cover" inline on the img
 * (aspectRatio attribute), so contain needs !important to win; the 3:2 box itself stays. */
.wp-block-post.type-product .wp-block-post-featured-image.revita-post-card__media {
	background-color: var(--wp--preset--color--cream);
}

.wp-block-post.type-product .revita-post-card__media img {
	box-sizing: border-box;
	padding: 8%;
	object-fit: contain !important;
	mix-blend-mode: multiply;
}

/* Keyboard focus on the title link rings the whole card (the theme ring, global.css). */
@supports selector(:has(*)) {
	.revita-post-card:has(.revita-post-card__title a:focus-visible) {
		outline: 2px solid var(--revita-focus, var(--wp--preset--color--primary-deep));
		outline-offset: 3px;
		box-shadow: 0 0 0 3px var(--revita-focus-ring, var(--wp--preset--color--base)), var(--wp--preset--shadow--soft);
	}

	.revita-post-card__title a:focus-visible {
		outline: none;
	}
}

/* Blog index: the newest post is a wide feature card (first page only). */
@media (min-width: 782px) {
	body:not(.paged) .revita-blog-index .revita-post-grid__items > li:first-child {
		grid-column: 1 / -1;
	}

	body:not(.paged) .revita-blog-index .revita-post-grid__items > li:first-child .revita-post-card {
		display: grid;
		grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
		align-items: center;
		column-gap: var(--wp--preset--spacing--60);
		padding: var(--wp--preset--spacing--40);
	}

	body:not(.paged) .revita-blog-index .revita-post-grid__items > li:first-child .revita-post-card__media,
	body:not(.paged) .revita-blog-index .revita-post-grid__items > li:first-child .revita-post-card::before {
		margin: 0;
	}

	body:not(.paged) .revita-blog-index .revita-post-grid__items > li:first-child .revita-post-card__title {
		font-size: var(--wp--preset--font-size--x-large) !important;
	}
}

/* Hexagon media on a honey offset hexagon. */
.revita-hex-media {
	position: relative;
	isolation: isolate;
	margin: 0;
}

.revita-hex-media img {
	display: block;
	inline-size: 100%;
	block-size: auto;
	aspect-ratio: 1.1547;
	object-fit: cover;
	border-radius: 0;
}

.revita-hex-media img,
.revita-hex-media::before {
	-webkit-mask: url("../../images/hexagon.svg") center / 100% 100% no-repeat;
	mask: url("../../images/hexagon.svg") center / 100% 100% no-repeat;
}

.revita-hex-media::before {
	content: "";
	position: absolute;
	z-index: -1;
	inset: 8% -6% -8% 6%;
	background: var(--wp--preset--gradient--honey);
}

/* Health-article card. */
.revita-service-card {
	padding: var(--wp--preset--spacing--40) var(--wp--preset--spacing--30);
	text-align: center;
}

.revita-service-card > * {
	margin: 0;
}

/* The honey offset hexagon (::before, 8% lower than the image) needs room above the title.
 * Two classes, so it beats core's "body .is-layout-flex > * { margin: 0 }". */
.revita-service-card .revita-service-card__media {
	inline-size: min(76%, 15rem);
	margin-block-end: calc(var(--wp--preset--spacing--20) + 1.1rem);
}

.revita-service-card:not(:has(.revita-service-card__media))::before {
	content: "";
	inline-size: min(64%, 12rem);
	aspect-ratio: 1.1547;
	background: url("../../images/revita-bee.svg") center / 46% auto no-repeat, var(--wp--preset--color--lavender-strong);
	-webkit-mask: url("../../images/hexagon.svg") center / 100% 100% no-repeat;
	mask: url("../../images/hexagon.svg") center / 100% 100% no-repeat;
}

.revita-service-card__title {
	line-height: 1.3;
	text-wrap: balance;
}

/* A taller hit area around one-line titles, without changing the layout (WCAG 2.5.8). */
.revita-service-card__title a {
	display: inline-block;
	padding-block: 0.25rem;
	margin-block: -0.25rem;
	color: var(--wp--preset--color--primary-deep);
	text-decoration: none;
}

.revita-service-card__title a:hover {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
}

.revita-service-card .revita-service-card__more {
	display: inline-flex;
	align-items: center;
	gap: 0.45em;
	margin-block-start: auto;
	padding-block-start: var(--wp--preset--spacing--20);
}

/* Phones and touch screens: the link is a 44px tall target with the text in the middle, in every
 * card layout (the compact phone cards below set the same). The half of the 44px row above the
 * text replaces the spacing above it. */
@media (max-width: 781.98px), (pointer: coarse) {
	.revita-service-card .revita-service-card__more {
		min-block-size: 2.75rem;
		padding-block-start: 0;
	}
}

/* Phones: compact horizontal cards (96px hexagon at the start, title, two lines of
 * excerpt and the link beside it), so 13 health articles are not nine screens long. */
@media (max-width: 599px) {
	.revita-service-grid .revita-service-card {
		display: grid;
		grid-template-columns: 6rem minmax(0, 1fr);
		grid-template-areas:
			"media title"
			"media excerpt"
			"media more";
		align-content: center;
		align-items: center;
		column-gap: var(--wp--preset--spacing--40);
		row-gap: var(--wp--preset--spacing--10);
		padding: var(--wp--preset--spacing--30);
		text-align: start;
	}

	.revita-service-grid .revita-service-card .revita-service-card__media,
	.revita-service-grid .revita-service-card:not(:has(.revita-service-card__media))::before {
		grid-area: media;
		align-self: center;
		inline-size: 6rem;
		margin: 0;
	}

	.revita-service-grid .revita-service-card .revita-service-card__title {
		grid-area: title;
		text-align: start;
	}

	.revita-service-grid .revita-service-card .revita-service-card__excerpt {
		grid-area: excerpt;
		text-align: start;
	}

	.revita-service-grid .revita-service-card .revita-service-card__excerpt p {
		display: -webkit-box;
		overflow: hidden;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		line-clamp: 2;
	}

	.revita-service-grid .revita-service-card .revita-service-card__more {
		grid-area: more;
		justify-self: start;
		min-block-size: 44px;
		padding-block-start: 0;
	}
}

.revita-service-card__more::after {
	content: "";
	inline-size: 1em;
	block-size: 1em;
	background-color: currentColor;
	-webkit-mask: url("../../images/icons/arrow-right.svg") center / contain no-repeat;
	mask: url("../../images/icons/arrow-right.svg") center / contain no-repeat;
	transition: transform var(--wp--custom--motion--duration--base) var(--wp--custom--motion--easing--honey);
}

/* Pagination and empty state. */
.wp-block-query-pagination.revita-pagination {
	gap: var(--wp--preset--spacing--20);
	margin-block-start: var(--wp--preset--spacing--60);
}

.revita-pagination :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-next) {
	padding: 0.55em 1.2em;
	border: 1.5px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--primary-deep);
	text-decoration: none;
}

.revita-pagination :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-next):hover {
	background-color: var(--wp--preset--color--lavender);
}

/* Phones and touch screens: page numbers and the previous/next pills are 44px tall targets with the
 * label in the middle (THEME_SPEC section 16); the numbers are already wider than that. */
@media (max-width: 781.98px), (pointer: coarse) {
	.wp-block-query-pagination.revita-pagination .page-numbers {
		min-block-size: 2.75rem;
	}

	.wp-block-query-pagination.revita-pagination :is(.wp-block-query-pagination-previous, .wp-block-query-pagination-next) {
		display: inline-flex;
		box-sizing: border-box;
		align-items: center;
		min-block-size: 2.75rem;
	}
}

.revita-empty-state {
	border-radius: var(--wp--custom--radius--xl);
	background: url("../../images/honeycomb-purple.svg") 0 0 / 84px 48px, var(--wp--preset--color--lavender);
}

.wp-block-search.revita-empty-state__search {
	margin-block-start: var(--wp--preset--spacing--40);
}

/* Motion: lift, image zoom, arrow nudge. */
@media (prefers-reduced-motion: no-preference) {
	body:not(.revita-motion-off) :is(.revita-post-card, .revita-service-card):hover {
		transform: translateY(-4px);
	}

	body:not(.revita-motion-off) .revita-post-card:hover .revita-post-card__media img {
		transform: scale(1.04);
	}

	body:not(.revita-motion-off) .revita-service-card:hover .revita-service-card__more::after {
		transform: translateX(4px);
	}
}
