/*
 * Shared content card (includes/content-card.php): image, title and text on
 * a white card, the whole card is the link. The parent sets the width, and
 * --content-card-ratio the image ratio (600 × 384 by default).
 */

.c-content-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: var(--space-sm);
	inline-size: 100%;
	padding-block-end: var(--space-xl);
	overflow: hidden;
	border-radius: var(--radius-md);
	background: var(--color-white);
	box-shadow: inset 0 0 0 1px var(--color-cloud);

	&:has(.c-content-card__link:focus-visible) {
		outline: 3px solid var(--color-focus);
		outline-offset: 3px;
	}
}

.c-content-card__media {
	aspect-ratio: var(--content-card-ratio, 25 / 16);
	overflow: hidden; /* keeps the ratio with taller images */
	background: var(--color-grey);
}

.c-content-card__image {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	transition: scale var(--duration-base) var(--ease-out);
}

.c-content-card__body {
	display: flex;
	flex-direction: column;
	gap: var(--space-xs);
	padding: var(--space-xs) var(--space-xl) 0;
	color: rgb(0 0 0 / 0.88);
}

.c-content-card__title {
	color: inherit;
	font-size: var(--font-size-h2);
	font-weight: var(--font-weight-bold); /* H2, Bold */
	line-height: var(--line-height-h2);
	letter-spacing: var(--letter-spacing-h2);
	text-wrap: pretty;
}

/* The whole card is the link */
.c-content-card__link {
	color: inherit;
	text-decoration: none;

	&::after {
		content: "";
		position: absolute;
		inset: 0;
		z-index: 1;
	}

	&:hover {
		color: inherit;
		text-decoration: underline;
		text-decoration-thickness: 2px;
		text-underline-offset: 0.15em;
	}

	&:focus-visible {
		outline: none;
	}
}

.c-content-card:hover .c-content-card__image {
	scale: 1.03;
}

.c-content-card__text {
	display: -webkit-box;
	overflow: hidden;
	font-size: var(--font-size-body-lg);
	line-height: var(--line-height-body-lg);
	letter-spacing: var(--letter-spacing-body-lg);
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

@media (prefers-reduced-motion: reduce) {
	.c-content-card__image {
		transition: none;
	}

	.c-content-card:hover .c-content-card__image {
		scale: none;
	}
}
