/* MANA – product loop image for MANA Builder: STRUCTURE ONLY.
   The node itself is the aspect-ratio frame; the images are absolutely positioned inside it, so no content, theme
   rule or image size can change the frame. Corners / border / background come from the node (classes, style) and
   the images inherit the corners. */

.mb-root .mb-mana-product-loop-image {
	--mana-loop-ratio: var(--mlp-ratio, 1 / 1);
	--mana-loop-fit: var(--mlp-fit, cover);
	--mana-loop-position: var(--mlp-pos, center);
	position: relative;
	aspect-ratio: var(--mana-loop-ratio);
	height: auto !important;
	min-height: 0 !important;
}

@media (max-width: 1024px) {
	.mb-root .mb-mana-product-loop-image {
		--mana-loop-ratio: var(--mlp-ratio-t, var(--mlp-ratio, 1 / 1));
		--mana-loop-fit: var(--mlp-fit-t, var(--mlp-fit, cover));
		--mana-loop-position: var(--mlp-pos-t, var(--mlp-pos, center));
	}
}

@media (max-width: 767px) {
	.mb-root .mb-mana-product-loop-image {
		--mana-loop-ratio: var(--mlp-ratio-m, var(--mlp-ratio-t, var(--mlp-ratio, 1 / 1)));
		--mana-loop-fit: var(--mlp-fit-m, var(--mlp-fit-t, var(--mlp-fit, cover)));
		--mana-loop-position: var(--mlp-pos-m, var(--mlp-pos-t, var(--mlp-pos, center)));
	}
}

/* Zero specificity: a width / corners / align-self set on the node always win. */
:where(.mb-root .mb-mana-product-loop-image) {
	width: 100%;
	align-self: flex-start;
	border-radius: var(--img-radius, 0);
}

.mb-root .mb-mana-product-loop-image > .mana-loop-link {
	position: absolute;
	inset: 0;
	display: block;
	border-radius: inherit;
}

.mb-root .mb-mana-product-loop-image .mana-loop-img,
.mb-root .mb-mana-product-loop-image .mana-loop-img > img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	object-fit: var(--mana-loop-fit) !important;
	object-position: var(--mana-loop-position);
	border-radius: inherit;
}

.mb-root .mb-mana-product-loop-image .mana-loop-img {
	position: absolute !important;
	inset: 0;
}

/* The second image: hidden (and, being lazy, never downloaded) on touch devices. */
.mb-root .mb-mana-product-loop-image .mana-loop-img--hover { display: none; }

@media (hover: hover) and (pointer: fine) {
	.mb-root .mb-mana-product-loop-image .mana-loop-img--hover {
		display: block;
		opacity: 0;
		transition: opacity var(--mana-loop-fade, .35s) ease;
	}

	.mb-root .mb-mana-product-loop-image:is(:hover, :focus-within) .mana-loop-img--hover,
	.mb-root :is(.mb-loop__item, .e-loop-item, li.product, .card):hover .mana-loop-hover-card .mana-loop-img--hover {
		opacity: 1;
	}
}

/* A swatch replaced the main image: the hover image must not cover the chosen colour. */
.mb-root .mana-loop-image.is-mana-swatched .mana-loop-img--hover { display: none !important; }

@media (prefers-reduced-motion: reduce) {
	.mb-root .mb-mana-product-loop-image .mana-loop-img--hover { transition: none; }
}
