/**
 * Cociditos Product Gallery 0.1.2 · DES token bridge 1.4.2
 * Capa visual progresiva sobre la galería clásica oficial de WooCommerce.
 */

.single-product .coci-product-gallery {
	/* DES 1.4.2 compatibility aliases. Rendering remains 1.4.1-identical. */
	--coci-gallery-cream: var(--coci-surface-gallery-canvas);
	--coci-gallery-paper: var(--coci-surface-gallery-paper);
	--coci-gallery-green: var(--coci-color-gallery-primary);
	--coci-gallery-green-dark: var(--coci-color-gallery-primary-dark);
	--coci-gallery-ink: var(--coci-color-gallery-ink);
	--coci-gallery-muted: var(--coci-color-gallery-muted);
	--coci-gallery-border: var(--coci-border-gallery-subtle);
	--coci-gallery-focus: var(--coci-color-gallery-focus);
	--coci-gallery-shadow: var(--coci-shadow-gallery);
	--coci-gallery-thumb: 66px;

	position: relative !important;
	isolation: isolate;
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0;
	padding: 12px !important;
	overflow: hidden !important;
}

.single-product .coci-product-gallery *,
.single-product .coci-product-gallery *::before,
.single-product .coci-product-gallery *::after {
	box-sizing: border-box;
}

.single-product .coci-product-gallery .flex-viewport {
	min-width: 0;
	height: auto !important;
	aspect-ratio: 4 / 3;
	overflow: hidden !important;
	overscroll-behavior-inline: contain;
	border-radius: 25px;
	background:
		radial-gradient(circle at 70% 18%, rgba(223, 233, 201, 0.46), transparent 35%),
		var(--coci-gallery-cream);
	touch-action: pan-y pinch-zoom;
}

.single-product .coci-product-gallery .woocommerce-product-gallery__wrapper {
	margin: 0 !important;
	min-width: 0;
	height: 100%;
}

.single-product .coci-product-gallery .woocommerce-product-gallery__image {
	height: 100%;
	overflow: hidden;
	background:
		radial-gradient(circle at 72% 16%, rgba(223, 233, 201, 0.34), transparent 34%),
		var(--coci-gallery-cream);
}

.single-product .coci-product-gallery .woocommerce-product-gallery__image > a {
	display: block;
	height: 100%;
	cursor: zoom-in;
}

.single-product .coci-product-gallery .woocommerce-product-gallery__image img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	object-fit: contain;
	object-position: center;
	border-radius: 24px !important;
	background: transparent;
}

/* Miniaturas visibles en todas las plataformas: no se sustituyen por puntos. */
.single-product .coci-product-gallery ol.flex-control-thumbs {
	display: flex !important;
	align-items: center;
	gap: 10px;
	width: 100%;
	margin: 12px 0 0 !important;
	padding: 2px 2px 5px !important;
	overflow-x: auto;
	overflow-y: hidden;
	list-style: none !important;
	scroll-snap-type: x proximity;
	overscroll-behavior-inline: contain;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-x pan-y;
}

.single-product .coci-product-gallery ol.flex-control-thumbs::-webkit-scrollbar {
	display: none;
}

.single-product .coci-product-gallery ol.flex-control-thumbs li {
	flex: 0 0 var(--coci-gallery-thumb) !important;
	float: none !important;
	width: var(--coci-gallery-thumb) !important;
	margin: 0 !important;
	padding: 0 !important;
	scroll-snap-align: start;
	list-style: none !important;
}

.single-product .coci-product-gallery ol.flex-control-thumbs img {
	display: block;
	width: var(--coci-gallery-thumb) !important;
	height: var(--coci-gallery-thumb) !important;
	padding: 3px;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	object-position: center;
	border: 2px solid transparent !important;
	border-radius: 17px !important;
	background: var(--coci-gallery-paper);
	box-shadow: 0 5px 16px rgba(44, 72, 54, 0.08);
	opacity: 0.68 !important;
	cursor: pointer;
	transition:
		opacity 160ms ease,
		border-color 160ms ease,
		box-shadow 160ms ease,
		transform 160ms ease;
}

.single-product .coci-product-gallery ol.flex-control-thumbs img.flex-active,
.single-product .coci-product-gallery ol.flex-control-thumbs img[aria-current="true"] {
	border-color: var(--coci-gallery-green) !important;
	box-shadow:
		0 0 0 3px rgba(255, 248, 234, 0.94),
		0 0 0 5px rgba(31, 107, 72, 0.2),
		0 9px 22px rgba(31, 107, 72, 0.14);
	opacity: 1 !important;
}

.single-product .coci-product-gallery ol.flex-control-thumbs img:focus-visible,
.single-product .coci-product-gallery .coci-gallery__arrow:focus-visible,
.single-product .coci-product-gallery .woocommerce-product-gallery__trigger:focus-visible {
	outline: 3px solid var(--coci-gallery-green) !important;
	outline-offset: 3px;
	box-shadow: 0 0 0 6px var(--coci-gallery-focus) !important;
}

/* Navegación superpuesta con objetivos táctiles amplios. */
.single-product .coci-product-gallery .coci-gallery__arrow {
	position: absolute;
	top: 50%;
	z-index: 55;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 1px solid rgba(31, 107, 72, 0.2);
	border-radius: 50%;
	background: rgba(255, 253, 247, 0.88);
	color: var(--coci-gallery-green-dark);
	box-shadow: var(--coci-gallery-shadow);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	cursor: pointer;
	transform: translateY(-50%);
	transition:
		transform 160ms ease,
		opacity 160ms ease,
		background-color 160ms ease,
		box-shadow 160ms ease;
}

.single-product .coci-product-gallery .coci-gallery__arrow svg {
	width: 20px;
	height: 20px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
	stroke-linejoin: round;
	pointer-events: none;
}

