/* -------------------------------------------------------------------
 * NPD Before & After Gallery
 * Enqueued by npd_ba_register_assets() in functions.php
 * Grid: --npd-ba-cols-sm / --npd-ba-cols-md (>=768) / --npd-ba-cols (>=992)
 * ---------------------------------------------------------------- */

.npd-ba-grid {
	position: relative;
	z-index: 0;
	display: grid;
	grid-template-columns: repeat(var(--npd-ba-cols-sm, 1), minmax(0, 1fr));
	gap: 14px;
}

@media (min-width: 768px) {
	.npd-ba-grid {
		grid-template-columns: repeat(var(--npd-ba-cols-md, 2), minmax(0, 1fr));
		gap: 20px;
	}
}

@media (min-width: 992px) {
	.npd-ba-grid {
		grid-template-columns: repeat(var(--npd-ba-cols, 4), minmax(0, 1fr));
	}
}

.npd-ba-item {
	position: relative;
	z-index: 0;
	margin: 0;
	min-width: 0;
}

.npd-ba-tile {
	position: relative;
	z-index: 0;
	isolation: isolate;
	/* Images are stacked as grid items, not absolutely positioned, so the
	   tile always has real height even if aspect-ratio fails to resolve.
	   Nothing can spill out and paint over the footer. */
	display: grid;
	grid-template-areas: "npd-ba-stack";
	width: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 6px;
	overflow: hidden;
	background: #e9e9e9;
	cursor: pointer;
	aspect-ratio: var(--npd-ba-ratio, 4/3);
	-webkit-tap-highlight-color: transparent;
}

.npd-ba-tile:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

.npd-ba-img {
	grid-area: npd-ba-stack;
	display: block;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	max-width: none;
	object-fit: cover;
}

.npd-ba-img--after {
	opacity: 0;
	transition: opacity .4s ease;
}

@media (hover: hover) and (pointer: fine) {
	.npd-ba-tile:hover .npd-ba-img--after,
	.npd-ba-tile:focus-visible .npd-ba-img--after {
		opacity: 1;
	}
	.npd-ba-tile:hover .npd-ba-badge__before,
	.npd-ba-tile:focus-visible .npd-ba-badge__before {
		opacity: 0;
	}
	.npd-ba-tile:hover .npd-ba-badge__after,
	.npd-ba-tile:focus-visible .npd-ba-badge__after {
		opacity: 1;
	}
}

/* Badge ------------------------------------------------------------ */
.npd-ba-badge {
	grid-area: npd-ba-stack;
	align-self: start;
	justify-self: start;
	position: relative;
	z-index: 2;
	margin: 8px 0 0 8px;
	display: block;
	width: 58px;
	height: 22px;
}

.npd-ba-badge span {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 100px;
	background: rgba(17, 17, 17, .72);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: .08em;
	text-transform: uppercase;
	line-height: 1;
	transition: opacity .4s ease;
}

.npd-ba-badge__after {
	opacity: 0;
}

/* Touch hint — replaces hover on phones/tablets */
.npd-ba-hint {
	grid-area: npd-ba-stack;
	align-self: end;
	justify-self: end;
	position: relative;
	z-index: 2;
	margin: 0 8px 8px 0;
	display: none;
	padding: 5px 10px;
	border-radius: 100px;
	background: rgba(17, 17, 17, .72);
	color: #fff;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	line-height: 1;
}

@media (hover: none) {
	.npd-ba-hint {
		display: block;
	}
}

/* Container guards -------------------------------------------------
 * Undoes fixed heights / clipping applied by matchHeight, Porto equal-
 * height rows or Elementor wrappers, which would otherwise cut the grid
 * off mid-way and let the footer paint over the remaining rows.
 * ---------------------------------------------------------------- */
.npd-ba-grid {
	clear: both;
}

.elementor-widget-shortcode:has(.npd-ba-grid),
.elementor-widget-shortcode:has(.npd-ba-grid) .elementor-widget-container,
.elementor-widget-text-editor:has(.npd-ba-grid),
.elementor-widget-text-editor:has(.npd-ba-grid) .elementor-widget-container,
.elementor-element:has(> .elementor-widget-container > .npd-ba-grid) {
	height: auto !important;
	min-height: 0 !important;
	max-height: none !important;
	overflow: visible !important;
}

/* Lightbox --------------------------------------------------------- */
.npd-ba-lb {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	height: 100dvh;
	background: rgba(10, 10, 10, .94);
	padding: 56px 12px 78px;
	overscroll-behavior: contain;
	touch-action: pan-y;
}

@media (min-width: 768px) {
	.npd-ba-lb {
		padding: 60px 20px 28px;
	}
}

.npd-ba-lb.is-open {
	display: flex;
	align-items: center;
	justify-content: center;
}

.npd-ba-lb__inner {
	width: 100%;
	max-width: 1200px;
	max-height: 100%;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
}

.npd-ba-lb__title {
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	text-align: center;
	margin: 0 0 12px;
	line-height: 1.3;
}

.npd-ba-lb__pair {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

@media (min-width: 768px) {
	.npd-ba-lb__pair {
		grid-template-columns: 1fr 1fr;
		gap: 18px;
	}
	.npd-ba-lb__title {
		font-size: 17px;
		margin-bottom: 14px;
	}
}

.npd-ba-lb__fig {
	margin: 0;
	min-width: 0;
}

.npd-ba-lb__fig img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 34dvh;
	object-fit: contain;
	border-radius: 4px;
	background: #1c1c1c;
}

@media (min-width: 768px) {
	.npd-ba-lb__fig img {
		max-height: 74dvh;
	}
}

.npd-ba-lb__cap {
	margin-top: 6px;
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .1em;
	text-transform: uppercase;
	text-align: center;
	opacity: .75;
}

.npd-ba-lb__btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .16);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background .2s ease;
	-webkit-tap-highlight-color: transparent;
}

.npd-ba-lb__btn:hover {
	background: rgba(255, 255, 255, .3);
}

.npd-ba-lb__close {
	top: 10px;
	right: 10px;
}

/* Phones: nav sits on a bar under the images, clear of the content */
.npd-ba-lb__prev {
	bottom: 18px;
	left: calc(50% - 62px);
}

.npd-ba-lb__next {
	bottom: 18px;
	right: calc(50% - 62px);
}

@media (min-width: 768px) {
	.npd-ba-lb__prev {
		top: 50%;
		bottom: auto;
		left: 12px;
		transform: translateY(-50%);
	}
	.npd-ba-lb__next {
		top: 50%;
		bottom: auto;
		right: 12px;
		transform: translateY(-50%);
	}
}

body.npd-ba-lock {
	overflow: hidden;
	position: relative;
}

@media (prefers-reduced-motion: reduce) {
	.npd-ba-img--after,
	.npd-ba-badge span {
		transition: none;
	}
}