.srd-gallery__title {
	margin: 0 0 0.4em;
}

.srd-gallery__description {
	margin: 0 0 1em;
}

.srd-gallery {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
}

/* Column variants */
.srd-gallery--cols-1 { grid-template-columns: 1fr; }
.srd-gallery--cols-2 { grid-template-columns: repeat(2, 1fr); }
.srd-gallery--cols-4 { grid-template-columns: repeat(4, 1fr); }

.srd-gallery figure {
	position: relative;
	margin: 0;
	display: flex;
	flex-direction: column;
}

/* Overlaid on the bottom of the thumbnail, same treatment as the lightbox caption */
.srd-gallery__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 3px 8px 3px;
	background: rgba(12, 23, 39, 0.7);
	border-radius: 0 0 4px 4px;
	pointer-events: none;
}

.srd-gallery__caption h3 {
	font-size: 0.75em;
	font-weight: 500;
	text-align: center;
	color: #fff;
	line-height: 1.4em;
}

/* Image wrapper — <a> for lightbox, bare <img> for non-lightbox */
.srd-gallery figure > a,
.srd-gallery figure > img {
	position: relative;
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 4px;
}

/* Kept in the DOM (for PhotoSwipe navigation) past the `limit` attribute,
   but not shown in the grid — see the "+N" overlay on the last visible tile.
   !important is needed here: grid/masonry/justified layouts each set their
   own `display` on .srd-gallery__item with equal-or-higher specificity, so a
   plain override can lose depending on layout and source order. */
.srd-gallery__item--hidden {
	display: none !important;
}

.srd-gallery__more-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(12, 23, 39, 0.55);
	color: #fff;
	font-size: 1.4em;
	font-weight: 700;
}

/* Crop variants */
.srd-gallery--crop-4-3 figure > a,
.srd-gallery--crop-4-3 figure > img { aspect-ratio: 4/3; }

.srd-gallery--crop-original figure > a,
.srd-gallery--crop-original figure > img { aspect-ratio: auto; height: auto; }

.srd-gallery img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.srd-gallery--crop-original img {
	height: auto;
	object-fit: unset;
}

.srd-gallery figure > a:hover img {
	transform: scale(1.05);
}

/* PhotoSwipe lightbox caption overlay */
.pswp__srd-caption {
	display: none;
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 48px 24px 20px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
	color: #fff;
	font-size: 1em;
	line-height: 1.5;
	text-align: center;
	pointer-events: none;
	z-index: 1;
}

.pswp__srd-caption h3 {
	margin: 0 0 4px;
	font-size: 1em;
	font-weight: 600;
	color: #fff;
	line-height: inherit;
}

@media (max-width: 580px) {
	.srd-gallery { grid-template-columns: repeat(2, 1fr); }
	.srd-gallery--cols-1 { grid-template-columns: 1fr; }
}

/* ── Masonry layout ───────────────────────────────────────────────────────── */
.srd-gallery--layout-masonry {
	display: block;
	columns: 3;
	column-gap: 8px;
}

.srd-gallery--layout-masonry.srd-gallery--cols-1 { columns: 1; }
.srd-gallery--layout-masonry.srd-gallery--cols-2 { columns: 2; }
.srd-gallery--layout-masonry.srd-gallery--cols-4 { columns: 4; }

.srd-gallery--layout-masonry .srd-gallery__item {
	break-inside: avoid;
	display: block;
	margin-bottom: 8px;
}

/* Masonry always shows natural image proportions */
.srd-gallery--layout-masonry .srd-gallery__item > a,
.srd-gallery--layout-masonry .srd-gallery__item > img {
	aspect-ratio: auto;
	height: auto;
}

.srd-gallery--layout-masonry img {
	height: auto;
	object-fit: unset;
}

@media (max-width: 580px) {
	.srd-gallery--layout-masonry { columns: 2; }
	.srd-gallery--layout-masonry.srd-gallery--cols-1 { columns: 1; }
}

/* ── Justified layout ────────────────────────────────────────────────────── */
.srd-gallery--layout-justified {
	display: flex;
	flex-wrap: wrap;
	gap: 0;
}

.srd-gallery--layout-justified .srd-gallery__item {
	overflow: hidden;
	box-sizing: border-box;
}

.srd-gallery--layout-justified .srd-gallery__item > a,
.srd-gallery--layout-justified .srd-gallery__item > img {
	display: block;
	width: 100%;
	height: 100%;
	aspect-ratio: auto;
	border-radius: 4px;
}

.srd-gallery--layout-justified img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}
