.snapgallery {
	box-sizing: border-box;
}

.snapgallery-disclaimer {
	margin: 0 0 12px;
	padding: 10px 14px;
	background: #222;
	color: #ccc;
	font-size: 13px;
	font-style: italic;
}

.snapgallery * {
	box-sizing: border-box;
}

.snapgallery-item {
	margin: 0;
	position: relative;
}

.snapgallery-item .snapgallery-link {
	display: block;
	line-height: 0;
	position: relative;
}

.snapgallery-item img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.snapgallery-caption {
	margin-top: 4px;
	font-size: 13px;
	color: #555;
}

/* Alignment (justified/masonry only — grid always stretches edge to edge) */
.snapgallery-align-left {
	justify-content: start;
}

.snapgallery-align-center {
	justify-content: center;
}

.snapgallery-align-right {
	justify-content: end;
}

/* Grid (columns flex to fill the full container width, edge to edge) */
.snapgallery-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(var(--sg-thumb-width, 150px), 100%), 1fr));
	row-gap: var(--sg-gutter, 10px);
	column-gap: var(--sg-gutter, 10px);
}

.snapgallery-grid.snapgallery-align-left,
.snapgallery-grid.snapgallery-align-center,
.snapgallery-grid.snapgallery-align-right {
	justify-content: normal;
}

.snapgallery-grid .snapgallery-item {
	/* Classic padding-percentage aspect-ratio box instead of the CSS
	 * aspect-ratio property: it resolves purely against width, in every
	 * browser, the same way, with no interaction with object-fit — the
	 * newer aspect-ratio property was found to visibly letterbox instead
	 * of cropping in some environments despite reporting correct computed
	 * styles, so it's avoided here entirely. */
	height: 0;
	padding-bottom: calc(100% / var(--sg-aspect-ratio, 1));
}

.snapgallery-grid .snapgallery-item .snapgallery-link,
.snapgallery-grid .snapgallery-item .snapgallery-link-static {
	position: absolute;
	inset: 0;
}

.snapgallery-grid .snapgallery-item img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Masonry (CSS columns waterfall, column width driven by thumbnail width) */
.snapgallery-masonry {
	column-width: var(--sg-thumb-width, 150px);
	column-gap: var(--sg-gutter, 10px);
}

.snapgallery-masonry .snapgallery-item {
	break-inside: avoid;
	margin-bottom: var(--sg-gutter, 10px);
}

/* On mobile, every template stacks as a single full-width column
 * regardless of the configured thumbnail width. */
@media (max-width: 600px) {
	.snapgallery-grid {
		grid-template-columns: 1fr;
	}

	.snapgallery-grid .snapgallery-item {
		/* A square (or taller) desktop crop stretched to full phone width
		 * turns into an oversized block, so cap how tall a single-column
		 * thumbnail is allowed to get regardless of the configured ratio. */
		padding-bottom: min(calc(100% / var(--sg-aspect-ratio, 1)), 75%);
	}

	.snapgallery-masonry {
		column-count: 1;
		column-width: auto;
	}

	.snapgallery-justified .snapgallery-item {
		width: 100% !important;
		flex-grow: 0 !important;
	}
}

/* Justified (rows built by JS, sizing applied inline) */
.snapgallery-justified {
	display: flex;
	flex-wrap: wrap;
	row-gap: var(--sg-gutter, 10px);
	column-gap: var(--sg-gutter, 10px);
}

.snapgallery-justified .snapgallery-item {
	flex-grow: 1;
}

.snapgallery-justified .snapgallery-item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}


/* Border styles */
.snapgallery-item img {
	outline: 1px solid rgba(255, 255, 255, 0.15);
	outline-offset: -1px;
}

.snapgallery-border-simple .snapgallery-item img {
	border: 4px solid #fff;
	box-shadow: 0 0 0 1px #ddd;
}

.snapgallery-border-rounded .snapgallery-item img {
	border-radius: 8px;
}

.snapgallery-border-circle .snapgallery-item img {
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	object-fit: cover;
}

/* Hover effects */
.snapgallery-item {
	overflow: hidden;
}

