.sgg-gallery {
	--sgg-columns: 3;
	--sgg-gutter: 10px;
	display: grid;
	grid-template-columns: repeat(var(--sgg-columns), 1fr);
	gap: var(--sgg-gutter);
	width: 100%;
}

.sgg-gallery .sgg-item {
	display: block;
	overflow: hidden;
	border-radius: 6px;
	position: relative;
}

.sgg-gallery.sgg-layout-grid .sgg-item {
	aspect-ratio: 3 / 2;
}

.sgg-gallery.sgg-layout-grid .sgg-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .3s ease;
}

.sgg-gallery.sgg-layout-grid .sgg-item:hover img {
	transform: scale(1.05);
}

/*
 * Masonry, implemented as CSS Grid (not column-count). Each item spans a
 * number of tiny auto-rows proportional to its own image height, set by
 * JS after the image loads. Because this is still CSS Grid, the browser's
 * auto-placement always fills left-to-right, row-by-row — items 1 and 2
 * land in row one, 3 and 4 in row two, etc. — it just lets each row be a
 * natural height instead of forcing every card into the same box.
 */
.sgg-gallery.sgg-layout-masonry {
	display: grid;
	grid-template-columns: repeat(var(--sgg-columns), 1fr);
	grid-auto-rows: 8px;
	gap: var(--sgg-gutter);
}

.sgg-gallery.sgg-layout-masonry .sgg-item img {
	width: 100%;
	height: auto;
	display: block;
	border-radius: 6px;
}

/*
 * Fallback only: used when an item has no data-ratio (e.g. very old
 * gallery data saved before dimensions were stored). Normally JS sets the
 * real span from data-ratio immediately on load, so this rarely applies
 * and no longer reserves a full oversized "guess" block.
 */
.sgg-gallery.sgg-layout-masonry .sgg-item-pending {
	grid-row-end: span 12;
}

/*
 * Liquid-glass skeleton: a frosted, semi-transparent panel (works over any
 * background — light or dark) instead of a flat white/grey block, with a
 * soft light sweep instead of a hard shimmer bar.
 */
.sgg-item-pending {
	position: relative;
	overflow: hidden;
	background: linear-gradient(
		135deg,
		rgba(255, 255, 255, 0.16) 0%,
		rgba(255, 255, 255, 0.05) 100%
	);
	backdrop-filter: blur(20px) saturate(180%);
	-webkit-backdrop-filter: blur(20px) saturate(180%);
	border: 1px solid rgba(255, 255, 255, 0.28);
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.35),
		inset 0 0 24px rgba(255, 255, 255, 0.06),
		0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Soft diagonal light sweep. */
.sgg-item-pending::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		115deg,
		rgba(255, 255, 255, 0) 25%,
		rgba(255, 255, 255, 0.45) 48%,
		rgba(255, 255, 255, 0.08) 52%,
		rgba(255, 255, 255, 0) 75%
	);
	background-size: 220% 100%;
	animation: sgg-shimmer 2s ease-in-out infinite;
}

/* Faint floating highlight so the panel never looks flat, even between
   shimmer sweeps. */
.sgg-item-pending::before {
	content: "";
	position: absolute;
	top: -40%;
	left: -20%;
	width: 60%;
	height: 60%;
	background: radial-gradient(
		circle,
		rgba(255, 255, 255, 0.25) 0%,
		rgba(255, 255, 255, 0) 70%
	);
	animation: sgg-glow 3.6s ease-in-out infinite;
	pointer-events: none;
}

@keyframes sgg-glow {
	0%,
	100% {
		opacity: 0.5;
		transform: translate(0, 0);
	}
	50% {
		opacity: 1;
		transform: translate(10%, 15%);
	}
}

@keyframes sgg-shimmer {
	from {
		background-position: 150% 0;
	}
	to {
		background-position: -50% 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sgg-item-pending::after {
		animation: none;
	}
}

@media (max-width: 782px) {
	.sgg-gallery {
		--sgg-columns: 2 !important;
	}
}

/* Lightbox */
.sgg-lightbox-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.9);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	padding: 20px;
}

.sgg-lightbox-overlay img {
	max-width: 90vw;
	max-height: 70vh;
	object-fit: contain;
	border-radius: 4px;
}

.sgg-lightbox-caption {
	position: absolute;
	bottom: 96px;
	left: 0;
	right: 0;
	text-align: center;
	color: #fff;
	font-size: 14px;
	padding: 0 20px;
}

.sgg-lightbox-thumbs {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	overflow-x: auto;
	background: rgba(0, 0, 0, 0.5);
	scrollbar-width: thin;
}

.sgg-lightbox-thumb {
	flex: 0 0 auto;
	width: 64px;
	height: 64px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 4px;
	overflow: hidden;
	background: none;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity .15s ease, border-color .15s ease;
}

.sgg-lightbox-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.sgg-lightbox-thumb:hover {
	opacity: 0.85;
}

.sgg-lightbox-thumb.is-active {
	opacity: 1;
	border-color: #fff;
}

.sgg-lightbox-close,
.sgg-lightbox-next,
.sgg-lightbox-prev {
	position: absolute;
	color: #fff;
	font-size: 32px;
	cursor: pointer;
	background: none;
	border: none;
	line-height: 1;
	padding: 10px;
}

.sgg-lightbox-close {
	top: 10px;
	right: 20px;
}

.sgg-lightbox-prev {
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
}

.sgg-lightbox-next {
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
}
