/**
 * « Card » — a post-template item as Apparence's list card (ISS-0075; Apparence → Cartes des listes).
 *
 * Opt-in: nothing applies until an editor picks the « Card » style on a Query Loop's post template, so existing loops
 * look as they did. Every value is a token Studio publishes for the list-card choice:
 *
 * - « image full width »: no padding around the image (`padding` 0), the text indented (`body-padding-x`);
 * - « image in the frame »: a padding around the image (`padding`), a rounded image (`media-radius`);
 * - « no frame »: `frame` 0 %, no padding, no inset, no border, no shadow, no lift.
 *
 * The frame is the surface of elevation 1, mixed at `frame` per cent (0 % is transparent). The border is an inset
 * outline: a `box-shadow` takes `none` or a list, so « no shadow » and « a hairline » could not share one.
 * Hover lifts the card and swaps its shadow; with reduced motion it only swaps the shadow.
 */
.wp-block-post-template.is-style-card > li {
	position: relative;
	box-sizing: border-box;
	overflow: hidden;
	padding: var(--wp--custom--semantic--list-card--padding);
	padding-bottom: var(--wp--custom--semantic--list-card--body-padding-bottom);
	border-radius: var(--wp--custom--semantic--border--radius--card);
	background-color: color-mix(
		in srgb,
		var(--wp--custom--semantic--elevated--1--surface) var(--wp--custom--semantic--list-card--frame),
		transparent
	);
	box-shadow: var(--wp--custom--semantic--list-card--shadow);
	outline: 1px solid var(--wp--custom--semantic--list-card--border);
	outline-offset: -1px;
	transition:
		transform var(--wp--custom--semantic--motion--duration--base, 0.3s) var(--wp--custom--semantic--motion--easing--out, ease),
		box-shadow var(--wp--custom--semantic--motion--duration--base, 0.3s) var(--wp--custom--semantic--motion--easing--out, ease);
}

.wp-block-post-template.is-style-card > li:hover {
	transform: translateY(var(--wp--custom--semantic--list-card--lift));
	box-shadow: var(--wp--custom--semantic--list-card--shadow-hover);
}

/*
 * The text sits in the card's indent; the image runs to the card's edges (or its padding).
 *
 * A post template often wraps its blocks in a group (patterns/template-query-loop.php): the indent goes to the blocks
 * that do not hold the image, and, one level down, to the siblings of an image inside such a wrapper — otherwise the
 * wrapper's margin would pull the image in and « image full width » would not reach the edges.
 *
 * The indent is padding, not margin: a constrained group centres its children with `margin-inline: auto !important`,
 * which no margin of ours could beat.
 */
.wp-block-post-template.is-style-card > li > :not(.wp-block-post-featured-image):not(:has(.wp-block-post-featured-image)),
.wp-block-post-template.is-style-card > li > :has(.wp-block-post-featured-image) > :not(.wp-block-post-featured-image) {
	padding-inline: var(--wp--custom--semantic--list-card--body-padding-x);
}

.wp-block-post-template.is-style-card > li .wp-block-post-featured-image {
	padding-inline: 0;
	overflow: hidden;
	border-radius: var(--wp--custom--semantic--list-card--media-radius);
}

/*
 * `overflow: hidden` clips the focus ring of a link that touches the card's edges (the image link): while anything in
 * the card has keyboard focus, the card draws the ring itself, inside its box, in place of its hairline.
 */
.wp-block-post-template.is-style-card > li:has(:focus-visible) {
	outline: var(--wp--custom--semantic--control--focus-ring--width) solid var(--wp--custom--semantic--control--focus-ring--color);
	outline-offset: calc(-1 * var(--wp--custom--semantic--control--focus-ring--width));
}

@media (prefers-reduced-motion: reduce) {

	.wp-block-post-template.is-style-card > li:hover {
		transform: none;
	}
}
