/**
 * Viora Project Gallery widget.
 *
 * Plates stacked down a project page. Half-width plates flow into pairs on
 * their own, so the rhythm is set by the images themselves rather than by a
 * row-and-column structure the editor has to keep in their head.
 */

.viora-project-gallery {
	position: relative;
	padding-block: clamp(2rem, 4.86vw, 4.375rem);
}

.viora-project-gallery__inner {
	width: min(1082px, 100% - 2 * var(--viora-layout-container-pad));
	margin-inline: auto;
}

.viora-project-gallery__grid {
	--viora-gallery-gap: clamp(1rem, 2.78vw, 2.5rem);

	display: flex;
	flex-wrap: wrap;
	gap: var(--viora-gallery-gap);
}

.viora-project-gallery__plate {
	flex: 1 1 100%;
	min-width: 0;
	margin: 0;
}

/*
 * Just under half, so two sit together and a third is forced onto the next
 * line rather than squeezing in.
 */
.viora-project-gallery__plate--half {
	flex: 1 1 calc(50% - var(--viora-gallery-gap));
}

.viora-project-gallery__media {
	position: relative;
	overflow: hidden;
	background-color: var(--viora-color-surface-alt);
}

/* Set only when a crop is chosen; otherwise the image keeps its own shape. */
.viora-project-gallery__media[style*="--viora-gallery-ratio"] {
	aspect-ratio: var(--viora-gallery-ratio);
}

.viora-project-gallery__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.viora-project-gallery__caption {
	margin-top: clamp(0.6rem, 1vw, 0.9rem);
	color: var(--viora-ink-soft, var(--viora-color-heading-soft));
	font-family: var(--viora-font-ui);
	font-size: 0.6875rem;
	font-weight: var(--viora-weight-medium);
	line-height: 1.7;
	letter-spacing: 0.2em;
	text-transform: uppercase;
}

/* -------------------------------------------------- *
 * Reveal
 * -------------------------------------------------- */

.viora-project-gallery.is-animated .viora-project-gallery__item {
	opacity: 0;
	transform: translateY(28px);
}

.viora-project-gallery.is-animated .viora-project-gallery__item.is-in {
	opacity: 1;
	transform: none;
	transition:
		opacity 0.9s var(--viora-motion-easing),
		transform 0.9s var(--viora-motion-easing);
}

/* -------------------------------------------------- *
 * Mobile
 * -------------------------------------------------- */

@media (max-width: 600px) {
	/* Half plates would be postage stamps on a phone. */
	.viora-project-gallery__plate--half {
		flex: 1 1 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.viora-project-gallery.is-animated .viora-project-gallery__item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}
