.sgal-gallery {
	display: grid;
	grid-template-columns: repeat(var(--sgal-columns, 3), 1fr);
	gap: var(--sgal-gap, 10px);
	margin: 1em 0;
}

.sgal-item {
	display: block;
	overflow: hidden;
	border-radius: var(--sgal-radius, 4px);
	line-height: 0;
	/* Stan początkowy: niewidoczny, lekko opuszczony i pomniejszony. */
	opacity: 0;
	transform: translateY(12px) scale(.98);
	transition: opacity .5s ease, transform .5s ease;
}

/* Po załadowaniu obrazka (dodawane przez JS). */
.sgal-item.is-loaded {
	opacity: 1;
	transform: none;
}

.sgal-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	aspect-ratio: 1 / 1;
	transition: transform .25s ease, opacity .25s ease;
	cursor: pointer;
}

.sgal-item:hover img {
	transform: scale(1.05);
	opacity: .9;
}

/* Szanuj ustawienia dostępności: bez animacji wejścia. */
@media (prefers-reduced-motion: reduce) {
	.sgal-item {
		opacity: 1;
		transform: none;
		transition: none;
	}
}

/* Responsywność: zmniejszamy liczbę kolumn na mniejszych ekranach */
@media (max-width: 768px) {
	.sgal-gallery {
		grid-template-columns: repeat(min(var(--sgal-columns, 3), 3), 1fr);
	}
}

@media (max-width: 480px) {
	.sgal-gallery {
		grid-template-columns: repeat(min(var(--sgal-columns, 3), 2), 1fr);
	}
}

/* Lightbox */
.sgal-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .9);
	opacity: 0;
	transition: opacity .25s ease;
}

.sgal-lightbox.is-open {
	display: flex;
	opacity: 1;
}

.sgal-stage {
	margin: 0;
	max-width: 92vw;
	max-height: 88vh;
	text-align: center;
}

.sgal-image {
	max-width: 92vw;
	max-height: 80vh;
	object-fit: contain;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

.sgal-caption {
	color: #fff;
	font-size: 14px;
	margin-top: 10px;
	min-height: 1.2em;
}

.sgal-close,
.sgal-prev,
.sgal-next {
	position: absolute;
	background: rgba(0, 0, 0, .4);
	color: #fff;
	border: 0;
	cursor: pointer;
	line-height: 1;
	transition: background .2s ease;
	user-select: none;
}

.sgal-close:hover,
.sgal-prev:hover,
.sgal-next:hover {
	background: rgba(255, 255, 255, .2);
}

.sgal-close {
	top: 16px;
	right: 16px;
	width: 44px;
	height: 44px;
	font-size: 28px;
	border-radius: 50%;
}

.sgal-prev,
.sgal-next {
	top: 50%;
	transform: translateY(-50%);
	width: 50px;
	height: 60px;
	font-size: 26px;
	border-radius: 6px;
}

.sgal-prev { left: 16px; }
.sgal-next { right: 16px; }

@media (max-width: 480px) {
	.sgal-prev, .sgal-next { width: 40px; height: 50px; font-size: 20px; }
}
