/* ==========================================
   ELEVATE PROJECT GALLERY
   ========================================== */

.nbpg-gallery {
	--nbpg-gap: 16px;
	--nbpg-orange: #ff7433;
	--nbpg-black: #000;
	--nbpg-fade-color: #000;

	position: relative;
	width: 100%;
	background: #000;
}

/* Gallery preview wrapper */
.nbpg-gallery__stage {
	position: relative;
	width: 100%;
	background: #000;
}

/* Image grid */
.nbpg-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: var(--nbpg-gap);
	width: 100%;
	background: #000;
}

/*
 * Limit the preview height so users can see that
 * more gallery content continues below.
 */
.nbpg-gallery:not(.is-expanded)
	.nbpg-gallery__grid {
	max-height: 520px;
	overflow: hidden;
}

/* Individual gallery image */
.nbpg-gallery__item {
	aspect-ratio: 4 / 3;
	width: 100%;
	margin: 0;
	overflow: hidden;
	background: #000;
}

/* Ensure hidden gallery items remain hidden */
.nbpg-gallery [hidden] {
	display: none !important;
}

/* Reset button styling around images */
.nbpg-gallery__image-button {
	appearance: none;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 0;
	background: transparent;
	cursor: zoom-in;
}

/* Responsive WordPress image */
.nbpg-gallery__image {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease;
}

.nbpg-gallery__image-button:hover
	.nbpg-gallery__image,
.nbpg-gallery__image-button:focus-visible
	.nbpg-gallery__image {
	transform: scale(1.035);
}

.nbpg-gallery__image-button:focus-visible {
	outline: 3px solid var(--nbpg-orange);
	outline-offset: -3px;
}

/* Bottom fade shown only while collapsed */
.nbpg-gallery__fade {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2;

	height: 58%;
	pointer-events: none;

	background: linear-gradient(
		to bottom,
		rgba(0, 0, 0, 0) 0%,
		rgba(0, 0, 0, 0.65) 48%,
		var(--nbpg-fade-color) 88%
	);

	transition: opacity 0.25s ease;
}

/* Expand/collapse button */
.nbpg-gallery__toggle {
	appearance: none;
	position: absolute;
	bottom: 32px;
	left: 50%;
	z-index: 3;

	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;

	min-width: 230px;
	margin: 0;
	padding: 15px 28px;

	border: 1px solid #fff;
	border-radius: 0;
	background: #fff;
	color: #000;

	font: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.04em;
	text-align: center;
	text-transform: uppercase;

	cursor: pointer;
	transform: translateX(-50%);

	transition:
		background-color 0.2s ease,
		border-color 0.2s ease,
		color 0.2s ease;
}

.nbpg-gallery__toggle:hover,
.nbpg-gallery__toggle:focus-visible {
	background: var(--nbpg-orange);
	border-color: var(--nbpg-orange);
	color: #000;
}

.nbpg-gallery__toggle:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

/* Smaller photo count below button label */
.nbpg-gallery__count {
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.12em;
	opacity: 0.7;
}

/* Expanded state */
.nbpg-gallery.is-expanded
	.nbpg-gallery__fade {
	opacity: 0;
	visibility: hidden;
}

/*
 * Once expanded, move the button below the gallery
 * instead of leaving it over the images.
 */
.nbpg-gallery.is-expanded
	.nbpg-gallery__toggle {
	position: relative;
	bottom: auto;
	left: auto;

	display: flex;
	width: max-content;
	margin: 24px auto 0;

	transform: none;
}

/* ==========================================
   LIGHTBOX
   ========================================== */

html.nbpg-lightbox-open,
html.nbpg-lightbox-open body {
	overflow: hidden !important;
}

.nbpg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;

	display: flex;
	align-items: center;
	justify-content: center;

	padding: 60px 80px;
	background: rgba(0, 0, 0, 0.94);

	opacity: 0;
	pointer-events: none;

	transition: opacity 0.2s ease;
}

