.sdmg-gallery {
	--sdmg-columns: 3;
	--sdmg-gap: 16px;
	position: relative;
}

.sdmg-item {
	display: block;
	width: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	overflow: hidden;
	border-radius: 14px;
	box-shadow: 0 10px 30px rgba(23, 21, 21, 0.1);
	transition: transform 0.35s cubic-bezier(0.3, 1, 0.3, 1), box-shadow 0.35s ease;
}

.sdmg-item:hover,
.sdmg-item:focus-visible {
	transform: translateY(-4px);
	box-shadow: 0 18px 38px rgba(23, 21, 21, 0.18);
	outline: none;
}

.sdmg-item__img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0 !important;
	vertical-align: top;
}

.sdmg-dots {
	display: none;
}

/* Desktop / tablet: JS-balanced masonry columns (Pinterest-style: each
   photo goes into whichever column is currently shortest). This keeps
   column heights even — native CSS `column-count` instead fills column 1
   completely before spilling into column 2, which can strand a single
   tall photo alone in the last column. Falls back to a simple wrap grid
   until JS runs. */
.sdmg-gallery .sdmg-track {
	display: flex;
	align-items: flex-start;
	gap: var(--sdmg-gap);
}

.sdmg-gallery .sdmg-col {
	flex: 1 1 0;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: var(--sdmg-gap);
}

/* This fallback (simple wrap grid before JS lays items into balanced
   columns) only makes sense at desktop widths — it must stay out of the
   mobile media query's way, since higher selector specificity here would
   otherwise win over the mobile slider's item sizing even though
   `.is-columned` is equally absent on mobile (JS never columns on
   mobile, so `:not(.is-columned)` matches there too). */
@media only screen and (min-width: 1000px) {
	.sdmg-gallery .sdmg-track:not(.is-columned) {
		flex-wrap: wrap;
	}

	.sdmg-gallery .sdmg-track:not(.is-columned) .sdmg-item {
		flex: 1 1 calc((100% - (var(--sdmg-columns) - 1) * var(--sdmg-gap)) / var(--sdmg-columns));
	}
}

/* Mobile: one-at-a-time swipeable slider */
@media only screen and (max-width: 999px) {
	.sdmg-gallery .sdmg-track {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		touch-action: pan-x;
		gap: 14px;
		padding: 4px 24px 4px;
		margin: 0 -24px;
		scrollbar-width: none;
	}

	.sdmg-gallery .sdmg-track::-webkit-scrollbar {
		display: none;
	}

	.sdmg-gallery .sdmg-item {
		flex: 0 0 86%;
		width: 86%;
		aspect-ratio: 4 / 5;
		grid-row-end: auto;
		box-shadow: none;
		scroll-snap-align: center;
		scroll-snap-stop: always;
		transform: none !important;
	}

	.sdmg-gallery .sdmg-item:hover,
	.sdmg-gallery .sdmg-item:focus-visible {
		transform: none;
	}

	.sdmg-gallery .sdmg-item__img {
		width: 100% !important;
		height: 100% !important;
		object-fit: cover;
	}

	.sdmg-dots {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 8px;
		margin-top: 14px;
	}

	.sdmg-dots__dot {
		width: 8px;
		height: 8px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: rgba(23, 21, 21, 0.2);
		cursor: pointer;
		transition: background 0.2s ease, transform 0.2s ease;
	}

	.sdmg-dots__dot.is-active {
		background: rgba(23, 21, 21, 0.75);
		transform: scale(1.2);
	}
}

/* Fullscreen lightbox (shared desktop + mobile) */
.sdmg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	background: rgba(10, 9, 9, 0.94);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease;
}

.sdmg-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.sdmg-lightbox__track {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.sdmg-lightbox__track::-webkit-scrollbar {
	display: none;
}

.sdmg-lightbox__slide {
	flex: 0 0 100%;
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	scroll-snap-align: center;
	scroll-snap-stop: always;
	padding: 40px;
	box-sizing: border-box;
}

.sdmg-lightbox__slide img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 6px;
}

.sdmg-lightbox__close {
	position: absolute;
	top: 18px;
	right: 18px;
	z-index: 2;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

.sdmg-lightbox__close:hover,
.sdmg-lightbox__close:focus-visible {
	background: rgba(255, 255, 255, 0.24);
	outline: none;
}

.sdmg-lightbox__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	width: 52px;
	height: 52px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transform: translateY(-50%);
	transition: background 0.2s ease, opacity 0.2s ease;
}

.sdmg-lightbox__nav--prev {
	left: 18px;
}

.sdmg-lightbox__nav--next {
	right: 18px;
}

.sdmg-lightbox__nav:hover,
.sdmg-lightbox__nav:focus-visible {
	background: rgba(255, 255, 255, 0.24);
	outline: none;
}

.sdmg-lightbox__nav[disabled] {
	opacity: 0.3;
	cursor: default;
	pointer-events: none;
}

@media only screen and (max-width: 640px) {
	.sdmg-lightbox__nav {
		width: 42px;
		height: 42px;
	}

	.sdmg-lightbox__nav--prev {
		left: 8px;
	}

	.sdmg-lightbox__nav--next {
		right: 8px;
	}
}

.sdmg-lightbox__counter {
	position: absolute;
	top: 26px;
	left: 24px;
	z-index: 2;
	color: rgba(255, 255, 255, 0.85);
	font-size: 14px;
	letter-spacing: 0.06em;
}

body.sdmg-lock {
	overflow: hidden;
}
