/**
 * WebPixel Gallery — Frontend
 */

.wpg-gallery {
	position: relative;
	width: 100%;
	margin: 1.5em 0;
	box-sizing: border-box;
}

.wpg-gallery * {
	box-sizing: border-box;
}

.wpg-item {
	margin: 0;
	overflow: hidden;
	border-radius: 6px;
	background: #f0f0f0;
}

.wpg-item .wpg-link {
	display: block;
	line-height: 0;
	cursor: zoom-in;
}

.wpg-item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease;
}

.wpg-item:hover img {
	transform: scale( 1.05 );
}

.wpg-caption {
	padding: 6px 8px;
	font-size: 13px;
	line-height: 1.35;
	color: #444;
	background: #fafafa;
}

/* ----------------------------------------------------------------
 * Grid
 * ---------------------------------------------------------------- */
.wpg-layout-grid .wpg-track {
	display: grid;
	grid-template-columns: repeat( var( --wpg-columns, 3 ), 1fr );
	gap: var( --wpg-gap, 10px );
}

.wpg-layout-grid .wpg-item {
	aspect-ratio: 1 / 1;
}

/* ----------------------------------------------------------------
 * Masonry (posicionamento via JS; fallback com CSS columns)
 * ---------------------------------------------------------------- */
.wpg-layout-masonry .wpg-track {
	position: relative;
}

.wpg-layout-masonry .wpg-item {
	aspect-ratio: auto;
}

/* Fallback antes do JS aplicar o posicionamento absoluto. */
.wpg-layout-masonry .wpg-track:not( [style*="height" ] ) {
	column-count: var( --wpg-columns, 3 );
	column-gap: var( --wpg-gap, 10px );
}

.wpg-layout-masonry .wpg-track:not( [style*="height" ] ) .wpg-item {
	break-inside: avoid;
	margin-bottom: var( --wpg-gap, 10px );
}

/* ----------------------------------------------------------------
 * Justified (posicionamento via JS)
 * ---------------------------------------------------------------- */
.wpg-layout-justified .wpg-track {
	position: relative;
}

.wpg-layout-justified .wpg-item {
	aspect-ratio: auto;
}

/* Fallback flex antes do JS. */
.wpg-layout-justified .wpg-track:not( [style*="height" ] ) {
	display: flex;
	flex-wrap: wrap;
	gap: var( --wpg-gap, 10px );
}

.wpg-layout-justified .wpg-track:not( [style*="height" ] ) .wpg-item {
	height: 220px;
	flex: 1 1 auto;
}

/* ----------------------------------------------------------------
 * Carrossel
 * ---------------------------------------------------------------- */
.wpg-layout-carousel {
	overflow: hidden;
	border-radius: 8px;
}

.wpg-layout-carousel .wpg-track {
	display: flex;
	transition: transform 0.45s ease;
}

.wpg-layout-carousel .wpg-item {
	flex: 0 0 100%;
	max-width: 100%;
	border-radius: 0;
	aspect-ratio: 16 / 9;
	background: #111;
}

.wpg-layout-carousel .wpg-item img {
	object-fit: contain;
}

.wpg-layout-carousel .wpg-item:hover img {
	transform: none;
}

.wpg-nav {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: rgba( 0, 0, 0, 0.45 );
	color: #fff;
	font-size: 18px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
	z-index: 2;
}

.wpg-nav:hover {
	background: rgba( 0, 0, 0, 0.75 );
}

.wpg-prev { left: 12px; }
.wpg-next { right: 12px; }

.wpg-dots {
	position: absolute;
	bottom: 12px;
	left: 0;
	right: 0;
	display: flex;
	justify-content: center;
	gap: 8px;
	z-index: 2;
}

.wpg-dot {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.5 );
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.wpg-dot.is-active {
	background: #fff;
	transform: scale( 1.3 );
}

/* ----------------------------------------------------------------
 * Collage (grid com destaques)
 * ---------------------------------------------------------------- */
.wpg-layout-collage .wpg-track {
	display: grid;
	grid-template-columns: repeat( var( --wpg-columns, 3 ), 1fr );
	grid-auto-rows: 1fr;
	gap: var( --wpg-gap, 10px );
}

.wpg-layout-collage .wpg-item {
	aspect-ratio: 1 / 1;
}

/* Alguns itens ganham destaque (span) formando a colagem. */
.wpg-layout-collage .wpg-item:nth-child( 6n + 1 ) {
	grid-column: span 2;
	grid-row: span 2;
	aspect-ratio: auto;
}

.wpg-layout-collage .wpg-item:nth-child( 6n + 4 ) {
	grid-row: span 2;
	aspect-ratio: auto;
}

@media ( max-width: 600px ) {
	.wpg-layout-collage .wpg-item:nth-child( 6n + 1 ),
	.wpg-layout-collage .wpg-item:nth-child( 6n + 4 ) {
		grid-column: span 1;
		grid-row: span 1;
		aspect-ratio: 1 / 1;
	}
}

/* Responsivo geral para grid/collage */
@media ( max-width: 1024px ) {
	.wpg-layout-grid .wpg-track,
	.wpg-layout-collage .wpg-track {
		grid-template-columns: repeat( min( var( --wpg-columns, 3 ), 3 ), 1fr );
	}
}

@media ( max-width: 768px ) {
	.wpg-layout-grid .wpg-track,
	.wpg-layout-collage .wpg-track {
		grid-template-columns: repeat( 2, 1fr );
	}
}

@media ( max-width: 480px ) {
	.wpg-layout-grid .wpg-track,
	.wpg-layout-collage .wpg-track {
		grid-template-columns: 1fr;
	}
}

/* ----------------------------------------------------------------
 * Lightbox
 * ---------------------------------------------------------------- */
body.wpg-lb-lock {
	overflow: hidden;
}

.wpg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba( 0, 0, 0, 0.9 );
	opacity: 0;
	transition: opacity 0.25s ease;
}

.wpg-lightbox.is-open {
	display: flex;
	opacity: 1;
}

.wpg-lb-figure {
	margin: 0;
	max-width: 92vw;
	max-height: 90vh;
	text-align: center;
}

.wpg-lb-img {
	max-width: 92vw;
	max-height: 82vh;
	display: block;
	margin: 0 auto;
	border-radius: 4px;
	opacity: 0;
	transform: scale( 0.97 );
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.wpg-lb-img.is-loaded {
	opacity: 1;
	transform: scale( 1 );
}

.wpg-lb-caption {
	margin-top: 12px;
	color: #eee;
	font-size: 14px;
}

.wpg-lb-close,
.wpg-lb-prev,
.wpg-lb-next {
	position: fixed;
	border: 0;
	background: rgba( 255, 255, 255, 0.12 );
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
	z-index: 1;
}

.wpg-lb-close:hover,
.wpg-lb-prev:hover,
.wpg-lb-next:hover {
	background: rgba( 255, 255, 255, 0.28 );
}

.wpg-lb-close {
	top: 18px;
	right: 18px;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	font-size: 30px;
	line-height: 1;
}

.wpg-lb-prev,
.wpg-lb-next {
	top: 50%;
	transform: translateY( -50% );
	width: 54px;
	height: 54px;
	border-radius: 50%;
	font-size: 22px;
}

.wpg-lb-prev { left: 20px; }
.wpg-lb-next { right: 20px; }

@media ( max-width: 600px ) {
	.wpg-lb-prev,
	.wpg-lb-next {
		width: 42px;
		height: 42px;
		font-size: 18px;
	}
	.wpg-lb-prev { left: 8px; }
	.wpg-lb-next { right: 8px; }
}
