/**
 * Current Fundraisers — Campaign Engine data additions (Phase 7E-1).
 *
 * Loaded after current-fundraisers.css, only where that stylesheet is
 * enqueued. Adds the amount raised / goal progress treatment, the Meals
 * Provided impact line, and layouts for one to four cards; the five-card
 * layout and every existing card style stay in current-fundraisers.css
 * unchanged. Every rule here targets markup only Campaign Engine cards render
 * (progress, impact) or is scoped with :has() to a card that renders it, so
 * the local fallback list looks exactly as before -- except the "View all
 * fundraisers" link (Phase 7E-2A), which appears in both modes whenever the
 * /fundraisers/ page is published.
 */

/* "View all fundraisers →" below the cards (only when /fundraisers/ is published). */
.hcfb-current-fundraisers__more {
	margin: clamp(1.5rem, 3vw, 2.25rem) 0 0;
	text-align: center;
}

.hcfb-current-fundraisers__more a {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	min-height: 44px;
	color: var(--wp--preset--color--hcfb-navy);
	font-size: 1.05rem;
	font-weight: 800;
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 0.25em;
}

.hcfb-current-fundraisers__more a:hover,
.hcfb-current-fundraisers__more a:focus-visible {
	text-decoration-color: var(--wp--preset--color--hcfb-orange);
}

/* Amount raised and goal progress. */
.hcfb-current-fundraiser__progress {
	margin: 0 0 1.25rem;
}

.hcfb-current-fundraiser__raised {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.35rem;
	margin: 0;
	color: var(--wp--preset--color--hcfb-green-text);
	font-weight: 800;
}

/* Standard cards: the amount stays below the fundraiser title (1.4–1.75rem). */
.hcfb-current-fundraiser__raised strong {
	color: var(--wp--preset--color--hcfb-navy);
	font-size: 1.3rem;
	line-height: 1.1;
	letter-spacing: -0.015em;
}

