/* ── Cards ────────────────────────────────────────────────────────────────── */
/* The one card behind News Feed, Event Cards and Post Cards — every card is
   rendered by aa_card_html() in inc/cards.php. Change the card here and all
   three change together.

   Per source, only two things differ, both set on the list wrapper: the image
   shape (.aa-cards--shape-portrait for news, landscape for events and posts)
   and, for events, the full-width featured card. */

/* ── Grid ─────────────────────────────────────────────────────────────────── */

.aa-cards__grid {
	display: grid;
	gap: var(--wp--preset--spacing--small, 1.5rem);
	grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
}

/* The column count is a class rather than an inline custom property so the
   breakpoints below can override it — an inline style would outrank them. */
.aa-cards__grid--cols-1 { grid-template-columns: minmax( 0, 1fr ); }
.aa-cards__grid--cols-2 { grid-template-columns: repeat( 2, minmax( 0, 1fr ) ); }
.aa-cards__grid--cols-3 { grid-template-columns: repeat( 3, minmax( 0, 1fr ) ); }
.aa-cards__grid--cols-4 { grid-template-columns: repeat( 4, minmax( 0, 1fr ) ); }

@media (max-width: 900px) {
	.aa-cards__grid--cols-3,
	.aa-cards__grid--cols-4 {
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	}
}

@media (max-width: 600px) {
	.aa-cards__grid--cols-1,
	.aa-cards__grid--cols-2,
	.aa-cards__grid--cols-3,
	.aa-cards__grid--cols-4 {
		grid-template-columns: minmax( 0, 1fr );
	}
}

.aa-cards__empty {
	opacity: 0.6;
	font-style: italic;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */

.aa-card {
	* {
		margin: 0;
	}

	display: flex;
	flex-direction: column;
	border-radius: var(--border-radius-default, 4px);
	border: 1px solid var(--aa-card-border, var(--wp--preset--color--base));
	background-color: var(--aa-card-bg, transparent);
	overflow: hidden;
	transition: box-shadow 0.15s ease;
}

.aa-card:hover {
	box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}

/* ── Image ────────────────────────────────────────────────────────────────── */

.aa-card__image-link,
.aa-card__image-placeholder {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: 16 / 9;
}

.aa-cards--shape-portrait .aa-card__image-link,
.aa-cards--shape-portrait .aa-card__image-placeholder {
	/* aspect-ratio: 3 / 4; */
	aspect-ratio: 4 / 3;
}

.aa-card__image-placeholder {
	background: rgba(0, 0, 0, 0.06);
}

.aa-card__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.2s ease;
}

.aa-card__badge {
	position: absolute;
	top: 0.5rem;
	left: 0.5rem;
	background: var(--wp--preset--color--primary, #0C2A4E);
	color: #fff;
	font-size: 0.7rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 0.2rem 0.55rem;
	border-radius: 2px;
	line-height: 1.4;
}

/* ── Body ─────────────────────────────────────────────────────────────────── */

.aa-card__body {
	padding: 1rem 1.1rem 1.25rem;
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	flex: 1;
}

.aa-card__title {
	margin-bottom: var(--wp--preset--spacing--x-small);
	&,
	a {
		text-decoration: none;
	}
}

.aa-card__meta {
	opacity: 0.65;
}

/* Date, title and teaser otherwise inherit the theme's typography. */

/* ── Featured (events) ────────────────────────────────────────────────────── */
/* After the shape rules on purpose: at the same specificity, this is what
   frees a featured card's image from the list's aspect ratio. */

.aa-card--featured:hover {
	box-shadow: 0 0 0 2px var(--wp--preset--color--primary, #0C2A4E), 0 6px 20px rgba(0, 0, 0, 0.15);
}

@media (min-width: 600px) {
	.aa-card--featured {
		grid-column: 1 / -1;
		flex-direction: row;
	}

	.aa-card--featured .aa-card__image-link,
	.aa-card--featured .aa-card__image-placeholder {
		flex: 0 0 42%;
		aspect-ratio: auto;
	}

	.aa-card--featured .aa-card__body {
		padding: 1.5rem 1.75rem;
		justify-content: center;
	}
}

/* ── Colour ───────────────────────────────────────────────────────────────── */
/* Colours only set custom properties on the list — --aa-card-bg, -fg, -hover,
   and (from section themes) -border. The rules above and below consume them.
   Where the properties come from, highest first: the block's own choice
   (.aa-cards--colour-{slug}), a section theme (sections.css, default lists
   only), then the site setting (.aa-cards--colour-default). All are generated
   from aa_card_colours() in inc/cards.php except the section themes.

   Text and link colours change ONLY for pairings (.aa-cards--paired). None and
   Frosted white keep whatever the surrounding group sets in the editor — a card
   that pinned its own text colour there would override the section's choice. */

.aa-cards--paired .aa-card {
	color: var(--aa-card-fg);
}

/* Two classes deep, so it outranks both a group's generated link colour
   (.wp-elements-N a:where(…)) and the site-wide yellow a:hover. */
.aa-cards--paired .aa-card__title a {
	color: inherit;
}

.aa-cards--paired .aa-card__title a:hover,
.aa-cards--paired .aa-card__title a:focus {
	color: var(--aa-card-hover, inherit);
}

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