/**
 * WSPVM – single product attribute selectors
 *
 * Styles for the link and button attribute selectors rendered by the
 * Single_Product_Selectors class on single product pages.
 *
 * Design intent:
 *  - Link selectors (primary attribute)  → minimal text links with an
 *    animated underline, matching the brand's uppercase-letter style.
 *  - Button selectors (other attributes) → pill-shaped buttons matching
 *    the archive-card swatch aesthetic.
 *  - Color / image swatches → circular / square thumbnails for both types.
 *  - The original WooCommerce <select> is visually hidden but kept in the
 *    DOM so WooCommerce's variation JS continues to work.
 */

/* ========================================================================
   WooCommerce variations table row spacing
   ======================================================================== */

body.single-product table.variations tbody tr {
	gap: 0;
}

/* ========================================================================
   Hidden select
   ======================================================================== */

.wspvm-sp-hidden-select {
	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;
}

/* Wrapper div only needs to be non-visual. */
.wspvm-sp-hidden-select-wrap {
	display: contents;
}

/* ========================================================================
   Group wrapper
   ======================================================================== */

.wspvm-sp-selector-group {
	display: block;
}

/* ========================================================================
   LINK selectors  (primary attribute)
   ======================================================================== */

.wspvm-sp-links {
	display:     inline-flex;
	flex-wrap:   wrap;
	align-items: center;
	gap:         0.9rem 1.75rem;
}

.wspvm-sp-link {
	appearance:      none;
	position:        relative;
	display:         inline-block;
	border:          0;
	background:      transparent;
	padding:         0.1rem 0;
	color:           currentColor;
	cursor:          pointer;
	font-family:     inherit;
	font-size:       0.95rem;
	font-weight:     700;
	letter-spacing:  0.22em;
	line-height:     1.2;
	text-decoration: none;
	text-transform:  uppercase;
	transition:      color 120ms ease, opacity 120ms ease;
}

.wspvm-sp-link:hover,
.wspvm-sp-link:focus {
	color:           currentColor;
	text-decoration: none;
}

/* Animated underline */
.wspvm-sp-link::after {
	position:         absolute;
	right:            0.22em;
	bottom:          -0.28rem;
	left:             0;
	height:           1px;
	background:       currentColor;
	content:          "";
	opacity:          0;
	transform:        scaleX( 0.5 );
	transform-origin: left center;
	transition:       opacity 160ms ease, transform 160ms ease;
}

.wspvm-sp-link.is-active::after,
.wspvm-sp-link:focus::after {
	opacity:   1;
	transform: scaleX( 1 );
}

.wspvm-sp-link.is-disabled {
	cursor:         not-allowed;
	opacity:        0.35;
	pointer-events: none;
}

/* --------------------------------------------------
   Link color swatches
   -------------------------------------------------- */

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

