/*
 * Event highlights and the event listing (Events page)
 *
 * Both are Query Loops of events built from the same card as the Event
 * Carousel (event-carousel.css), in its open form:
 *
 *   kindling-event-card--open   no border or panel; the text sits under the
 *                               photo, flush with its edges
 *
 * Highlights: a Columns block (`kindling-event-highlights`) with two Query
 * Loops, the next upcoming event large (`__lead`, 4:3 photo) and the two after
 * it stacked beside it (`__more`, Offset 1, 16:9 photos). An optional Buttons
 * block (`__footer`) at the end of the lead column sits at the bottom of that
 * column, and moves below all three cards once the columns stack.
 *
 * Listing: a filterable Query Loop (`kindling-event-listing`) with the Event
 * Filters and Event Load More blocks from the Core Features plugin, which adds
 * the view class to the Query Loop:
 *
 *   is-event-view-list    one event per row, photo beside the text, divided
 *                         by rules; text only on phones (no photo)
 *   is-event-view-photo   a grid of cards: three, two on tablets, one on phones
 *
 * @package Kindling
 * @since Kindling 4.1.0
 */

/* Open card --------------------------------------------------------------- */

.kindling-event-card--open {
	background-color: transparent;
	border: 0;

	.kindling-event-card__body {
		padding-block-start: var(--wp--preset--spacing--30);
	}
}

/* Highlights -------------------------------------------------------------- */

.kindling-event-highlights {
	.wp-block-post-template {
		margin-block: 0;
	}
}

.kindling-event-highlights__lead {
	--kindling-event-card-ratio: 4 / 3;
}

.kindling-event-highlights__more {
	--kindling-event-card-ratio: 16 / 9;
}

/* Columns stack below 782px: give the stacked cards the lead's room between them. */
@media (max-width: 781px) {
	.kindling-event-highlights__more {
		--kindling-event-card-ratio: 4 / 3;
	}
}

/* Footer button: at the bottom of the lead column, level with the last card beside it. */
.kindling-event-highlights > .wp-block-column:has(> .kindling-event-highlights__footer) {
	display: flex;
	flex-direction: column;

	> .wp-block-query {
		flex: 1 0 auto;
	}
}

.kindling-event-highlights__footer {
	margin-block: var(--wp--preset--spacing--60) 0;
}

/* Stacked: the button follows all three cards rather than splitting them. */
@media (max-width: 781px) {
	.kindling-event-highlights:has(.kindling-event-highlights__footer) {
		flex-direction: column;

		> .wp-block-column {
			display: contents;
		}
	}

	.kindling-event-highlights__footer {
		order: 1;
		margin-block-start: 0;
	}
}

/* Listing ----------------------------------------------------------------- */

.kindling-event-listing {
	> .wp-block-post-template {
		margin-block: var(--wp--preset--spacing--60) 0;
		transition: opacity 0.2s ease-out;

		> li {
			margin: 0;
		}

		@media (prefers-reduced-motion: reduce) {
			transition: none;
		}
	}

	&.is-loading > .wp-block-post-template {
		opacity: 0.5;
	}

	/* No results: the Query No Results paragraph. */
	> .wp-block-matchbox-event-filters ~ p {
		margin-block-start: var(--wp--preset--spacing--60);
	}
}

/* List view: a centered column of rows, photo beside the text. */
.kindling-event-listing.is-event-view-list {
	> .wp-block-post-template {
		max-width: 60rem;
		margin-inline: auto;

		> li {
			padding-block: var(--wp--preset--spacing--40);
			border-block-end: 1px solid var(--wp--custom--color--separator);
		}
	}

	.kindling-event-card {
		display: grid;
		grid-template-columns: minmax(0, 17.5rem) minmax(0, 1fr);
		gap: var(--wp--preset--spacing--40);
		align-items: start;
	}

	.kindling-event-card__body {
		padding-block-start: 0;
	}

	.wp-block-post-title {
		font-size: var(--wp--preset--font-size--large);
	}

	/* Phones: text only, so the list reads differently from Photo view. The date line still shows the date. */
	@media (max-width: 599px) {
		.kindling-event-card {
			grid-template-columns: minmax(0, 1fr);
		}

		.kindling-event-card__media {
			display: none;
		}
	}
}

/* Photo view: a grid of open cards. */
.kindling-event-listing.is-event-view-photo > .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--wp--preset--spacing--60) var(--wp--preset--spacing--40);

	@media (max-width: 1023px) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	@media (max-width: 599px) {
		grid-template-columns: minmax(0, 1fr);
	}
}
