/* ==========================================================================
   Custom Portfolio Lightbox Gallery — frontend styles
   ========================================================================== */

/* Grid layout
   ----------------------------------------------------------------- */
.cplg-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 24px;
}

@media (max-width: 1024px) {
	.cplg-grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 18px;
	}
}

@media (max-width: 640px) {
	.cplg-grid {
		grid-template-columns: 1fr;
		gap: 14px;
	}
}

/* Item card
   ----------------------------------------------------------------- */
.cplg-item {
	position: relative;
}

.cplg-trigger {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	background: transparent !important;
	border: 0 !important;
	box-shadow: none !important;
	border-radius: 0;
	cursor: pointer;
	font: inherit;
	color: inherit;
	text-align: left;
	-webkit-appearance: none;
	appearance: none;
	line-height: 1.3;
}

.cplg-trigger:hover,
.cplg-trigger:focus {
	background: transparent !important;
	color: inherit;
}

.cplg-trigger:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 3px;
}

.cplg-image {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: 8px;
	background: #f3f3f3;
	aspect-ratio: 4 / 3;
}

.cplg-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	margin: 0;
	transition: transform .4s ease, opacity .3s ease;
}

.cplg-trigger:hover .cplg-image img {
	transform: scale(1.04);
	opacity: .92;
}

.cplg-title {
	display: block;
	margin-top: 10px;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.3;
	color: inherit;
}

/* Single shortcode: keep image natural ratio. */
.cplg-single .cplg-image {
	aspect-ratio: auto;
	background: transparent;
}

.cplg-single .cplg-image img {
	height: auto;
}

/* Lightbox
   ----------------------------------------------------------------- */
.cplg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: rgba(15, 15, 15, .94);
	display: none;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity .2s ease;
}

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

.cplg-lightbox,
.cplg-lightbox * {
	box-sizing: border-box;
}

.cplg-stage {
	position: relative;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cplg-slides {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: hidden;
	touch-action: pan-y;
}

.cplg-slide {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 64px 72px 88px;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease;
	pointer-events: none;
}

.cplg-slide.is-active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.cplg-slide img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	display: block;
	margin: 0;
	user-select: none;
	-webkit-user-drag: none;
}

/* Caption — hidden when empty (CSS :empty). */
.cplg-caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 18px 80px 22px;
	color: #fff;
	text-align: center;
	font-size: 14px;
	line-height: 1.5;
	background: linear-gradient(to top, rgba(0, 0, 0, .55), transparent);
	pointer-events: none;
	min-height: 0;
}

.cplg-caption:empty {
	display: none;
}

/* Buttons */
.cplg-btn {
	position: absolute;
	background: rgba(0, 0, 0, .35);
	border: 0;
	color: #fff;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	margin: 0;
	transition: background .2s ease, opacity .2s ease;
	z-index: 5;
	-webkit-appearance: none;
	appearance: none;
}

.cplg-btn:hover,
.cplg-btn:focus {
	background: rgba(0, 0, 0, .65);
	outline: none;
}

.cplg-btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.cplg-btn svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: #fff;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.cplg-close {
	top: 18px;
	right: 18px;
}

.cplg-prev {
	left: 18px;
	top: 50%;
	transform: translateY(-50%);
}

.cplg-next {
	right: 18px;
	top: 50%;
	transform: translateY(-50%);
}

/* Counter pill (top-center) */
.cplg-counter {
	position: absolute;
	top: 22px;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-size: 13px;
	letter-spacing: .5px;
	background: rgba(0, 0, 0, .4);
	padding: 6px 12px;
	border-radius: 999px;
	z-index: 5;
}

/* Dots */
.cplg-dots {
	position: absolute;
	bottom: 14px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 8px;
	z-index: 5;
}

.cplg-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: rgba(255, 255, 255, .35);
	border: 0;
	padding: 0;
	cursor: pointer;
	transition: background .2s ease, transform .2s ease;
	-webkit-appearance: none;
	appearance: none;
}

.cplg-dot:hover {
	background: rgba(255, 255, 255, .55);
}

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

/* Hide dots when there are many slides — counter handles wayfinding. */
.cplg-lightbox[data-many="1"] .cplg-dots {
	display: none;
}

/* Mobile tuning */
@media (max-width: 640px) {
	.cplg-slide {
		padding: 56px 16px 72px;
	}

	.cplg-caption {
		padding: 14px 20px 16px;
		font-size: 13px;
	}

	.cplg-prev,
	.cplg-next {
		width: 40px;
		height: 40px;
	}

	.cplg-prev { left: 8px; }
	.cplg-next { right: 8px; }
	.cplg-close { top: 10px; right: 10px; }
	.cplg-counter { top: 12px; font-size: 12px; padding: 4px 10px; }
}

/* When body is locked while lightbox is open. */
.cplg-body-lock {
	overflow: hidden !important;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
	.cplg-lightbox,
	.cplg-slide,
	.cplg-image img,
	.cplg-btn,
	.cplg-dot {
		transition: none !important;
	}
}
