/**
 * Appeal card (APPEALS): article.mcard.mcard--appeal, used on Home, Our work, program pages and the
 * appeal pages. Open content: the photo carries the radius, the text sits on the surface. No box,
 * no shadow and no lift; hover zooms the photo inside its frame and turns the title blue.
 *
 * Grid: two named columns (media | body). The stack layout spans both; the row layout places the
 * photo and the text side by side. Inside a .card-grid (or a rail that becomes a grid) the card is a
 * 5-row subgrid: photo | title and region | summary | progress | actions, so these stay level
 * across a row. Spacing inside the card is margin-based (row gap 0), so a missing summary or
 * progress bar collapses to nothing while the buttons still line up.
 *
 * Row layout: a .mcard--row card is a size container and switches at 44rem wide. A stack card in a
 * .card-grid cannot be a container and a subgrid at once (containment makes it an independent
 * formatting context), so .span-full (72em and up) and .span-full-md (44em to 72em) switch it.
 */

.mcard--appeal {
	--mcard-col-gap: clamp(1.25rem, .5rem + 2vw, 2.75rem);
	position: relative;
	display: grid;
	grid-template-columns: [media-start] minmax(0, 1.15fr) [media-end body-start] minmax(0, 1fr) [body-end];
	grid-template-rows: auto auto;
	align-content: start;
	gap: 0 var(--mcard-col-gap);
	min-width: 0;
}

.mcard--appeal > .mcard__media {
	grid-column: media-start / body-end;
	grid-row: 1;
}

.mcard--appeal > .mcard__body {
	display: grid;
	grid-column: media-start / body-end;
	grid-row: 2;
	grid-template-rows: auto auto auto auto;
	align-content: start;
	row-gap: 0;
	min-width: 0;
}

/* Body rows: head, summary, progress, actions (fixed rows, so empty ones collapse). */
.mcard--appeal .mcard__head {
	grid-row: 1;
	padding-top: 16px;
}

.mcard--appeal .mcard__title {
	max-width: none;
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.25;
	letter-spacing: -.015em;
}

.mcard--appeal .mcard__title a {
	color: var(--c-blue-950);
	text-decoration: none;
	transition: color var(--dur-fast) var(--ease-out);
}

/* The title link covers the card; the actions sit above it. */
.mcard--appeal .mcard__title a::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.mcard--appeal:hover .mcard__title a,
.mcard--appeal .mcard__title a:focus-visible {
	color: var(--c-blue);
}

.mcard--appeal .mcard__meta {
	margin-top: 4px;
	font-size: var(--fs-small);
	line-height: 1.45;
	color: var(--c-ink-3);
}

.mcard--appeal .mcard__summary {
	display: -webkit-box;
	grid-row: 2;
	margin-top: 10px;
	overflow: hidden;
	font-size: .9375rem;
	line-height: 1.55;
	color: var(--c-ink-2);
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
}

.mcard--appeal .mcard__body > .progress {
	grid-row: 3;
	margin-top: 18px;
}

.mcard--appeal .mcard__actions {
	position: relative;
	z-index: 2;
	display: flex;
	flex-wrap: wrap;
	grid-row: 4;
	align-items: center;
	gap: 10px 16px;
	margin-top: 18px;
}

/* Hover: the photo zooms inside its fixed frame (never on media with parallax). */
@media (prefers-reduced-motion: no-preference) {
	.mcard--appeal .mcard__media > img {
		transition: scale 600ms var(--ease-out);
	}

	.mcard--appeal:hover .mcard__media > img {
		scale: 1.04;
	}

	.mcard--appeal:has(.mcard__title a:focus-visible) .mcard__media > img {
		scale: 1.04;
	}
}

/* Subgrid inside card grids: the five rows line up across the cards of a row. Descendant
   selectors, so a card wrapped in a grid item that is itself a 5-row subgrid (li.rail__item)
   still lines up; where the wrapper is not a grid the card simply lays out its own rows. */
.card-grid .mcard--appeal:not(.mcard--row) {
	grid-row: span 5;
	grid-template-rows: subgrid;
}

.card-grid .mcard--appeal:not(.mcard--row) > .mcard__body {
	grid-row: 2 / span 4;
	grid-template-rows: subgrid;
}