.single-product .coci-product-gallery .coci-gallery__arrow--previous {
	left: 22px;
}

.single-product .coci-product-gallery .coci-gallery__arrow--next {
	right: 22px;
}

.single-product .coci-product-gallery .coci-gallery__arrow:disabled {
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
}

.single-product .coci-product-gallery .coci-gallery__counter {
	position: absolute;
	right: 22px;
	bottom: calc(var(--coci-gallery-thumb) + 31px);
	z-index: 56;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 54px;
	min-height: 34px;
	padding: 7px 11px;
	border: 1px solid rgba(31, 107, 72, 0.16);
	border-radius: 999px;
	background: rgba(255, 253, 247, 0.9);
	color: var(--coci-gallery-green-dark);
	box-shadow: 0 8px 22px rgba(44, 72, 54, 0.1);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	font-size: 0.76rem;
	font-weight: 850;
	line-height: 1;
	letter-spacing: 0.03em;
	pointer-events: none;
}

.single-product .coci-product-gallery .coci-gallery__hint {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	margin: 6px 2px 0;
	color: var(--coci-gallery-muted);
	font-size: 0.76rem;
	font-weight: 700;
	line-height: 1.3;
	text-align: center;
}

.single-product .coci-product-gallery .coci-gallery__hint::before {
	content: "";
	width: 20px;
	height: 1px;
	background: rgba(31, 107, 72, 0.32);
}

.single-product .coci-product-gallery.coci-gallery--single .coci-gallery__arrow,
.single-product .coci-product-gallery.coci-gallery--single .coci-gallery__counter,
.single-product .coci-product-gallery.coci-gallery--single .coci-gallery__hint {
	display: none !important;
}

.single-product .coci-product-gallery .coci-gallery__sr-status {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	padding: 0 !important;
	margin: -1px !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* La lupa de WooCommerce sigue siendo la entrada al lightbox nativo. */
.single-product .coci-product-gallery .woocommerce-product-gallery__trigger {
	top: 22px !important;
	right: 22px !important;
	z-index: 70 !important;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 46px !important;
	height: 46px !important;
	border: 1px solid rgba(31, 107, 72, 0.2) !important;
	border-radius: 50% !important;
	background: rgba(255, 253, 247, 0.9) !important;
	color: var(--coci-gallery-green-dark) !important;
	box-shadow: var(--coci-gallery-shadow);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
}

@media (hover: hover) and (pointer: fine) {
	.single-product .coci-product-gallery ol.flex-control-thumbs img:hover {
		opacity: 1 !important;
		transform: translateY(-2px);
	}

	.single-product .coci-product-gallery .coci-gallery__arrow:hover {
		background: var(--coci-gallery-paper);
		box-shadow: 0 20px 38px rgba(44, 72, 54, 0.18);
		transform: translateY(-50%) scale(1.04);
	}
}

/*
 * Un único patrón predecible en todas las pantallas: miniaturas horizontales
 * debajo de la imagen. En escritorio evita la "torre" lateral y mantiene la
 * lectura natural imagen → opciones; con muchas fotos el carril se desplaza
 * internamente sin aumentar la altura de la ficha.
 */
@media (min-width: 1024px) {
	.single-product .coci-product-gallery.coci-gallery--enhanced {
		display: block !important;
		padding: 14px !important;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .flex-viewport {
		width: 100%;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced ol.flex-control-thumbs {
		position: static;
		top: auto;
		right: auto;
		bottom: auto;
		left: auto;
		flex-direction: row;
		align-items: center;
		width: 100%;
		height: auto;
		max-height: none;
		margin: 12px 0 0 !important;
		padding: 3px 2px 6px !important;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x proximity;
		touch-action: pan-x pan-y;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .coci-gallery__hint {
		display: none;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .coci-gallery__arrow--previous {
		left: 24px;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .coci-gallery__arrow {
		top: calc(50% - 42px);
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .coci-gallery__arrow--next {
		right: 24px;
	}

	.single-product .coci-product-gallery.coci-gallery--enhanced .coci-gallery__counter {
		right: 24px;
		bottom: calc(var(--coci-gallery-thumb) + 33px);
	}
}

@media (max-width: 767px) {
	.single-product .coci-product-gallery {
		--coci-gallery-thumb: 60px;
		padding: 9px !important;
		border-radius: 27px !important;
	}

	.single-product .coci-product-gallery .flex-viewport {
		aspect-ratio: 1 / 1;
		border-radius: 21px;
	}

	.single-product .coci-product-gallery .woocommerce-product-gallery__image img {
		aspect-ratio: 1 / 1;
		border-radius: 20px !important;
	}

	.single-product .coci-product-gallery ol.flex-control-thumbs {
		gap: 9px;
		margin-top: 10px !important;
	}

	.single-product .coci-product-gallery .coci-gallery__arrow,
	.single-product .coci-product-gallery .woocommerce-product-gallery__trigger {
		width: 44px !important;
		height: 44px !important;
	}

	.single-product .coci-product-gallery .coci-gallery__arrow--previous {
		left: 15px;
	}

	.single-product .coci-product-gallery .coci-gallery__arrow--next {
		right: 15px;
	}

	.single-product .coci-product-gallery .woocommerce-product-gallery__trigger {
		top: 15px !important;
		right: 15px !important;
	}

	.single-product .coci-product-gallery .coci-gallery__counter {
		right: 15px;
		bottom: calc(var(--coci-gallery-thumb) + 47px);
	}
}

@media (max-width: 380px) {
	.single-product .coci-product-gallery {
		--coci-gallery-thumb: 56px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.single-product .coci-product-gallery *,
	.single-product .coci-product-gallery *::before,
	.single-product .coci-product-gallery *::after {
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
	}
}
