/* Related recipes carousel and its card. */

.related-recipes {
	overflow: clip;
	/* 140 on both sides in the node, against the 140/120 of the default .section. */
	padding-block: var(--section-padding-start) var(--section-padding-start);
	--recipe-card-height: 400px;
}

/*
 * The contrast inversion between the two variants is intentional in the design: a white
 * card over gray, and a gray card over white.
 */
.related-recipes--gray {
	background-color: var(--color-surface-subtle);
	--recipe-card-bg: var(--color-surface);
}

.related-recipes--white {
	background-color: var(--color-surface);
	/* Light Gray in 789:54082, a step darker than the Gray 30 band of the gray variant. */
	--recipe-card-bg: var(--color-surface-muted);
}

.related-recipes__header {
	margin-block-end: var(--space-gap-section);
}

.related-recipes__item {
	width: 392px;
}

/*
 * The dots push the default centre of the arrows down by about 22px, and the node puts
 * them on the vertical centre of the card, so the offset is measured from the card.
 */
.related-recipes .carousel__nav {
	top: calc(var(--recipe-card-height) / 2 - 26px);
}

/* NAVEGAÇÃO sits at y 180 of the 440 carousel in 702:95570, 6px under the card centre. */
@media (min-width: 1024px) {
	.related-recipes .carousel__nav {
		top: calc(var(--recipe-card-height) / 2 - 20px);
	}
}

/* Card */

/*
 * Flex column, not block: Chrome lays the content of a <button> out in an anonymous box
 * that centres it vertically, which pushed the photo 49px down the card and left a white
 * strip above it. Flex takes that centring away.
 */
.recipe-card {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	height: var(--recipe-card-height);
	padding: 0;
	border-radius: var(--radius-card);
	background-color: var(--recipe-card-bg);
	overflow: hidden;
	text-align: center;
}

/* No featured image leaves an empty gray box, never an <img> with an empty src. */
.recipe-card__media {
	/* Context of the clip over the photo (media-motion.css). */
	position: relative;
	display: block;
	flex: none;
	height: 302px;
	background-color: var(--color-surface-subtle);
	overflow: hidden;
}

.recipe-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transform: scale(1);
	transition: transform var(--duration-thumb-hover) var(--ease-out);
}

/*
 * Zoom of the same photograph, not a photo swap: rendering both variants of node
 * 702:95563 side by side shows the same croissant, the same board and the same table,
 * only closer. Measured factors run from 1.196 to 1.205.
 */
.recipe-card:hover .recipe-card__image,
.recipe-card:focus-visible .recipe-card__image,
.recipe-card:hover .media-motion,
.recipe-card:focus-visible .media-motion {
	transform: scale(1.2);
}

/* The clip over the photo (media-motion.css) zooms with it. */
.recipe-card .media-motion {
	transition:
		opacity var(--duration-thumb-hover) var(--ease-out),
		transform var(--duration-thumb-hover) var(--ease-out);
}

/*
 * Anchored to the bottom and growing upwards over the photo, which is what the node
 * does: the card keeps its height and the photo window loses the difference.
 */
.recipe-card__band {
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: var(--space-1);
	min-height: 98px;
	padding: 20px;
	background-color: var(--recipe-card-bg);
}

.recipe-card__title {
	color: var(--color-title-card);
	font-family: var(--font-heading);
	font-size: var(--font-h5);
	font-weight: var(--weight-heading);
	line-height: var(--lh-heading);
	letter-spacing: var(--ls-heading);
	overflow-wrap: anywhere;
}

/*
 * Collapsed by grid rows rather than removed: the text stays in the DOM for a screen
 * reader, and 0fr to 1fr is the only way to animate to a height the content decides.
 */
.recipe-card__excerpt {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	color: var(--color-text);
	font-size: var(--font-p2);
	line-height: 1.4;
	transition: grid-template-rows var(--duration-thumb-hover) var(--ease-out),
		opacity var(--duration-thumb-hover) var(--ease-out);
}

.recipe-card__excerpt-text {
	overflow: hidden;
}

.recipe-card:hover .recipe-card__excerpt,
.recipe-card:focus-visible .recipe-card__excerpt {
	grid-template-rows: 1fr;
	opacity: 1;
}

/* Link variant, the /receitas/ listing (desktop-fidelity X1): the whole card is the link. */
.recipe-card--link .recipe-card__title {
	margin: 0;
}

@media (hover: none) {
	.recipe-card__excerpt {
		grid-template-rows: 1fr;
		opacity: 1;
	}

	.recipe-card:hover .recipe-card__image,
	.recipe-card:hover .media-motion {
		transform: scale(1);
	}
}

@media (prefers-reduced-motion: reduce) {
	.recipe-card__image,
	.recipe-card__excerpt {
		transition: none;
	}
}

@media (max-width: 1023px) {
	.related-recipes__item {
		width: 340px;
	}
}

@media (max-width: 767px) {
	.related-recipes {
		--recipe-card-height: 340px;
	}

	.related-recipes__item {
		width: min(84vw, 340px);
	}

	.recipe-card__media {
		height: 252px;
	}

	.recipe-card__band {
		min-height: 88px;
	}
}

@media (max-width: 479px) {
	.related-recipes {
		--recipe-card-height: 300px;
	}

	.related-recipes__item {
		width: min(84vw, 300px);
	}

	.recipe-card__media {
		height: 212px;
	}
}