@media (min-width: 44em) {
	.rail--to-grid .rail__item > .mcard--appeal:not(.mcard--row) {
		grid-row: span 5;
		grid-template-rows: subgrid;
	}

	.rail--to-grid .rail__item > .mcard--appeal:not(.mcard--row) > .mcard__body {
		grid-row: 2 / span 4;
		grid-template-rows: subgrid;
	}
}

/* A subgridded card's rows are the grid's own tracks, so every row gutter of the grid would also
   open inside each card: an empty summary row (summary: false) alone would add a full gutter above
   the progress bar. Grids of appeal cards therefore drop their row gap, space their rows with a
   bottom margin on each card (it lands on the card's last track), and take the last one back. */
.card-grid:has(> .mcard--appeal) {
	row-gap: 0;
	margin-bottom: calc(-1 * var(--space-xl));
}

.card-grid > .mcard--appeal {
	margin-bottom: var(--space-xl);
}

@media (min-width: 44em) {
	.rail--to-grid .rail__track:has(> .rail__item > .mcard--appeal) {
		row-gap: 0;
		margin-bottom: calc(-1 * var(--space-xl));
	}

	.rail--to-grid .rail__item:has(> .mcard--appeal) {
		margin-bottom: var(--space-xl);
	}
}

/* A row card always takes the full width of a card grid. */
.card-grid > .mcard--row {
	grid-column: 1 / -1;
}

/* Row layout (1): a row card once it is 44rem wide. */
.mcard--row {
	container: appeal-card / inline-size;
}

@container appeal-card (min-width: 44rem) {
	.mcard--row > .mcard__media {
		grid-column: media;
		grid-row: 1;
		aspect-ratio: 16 / 10;
	}

	.mcard--row > .mcard__body {
		grid-column: body;
		grid-row: 1;
		align-self: center;
	}

	.mcard--row .mcard__head {
		padding-top: 0;
	}

	.mcard--row .mcard__title {
		font-size: clamp(1.375rem, 1.1rem + .9vw, 1.875rem);
		letter-spacing: -.02em;
	}

	.mcard--row .mcard__summary {
		font-size: var(--fs-body);
		-webkit-line-clamp: 4;
		line-clamp: 4;
	}
}

/* Row layout (2): the lone last card of a three-column grid; two last cards share the row. */
@media (min-width: 72em) {
	.card-grid > .mcard--appeal.span-full {
		grid-row: auto;
		grid-template-rows: auto;
	}

	.card-grid > .mcard--appeal.span-full > .mcard__media {
		grid-column: media;
		grid-row: 1;
		aspect-ratio: 16 / 10;
	}

	.card-grid > .mcard--appeal.span-full > .mcard__body {
		grid-column: body;
		grid-row: 1;
		grid-template-rows: auto auto auto auto;
		align-self: center;
	}

	.card-grid > .mcard--appeal.span-full .mcard__head {
		padding-top: 0;
	}

	.card-grid > .mcard--appeal.span-full .mcard__title {
		font-size: clamp(1.375rem, 1.1rem + .9vw, 1.875rem);
		letter-spacing: -.02em;
	}

	.card-grid > .mcard--appeal.span-full .mcard__summary {
		font-size: var(--fs-body);
		-webkit-line-clamp: 4;
		line-clamp: 4;
	}

	/* Two cards sharing the last row: 2:1 keeps their photos as tall as the 4:3 photos above. */
	.card-grid > .mcard--appeal.span-half > .mcard__media {
		aspect-ratio: 2 / 1;
	}
}

/* Row layout (3): the lone last card of a two-column grid. */
@media (min-width: 44em) and (max-width: 71.99em) {
	.card-grid > .mcard--appeal.span-full-md {
		grid-row: auto;
		grid-template-rows: auto;
	}

	.card-grid > .mcard--appeal.span-full-md > .mcard__media {
		grid-column: media;
		grid-row: 1;
		aspect-ratio: 16 / 10;
	}

	.card-grid > .mcard--appeal.span-full-md > .mcard__body {
		grid-column: body;
		grid-row: 1;
		grid-template-rows: auto auto auto auto;
		align-self: center;
	}

	.card-grid > .mcard--appeal.span-full-md .mcard__head {
		padding-top: 0;
	}

	.card-grid > .mcard--appeal.span-full-md .mcard__title {
		font-size: clamp(1.25rem, 1.05rem + .7vw, 1.5rem);
	}
}

@media print {
	.mcard--appeal .mcard__actions {
		display: none;
	}
}