.nbpg-lightbox.is-open {
	opacity: 1;
	pointer-events: auto;
}

.nbpg-lightbox[hidden] {
	display: none !important;
}

.nbpg-lightbox__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;

	width: 100%;
	height: 100%;
	margin: 0;
}

.nbpg-lightbox__image {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 150px);
	width: auto;
	height: auto;
	object-fit: contain;
}

.nbpg-lightbox__caption {
	max-width: 900px;
	margin-top: 14px;
	color: #fff;
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
}

.nbpg-lightbox__close,
.nbpg-lightbox__previous,
.nbpg-lightbox__next {
	appearance: none;
	position: absolute;
	z-index: 2;

	display: flex;
	align-items: center;
	justify-content: center;

	margin: 0;
	padding: 0;

	border: 0;
	background: transparent;
	color: #fff;

	cursor: pointer;
	transition:
		color 0.2s ease,
		background-color 0.2s ease;
}

.nbpg-lightbox__close:hover,
.nbpg-lightbox__previous:hover,
.nbpg-lightbox__next:hover,
.nbpg-lightbox__close:focus-visible,
.nbpg-lightbox__previous:focus-visible,
.nbpg-lightbox__next:focus-visible {
	color: var(--nbpg-orange);
}

.nbpg-lightbox__close {
	top: 18px;
	right: 24px;

	width: 48px;
	height: 48px;
	font-size: 44px;
	line-height: 1;
}

.nbpg-lightbox__previous,
.nbpg-lightbox__next {
	top: 50%;

	width: 60px;
	height: 80px;

	font-size: 70px;
	line-height: 1;

	transform: translateY(-50%);
}

.nbpg-lightbox__previous {
	left: 16px;
}

.nbpg-lightbox__next {
	right: 16px;
}

.nbpg-lightbox__counter {
	position: absolute;
	right: 0;
	bottom: 20px;
	left: 0;

	color: #fff;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-align: center;
}

/* ==========================================
   TABLET
   768px–1024px: show two preview images
   ========================================== */

@media (max-width: 1024px) {
	.nbpg-gallery__grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	/* Hide the third preview image and everything after it */
	.nbpg-gallery:not(.is-expanded)
		.nbpg-gallery__item:nth-child(n + 3) {
		display: none !important;
	}

	.nbpg-lightbox {
		padding: 60px;
	}
}

/* ==========================================
   MOBILE
   767px and below: show one preview image
   ========================================== */

@media (max-width: 767px) {
	.nbpg-gallery {
		--nbpg-gap: 12px;
	}

	.nbpg-gallery__grid {
		grid-template-columns: 1fr;
	}

	/* Hide the second preview image and everything after it */
	.nbpg-gallery:not(.is-expanded)
		.nbpg-gallery__item:nth-child(n + 2) {
		display: none !important;
	}

	.nbpg-gallery:not(.is-expanded)
		.nbpg-gallery__grid {
		max-height: 520px;
	}

	.nbpg-gallery__toggle {
		width: calc(100% - 32px);
		min-width: 0;
		max-width: 360px;
		padding-right: 18px;
		padding-left: 18px;
	}

	.nbpg-gallery.is-expanded
		.nbpg-gallery__toggle {
		width: calc(100% - 32px);
	}

	.nbpg-lightbox {
		padding: 70px 14px 80px;
	}

	.nbpg-lightbox__image {
		max-height: calc(100vh - 180px);
	}

	.nbpg-lightbox__previous,
	.nbpg-lightbox__next {
		top: auto;
		bottom: 14px;

		width: 56px;
		height: 56px;

		background: rgba(255, 255, 255, 0.08);
		font-size: 48px;

		transform: none;
	}

	.nbpg-lightbox__previous {
		left: 14px;
	}

	.nbpg-lightbox__next {
		right: 14px;
	}

	.nbpg-lightbox__counter {
		bottom: 32px;
	}
}