/**
 * SNN Product Gallery (Free Version) — v2.5
 *
 * Premium styles for the gallery elements and custom PhotoSwipe v5 integration.
 */

/* ─────────────────── Gallery Wrapper ─────────────────── */
.snn-product-gallery-wrapper {
	width: 100%;
	display: block;
	position: relative;
}

.snn-product-gallery-wrapper .snn-pg-empty {
	padding: 24px;
	text-align: center;
	color: rgba(0, 0, 0, 0.45);
	background: rgba(0, 0, 0, 0.03);
	border-radius: 8px;
	font-size: 0.875rem;
	border: 1px dashed rgba(0, 0, 0, 0.1);
}

/* ─────────────────── Main Image ─────────────────── */
.snn-product-gallery-wrapper .snn-pg-main {
	position: relative;
	width: 100%;
	overflow: hidden;
	line-height: 0;
}

.snn-product-gallery-wrapper .snn-pg-main-trigger {
	display: block;
	width: 100%;
	height: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	cursor: var(--snn-pg-cursor, zoom-in);
	font: inherit;
	color: inherit;
	text-align: inherit;
	appearance: none;
	-webkit-appearance: none;
}

.snn-product-gallery-wrapper[data-enable-lightbox="0"] .snn-pg-main-trigger {
	cursor: default;
}

.snn-product-gallery-wrapper .snn-pg-main-trigger:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.snn-product-gallery-wrapper .snn-pg-main-img {
	width: 100%;
	height: 100%;
	display: block;
	aspect-ratio: var(--snn-pg-ratio, 4/3);
	object-fit: var(--snn-pg-object-fit, cover);
	transition: opacity 0.2s ease;
}

.snn-product-gallery-wrapper .snn-pg-counter {
	position: absolute;
	bottom: 12px;
	right: 12px;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(4px);
	color: #fff;
	font-size: 0.75rem;
	line-height: 1;
	padding: 6px 10px;
	border-radius: 6px;
	font-family: inherit;
	pointer-events: none;
	letter-spacing: 0.02em;
	z-index: 2;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─────────────────── Thumbnail Grid ─────────────────── */
.snn-product-gallery-wrapper .snn-pg-thumbs {
	display: grid;
	grid-template-columns: repeat(var(--snn-pg-columns, 4), 1fr);
	gap: var(--snn-pg-gap, 8px);
	margin-top: var(--snn-pg-main-gap, 8px);
}

.snn-product-gallery-wrapper .snn-pg-thumb {
	display: block;
	position: relative;
	width: 100%;
	padding: 0;
	margin: 0;
	border: 0;
	background: rgba(0, 0, 0, 0.03);
	overflow: hidden;
	aspect-ratio: 1 / 1;
	cursor: pointer;
	line-height: 0;
	transition: outline-color 0.2s ease, transform 0.2s ease;
	font: inherit;
	color: inherit;
	appearance: none;
	-webkit-appearance: none;
}

.snn-product-gallery-wrapper .snn-pg-thumb img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: var(--snn-pg-thumb-fit, cover);
	transition: transform 0.25s ease;
}

.snn-product-gallery-wrapper .snn-pg-thumb:hover img {
	transform: scale(1.06);
}

.snn-product-gallery-wrapper .snn-pg-thumb.is-active {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.snn-product-gallery-wrapper .snn-pg-thumb:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 0;
}

.snn-product-gallery-wrapper .snn-pg-thumb--more {
	cursor: zoom-in;
}

.snn-product-gallery-wrapper .snn-pg-thumb--more .snn-pg-more-badge {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	backdrop-filter: blur(2px);
	color: #fff;
	font-size: 1.25rem;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1;
	pointer-events: none;
	letter-spacing: 0.02em;
}

/* ─────────────────── Builder Safety ─────────────────── */
.bricks-is-builder .snn-product-gallery-wrapper {
	min-height: 100px;
}


/* ═══════════════════════════════════════════════════════
 * PHOTOSWIPE CUSTOMIZATIONS (100% FREE REWRITE)
 * ═══════════════════════════════════════════════════════ */

/* ── 1. General Lightbox Adjustments ──────────────── */
.pswp {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── 2. Custom Thumbnail Strip Inside Lightbox ────── */
.pswp__custom-thumbs {
	position: absolute;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	gap: 12px;
	padding: 12px 18px;
	z-index: 1000;
	max-width: calc(100% - 32px);
	overflow-x: auto;
	scrollbar-width: none; /* Firefox scrollbar removal */
	-ms-overflow-style: none; /* IE/Edge scrollbar removal */
	border-radius: 14px;
	transition: background-color 0.25s ease;
}

.pswp__custom-thumbs::-webkit-scrollbar {
	display: none; /* Chrome/Safari scrollbar removal */
}

/* Thumbnail strip items */
.pswp__custom-thumbs-item {
	display: block;
	width: 56px;
	height: 56px;
	padding: 0;
	margin: 0;
	border: 0;
	background: rgba(0, 0, 0, 0.1);
	overflow: hidden;
	cursor: pointer;
	flex-shrink: 0;
	outline: 2px solid transparent;
	outline-offset: -2px;
	transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), outline-color 0.2s ease;
}

.pswp__custom-thumbs-item:hover {
	transform: translateY(-2px);
}

.pswp__custom-thumbs-item img {
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
}

