/*!
 * Sterling Sports Group — gallery component.
 *
 * Loaded as its own stylesheet (handle: ssg-gallery) by ssg_enqueue_assets()
 * in functions.php. Depends on the brand tokens declared in style.css.
 *
 * Markup: template-parts/components/gallery.php
 */

.ssg-gallery {
	background-color: var(--ssg-surface);
	padding-block: var(--ssg-section-y);
}

/*
 * CSS multi-column masonry. The photos run three portraits, two squares and
 * two landscapes, so a fixed-cell grid would have to crop most of them —
 * columns let every shot keep its own aspect ratio uncropped. Reading order
 * runs down each column rather than across, which is irrelevant here because
 * the images carry no captions and no order-dependent meaning.
 */
.ssg-gallery__grid {
	width: min(100% - 2.5rem, 1320px);
	margin-inline: auto;
	columns: 4;
	column-gap: 14px;
}

.ssg-gallery__item {
	/* Stops a photo being split across a column boundary. */
	break-inside: avoid;
	/* Safari needs the older property name as well. */
	-webkit-column-break-inside: avoid;
	position: relative;
	margin: 0 0 14px;
	overflow: hidden;
	border-radius: var(--ssg-radius);
	background-color: var(--ssg-surface-alt);
	/* Promotes the item so the child transform does not bleed past the radius. */
	isolation: isolate;
}

.ssg-gallery__img {
	display: block;
	width: 100%;
	height: auto;
	/* width/height attributes on the tag reserve the box before load, so the
	   masonry does not reflow as images stream in. */
	transition: transform 0.45s ease;
}

.ssg-gallery__item:hover .ssg-gallery__img {
	transform: scale(1.05);
}

/* Crimson wash on hover, tying the photos to the brand. */
.ssg-gallery__item::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		to top,
		rgba(157, 0, 31, 0.45) 0%,
		rgba(10, 9, 6, 0.15) 55%,
		rgba(10, 9, 6, 0) 100%
	);
	opacity: 0;
	transition: opacity var(--ssg-transition);
	pointer-events: none;
}

.ssg-gallery__item:hover::after {
	opacity: 1;
}

/* --------------------------------------------------------------
 * Breakpoints
 * ----------------------------------------------------------- */
@media (max-width: 1200px) {
	.ssg-gallery__grid {
		columns: 3;
	}
}

@media (max-width: 900px) {
	.ssg-gallery__grid {
		columns: 2;
	}
}

@media (max-width: 600px) {
	.ssg-gallery__grid {
		columns: 2;
		column-gap: 10px;
	}

	.ssg-gallery__item {
		margin-bottom: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ssg-gallery__img,
	.ssg-gallery__item::after {
		transition: none;
	}

	.ssg-gallery__item:hover .ssg-gallery__img {
		transform: none;
	}
}
