/* ===== Galeria ===== */
.cpg {
	--cpg-gap: 8px;
	--cpg-tn: var(--cpg-thumbs, 6);
	--cpg-w: min(100%, calc(var(--cpg-max-h, 85vh) * var(--cpg-ratio, 1)));
	width: 100%;
	margin: 0 0 1.5em;
}

.cpg__stage {
	position: relative;
	width: var(--cpg-w);
	aspect-ratio: var(--cpg-ratio, 1);
	margin: 0 auto;
}

.cpg__track {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	outline: none;
}
.cpg__track::-webkit-scrollbar { display: none; }
.cpg__track:focus-visible { box-shadow: inset 0 0 0 2px #111; }

.cpg__slide {
	position: relative;
	flex: 0 0 100%;
	height: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	cursor: zoom-in;
}
.cpg__slide img,
.cpg__slide .cpg__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--cpg-fit, contain);
	user-select: none;
	-webkit-user-drag: none;
}
.cpg__video {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: var(--cpg-video-fit, contain);
}
.cpg__slide--embed { cursor: default; }
.cpg__slide iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Badge (Promocja! itp.) w lewym górnym rogu */
.cpg__badges {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 3;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	pointer-events: none;
}
.cpg__badges > * { pointer-events: auto; }
.cpg .cpg__badges .onsale {
	position: static;
	display: inline-block;
	margin: 0;
	top: auto;
	left: auto;
	right: auto;
	/* kolory i czcionka zostają z motywu – tak jak badge na liście produktów */
}

/* Strzałki i przycisk powiększenia */
.cpg__nav,
.cpg__expand {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .9);
	color: #111;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
	transition: opacity .2s;
}
.cpg__nav svg,
.cpg__expand svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.cpg__nav {
	top: 50%;
	width: 40px;
	height: 40px;
	transform: translateY(-50%);
	opacity: 0;
}
.cpg__nav--prev { left: 10px; }
.cpg__nav--next { right: 10px; }
.cpg__expand {
	top: 10px;
	right: 10px;
	width: 36px;
	height: 36px;
	opacity: .85;
}
.cpg__stage:hover .cpg__nav,
.cpg__stage:focus-within .cpg__nav { opacity: 1; }
@media (hover: none) {
	.cpg__nav { opacity: .85; width: 34px; height: 34px; }
}
.cpg--single .cpg__nav { display: none; }

/* Miniaturki */
.cpg__thumbs {
	position: relative;
	display: flex;
	gap: var(--cpg-gap);
	width: var(--cpg-w);
	margin: var(--cpg-gap) auto 0;
	padding: 2px;
	box-sizing: border-box;
	overflow-x: auto;
	scrollbar-width: none;
}
.cpg__thumbs::-webkit-scrollbar { display: none; }
@media (max-width: 600px) {
	.cpg { --cpg-tn: min(var(--cpg-thumbs, 6), 5); }
}
.cpg__thumb {
	position: relative;
	flex: 0 0 calc((100% - (var(--cpg-tn) - 1) * var(--cpg-gap)) / var(--cpg-tn));
	aspect-ratio: 1;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	background: #f2f2f2;
	cursor: pointer;
	opacity: .55;
	outline: 2px solid transparent;
	outline-offset: -2px;
	transition: opacity .2s, outline-color .2s;
	overflow: hidden;
}
.cpg__thumb:hover { opacity: .85; }
.cpg__thumb.is-active { opacity: 1; outline-color: #111; }
.cpg__thumb:focus-visible { outline-color: #111; opacity: 1; }
.cpg__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}
.cpg__thumb--video { background: #222; }
.cpg__play {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 28px;
	height: 28px;
	margin: -14px 0 0 -14px;
	border-radius: 50%;
	background: rgba(0, 0, 0, .6);
}
.cpg__play::after {
	content: "";
	position: absolute;
	top: 8px;
	left: 11px;
	border-style: solid;
	border-width: 6px 0 6px 9px;
	border-color: transparent transparent transparent #fff;
}

/* ===== Lightbox ===== */
html.cpg-lock { overflow: hidden; }

.cpg-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	background: rgba(12, 12, 12, .95);
	color: #fff;
}
.cpg-lb.is-open { display: block; }

.cpg-lb__track {
	display: flex;
	width: 100%;
	height: 100%;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior: contain;
	scrollbar-width: none;
}
.cpg-lb__track::-webkit-scrollbar { display: none; }

.cpg-lb__slide {
	flex: 0 0 100%;
	height: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 60px 16px;
	box-sizing: border-box;
}
.cpg-lb__slide img,
.cpg-lb__slide video {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}
.cpg-lb__slide iframe {
	width: min(100%, calc((100vh - 120px) * 16 / 9));
	aspect-ratio: 16 / 9;
	border: 0;
}

.cpg-lb__btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .12);
	color: #fff;
	cursor: pointer;
}
.cpg-lb__btn:hover,
.cpg-lb__btn:focus-visible { background: rgba(255, 255, 255, .25); outline: none; }
.cpg-lb__btn svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.cpg-lb__close { top: 10px; right: 10px; }
.cpg-lb__prev { top: 50%; left: 10px; transform: translateY(-50%); }
.cpg-lb__next { top: 50%; right: 10px; transform: translateY(-50%); }
.cpg-lb--single .cpg-lb__prev,
.cpg-lb--single .cpg-lb__next { display: none; }
.cpg-lb__counter {
	position: absolute;
	top: 20px;
	left: 20px;
	z-index: 2;
	font-size: 14px;
	opacity: .8;
}
