/**
 * Subpage section: Product cards (template-parts/sections/subpage/section-product_cards.php).
 *
 * A centred heading over a grid of full and half-width cards (two half cards
 * share a row from --bp-md). A card: a wash, a title, a text, a decorative
 * "Learn more", and a screenshot anchored to the card's bottom or inline-end
 * edge and cropped by the card. The title's link is stretched over the card.
 *
 * Measured from design/pages/products/products.png at 1:1 (CLAUDE.md 8.13).
 * Mobile (TODO, no frame): one column, every image below the text.
 */

.product-cards {
	--product-cards-max: 71.25rem;              /* ~1140px grid. TODO: verify in Figma */
	--product-cards-gap: 2.25rem;               /* ~36px between cards. TODO: verify in Figma */
	--product-card-wash-start: #fbf7f5;         /* Sampled: peach at the start edge. TODO: verify in Figma */
	--product-card-wash-end: #f8fbfe;           /* Sampled: pale blue at the end edge. TODO: verify in Figma */
	--product-card-pad: var(--space-lg);
	--product-card-pad-desktop: var(--space-xl); /* ~48px. TODO: verify in Figma */
	--product-card-title-size: 1.75rem;          /* ~28px, Montserrat 600 (notes). TODO: verify in Figma */
	--product-card-text-colour: var(--color-text-muted);
	--product-card-more-colour: var(--color-text-accent);
	--product-card-media-max: 12rem;             /* Visible screenshot height on a half card (~190px). TODO: verify in Figma */
	--product-card-media-end-max: 20rem;         /* A full card's screenshot (~320px). TODO: verify in Figma */
	--product-card-full-min: 21.875rem;          /* ~350px full card. TODO: verify in Figma */
	--product-card-half-min: 31.25rem;           /* ~500px half card. TODO: verify in Figma */
}

.product-cards__heading {
	margin: 0 0 var(--space-xl);
	text-align: center;
}

.product-cards__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--product-cards-gap);
	max-inline-size: var(--product-cards-max);
	margin: 0 auto;
	padding: 0;
	list-style: none;
}

.product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: linear-gradient(90deg, var(--product-card-wash-start), var(--product-card-wash-end));
}

.product-card:dir(rtl) {
	background: linear-gradient(270deg, var(--product-card-wash-start), var(--product-card-wash-end));
}

.product-card__body {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-sm);
	padding: var(--product-card-pad);
	min-inline-size: 0;
}

.product-card__title {
	margin: 0;
	color: var(--color-text);
	font-family: var(--font-heading);
	font-size: var(--product-card-title-size);
	font-weight: 600;
	line-height: 1.25;
	overflow-wrap: anywhere;
}

.product-card__link {
	color: inherit;
	text-decoration: none;
}

/* Stretched link: the whole card is the click target; its name is the title. */
.product-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.product-card__link:focus-visible {
	outline: none;
}

.product-card__link:focus-visible::after {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: -2px; /* Inside the card: its overflow is hidden. */
}

.product-card__text {
	margin: 0;
	color: var(--product-card-text-colour);
	font-family: var(--font-body);
	font-size: var(--t-body-size);
	line-height: var(--t-body-line-height);
	overflow-wrap: anywhere;
}

.product-card__more {
	color: var(--product-card-more-colour);
	font-family: var(--font-body);
	font-size: var(--t-body-size);
	text-decoration: underline;
	text-underline-offset: 0.25em;
	overflow-wrap: anywhere;
}

/* The screenshot: from the start padding, at the card's bottom edge, cropped by it (it "bleeds"). */
.product-card__media {
	margin-top: auto;
	max-block-size: var(--product-card-media-max);
	padding-inline: var(--product-card-pad);
	overflow: hidden;
}

.product-card__image {
	display: block;
	inline-size: auto;
	max-inline-size: 100%;
	block-size: auto;
}

/* TODO: verify hover state in Figma (no hover frame supplied). */
@media (hover: hover) {
	.product-card--linked:hover .product-card__title,
	.product-card--linked:hover .product-card__more {
		color: var(--color-text-accent);
	}
}

@media (min-width: 48em) { /* --bp-md */
	.product-cards__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.product-card--full {
		grid-column: 1 / -1;
		min-block-size: var(--product-card-full-min);
	}

	.product-card--half {
		min-block-size: var(--product-card-half-min);
	}

	.product-card__body {
		padding: var(--product-card-pad-desktop);
	}

	.product-card__media {
		padding-inline: var(--product-card-pad-desktop);
	}

	/* A full card with its image at the end: text and image side by side, the image on the bottom-end corner. */
	.product-card--full.product-card--image-end {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		align-items: start;
	}

	.product-card--full.product-card--image-end .product-card__media {
		align-self: end;
		justify-self: end;
		max-block-size: var(--product-card-media-end-max);
		margin-top: 0;
		padding-inline: 0 var(--product-card-pad-desktop);
	}
}
