/* Simple Post Gallery — front end styles */

.spg-gallery {
	--spg-columns: 3;
	--spg-gap: 12px;
	display: grid !important;
	grid-template-columns: repeat(var(--spg-columns), 1fr);
	gap: var(--spg-gap);
	margin: 1.75em 0;
	box-sizing: border-box;
}

.spg-gallery * {
	box-sizing: border-box;
}

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

@media (max-width: 480px) {
	.spg-gallery {
		grid-template-columns: repeat(1, 1fr);
	}
}

/* Reset margins/padding that themes sometimes add to figure/figcaption/img
   inside post content, which is what causes empty gaps under each photo. */
.spg-gallery .spg-item,
.spg-gallery .spg-item img,
.spg-gallery .spg-link,
.spg-gallery .spg-caption {
	margin: 0 !important;
	padding: 0 !important;
}

.spg-item {
	position: relative;
	overflow: hidden;
	border-radius: 10px;
	background: #eee;
	display: block !important;
	float: none !important;
	width: auto !important;
}

.spg-link {
	display: block !important;
	position: relative;
	overflow: hidden;
}

.spg-item img {
	display: block !important;
	width: 100% !important;
	transition: transform .35s ease;
	max-width: 100% !important;
}

/* --- Cropped / uniform-square mode (default) --------------------------- */
/* Uses an explicit aspect-ratio box plus a belt-and-braces padding-bottom
   fallback, and !important on the image sizing so theme rules like
   ".entry-content img { height: auto }" can't leave the box empty. */

.spg-gallery[data-fit="cover"] .spg-link {
	aspect-ratio: 1 / 1;
}

.spg-gallery[data-fit="cover"] .spg-link::before {
	content: "";
	display: block;
	padding-top: 100%;
}

@supports (aspect-ratio: 1 / 1) {
	.spg-gallery[data-fit="cover"] .spg-link::before {
		display: none;
	}
}

.spg-gallery[data-fit="cover"] .spg-link img {
	position: absolute;
	inset: 0;
	top: 0;
	left: 0;
	height: 100% !important;
	width: 100% !important;
	object-fit: cover !important;
}

.spg-gallery[data-fit="cover"] .spg-link:hover img {
	transform: scale(1.06);
}

/* --- Original-size mode ------------------------------------------------- */
/* No forced aspect ratio — each image keeps its own natural proportions,
   the grid row simply grows to fit the tallest image in that row. */

.spg-gallery[data-fit="original"] .spg-link {
	aspect-ratio: auto;
	display: flex !important;
	align-items: center;
}

.spg-gallery[data-fit="original"] .spg-link img {
	position: static;
	height: auto !important;
	width: 100% !important;
	object-fit: contain !important;
}

.spg-gallery[data-fit="original"] .spg-link:hover img {
	transform: scale(1.03);
}

.spg-zoom-icon {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: translateY(-4px);
	transition: opacity .2s ease, transform .2s ease;
	z-index: 2;
}

.spg-link:hover .spg-zoom-icon {
	opacity: 1;
	transform: translateY(0);
}

.spg-caption {
	font-size: .85em;
	color: #555;
	padding: 6px 4px 2px !important;
}

/* Lightbox */

.spg-lightbox-overlay {
	position: fixed;
	inset: 0;
	background: rgba(10, 10, 12, .92);
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity .25s ease;
}

.spg-lightbox-overlay.spg-open {
	opacity: 1;
}

.spg-lightbox-figure {
	max-width: 92vw;
	max-height: 88vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}

.spg-lightbox-figure img {
	max-width: 92vw;
	max-height: 80vh;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

.spg-lightbox-caption {
	color: #eee;
	font-size: .95em;
	text-align: center;
	max-width: 70vw;
}

.spg-lightbox-close,
.spg-lightbox-prev,
.spg-lightbox-next {
	position: fixed;
	background: rgba(255, 255, 255, .08);
	border: none;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background .2s ease;
}

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

.spg-lightbox-close {
	top: 20px;
	right: 20px;
	width: 42px;
	height: 42px;
}

.spg-lightbox-prev,
.spg-lightbox-next {
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
}

.spg-lightbox-prev {
	left: 16px;
}

.spg-lightbox-next {
	right: 16px;
}

.spg-lightbox-counter {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	color: #ddd;
	font-size: .85em;
	letter-spacing: .04em;
}

@media (max-width: 600px) {
	.spg-lightbox-prev,
	.spg-lightbox-next {
		width: 38px;
		height: 38px;
	}
}
