/* ============================================================
   Nexus Gallery — Frontend UI
   Grid · Filter bar · Lightbox · Lazy loading skeletons
   ============================================================ */

/* ── Reset / base ───────────────────────────────────────────────── */
.nx-gallery-wrap *,
.nx-lightbox * {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

/* ── Gallery wrapper ────────────────────────────────────────────── */
.nx-gallery-wrap {
	width: 100%;
	font-family: inherit;
}

/* ── Event filter bar ───────────────────────────────────────────── */
.nx-gallery-filters {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	padding: 12px 0 20px;
	position: sticky;
	top: 0;
	z-index: 10;
	background: inherit;
}

.nx-filter-btn {
	padding: 7px 18px;
	border: 1.5px solid #e2e8f0;
	border-radius: 24px;
	background: #fff;
	color: #475569;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.18s ease;
	outline: none;
}
.nx-filter-btn:hover {
	border-color: #94a3b8;
	color: #1e293b;
}
.nx-filter-btn.nx-filter-active {
	background: #1e293b;
	border-color: #1e293b;
	color: #fff;
	font-weight: 600;
}

.nx-filter-sep {
	width: 1px;
	height: 24px;
	background: #e2e8f0;
	margin: 0 4px;
}

.nx-filter-cat {
	padding: 6px 12px;
	border: 1.5px solid #e2e8f0;
	border-radius: 8px;
	font-size: 13px;
	color: #475569;
	background: #fff;
	cursor: pointer;
	outline: none;
	transition: border-color 0.18s;
}
.nx-filter-cat:focus { border-color: #94a3b8; }

/* ── Image grid ─────────────────────────────────────────────────── */
.nx-gallery-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 12px;
}

@media (max-width: 1024px) {
	.nx-gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
	.nx-gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
@media (max-width: 360px) {
	.nx-gallery-grid { grid-template-columns: 1fr; }
}

/* ── Image card ─────────────────────────────────────────────────── */
.nx-gallery-card {
	position: relative;
	border-radius: 8px;
	overflow: hidden;
	cursor: pointer;
	background: #f1f5f9;
	/* Prevent layout shift before image loads */
	aspect-ratio: 1 / 1;
}

.nx-card-img-wrap {
	position: relative;
	width: 100%;
	height: 100%;
}

/* Skeleton placeholder shown until image loads */
.nx-card-skeleton {
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
	background-size: 200% 100%;
	animation: nx-shimmer 1.4s infinite ease-in-out;
	border-radius: 8px;
	transition: opacity 0.3s;
}
.nx-card-skeleton.hidden { opacity: 0; pointer-events: none; }

.nx-card-img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	display: block;
	opacity: 0;
	transition: opacity 0.35s ease;
	border-radius: 8px;
}
.nx-card-img.nx-loaded { opacity: 1; }

/* Hover overlay */
.nx-card-overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(to top, rgba(0,0,0,.62) 0%, transparent 55%);
	opacity: 0;
	transition: opacity 0.25s ease;
	display: flex;
	align-items: flex-end;
	padding: 10px 12px;
	border-radius: 8px;
}
.nx-gallery-card:hover .nx-card-overlay { opacity: 1; }

.nx-card-title {
	color: #fff;
	font-size: 13px;
	font-weight: 500;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-shadow: 0 1px 3px rgba(0,0,0,.4);
}

/* ── Loader / sentinel ──────────────────────────────────────────── */
.nx-gallery-loader {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 40px 0;
}
.nx-spinner {
	width: 32px;
	height: 32px;
	border: 3px solid #e2e8f0;
	border-top-color: #1e293b;
	border-radius: 50%;
	animation: nx-spin 0.7s linear infinite;
}

.nx-gallery-sentinel {
	height: 1px;
	margin-top: -1px;
}

.nx-gallery-empty {
	text-align: center;
	color: #94a3b8;
	font-size: 15px;
	padding: 60px 0;
}

/* ── Lightbox overlay ───────────────────────────────────────────── */
.nx-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	visibility: hidden;
	pointer-events: none;
}
.nx-lightbox.nx-lb-open {
	visibility: visible;
	pointer-events: auto;
}

.nx-lb-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .92);
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.25s ease;
}
.nx-lb-open .nx-lb-backdrop { opacity: 1; }

/* ── Lightbox stage ─────────────────────────────────────────────── */
.nx-lb-stage {
	position: relative;
	z-index: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	max-width: min(90vw, 1100px);
	max-height: 90vh;
	width: 100%;
	transform: scale(0.96);
	opacity: 0;
	transition: transform 0.25s ease, opacity 0.25s ease;
}
.nx-lb-open .nx-lb-stage {
	transform: scale(1);
	opacity: 1;
}

.nx-lb-img-wrap {
	position: relative;
	width: 100%;
	max-height: calc(90vh - 80px);
	display: flex;
	align-items: center;
	justify-content: center;
}

.nx-lb-skeleton {
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
	background-size: 200% 100%;
	animation: nx-shimmer 1.4s infinite ease-in-out;
	border-radius: 6px;
	transition: opacity 0.3s;
}
.nx-lb-skeleton.hidden { opacity: 0; }

#nx-lb-picture {
	display: block;
	max-width: 100%;
	max-height: calc(90vh - 80px);
}
#nx-lb-img {
	display: block;
	max-width: 100%;
	max-height: calc(90vh - 80px);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 6px;
	opacity: 0;
	transition: opacity 0.3s ease;
	user-select: none;
	-webkit-user-drag: none;
}
#nx-lb-img.nx-lb-ready { opacity: 1; }

/* ── Lightbox caption ───────────────────────────────────────────── */
.nx-lb-caption {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 14px 20px 0;
	text-align: center;
}
.nx-lb-title {
	color: #f1f5f9;
	font-size: 15px;
	font-weight: 600;
}
.nx-lb-event {
	color: #94a3b8;
	font-size: 12px;
}
.nx-lb-counter {
	color: #64748b;
	font-size: 12px;
	margin-top: 6px;
}

/* ── Lightbox nav buttons ───────────────────────────────────────── */
.nx-lb-btn {
	position: fixed;
	z-index: 2;
	background: rgba(255,255,255,.1);
	border: none;
	border-radius: 50%;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	transition: background 0.18s;
	backdrop-filter: blur(4px);
}
.nx-lb-btn:hover  { background: rgba(255,255,255,.22); }
.nx-lb-btn svg    { width: 22px; height: 22px; flex-shrink: 0; }

.nx-lb-close {
	top: 18px;
	right: 18px;
}
.nx-lb-prev {
	left: 18px;
	top: 50%;
	transform: translateY(-50%);
}
.nx-lb-next {
	right: 18px;
	top: 50%;
	transform: translateY(-50%);
}

.nx-lb-btn.nx-lb-hidden { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
	.nx-lb-prev { left: 8px; }
	.nx-lb-next { right: 8px; }
	.nx-lb-btn  { width: 40px; height: 40px; }
	.nx-lb-btn svg { width: 18px; height: 18px; }
}

/* ── Shared animations ──────────────────────────────────────────── */
@keyframes nx-shimmer {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}
@keyframes nx-spin {
	to { transform: rotate(360deg); }
}