.snapgallery-hover-icon {
	/* Width/height/top/left are set as fixed pixel values via JS at hover
	 * time (see snapgallery.js). z-index is required here: the hover JS
	 * applies `transform: scale()` to the <img>, which creates a new
	 * stacking context for it. Since the img comes after this icon in the
	 * DOM, without an explicit z-index its new stacking context wins and
	 * paints over the icon the instant the zoom/grow effect kicks in. */
	position: absolute;
	top: 0;
	left: 0;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	color: #fff;
	background: rgba(0, 0, 0, 0.55);
	pointer-events: none;
}

.snapgallery-hover-icon.is-visible {
	display: flex;
}

.snapgallery-hover-icon svg {
	width: 32px;
	height: 32px;
	filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}

.snapgallery-hover-none .snapgallery-hover-icon {
	display: none !important;
}

/* Lightbox */
.snapgallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	background: #000;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease;
}

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

.snapgallery-lightbox-toolbar {
	position: absolute;
	top: 16px;
	right: 16px;
	z-index: 2;
	display: flex;
	gap: 8px;
}

.snapgallery-lightbox-toolbar button {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.snapgallery-lightbox-toolbar button:hover {
	background: rgba(255, 255, 255, 0.18);
}

.snapgallery-lightbox-toolbar button.is-active {
	background: #fff;
	color: #000;
}

.snapgallery-lightbox-toolbar button svg {
	width: 20px;
	height: 20px;
}

.snapgallery-lightbox-stage {
	position: relative;
	flex: 1;
	min-height: 0;
	display: flex;
	align-items: stretch;
}

.snapgallery-lightbox-zone {
	flex: 0 0 80px;
	border: none;
	background: transparent;
	color: #b3b3b3;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.snapgallery-lightbox-zone svg {
	width: 26px;
	height: 26px;
}

.snapgallery-lightbox-zone:hover {
	background: rgba(255, 255, 255, 0.06);
	color: #fff;
}

.snapgallery-lightbox-figure {
	flex: 1;
	min-width: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 12px;
	/* Reserves room for the floating filmstrip overlay so the image isn't
	 * rendered partly hidden underneath it. */
	padding-bottom: 130px;
}

.snapgallery-lightbox-figure img {
	max-width: 100%;
	max-height: 100%;
	display: block;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.snapgallery-lightbox-caption-bar {
	flex-shrink: 0;
	background: #222;
	border-top: 1px solid #333;
	padding: 16px 24px;
	text-align: center;
}

.snapgallery-lightbox-caption-bar.is-hidden {
	display: none !important;
}

.snapgallery-lightbox-title {
	font-weight: 600;
	font-size: 15px;
	color: #ccc;
	margin-bottom: 4px;
}

.snapgallery-lightbox-desc {
	font-size: 13px;
	color: #999;
}

.snapgallery-lightbox-filmstrip {
	/* Overlays the bottom of the stage instead of sitting in normal flex
	 * flow, so enlarging the thumbnails never shrinks the main image by
	 * competing with it for a share of the fixed-height lightbox column. */
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(17, 17, 17, 0.85);
	backdrop-filter: blur(4px);
	overflow-x: auto;
	overflow-y: hidden;
}

.snapgallery-lightbox-filmstrip-track {
	display: flex;
	gap: 6px;
	padding: 14px;
	width: max-content;
}

.snapgallery-lightbox-thumb {
	flex: 0 0 auto;
	width: 130px;
	height: 88px;
	padding: 0;
	border: 2px solid transparent;
	background: none;
	cursor: pointer;
	opacity: 0.55;
	transition: opacity 0.15s ease, border-color 0.15s ease;
}

.snapgallery-lightbox-thumb:hover {
	opacity: 0.85;
}

.snapgallery-lightbox-thumb.is-active {
	opacity: 1;
	border-color: #fff;
}

.snapgallery-lightbox-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

@media (max-width: 600px) {
	.snapgallery-lightbox-zone {
		flex-basis: 40px;
	}
	.snapgallery-lightbox-zone svg {
		width: 18px;
		height: 18px;
	}
	.snapgallery-lightbox-figure {
		padding: 12px;
		padding-bottom: 90px;
	}
	.snapgallery-lightbox-thumb {
		width: 90px;
		height: 62px;
	}
}
