/*
 * NextGenBuilds OS - reusable gallery lightbox/carousel styles.
 *
 * Design-system-neutral: uses only structural CSS (grid, flex, sizing) -
 * no colors, fonts or spacing tokens - so it drops cleanly into any
 * preset's theme.json without fighting project-specific design tokens.
 * A project's own stylesheet may still restyle `.ngb-gallery*` classes
 * for its palette (e.g. the modal backdrop tint), same as any other
 * block.
 */

.ngb-gallery__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 1rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ngb-gallery__item {
	margin: 0;
}

.ngb-gallery__trigger {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	cursor: zoom-in;
	aspect-ratio: 4 / 3;
	overflow: hidden;
}

.ngb-gallery__thumb {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover; /* thumbnails may crop to a consistent grid cell - the full image is never cropped (see modal image below) */
}

.ngb-gallery__trigger:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 2px;
}

/* --- Modal / lightbox / carousel ----------------------------------- */

.ngb-gallery-modal {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ngb-gallery-modal[hidden] {
	display: none;
}

.ngb-gallery-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
}

.ngb-gallery-modal__content {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: min(100%, 1100px);
	max-height: 92vh;
	padding: 1rem;
	box-sizing: border-box;
}

.ngb-gallery-modal__figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.5rem;
	min-width: 0;
	max-width: 100%;
}

.ngb-gallery-modal__image {
	display: block;
	max-width: 100%;
	max-height: 80vh;
	width: auto;
	height: auto;
	object-fit: contain; /* full image is NEVER stretched or cropped */
	background: #111;
}

.ngb-gallery-modal__image.is-loading {
	opacity: 0.4;
}

.ngb-gallery-modal__caption {
	color: #fff;
	font-size: 0.9rem;
	text-align: center;
	max-width: 60ch;
}

.ngb-gallery-modal__close,
.ngb-gallery-modal__prev,
.ngb-gallery-modal__next {
	position: absolute;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	border: 0;
	border-radius: 999px;
	width: 2.75rem;
	height: 2.75rem;
	font-size: 1.5rem;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ngb-gallery-modal__close:focus-visible,
.ngb-gallery-modal__prev:focus-visible,
.ngb-gallery-modal__next:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.ngb-gallery-modal__close {
	top: 0.5rem;
	right: 0.5rem;
}

.ngb-gallery-modal__prev {
	left: 0.5rem;
	top: 50%;
	transform: translateY(-50%);
}

.ngb-gallery-modal__next {
	right: 0.5rem;
	top: 50%;
	transform: translateY(-50%);
}

.ngb-gallery-modal__prev[hidden],
.ngb-gallery-modal__next[hidden] {
	display: none;
}

.ngb-gallery-modal__counter {
	position: absolute;
	bottom: 0.5rem;
	left: 50%;
	transform: translateX(-50%);
	color: #fff;
	font-size: 0.85rem;
	background: rgba(0, 0, 0, 0.5);
	padding: 0.2rem 0.6rem;
	border-radius: 999px;
}

@media (prefers-reduced-motion: no-preference) {
	.ngb-gallery-modal__image {
		transition: opacity 0.15s ease;
	}
}

@media (max-width: 599px) {
	.ngb-gallery__grid {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
		gap: 0.5rem;
	}
	.ngb-gallery-modal__prev,
	.ngb-gallery-modal__next {
		width: 2.25rem;
		height: 2.25rem;
		font-size: 1.25rem;
	}
}
