/* =========================================================
   Plataforma Política — Gallery & Lightbox
   ========================================================= */

/* --- Gallery grid --- */
.pp-gallery-grid {
	display: grid;
	grid-template-columns: repeat( 4, 1fr );
	gap: 8px;
	margin: var( --wp--preset--spacing--60, 2rem ) 0;
}

@media ( max-width: 1024px ) {
	.pp-gallery-grid {
		grid-template-columns: repeat( 3, 1fr );
	}
}

@media ( max-width: 640px ) {
	.pp-gallery-grid {
		grid-template-columns: repeat( 2, 1fr );
		gap: 4px;
	}
}

.pp-gallery-item {
	margin: 0;
	overflow: hidden;
	aspect-ratio: 1 / 1;
	background: var( --wp--preset--color--gray-light, #f3f4f6 );
}

.pp-gallery-link {
	display: block;
	width: 100%;
	height: 100%;
	overflow: hidden;
	text-decoration: none;
}

.pp-gallery-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.pp-gallery-link:hover .pp-gallery-img,
.pp-gallery-link:focus .pp-gallery-img {
	transform: scale( 1.06 );
	opacity: 0.88;
}

.pp-gallery-link:focus-visible {
	outline: 3px solid var( --wp--preset--color--accent, #f5c518 );
	outline-offset: -3px;
}

/* --- Lightbox overlay --- */
.pp-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pp-lightbox[hidden] {
	display: none;
}

.pp-lightbox-open {
	overflow: hidden;
}

.pp-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.92 );
	cursor: pointer;
}

/* Close button */
.pp-lightbox__close {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	width: 44px;
	height: 44px;
	background: rgba( 255, 255, 255, 0.1 );
	border: 1px solid rgba( 255, 255, 255, 0.2 );
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s;
}

.pp-lightbox__close:hover,
.pp-lightbox__close:focus-visible {
	background: rgba( 255, 255, 255, 0.22 );
	outline: 2px solid var( --wp--preset--color--accent, #f5c518 );
	outline-offset: 2px;
}

/* Nav arrows */
.pp-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
	z-index: 2;
	width: 52px;
	height: 52px;
	background: rgba( 255, 255, 255, 0.1 );
	border: 1px solid rgba( 255, 255, 255, 0.2 );
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s;
}

.pp-lightbox__prev { left: 16px; }
.pp-lightbox__next { right: 16px; }

.pp-lightbox__nav:hover,
.pp-lightbox__nav:focus-visible {
	background: rgba( 255, 255, 255, 0.22 );
	outline: 2px solid var( --wp--preset--color--accent, #f5c518 );
	outline-offset: 2px;
}

.pp-lightbox__nav[hidden] {
	display: none;
}

@media ( max-width: 640px ) {
	.pp-lightbox__nav {
		width: 40px;
		height: 40px;
	}
	.pp-lightbox__prev { left: 8px; }
	.pp-lightbox__next { right: 8px; }
}

/* Stage */
.pp-lightbox__stage {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: 90vw;
	max-height: 90vh;
}

.pp-lightbox__stage--loading::before {
	content: '';
	position: absolute;
	width: 40px;
	height: 40px;
	border: 3px solid rgba( 255, 255, 255, 0.2 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: pp-spin 0.7s linear infinite;
}

@keyframes pp-spin {
	to { transform: rotate( 360deg ); }
}

.pp-lightbox__figure {
	margin: 0;
	text-align: center;
}

.pp-lightbox__img {
	display: block;
	max-width: 88vw;
	max-height: 80vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 2px;
	box-shadow: 0 8px 48px rgba( 0, 0, 0, 0.6 );
}

.pp-lightbox__caption {
	color: rgba( 255, 255, 255, 0.78 );
	font-size: 13px;
	line-height: 1.45;
	margin-top: 10px;
	max-width: 600px;
	padding: 0 8px;
}

.pp-lightbox__caption[hidden] {
	display: none;
}

/* Counter badge */
.pp-lightbox__counter {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX( -50% );
	z-index: 2;
	color: rgba( 255, 255, 255, 0.7 );
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	background: rgba( 0, 0, 0, 0.45 );
	padding: 4px 14px;
	border-radius: 20px;
	white-space: nowrap;
}

@media ( prefers-reduced-motion: reduce ) {
	.pp-gallery-img {
		transition: none;
	}
	.pp-lightbox__stage--loading::before {
		animation: none;
	}
}
