/* ═══════════════════════════════════════════════════════════════
   GALLERY GRID
   ═══════════════════════════════════════════════════════════════ */
.c2-gallery-masonry-wrap {
	container-type: inline-size;
}

.c2-gallery-masonry {
	display: flex;
	flex-direction: column;
	gap: var( --c2-gutter, 8px );
}

.c2-gallery-masonry-item {
	position: relative;
	overflow: hidden;
	width: 100%;
	border-radius: var( --c2-radius, 4px );
	background: #ddd;
}

.c2-gallery-masonry-item img {
	width: 100%;
	height: auto;
	object-fit: cover;
	display: block;
}

/* shadow variant */
.c2-shadow .c2-gallery-masonry-item {
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.18 );
}

/* ═══════════════════════════════════════════════════════════════
   HOVER EFFECTS
   ═══════════════════════════════════════════════════════════════ */

/* zoom */
.c2-hover-zoom .c2-gallery-masonry-item img {
	transition: transform 0.35s ease;
}
.c2-hover-zoom .c2-gallery-masonry-item:hover img {
	transform: scale( 1.07 );
}

/* dim */
.c2-hover-dim .c2-gallery-masonry-item::after {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0 );
	transition: background 0.3s ease;
	pointer-events: none;
	border-radius: inherit;
}
.c2-hover-dim .c2-gallery-masonry-item:hover::after {
	background: rgba( 0, 0, 0, 0.4 );
}

/* slide — reveals the caption from the bottom */
.c2-hover-slide .c2-gallery-caption {
	transform: translateY( 100% );
	transition: transform 0.35s ease;
}
.c2-hover-slide .c2-gallery-masonry-item:hover .c2-gallery-caption {
	transform: translateY( 0 );
}

/* ═══════════════════════════════════════════════════════════════
   CAPTIONS
   ═══════════════════════════════════════════════════════════════ */
.c2-gallery-caption {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.c2-gallery-caption__title {
	font-weight: 600;
	font-size: 0.875rem;
	line-height: 1.3;
}

.c2-gallery-caption__text {
	font-size: 0.8rem;
	opacity: 0.85;
	line-height: 1.4;
}

/* overlay */
.c2-caption-overlay .c2-gallery-caption {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 28px 12px 12px;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.72 ) 0%, transparent 100% );
	color: #fff;
	opacity: 0;
	transition: opacity 0.28s ease;
	border-radius: inherit;
}
.c2-caption-overlay .c2-gallery-masonry-item:hover .c2-gallery-caption {
	opacity: 1;
}
/* keep slide effect from fighting the overlay opacity */
.c2-hover-slide.c2-caption-overlay .c2-gallery-caption {
	opacity: 1;
}

/* below */
.c2-caption-below .c2-gallery-masonry-item {
	display: flex;
	flex-direction: column;
}
.c2-caption-below .c2-gallery-masonry-item img {
	flex: 0 0 auto;
	min-height: 0;
}
.c2-caption-below .c2-gallery-caption {
	flex-shrink: 0;
	padding: 8px 10px;
	background: #fff;
	color: #333;
	border-top: 1px solid rgba( 0, 0, 0, 0.06 );
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@container ( min-width: 769px ) {
	.c2-gallery-masonry {
		display: grid;
		grid-template-columns: repeat( var( --c2-columns, 4 ), 1fr );
		grid-auto-rows: calc( ( 100cqi - var( --c2-gutter, 8px ) * ( var( --c2-columns, 4 ) - 1 ) ) / var( --c2-columns, 4 ) * var( --c2-row-ratio, 1 ) );
	}

	.c2-gallery-masonry-item {
		grid-column: span var( --col-span, 1 );
		grid-row: span var( --row-span, 1 );
		width: auto;
	}

	.c2-gallery-masonry-item img {
		height: 100%;
	}

	.c2-caption-below .c2-gallery-masonry-item img {
		flex: 1 1 auto;
		min-height: 0;
	}
}

@supports not ( container-type: inline-size ) {
	@media ( min-width: 769px ) {
		.c2-gallery-masonry {
			display: grid;
			grid-template-columns: repeat( var( --c2-columns, 4 ), 1fr );
			grid-auto-rows: calc( ( 100cqi - var( --c2-gutter, 8px ) * ( var( --c2-columns, 4 ) - 1 ) ) / var( --c2-columns, 4 ) * var( --c2-row-ratio, 1 ) );
		}

		.c2-gallery-masonry-item {
			grid-column: span var( --col-span, 1 );
			grid-row: span var( --row-span, 1 );
			width: auto;
		}

		.c2-gallery-masonry-item img {
			height: 100%;
		}

		.c2-caption-below .c2-gallery-masonry-item img {
			flex: 1 1 auto;
			min-height: 0;
		}
	}
}

/* ═══════════════════════════════════════════════════════════════
   CAROUSEL
   ═══════════════════════════════════════════════════════════════ */
.c2-gallery-carousel-wrap {
	overflow: hidden;
	width: 100%;
}

.c2-gallery-carousel__track {
	display: flex;
	animation: c2-carousel-scroll var( --c2-carousel-speed, 30s ) linear infinite;
	will-change: transform;
}

.c2-gallery-carousel__track:hover {
	animation-play-state: paused;
}

.c2-gallery-carousel__item {
	flex-shrink: 0;
	height: var( --c2-carousel-height, 200px );
	margin-right: var( --c2-gutter, 8px );
	border-radius: var( --c2-radius, 4px );
	overflow: hidden;
	cursor: pointer;
}

.c2-gallery-carousel__item img {
	height: 100%;
	width: auto;
	object-fit: cover;
	display: block;
}

.c2-shadow .c2-gallery-carousel__item {
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.18 );
}

