/*
 * Past Events Gallery (v0.2.32) — Elementor\Widgets\PastEventsGalleryWidget
 * via templates/past-events-gallery.php. Registered with
 * frontend-event-card.css as its dependency, so the shared :root tokens
 * (fonts, colors, border, focus ring) are reused, never redefined.
 *
 * Defaults: 4 columns desktop, 2 tablet (<= 999px), 2 mobile (<= 649px) —
 * the same breakpoints Event Grid/Event Index already use. Elementor's
 * Style controls (all {{WRAPPER}}-scoped) override any of this per
 * instance. No brand literals: every color routes through an existing JDX
 * token.
 */

.jdx-events-gallery {
	width: 100%;
	box-sizing: border-box;
	font-family: var(--jdx-events-font-secondary);
	color: var(--jdx-events-color-text);
}

.jdx-events-gallery__grid {
	display: grid;
	grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
	gap: 1.5em;
	margin: 0;
	padding: 0;
	list-style: none;
}

@media ( max-width: 999px ) {
	.jdx-events-gallery__grid {
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
	}
}

@media ( max-width: 649px ) {
	.jdx-events-gallery__grid {
		grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
		gap: 0.75em;
	}
}

.jdx-events-gallery__item {
	margin: 0;
	padding: 0;
	min-width: 0;
}

/* The whole card is one link (templates/past-events-gallery.php). */
.jdx-events-gallery__card {
	display: flex;
	flex-direction: column;
	height: 100%;
	box-sizing: border-box;
	color: inherit;
	text-decoration: none;
	border: 1px solid var(--jdx-events-card-border-color);
	background-color: var(--jdx-events-card-bg, transparent);
	overflow: hidden;
	transition: border-color 175ms;
}

.jdx-events-gallery__card:focus-visible {
	outline: 2px solid var(--jdx-events-focus-ring-outline);
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--jdx-events-focus-ring-shadow);
}

@media ( hover: hover ) {
	.jdx-events-gallery__card:hover {
		border-color: var(--jdx-events-color-accent);
	}

	.jdx-events-gallery__card:hover .jdx-events-gallery__title {
		color: var(--jdx-events-color-accent);
	}
}

.jdx-events-gallery__media {
	display: block;
	position: relative;
	aspect-ratio: 16 / 10;
	overflow: hidden;
	background-color: var(--jdx-events-card-border-color);
}

.jdx-events-gallery__media--empty {
	opacity: 0.35;
}

/*
 * The poster always fills the media box (aspect-ratio above, or Style →
 * Card → Image Aspect Ratio): cropped, never distorted, never letterboxed
 * (v0.2.34). Absolutely positioned so the image's own proportions can
 * never change the box or the card height. `html body .x` (0,1,2) beats
 * Elementor's `.elementor img { height: auto; max-width: 100% }` (0,1,1),
 * which otherwise shrank a 1920x800 poster to its natural height and left
 * an empty band below it. Style → Card → Image Fit ({{WRAPPER}}-scoped,
 * 0,4,0) still overrides object-fit per instance.
 */
html body .jdx-events-gallery__image {
	display: block;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	object-fit: cover;
	object-position: center center;
}

.jdx-events-gallery__body {
	display: flex;
	flex-direction: column;
	gap: 0.35em;
	padding: 0.9em 1em 1.1em;
	min-width: 0;
}

.jdx-events-gallery__date {
	display: block;
	font-size: 0.8em;
	opacity: 0.7;
}

.jdx-events-gallery__title {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin: 0;
	font-family: var(--jdx-events-font-primary);
	font-size: 1.1em;
	font-weight: 700;
	line-height: 1.25;
	text-transform: uppercase;
	overflow-wrap: anywhere;
	transition: color 175ms;
}

/* Plain-text preview (Decision 052) clamped to --jdx-events-gallery-
 * excerpt-lines (default 3; Style → Excerpt → Lines overrides). */
.jdx-events-gallery__excerpt {
	--jdx-events-gallery-excerpt-lines: 3;
	display: -webkit-box;
	-webkit-line-clamp: var( --jdx-events-gallery-excerpt-lines );
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.85em;
	line-height: 1.45;
	opacity: 0.85;
	overflow-wrap: anywhere;
}

.jdx-events-gallery__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.jdx-events-gallery__nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.75em;
	margin-top: 2em;
}

.jdx-events-gallery__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 0.6em 1.4em;
	box-sizing: border-box;
	font-family: var(--jdx-events-font-secondary);
	font-size: 0.8em;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: inherit;
	text-decoration: none;
	background: transparent;
	border: 1px solid var(--jdx-events-card-border-color);
	transition: background-color 175ms, color 175ms, border-color 175ms;
}

.jdx-events-gallery__button[aria-busy="true"] {
	opacity: 0.6;
	cursor: progress;
}

@media ( hover: hover ) {
	.jdx-events-gallery__button:hover {
		background: var(--jdx-events-color-accent);
		color: var(--jdx-events-cta-primary-fg);
		border-color: var(--jdx-events-color-accent);
	}
}

.jdx-events-gallery__button:focus-visible {
	outline: 2px solid var(--jdx-events-focus-ring-outline);
	outline-offset: 3px;
	box-shadow: 0 0 0 3px var(--jdx-events-focus-ring-shadow);
}
