/**
 * MR Stiff Product Manual Tab — Specific Product widget styles.
 *
 * Two columns: the gallery (or featured image) beside the product details —
 * title, price, stock, add-to-cart form and tabs. The gallery column can sit
 * left, right or above the details; below 992px the layout always stacks.
 *
 * The gallery's own look comes from the MrStiff Product Gallery stylesheet and
 * the tab accordion's from mspmt-wc-tabs-accordion.css; nothing here overrides
 * either of them.
 */

.mspmt-sp {
	--mspmt-sp-media-width: 50%;

	display: flex;
	align-items: flex-start;
	gap: 40px;
}

.mspmt-sp__media {
	flex: 0 0 var( --mspmt-sp-media-width );
	max-width: var( --mspmt-sp-media-width );
	min-width: 0;
}

.mspmt-sp__summary {
	--mspmt-sp-gap: 16px;

	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: var( --mspmt-sp-gap );
	min-width: 0;
}

/* ---- Gallery position -------------------------------------------------- */

.mspmt-sp--pos-right {
	flex-direction: row-reverse;
}

.mspmt-sp--pos-top {
	flex-direction: column;
}

.mspmt-sp--pos-top .mspmt-sp__media {
	flex-basis: auto;
	max-width: 100%;
	width: 100%;
}

.mspmt-sp--no-media .mspmt-sp__summary {
	flex-basis: 100%;
}

/* ---- Featured image ---------------------------------------------------- */

.mspmt-sp__featured {
	margin: 0;
}

.mspmt-sp__image {
	display: block;
	width: 100%;
	height: auto;
}

/* ---- Guarantee card ----------------------------------------------------- */

/* Sits under the gallery, as in the design. The card's own look comes from
   mspmt-guarantee.css; only the spacing above it belongs to this widget. */
.mspmt-sp__guarantee {
	margin-top: var( --mspmt-sp-guarantee-gap, 24px );
}

/* ---- Product details --------------------------------------------------- */

.mspmt-sp__title {
	margin: 0;
}

.mspmt-sp__title a {
	color: inherit;
	text-decoration: none;
}

.mspmt-sp__price {
	margin: 0;
}

.mspmt-sp__stock,
.mspmt-sp__cart,
.mspmt-sp__tabs {
	margin: 0;
}

/* ---- Stock status dot -------------------------------------------------- */

/* An animated status dot before the availability text, colour-keyed to the
   stock state (see MSPMT_Specific_Product_Render::stock_dot_html). Scoped to
   this widget, so the stock line on product pages is unaffected. */
.mspmt-sp .stock.mspmt-sp-stock {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
}

.mspmt-sp .stock.mspmt-sp-stock::before {
	content: "";
	flex: 0 0 auto;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var( --mspmt-sp-dot, #19a04b );
	box-shadow: 0 0 0 0 var( --mspmt-sp-dot, #19a04b );
	animation: mspmt-sp-pulse 1.6s ease-out infinite;
}

/* In stock — green (the default above). Low stock, backorder and out-of-stock
   override it; each selector carries one extra class so it always wins over the
   green default regardless of the source order of WooCommerce's own classes. */

/* Low stock ("almost out of stock") and backorder — amber. */
.mspmt-sp .stock.mspmt-sp-stock.mspmt-sp-stock--low,
.mspmt-sp .stock.mspmt-sp-stock.available-on-backorder {
	--mspmt-sp-dot: #f5a623;
}

/* Out of stock — red. */
.mspmt-sp .stock.mspmt-sp-stock.out-of-stock {
	--mspmt-sp-dot: #e0402c;
}

@keyframes mspmt-sp-pulse {
	0% {
		box-shadow: 0 0 0 0 var( --mspmt-sp-dot, #19a04b );
		opacity: 1;
	}

	70% {
		box-shadow: 0 0 0 6px transparent;
		opacity: .85;
	}

	100% {
		box-shadow: 0 0 0 0 transparent;
		opacity: 1;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.mspmt-sp .stock.mspmt-sp-stock::before {
		animation: none;
	}
}

/* ---- Add-to-cart AJAX loader ------------------------------------------- */

/* The site's AJAX add-to-cart plugin toggles a `.loading` class on the button
   while the request runs, but WooCommerce's own spinner styles live in a
   stylesheet that only loads on WooCommerce pages (and are scoped under a
   `.woocommerce` ancestor this widget does not have). This provides a
   self-contained spinner so the loader shows wherever the widget is placed. */
.mspmt-sp__cart .single_add_to_cart_button.loading {
	position: relative;
	opacity: .6;
	padding-right: 2.618em;
	pointer-events: none;
}

.mspmt-sp__cart .single_add_to_cart_button.loading::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 1em;
	width: 1em;
	height: 1em;
	margin-top: -0.5em;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	box-sizing: border-box;
	animation: mspmt-sp-spin .7s linear infinite;
}

.mspmt-sp__cart .single_add_to_cart_button.added::after {
	display: none;
}

@keyframes mspmt-sp-spin {
	to {
		transform: rotate( 360deg );
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.mspmt-sp__cart .single_add_to_cart_button.loading::after {
		animation-duration: 2s;
	}
}

/* The summary column owns the vertical rhythm, so the blocks WooCommerce and
   the accordion render inside it should not add their own trailing margin. */
.mspmt-sp__cart .cart,
.mspmt-sp__stock .stock,
.mspmt-sp__tabs .mspmt-wc-tabs {
	margin-bottom: 0;
}

/* ---- Variation switch buttons ------------------------------------------ */

/* WooCommerce's own <select> stays in the DOM and keeps driving the variation
   form — it is only hidden, never removed, so its script still reads and
   writes it. Scoped to this widget so no other variation form is affected. */
.mspmt-sp .mspmt-sp-variation > select {
	display: none;
}

.mspmt-sp-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.mspmt-sp-swatch {
	padding: 8px 16px;
	color: inherit;
	font-size: inherit;
	line-height: 1.2;
	background: transparent;
	border: 1px solid currentColor;
	border-radius: 999px;
	cursor: pointer;
	transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.mspmt-sp-swatch:hover:not( [disabled] ) {
	border-color: currentColor;
	opacity: .75;
}

.mspmt-sp-swatch:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.mspmt-sp-swatch.is-active {
	color: #fff;
	background: var( --mspmt-sp-swatch-active, #111 );
	border-color: var( --mspmt-sp-swatch-active, #111 );
}

/* Combinations WooCommerce reports as unavailable. */
.mspmt-sp-swatch.is-unavailable,
.mspmt-sp-swatch[disabled] {
	cursor: not-allowed;
	opacity: .35;
	text-decoration: line-through;
}

/* ---- Editor empty state ------------------------------------------------ */

.mspmt-sp--empty {
	display: block;
	padding: 20px;
	color: #767676;
	background: #f7f7f7;
	border: 1px dashed #c3c4c7;
	border-radius: 4px;
	text-align: center;
}

/* ---- Responsive -------------------------------------------------------- */

@media ( max-width: 991px ) {
	.mspmt-sp,
	.mspmt-sp--pos-right {
		flex-direction: column;
		gap: 24px;
	}

	.mspmt-sp__media {
		flex-basis: auto;
		max-width: 100%;
		width: 100%;
	}
}