@keyframes c2-carousel-scroll {
	from { transform: translateX( 0 ); }
	to   { transform: translateX( -50% ); }
}

/* ═══════════════════════════════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════════════════════════════ */
#c2-lightbox {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 99999;
	align-items: center;
	justify-content: center;
}
#c2-lightbox.c2-lb--open {
	display: flex;
}

.c2-lb-backdrop {
	position: absolute;
	inset: 0;
	background: var( --c2-lb-backdrop-bg, rgba( 0, 0, 0, 0.92 ) );
	cursor: pointer;
}

.c2-lb-content {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: 92vw;
	max-height: 92vh;
}

.c2-lb-img {
	display: block;
	max-width: 90vw;
	max-height: 82vh;
	object-fit: contain;
	transition: opacity 0.2s ease;
	border-radius: 2px;
}

.c2-lb-caption {
	color: rgba( 255, 255, 255, 0.88 );
	font-size: 0.9rem;
	margin-top: 14px;
	text-align: center;
	max-width: 640px;
	padding: 0 16px;
}

.c2-lb-caption__title,
.c2-lb-caption__text {
	display: block;
}

.c2-lb-caption__title {
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.35;
}

.c2-lb-caption__text {
	margin-top: 4px;
	line-height: 1.45;
}

.c2-lb-spinner {
	display: none;
	width: 36px;
	height: 36px;
	border: 3px solid rgba( 255, 255, 255, 0.2 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: c2-spin 0.7s linear infinite;
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
}

@keyframes c2-spin { to { transform: translate( -50%, -50% ) rotate( 360deg ); } }

.c2-lb-close,
.c2-lb-prev,
.c2-lb-next {
	position: fixed;
	background: var( --c2-lb-button-bg, rgba( 255, 255, 255, 0.12 ) );
	border: none;
	color: var( --c2-lb-button-color, #fff );
	cursor: pointer;
	z-index: 2;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	line-height: 1;
}
.c2-lb-close:hover,
.c2-lb-prev:hover,
.c2-lb-next:hover {
	background: var( --c2-lb-button-bg, rgba( 255, 255, 255, 0.25 ) );
	filter: brightness( 1.12 );
}

.c2-lb-close {
	top: 18px;
	right: 18px;
	width: 40px;
	height: 40px;
	font-size: 18px;
}
.c2-lb-prev,
.c2-lb-next {
	top: 50%;
	transform: translateY( -50% );
	width: 52px;
	height: 52px;
	font-size: 32px;
}
.c2-lb-prev { left: 16px; }
.c2-lb-next { right: 16px; }

.c2-lb-body-open {
	overflow: hidden;
}

@media ( max-width: 600px ) {
	.c2-lb-prev { left: 6px; }
	.c2-lb-next { right: 6px; }
	.c2-lb-prev, .c2-lb-next { width: 40px; height: 40px; font-size: 24px; }
}