.wspvm-sp-link--color {
	box-sizing:     border-box;
	width:          var( --wspvm-sp-color-swatch-width, 4rem );
	height:         var( --wspvm-sp-color-swatch-height, 1.5rem );
	padding:        0;
	border:         var( --wspvm-sp-color-swatch-border, none );
	border-radius:  0;
	overflow:       visible;
	background:     var( --wspvm-swatch-color, #ccc );
	box-shadow:     none;
	outline:        none;
	flex-shrink:    0;
	letter-spacing: 0;
}

/* Thin underline under the active colour swatch (replaces the outer ring). */
.wspvm-sp-link--color::after {
	right:            0;
	bottom:          -5px;
	left:             0;
	height:           1px;
	background:       currentColor;
	content:          "";
	opacity:          0;
	transform:        none;
	transform-origin: center;
	transition:       opacity 160ms ease;
}

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

.wspvm-sp-link--color.is-active::after,
.wspvm-sp-link--color:focus::after {
	opacity: 1;
}

/* --------------------------------------------------
   Link image swatches
   -------------------------------------------------- */

.wspvm-sp-link--image {
	width:         2.25rem;
	height:        2.25rem;
	padding:       0;
	border-radius: 3px;
	overflow:      hidden;
	box-shadow:    0 0 0 1px rgba( 0, 0, 0, 0.14 ) inset;
	flex-shrink:   0;
	letter-spacing: 0;
}

.wspvm-sp-link--image::after {
	content: none;
}

.wspvm-sp-link--image.is-active {
	box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px currentColor;
}

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

/* ========================================================================
   BUTTON selectors  (non-primary attributes)
   ======================================================================== */

.wspvm-sp-buttons {
	display:     inline-flex;
	flex-wrap:   wrap;
	align-items: center;
	gap:         0.5rem;
}

.wspvm-sp-button {
	appearance:     none;
	display:        inline-flex;
	align-items:    center;
	justify-content:center;
	border:         1px solid currentColor;
	border-radius:  2px;
	background:     transparent;
	padding:        0.45rem 0.9rem;
	color:          currentColor;
	cursor:         pointer;
	font-family:    inherit;
	font-size:      0.85rem;
	font-weight:    600;
	letter-spacing: 0.12em;
	line-height:    1.2;
	text-transform: uppercase;
	transition:     background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.wspvm-sp-button:hover:not( .is-disabled ),
.wspvm-sp-button:focus:not( .is-disabled ) {
	background: transparent;
	color: #fff;
}

/* Try to keep text readable when the parent's currentColor is dark. */
.wspvm-sp-button.is-active {
	background: currentColor;
	color:      #fff;
}

/* Attempt to keep text readable against the fill in dark-on-dark situations.
   Themes that provide a contrasting text colour will override this. */
.wspvm-sp-button.is-active .wspvm-sp-button__label {
	mix-blend-mode: difference;
}

.wspvm-sp-button.is-disabled {
	cursor:         not-allowed;
	opacity:        0.35;
	pointer-events: none;
}

.wspvm-sp-button__label {
	pointer-events: none;
}

/* --------------------------------------------------
   Button color swatches
   -------------------------------------------------- */

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

.wspvm-sp-button--color {
	box-sizing:    border-box;
	position:      relative;
	width:         var( --wspvm-sp-color-swatch-width, 4rem );
	height:        var( --wspvm-sp-color-swatch-height, 1.5rem );
	padding:       0;
	border-radius: 0;
	border:        var( --wspvm-sp-color-swatch-border, none );
	overflow:      visible;
	background:    var( --wspvm-swatch-color, #ccc );
	box-shadow:    none;
	outline:       none;
	flex-shrink:   0;
}

.wspvm-sp-button--color::after {
	position:   absolute;
	right:      0;
	bottom:    -5px;
	left:       0;
	height:     1px;
	background: currentColor;
	content:    "";
	opacity:    0;
	transition: opacity 160ms ease;
}

.wspvm-sp-button--color:hover:not( .is-disabled ),
.wspvm-sp-button--color:focus:not( .is-disabled ),
.wspvm-sp-button--color:focus-visible:not( .is-disabled ) {
	background: var( --wspvm-swatch-color, #ccc );
	color:      currentColor;
	box-shadow: none;
	outline:    none;
}

.wspvm-sp-button--color.is-active {
	background: var( --wspvm-swatch-color, #ccc );
	color:      currentColor;
	box-shadow: none;
	outline:    none;
}

.wspvm-sp-button--color.is-active::after,
.wspvm-sp-button--color:focus:not( .is-disabled )::after {
	opacity: 1;
}

/* --------------------------------------------------
   Button image swatches
   -------------------------------------------------- */

.wspvm-sp-button--image {
	width:       2.25rem;
	height:      2.25rem;
	padding:     0;
	border-radius: 3px;
	overflow:    hidden;
	border:      none;
	box-shadow:  0 0 0 1px rgba( 0, 0, 0, 0.14 ) inset;
	flex-shrink: 0;
}

.wspvm-sp-button--image:hover:not( .is-disabled ),
.wspvm-sp-button--image:focus:not( .is-disabled ) {
	background: transparent;
	box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px currentColor;
}

.wspvm-sp-button--image.is-active {
	background: transparent;
	box-shadow: 0 0 0 2px #fff inset, 0 0 0 3px currentColor;
}

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

/* ========================================================================
   Reset / clear button
   ======================================================================== */

.wspvm-sp-reset {
	opacity:         0;
	pointer-events:  none;
	appearance:      none;
	border:          0;
	background:      transparent;
	padding:         0;
	color:           currentColor;
	cursor:          pointer;
	font:            inherit;
	text-decoration: underline;
}

.wspvm-sp-reset:hover,
.wspvm-sp-reset:focus {
	text-decoration: none;
}

/* ========================================================================
   Add to Cart + Options block compatibility
   ======================================================================== */

/* Primary URL links replace product-filter-chips inside the ATCWO attribute row. */
.wp-block-woocommerce-add-to-cart-with-options .wspvm-sp-selector-group,
.wp-block-add-to-cart-with-options-variation-selector-attribute .wspvm-sp-selector-group {
	display: block;
	margin: 0;
}

.wp-block-woocommerce-add-to-cart-with-options .wspvm-sp-links,
.wp-block-add-to-cart-with-options-variation-selector-attribute .wspvm-sp-links {
	display:     inline-flex;
	flex-wrap:   wrap;
	align-items: center;
	gap:         0.9rem 1.75rem;
}

.wp-block-woocommerce-add-to-cart-with-options .wspvm-sp-links:has( .wspvm-sp-link--color ),
.wp-block-add-to-cart-with-options-variation-selector-attribute .wspvm-sp-links:has( .wspvm-sp-link--color ) {
	gap: 8px;
	padding-bottom: 6px;
}

/* ATCWO primary links are never disabled via classic select sync. */
.wp-block-woocommerce-add-to-cart-with-options .wspvm-sp-link,
.wp-block-add-to-cart-with-options-variation-selector-attribute .wspvm-sp-link {
	pointer-events: auto;
	cursor: pointer;
}

.wp-block-woocommerce-add-to-cart-with-options .wspvm-sp-link.is-disabled,
.wp-block-add-to-cart-with-options-variation-selector-attribute .wspvm-sp-link.is-disabled {
	opacity: 1;
	pointer-events: auto;
	cursor: pointer;
}

/* When WSPVM injects colour/image visuals, WC adds is-style-swatch — keep chips
   aligned with the rest of the form spacing. */
.wp-block-woocommerce-add-to-cart-with-options .wc-block-product-filter-chips.is-style-swatch,
.wp-block-add-to-cart-with-options-variation-selector-attribute .wc-block-product-filter-chips.is-style-swatch {
	gap: 8px;
}
