.wspvm-product-image {
	position: relative;
	display: block;
	overflow: hidden;
	/* Re-enable pointer events in case a WooCommerce block ancestor uses
	   pointer-events: none and then re-enables it only on <a> elements. */
	pointer-events: auto;
}

.wspvm-product-image img {
	display: block;
	width: 100%;
	height: auto;
}

.wspvm-image-primary,
.wspvm-image-rollover {
	transition: opacity 0.25s ease;
}

/* Override the generic img rule so the rollover stretches to fill the container. */
.wspvm-product-image .wspvm-image-rollover {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
}

/* Standard (non-WSPVM-card) products with a rollover image configured.
   The rollover <img> is appended inside the block's <a>; the WC container
   becomes the positioning parent. */
.wc-block-components-product-image.has-rollover {
	position: relative;
	overflow: hidden;
}

.wc-block-components-product-image.has-rollover .wspvm-image-rollover {
	position:   absolute;
	top:        0;
	left:       0;
	width:      100%;
	height:     100%;
	object-fit: cover;
	opacity:    0;
}

/* Hover triggers — covers both WSPVM and standard cards:
   • Block themes:  the WC container receives real mouse events even when an
     invisible overlay sits above .wspvm-product-image.
   • Classic themes: .wspvm-product-image is used directly as the trigger. */
.wc-block-components-product-image:hover .wspvm-image-rollover,
.wspvm-product-image.has-rollover:hover .wspvm-image-rollover,
.wspvm-product-image.has-rollover:focus-within .wspvm-image-rollover {
	opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
	.wspvm-image-primary,
	.wspvm-image-rollover {
		transition: none;
	}
}

.wspvm-selectors {
	margin-top: 0.75rem;
}

.wspvm-selectors__list {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.wspvm-selectors__list:has( .wspvm-selector--color ) {
	gap: 8px;
	padding-bottom: 6px; /* Room for the active underline below swatches. */
}

/* Block editor text-align support — adjusts swatch row justification. */
.has-text-align-center .wspvm-selectors__list {
	justify-content: center;
}

.has-text-align-right .wspvm-selectors__list {
	justify-content: flex-end;
}

.wspvm-selector {
	appearance: none;
	border: 1px solid currentColor;
	background: transparent;
	padding: 0.25rem 0.5rem;
	cursor: pointer;
	line-height: 1.2;
	position: relative;
}

.wspvm-selector.is-active {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.wspvm-selector.is-disabled,
.wspvm-selector.wspvm-is-inactive {
	cursor: not-allowed;
	opacity: 0.55;
}

.wspvm-selector.is-disabled::after,
.wspvm-primary-card.wspvm-is-inactive .wspvm-product-image::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(to top left, transparent calc(50% - 1px), currentColor, transparent calc(50% + 1px));
	pointer-events: none;
}

.wspvm-selector--color {
	box-sizing:       border-box;
	width:            var( --wspvm-archive-color-swatch-width, 3.5rem );
	height:           var( --wspvm-archive-color-swatch-height, 1rem );
	padding:          0;
	border:           var( --wspvm-archive-color-swatch-border, none );
	border-radius:    0;
	overflow:         visible;
	background-color: var( --wspvm-swatch-color, #ccc );
	box-shadow:       none;
	outline:          none;
}

.wspvm-selector--color:focus,
.wspvm-selector--color:focus-visible,
.wspvm-selector--color.is-active {
	outline:    none;
	box-shadow: none;
}

/* Thin underline under the active colour swatch (matches product page). */
.wspvm-selector--color.is-active::after {
	position:   absolute;
	inset:      auto;
	right:      0;
	bottom:    -5px;
	left:       0;
	height:     1px;
	background: currentColor;
	content:    "";
	opacity:    1;
	pointer-events: none;
}

/* Keep the OOS strike on disabled colour swatches (overrides the underline rule). */
.wspvm-selector--color.is-disabled::after,
.wspvm-selector--color.wspvm-is-inactive::after {
	inset: 0;
	right: auto;
	bottom: auto;
	left: auto;
	height: auto;
	background: linear-gradient( to top left, transparent calc( 50% - 1px ), currentColor, transparent calc( 50% + 1px ) );
}

.wspvm-selector--image {
	width: 2rem;
	height: 2rem;
	padding: 0;
	overflow: hidden;
}

.wspvm-selector__swatch-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.wspvm-primary-card.wspvm-is-inactive {
	opacity: 0.75;
}

.wspvm-primary-card.wspvm-is-inactive a {
	pointer-events: none;
}

.wspvm-primary-card.wspvm-is-inactive.wspvm-allow-click-through a {
	pointer-events: auto;
}
