/**
 * Single-product gallery. Markup: inc/product-gallery.php,
 * behaviour: js/product-gallery.js. Loaded on product pages only.
 */

.ec-gallery {
	position: relative;
	margin-bottom: 24px;
}

/* ── Main stage: native swipe via scroll-snap ── */
.ec-gallery__stage {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	border-radius: 8px;
	background: #fff;
	outline: none;
}

.ec-gallery__stage::-webkit-scrollbar {
	display: none;
}

.ec-gallery__stage:focus-visible {
	box-shadow: 0 0 0 2px #ce1d76;
}

.ec-gallery__slide {
	flex: 0 0 100%;
	margin: 0;
	scroll-snap-align: start;
	scroll-snap-stop: always;
}

.ec-gallery__open {
	display: block;
	cursor: zoom-in;
}

.ec-gallery__img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
}

/* ── Arrows (desktop; on touch the stage swipes) ── */
.ec-gallery__arrow {
	position: absolute;
	top: 0;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(19, 19, 19, 0.55);
	color: #fff;
	cursor: pointer;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.ec-gallery__arrow::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 10px;
	height: 10px;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
}

.ec-gallery__arrow--prev::before {
	transform: translate(-30%, -50%) rotate(-135deg);
}

.ec-gallery__arrow--next::before {
	transform: translate(-70%, -50%) rotate(45deg);
}

.ec-gallery__main {
	position: relative;
}

.ec-gallery__main > .ec-gallery__arrow {
	top: calc(50% - 20px);
}

.ec-gallery__main > .ec-gallery__arrow--prev {
	left: 12px;
}

.ec-gallery__main > .ec-gallery__arrow--next {
	right: 12px;
}

.ec-gallery__main:hover > .ec-gallery__arrow,
.ec-gallery__main > .ec-gallery__arrow:focus-visible {
	opacity: 1;
}

@media (hover: none) {
	.ec-gallery__main > .ec-gallery__arrow {
		display: none;
	}
}

/* ── Thumbnails with optional caption labels ── */
/* One sliding row at every width, scrollbar hidden. Desktop slides it by
   click-and-drag (js); touch swipes natively. A fade on whichever edge has
   more thumbs (.has-more-left / .has-more-right, set by the JS) shows the
   row continues. */
.ec-gallery__thumbs {
	display: flex;
	gap: 8px;
	margin-top: 12px;
	overflow-x: auto;
	scroll-behavior: smooth;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
}

.ec-gallery__thumbs::-webkit-scrollbar {
	display: none;
}

.ec-gallery__thumbs.has-more-right {
	-webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
	mask-image: linear-gradient(to right, #000 85%, transparent);
}

.ec-gallery__thumbs.has-more-left {
	-webkit-mask-image: linear-gradient(to left, #000 85%, transparent);
	mask-image: linear-gradient(to left, #000 85%, transparent);
}

.ec-gallery__thumbs.has-more-left.has-more-right {
	-webkit-mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
	mask-image: linear-gradient(to right, transparent, #000 15%, #000 85%, transparent);
}

/* Mouse drag (js adds .is-draggable / .is-dragging). Snap and smooth
   scrolling are suspended mid-drag so the row follows the pointer exactly. */
.ec-gallery .is-draggable {
	cursor: grab;
}

.ec-gallery .is-dragging {
	cursor: grabbing;
	scroll-snap-type: none;
	scroll-behavior: auto;
	user-select: none;
}

.ec-gallery .is-dragging .ec-gallery__open {
	cursor: grabbing;
}

.ec-gallery__thumb {
	flex: 0 0 76px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 6px;
	background: #f5f5f5;
	cursor: pointer;
	text-align: center;
	transition: border-color 0.15s ease;
}

.ec-gallery__thumb:hover {
	border-color: #e0e0e0;
}

.ec-gallery__thumb.is-active {
	border-color: #ce1d76;
}

.ec-gallery__thumb:focus-visible {
	outline: 2px solid #ce1d76;
	outline-offset: 2px;
}

.ec-gallery__thumb-img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	border-radius: 4px;
}

.ec-gallery__label {
	display: block;
	padding: 4px 2px 3px;
	font-size: 11px;
	line-height: 1.2;
	font-weight: 600;
	color: #333;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ec-gallery__thumb.is-active .ec-gallery__label {
	color: #ce1d76;
}

@media (max-width: 767px) {
	.ec-gallery__thumb {
		flex-basis: 64px;
	}
}

/* ── Lightbox ── */
.ec-gallery__dialog {
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	max-height: 100vh;
	margin: 0;
	padding: 0;
	border: 0;
	background: rgba(19, 19, 19, 0.94);
}

.ec-gallery__dialog::backdrop {
	background: rgba(19, 19, 19, 0.94);
}

.ec-gallery__dialog[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.ec-gallery__dialog-img {
	max-width: calc(100vw - 120px);
	max-height: calc(100vh - 40px);
	object-fit: contain;
}

.ec-gallery__dialog .ec-gallery__arrow {
	top: calc(50% - 20px);
	opacity: 1;
}

.ec-gallery__dialog .ec-gallery__arrow--prev {
	left: 16px;
}

.ec-gallery__dialog .ec-gallery__arrow--next {
	right: 16px;
}

.ec-gallery__close {
	position: absolute;
	top: 16px;
	right: 16px;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	cursor: pointer;
}

.ec-gallery__close::before,
.ec-gallery__close::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 2px;
	background: #fff;
}

.ec-gallery__close::before {
	transform: translate(-50%, -50%) rotate(45deg);
}

.ec-gallery__close::after {
	transform: translate(-50%, -50%) rotate(-45deg);
}

@media (max-width: 767px) {
	.ec-gallery__dialog-img {
		max-width: 100vw;
		max-height: calc(100vh - 120px);
	}

	.ec-gallery__dialog .ec-gallery__arrow {
		top: auto;
		bottom: 24px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ec-gallery__stage {
		scroll-behavior: auto;
	}
}

/* ── Electro button override ──
   Electro styles every <button> with
   `.btn:not(...):not(...)...` (a long :not() chain, so very high specificity),
   forcing background/border-color #efecec, plus a black-on-hover rule. That
   beat the plain class rules above, so the active thumb showed grey, not pink,
   and the arrows/close went grey. !important is the only sane way past a
   selector like that. */
.ec-gallery .ec-gallery__thumb,
.ec-gallery .ec-gallery__thumb:hover,
.ec-gallery .ec-gallery__thumb:focus {
	background-color: #f5f5f5 !important;
	border-color: transparent !important;
	color: #333 !important;
}

.ec-gallery .ec-gallery__thumb:hover {
	border-color: #e0e0e0 !important;
}

.ec-gallery .ec-gallery__thumb.is-active,
.ec-gallery .ec-gallery__thumb.is-active:hover {
	border-color: #ce1d76 !important;
}

.ec-gallery .ec-gallery__arrow,
.ec-gallery .ec-gallery__arrow:hover,
.ec-gallery .ec-gallery__arrow:focus {
	background-color: rgba(19, 19, 19, 0.55) !important;
	border-color: transparent !important;
	color: #fff !important;
}

.ec-gallery .ec-gallery__arrow:hover {
	background-color: rgba(19, 19, 19, 0.8) !important;
}

.ec-gallery .ec-gallery__close,
.ec-gallery .ec-gallery__close:hover,
.ec-gallery .ec-gallery__close:focus {
	background-color: rgba(255, 255, 255, 0.12) !important;
	border-color: transparent !important;
}

.ec-gallery .ec-gallery__close:hover {
	background-color: rgba(255, 255, 255, 0.25) !important;
}
