/**
 * Miramono single product gallery — vertical scroll + sticky thumbnail column.
 *
 * Loaded on single product pages only, after storefront-woocommerce-style.
 */

.single-product div.product .mm-gallery {
	/* Sticky header clearance: thumbnail column offset + image scroll anchor. */
	--mm-gallery-offset: 100px;
	--mm-gallery-gap: 4px;
	--mm-gallery-nav-width: 100px;

	display: flex;
	align-items: flex-start;
	gap: var(--mm-gallery-gap);
	position: relative;
}

/* ---------------------------------------------------------------
 * Thumbnail navigation (left column)
 * --------------------------------------------------------------- */

.single-product div.product .mm-gallery .mm-gallery__nav {
	order: 1;
	flex: 0 0 var(--mm-gallery-nav-width);
	width: var(--mm-gallery-nav-width);
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: var(--mm-gallery-gap);
	position: sticky;
	top: var(--mm-gallery-offset);
	max-height: calc(100vh - var(--mm-gallery-offset) - 20px);
	overflow-y: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.single-product div.product .mm-gallery .mm-gallery__nav::-webkit-scrollbar {
	display: none;
}

.single-product div.product .mm-gallery .mm-gallery__nav-item {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* Reset Storefront's global button styling. */
.single-product div.product .mm-gallery .mm-gallery__nav-link,
.single-product div.product .mm-gallery .mm-gallery__nav-link:hover,
.single-product div.product .mm-gallery .mm-gallery__nav-link:focus,
.single-product div.product .mm-gallery .mm-gallery__nav-link:active {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	background-color: transparent;
	box-shadow: none;
	line-height: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.single-product div.product .mm-gallery .mm-gallery__nav-link img {
	display: block;
	width: 100%;
	height: auto;
	margin: 0;
	opacity: 0.5;
	transition: opacity 0.2s ease;
}

.single-product div.product .mm-gallery .mm-gallery__nav-link:hover img,
.single-product div.product .mm-gallery .mm-gallery__nav-link:focus-visible img,
.single-product div.product .mm-gallery .mm-gallery__nav-link.is-active img {
	opacity: 1;
}

/* ---------------------------------------------------------------
 * Stacked images (right column)
 * --------------------------------------------------------------- */

.single-product div.product .mm-gallery .woocommerce-product-gallery__wrapper {
	order: 2;
	flex: 1 1 auto;
	min-width: 0;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: var(--mm-gallery-gap);
	/* No slider: undo any leftover carousel positioning. */
	transform: none !important;
	width: auto !important;
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image,
.single-product div.product .mm-gallery .woocommerce-product-gallery__image--placeholder {
	width: 100% !important;
	margin: 0;
	padding: 0;
	float: none;
	scroll-margin-top: var(--mm-gallery-offset);
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a {
	display: block;
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image img {
	display: block;
	width: 100%;
	/* Keep the original vertical proportions of the file. */
	height: auto;
	margin: 0;
}

/* ---------------------------------------------------------------
 * Handheld: horizontal slider.
 *
 * Below this width the summary drops under the gallery instead of sitting to its
 * right, so there is no room for a tall stack. The images become a swipeable
 * carousel using native scroll-snap — no slider library involved — and the
 * thumbnail rail moves under them as a strip that doubles as page indicator.
 *
 * The breakpoint matches the one in custom.css that switches the product layout
 * to a single column.
 * --------------------------------------------------------------- */

@media (max-width: 768px) {
	.single-product div.product .mm-gallery {
		flex-direction: column;
		gap: 0;
	}

	/* Se invierte el orden: imagenes arriba, tira de thumbnails debajo. */
	.single-product div.product .mm-gallery .woocommerce-product-gallery__wrapper {
		order: 1;
		flex-direction: row;
		align-items: flex-start;
		gap: 0;
		width: 100% !important;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		-ms-overflow-style: none;
	}

	.single-product div.product .mm-gallery .woocommerce-product-gallery__wrapper::-webkit-scrollbar {
		display: none;
	}

	.single-product div.product .mm-gallery .woocommerce-product-gallery__image {
		flex: 0 0 100%;
		scroll-snap-align: center;
		scroll-snap-stop: always;
	}

	.single-product div.product .mm-gallery .mm-gallery__nav {
		order: 2;
		position: static;
		flex: 0 0 auto;
		flex-direction: row;
		width: 100%;
		max-height: none;
		margin-top: var(--mm-gallery-gap);
		overflow-x: auto;
	}

	.single-product div.product .mm-gallery .mm-gallery__nav-item {
		flex: 0 0 52px;
	}
}

/* ---------------------------------------------------------------
   Zoom sobre la imagen (assets/js/miramono-product-zoom.js)
   --------------------------------------------------------------- */

/* La clase la pone el JS, y solo si el dispositivo tiene hover, asi que en
   tactil ni el cursor cambia. `overflow: hidden` recorta la capa ampliada al
   marco de la foto: es lo que hace que parezca una lupa y no una imagen
   desbordada. */
.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a.mm-zoom {
	position: relative;
	overflow: hidden;
}

/* La lupa no aparece hasta que el original esta cargado y se sabe que amplia de
   verdad: si el archivo no da mas resolucion, el JS quita .mm-zoom y esto no
   llega a aplicarse. El zoom lo dispara el clic, no el hover, asi que el cursor
   es la unica señal de que la foto se puede ampliar. */
.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a.mm-zoom--listo {
	cursor: zoom-in;
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a.mm-zoom--activo {
	cursor: zoom-out;
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a .mm-zoom__layer {
	position: absolute;
	top: 0;
	left: 0;
	max-width: none;
	opacity: 0;
	/* El desplazamiento lo escribe el JS en cada movimiento del raton; sin
	   transicion, o la lupa iria por detras del cursor. Solo se suaviza la
	   aparicion. */
	transition: opacity .12s ease-out;
	pointer-events: none;
	transform-origin: 0 0;
}

.single-product div.product .mm-gallery .woocommerce-product-gallery__image > a.mm-zoom--activo .mm-zoom__layer {
	opacity: 1;
}
