/**
 * Component: story card (case studies in listings).
 *
 * Markup: template-parts/components/story-card.php. DOM order is title
 * first (for screen readers); flex `order` shows the image, tags, title,
 * then "Read full story". The link's ::after makes the whole card
 * clickable. Frame: case-study-overview.
 *
 * @package cartrack
 */

.story-card {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	height: 100%;
	color: var(--color-text);
}

.story-card__media {
	position: relative;
	order: 1;
	display: grid;
	place-items: center;
	align-self: stretch;
	overflow: hidden;
	aspect-ratio: var(--story-card-image-ratio);
	background-color: var(--story-card-image-bg);
}

.story-card__image {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Light scrim so a white logo reads on any photo. */
.story-card--has-logo .story-card__media::after {
	content: "";
	position: absolute;
	inset: 0;
	background-color: var(--story-card-scrim);
	pointer-events: none;
}

.story-card__logo {
	position: relative;
	z-index: 1;
	width: auto;
	max-width: var(--story-card-logo-max-width);
	height: auto;
	max-height: var(--story-card-logo-max-height);
	object-fit: contain;
}

.story-card__tags {
	order: 2;
	margin-top: var(--story-card-tags-gap);
}

.story-card__title {
	order: 3;
	margin: var(--story-card-title-gap) 0 0;
	color: inherit;
	font-family: var(--font-body);
	font-size: var(--story-card-title-size);
	font-weight: var(--font-weight-medium);
	line-height: var(--line-height-snug);
}

.story-card__link {
	order: 4;
	margin-top: var(--story-card-link-gap);
	color: var(--story-card-link-colour);
	font-family: var(--font-body);
	font-size: var(--story-card-link-size);
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

/* Stretched link: the whole card is the click target. */
.story-card__link::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 2;
}

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

.story-card__link:focus-visible::after {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 4px;
}

/* TODO: verify hover state in Figma (no hover frame supplied). */
@media (hover: hover) {
	.story-card:hover .story-card__image {
		transform: scale(var(--story-card-hover-zoom));
	}

	.story-card:hover .story-card__title {
		color: var(--color-primary);
	}
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.story-card__image {
		transition: transform var(--transition-base);
	}

	.story-card__title {
		transition: color var(--transition-fast);
	}
}