/* Active outline state */
.pswp__custom-thumbs-item.is-active {
	outline-color: currentColor;
	transform: scale(1.06);
}

/* Strip Types (Modern / Classic / Scrollable) */
.pswp__custom-thumbs--modern {
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(14px) saturate(180%);
	-webkit-backdrop-filter: blur(14px) saturate(180%);
	border: 1px solid rgba(255, 255, 255, 0.15);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.pswp__custom-thumbs--modern .pswp__custom-thumbs-item {
	border-radius: 50%; /* Rounded avatars */
}

.pswp__custom-thumbs--classic {
	background: rgba(0, 0, 0, 0.6);
	border: 1px solid rgba(255, 255, 255, 0.1);
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.pswp__custom-thumbs--classic .pswp__custom-thumbs-item {
	border-radius: 4px; /* Slightly rounded square */
}

.pswp__custom-thumbs--scrollable {
	justify-content: flex-start;
	background: rgba(0, 0, 0, 0.6);
	max-width: 600px;
	width: auto;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.pswp__custom-thumbs--scrollable .pswp__custom-thumbs-item {
	border-radius: 4px;
}

/* ── 3. Custom Caption Overlays ─────────────────── */
.pswp__custom-caption {
	position: absolute;
	bottom: 30px; /* Lower fallback positioning if no thumbs */
	left: 50%;
	transform: translateX(-50%);
	z-index: 1000;
	max-width: calc(100% - 32px);
	text-align: center;
	pointer-events: none;
	animation: pswpCaptionSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.pswp__custom-caption-inner {
	display: inline-block;
	padding: 8px 18px;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 0.875rem;
	line-height: 1.4;
	border-radius: 8px;
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.12);
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
	pointer-events: auto;
	letter-spacing: 0.01em;
}

/* Smart upward raise using CSS :has() selector if thumbnails exist */
.pswp:has(.pswp__custom-thumbs) .pswp__custom-caption {
	bottom: 112px;
}

@keyframes pswpCaptionSlideUp {
	from { opacity: 0; transform: translate(-50%, 8px); }
	to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── 4. Theme Configurations ─────────────────────── */

/* --- Dark Theme (Default) --- */
.pswp-theme-dark .pswp__bg {
	background: #09090b !important; /* Sleek zinc black background */
}
.pswp-theme-dark .pswp__button,
.pswp-theme-dark .pswp__counter {
	color: #f4f4f5 !important;
}
.pswp-theme-dark .pswp__custom-thumbs-item.is-active {
	outline-color: #f4f4f5 !important;
}

/* --- Light Theme --- */
.pswp-theme-light .pswp__bg {
	background: #ffffff !important; /* Pure white background */
}
.pswp-theme-light .pswp__button,
.pswp-theme-light .pswp__counter {
	color: #18181b !important;
}
.pswp-theme-light .pswp__button svg {
	fill: #18181b !important; /* Force dark UI elements */
}
.pswp-theme-light .pswp__custom-thumbs-item.is-active {
	outline-color: #18181b !important;
}
.pswp-theme-light .pswp__custom-thumbs--modern {
	background: rgba(0, 0, 0, 0.05);
	border-color: rgba(0, 0, 0, 0.08);
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}
.pswp-theme-light .pswp__custom-caption-inner {
	background: rgba(255, 255, 255, 0.85);
	color: #18181b;
	border-color: rgba(0, 0, 0, 0.08);
	box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
}

/* --- Auto Theme (Based on user device preference) --- */
@media (prefers-color-scheme: light) {
	.pswp-theme-auto .pswp__bg {
		background: #ffffff !important;
	}
	.pswp-theme-auto .pswp__button,
	.pswp-theme-auto .pswp__counter {
		color: #18181b !important;
	}
	.pswp-theme-auto .pswp__button svg {
		fill: #18181b !important;
	}
	.pswp-theme-auto .pswp__custom-thumbs-item.is-active {
		outline-color: #18181b !important;
	}
	.pswp-theme-auto .pswp__custom-thumbs--modern {
		background: rgba(0, 0, 0, 0.05);
		border-color: rgba(0, 0, 0, 0.08);
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
	}
	.pswp-theme-auto .pswp__custom-caption-inner {
		background: rgba(255, 255, 255, 0.85);
		color: #18181b;
		border-color: rgba(0, 0, 0, 0.08);
		box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
	}
}
@media (prefers-color-scheme: dark) {
	.pswp-theme-auto .pswp__bg {
		background: #09090b !important;
	}
	.pswp-theme-auto .pswp__button,
	.pswp-theme-auto .pswp__counter {
		color: #f4f4f5 !important;
	}
	.pswp-theme-auto .pswp__custom-thumbs-item.is-active {
		outline-color: #f4f4f5 !important;
	}
}

/* ── 5. Toolbar and Layout Options ───────────────── */
.pswp-no-toolbar .pswp__button--zoom,
.pswp-no-toolbar .pswp__counter {
	display: none !important; /* Hide zoom & infobar if toolbar disabled */
}

/* ── 6. Lightbox Image Fit Options ───────────────── */

/* Fit: Cover (Makes slide images fill the screen nicely) */
.pswp-fit-cover .pswp__img {
	object-fit: cover !important;
	width: 100% !important;
	height: 100% !important;
}

/* Default Fit: Contain (Respects natural image bounds) */
.pswp-fit-contain .pswp__img {
	object-fit: contain !important;
}