.hcfb-current-fundraiser__raised span {
	font-size: 0.75rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.hcfb-current-fundraiser__bar {
	height: 0.5rem;
	margin-top: 0.75rem;
	overflow: hidden;
	border-radius: 999px;
	background: color-mix(in srgb, var(--wp--preset--color--hcfb-navy) 12%, transparent);
}

.hcfb-current-fundraiser__bar span {
	display: block;
	width: var(--hcfb-cf-progress, 0%);
	height: 100%;
	border-radius: inherit;
	background: var(--wp--preset--color--hcfb-green);
}

.hcfb-current-fundraiser__goal {
	margin: 0.5rem 0 0;
	font-size: 0.9rem;
	font-weight: 700;
	line-height: 1.4;
}

/*
 * Meals Provided: a single-line impact statement ("6,400 meals provided") in
 * the brand green text color, deliberately quieter than the dollar amount so
 * the two never read as competing donation totals. Overrides the original
 * stacked stat in current-fundraisers.css, which only Campaign Engine cards
 * render.
 */
.hcfb-current-fundraisers .hcfb-current-fundraiser__impact {
	flex-direction: row;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.3em;
	margin: -0.25rem 0 1.25rem;
	color: var(--wp--preset--color--hcfb-green-text);
	font-size: 0.95rem;
	font-weight: 700;
	line-height: 1.4;
}

.hcfb-current-fundraisers .hcfb-current-fundraiser__impact strong {
	color: inherit;
	font-size: inherit;
	font-weight: 800;
	line-height: inherit;
	letter-spacing: normal;
}

.hcfb-current-fundraisers .hcfb-current-fundraiser__impact span {
	font-size: inherit;
	font-weight: inherit;
	letter-spacing: normal;
	text-transform: lowercase;
}

.hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__raised {
	color: color-mix(in srgb, var(--wp--preset--color--hcfb-surface) 78%, transparent);
}

.hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__raised strong {
	color: var(--wp--preset--color--hcfb-orange);
	font-size: clamp(2.25rem, 3.5vw, 3rem);
}

.hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__bar {
	max-width: 38rem;
	background: color-mix(in srgb, var(--wp--preset--color--hcfb-surface) 22%, transparent);
}

.hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__bar span {
	background: var(--wp--preset--color--hcfb-orange);
}

.hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__goal {
	color: color-mix(in srgb, var(--wp--preset--color--hcfb-surface) 88%, transparent);
}

/* The featured card keeps a larger impact line, in light text so it stays distinct from the orange amount. */
.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__impact {
	color: color-mix(in srgb, var(--wp--preset--color--hcfb-surface) 88%, transparent);
	font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__impact strong {
	color: var(--wp--preset--color--hcfb-surface);
}

/*
 * Forced colors: author backgrounds are replaced, so the track and fill opt
 * out and use system colors -- Canvas track, CanvasText outline, Highlight
 * fill -- on the featured and standard cards alike.
 */
@media (forced-colors: active) {
	.hcfb-current-fundraisers .hcfb-current-fundraiser .hcfb-current-fundraiser__bar {
		forced-color-adjust: none;
		border: 1px solid CanvasText;
		background: Canvas;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraiser .hcfb-current-fundraiser__bar span {
		forced-color-adjust: none;
		background: Highlight;
	}
}

/*
 * Featured card spacing: where the featured card spans two rows (wider than
 * 850px), its image grows into the height the taller data cards create
 * instead of leaving a gap above the button. The image keeps object-fit:
 * cover (cropped, never stretched) and stops at a square so a landscape photo
 * is not cut down to a narrow strip. Scoped to a featured card that renders
 * Campaign Engine totals, so the local fallback list is untouched.
 */
@media (min-width: 851px) {
	.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child:has(.hcfb-current-fundraiser__progress) {
		container-type: inline-size;
	}

	/* The image takes nearly all spare height; anything left past the square cap returns to the content. */
	.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser__media {
		flex: 100 1 auto;
		min-height: calc(100cqi * 9 / 16);
		max-height: 100cqi;
		aspect-ratio: auto;
	}

	/* Amount, goal, meals, and the button stay together at the bottom of the card, so any remaining space sits above them as one footer group rather than as a hole above the button. */
	.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child .hcfb-current-fundraiser__progress {
		margin-top: auto;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraiser:first-child:has(.hcfb-current-fundraiser__progress) .hcfb-current-fundraiser__cta {
		margin-top: 0;
	}
}

/*
 * One to four cards. The featured first card keeps its existing treatment;
 * the remaining cards fill the space beside it instead of leaving empty
 * grid cells. (Selectors carry three classes so they follow the existing
 * two-class `:first-child` rules regardless of source order.)
 */
.hcfb-current-fundraisers__grid--count-1 {
	grid-template-columns: minmax(0, 1fr);
}

.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-1 > .hcfb-current-fundraiser:first-child {
	grid-column: auto;
	grid-row: auto;
}

@media (min-width: 851px) {
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-2 > .hcfb-current-fundraiser:nth-child(2),
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-3 > .hcfb-current-fundraiser:not(:first-child) {
		grid-column: span 2;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-2 > .hcfb-current-fundraiser:nth-child(2) {
		grid-row: span 2;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-4 > .hcfb-current-fundraiser:nth-child(4) {
		grid-column: span 2;
	}
}

@media (min-width: 601px) and (max-width: 850px) {
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-2 > .hcfb-current-fundraiser:nth-child(2),
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-4 > .hcfb-current-fundraiser:nth-child(4) {
		grid-column: 1 / -1;
	}
}

/*
 * 851–1050px with Campaign Engine totals (Ryan-approved, 2026-10-13): the
 * three-column arrangement made the featured card a narrow column spanning
 * two tall rows, leaving a large empty area. In this range only, data-driven
 * cards use the approved 768px arrangement instead: a full-width featured
 * card (16:9 image, navy treatment unchanged) with the supporting cards in
 * two columns below; a lone last card spans the full width. Above 1050px and
 * at 850px and below nothing changes, and the local fallback list (which
 * renders no totals) never matches.
 */
@media (min-width: 851px) and (max-width: 1050px) {
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid:has(.hcfb-current-fundraiser__progress) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-auto-rows: auto;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser {
		grid-column: auto;
		grid-row: auto;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser:first-child,
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-2:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser:nth-child(2),
	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid--count-4:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser:nth-child(4) {
		grid-column: 1 / -1;
	}

	.hcfb-current-fundraisers .hcfb-current-fundraisers__grid:has(.hcfb-current-fundraiser__progress) > .hcfb-current-fundraiser:first-child > .hcfb-current-fundraiser__media {
		flex: none;
		min-height: 0;
		max-height: none;
		aspect-ratio: 16 / 9;
	}
}
