/* Stylish Gallery — front-end */

.sgal-wrap {
	--sgal-cols: 3;
	--sgal-gap: 16px;
	--sgal-radius: 14px;
	width: 100%;
}

/* Masonry via CSS columns */
.sgal-layout-masonry {
	column-count: var(--sgal-cols);
	column-gap: var(--sgal-gap);
}
.sgal-layout-masonry .sgal-item {
	break-inside: avoid;
	margin: 0 0 var(--sgal-gap);
}

/* Uniform grid */
.sgal-layout-grid {
	display: grid;
	grid-template-columns: repeat(var(--sgal-cols), 1fr);
	gap: var(--sgal-gap);
}
.sgal-layout-grid .sgal-item {
	margin: 0;
	aspect-ratio: 1 / 1;
}
.sgal-layout-grid .sgal-item img {
	height: 100%;
	object-fit: cover;
}

/* Item */
.sgal-item {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: var(--sgal-radius);
	cursor: pointer;
	background: #f1f1f1;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
	transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1),
		box-shadow 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
	outline: none;
}
.sgal-item img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
		filter 0.45s ease;
}
.sgal-item:hover,
.sgal-item:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.32);
}
.sgal-item:hover img,
.sgal-item:focus-visible img {
	transform: scale(1.06);
}
.sgal-item:focus-visible {
	box-shadow: 0 0 0 3px #fff, 0 0 0 5px #111;
}

/* Caption */
.sgal-caption {
	position: absolute;
	inset: auto 0 0 0;
	padding: 28px 16px 14px;
	margin: 0;
	color: #fff;
	font-size: 14px;
	line-height: 1.35;
	letter-spacing: 0.01em;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
	transform: translateY(8px);
	opacity: 0;
	transition: opacity 0.4s ease, transform 0.4s ease;
}
.sgal-item:hover .sgal-caption,
.sgal-item:focus-visible .sgal-caption {
	opacity: 1;
	transform: translateY(0);
}

/* Empty-state notice (admins only) */
.sgal-empty {
	padding: 18px 20px;
	border: 1px dashed #c9c9c9;
	border-radius: 10px;
	color: #555;
	background: #fafafa;
	font-size: 14px;
}

/* ---------- Lightbox ---------- */
.sgal-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(10, 10, 12, 0.92);
	backdrop-filter: blur(6px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.35s ease, visibility 0.35s ease;
}
.sgal-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}
.sgal-lb-stage {
	margin: 0;
	max-width: 90vw;
	max-height: 86vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	transform: scale(0.96);
	transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sgal-lightbox.is-open .sgal-lb-stage {
	transform: scale(1);
}
.sgal-lb-stage img {
	max-width: 90vw;
	max-height: 78vh;
	width: auto;
	height: auto;
	border-radius: 10px;
	box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
.sgal-lb-stage figcaption {
	margin-top: 14px;
	color: rgba(255, 255, 255, 0.85);
	font-size: 14px;
	text-align: center;
	max-width: 70vw;
}
.sgal-lb-stage figcaption:empty {
	display: none;
}

/* Lightbox controls */
.sgal-lb-close,
.sgal-lb-prev,
.sgal-lb-next {
	position: absolute;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.16);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background 0.25s ease, transform 0.25s ease;
	line-height: 1;
}
.sgal-lb-close:hover,
.sgal-lb-prev:hover,
.sgal-lb-next:hover {
	background: rgba(255, 255, 255, 0.2);
	transform: scale(1.08);
}
.sgal-lb-close {
	top: 22px;
	right: 22px;
	width: 46px;
	height: 46px;
	font-size: 26px;
}
.sgal-lb-prev,
.sgal-lb-next {
	top: 50%;
	transform: translateY(-50%);
	width: 54px;
	height: 54px;
	font-size: 34px;
}
.sgal-lb-prev:hover,
.sgal-lb-next:hover {
	transform: translateY(-50%) scale(1.08);
}
.sgal-lb-prev { left: 22px; }
.sgal-lb-next { right: 22px; }

.sgal-lb-counter {
	position: absolute;
	bottom: 22px;
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.7);
	font-size: 13px;
	letter-spacing: 0.08em;
}

/* Responsive fallbacks (Elementor controls override these when set) */
@media (max-width: 1024px) {
	.sgal-wrap { --sgal-cols: 2; }
}
@media (max-width: 600px) {
	.sgal-wrap { --sgal-cols: 1; }
	.sgal-lb-prev, .sgal-lb-next { width: 44px; height: 44px; font-size: 28px; }
	.sgal-lb-prev { left: 10px; }
	.sgal-lb-next { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
	.sgal-item, .sgal-item img, .sgal-caption,
	.sgal-lightbox, .sgal-lb-stage { transition: none; }
}
