/* =========================================================================
 * Ripple effect — Add to Cart buttons only
 *
 * Scope: ONLY the WooCommerce add-to-cart buttons.
 *   .single_add_to_cart_button   → product page  ("افزودن به سبد خرید")
 *   .add_to_cart_button:not(.product_type_variable)  → product loop (simple products)
 *
 * Deliberately NOT applied to: buy-now, "اطلاع از موجودشدن", gallery controls,
 * header icons, pagination, or any other .button on the site.
 *
 * No framework, no dependency. The whole effect is one absolutely-positioned
 * span animating transform+opacity, which the compositor handles on the GPU.
 *
 * Loaded after brand-child so it wins the cascade over the parent theme.
 * ========================================================================= */

/* The ripple needs a clipping box and a paint context. The parent theme sets
 * overflow implicitly (visible), so without this the circle would spill out.
 * position:relative lives here rather than in PHP so anything that re-renders
 * the button later (variation swaps, AJAX) still gets it. */
.single_add_to_cart_button,
.add_to_cart_button:not(.product_type_variable) {
	position: relative;
	overflow: hidden;
	-webkit-tap-highlight-color: transparent;
}

/* The span injected by ripple.js. width/height/left/top are set inline so the
 * wave starts at the exact pointer position. */
.mg-ripple {
	position: absolute;
	border-radius: 50%;
	pointer-events: none;   /* never steal the click or cover the label */
	transform: scale(0);
	will-change: transform, opacity;
	animation: mg-ripple-out 560ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* Product-page button is near-black (--ink) with white text, so the wave is
 * bright: a soft white wash on a dark surface, like the Animate UI reference. */
.single_add_to_cart_button .mg-ripple {
	background: #fff;
	--mg-ripple-peak: 0.30;
}

/* Loop buttons are white with dark text, so the wave has to be dark instead,
 * otherwise it would be invisible. */
.add_to_cart_button:not(.product_type_variable) .mg-ripple {
	background: currentColor;
	--mg-ripple-peak: 0.18;
}

/* Full expansion: the wave grows past the button's diagonal, so it always
 * covers the whole surface regardless of where the tap landed. */
@keyframes mg-ripple-out {
	0% {
		transform: scale(0);
		opacity: var(--mg-ripple-peak, 0.25);
	}
	55% {
		opacity: calc(var(--mg-ripple-peak, 0.25) * 0.5);
	}
	100% {
		transform: scale(1);
		opacity: 0;
	}
}

/* Pointer-down scale, matching the reference component's tapScale. Kept well
 * under 1 so it reads as a press, not a jump. Only the button itself moves. */
.single_add_to_cart_button,
.add_to_cart_button:not(.product_type_variable) {
	transition: transform 120ms ease-out;
}

.single_add_to_cart_button.mg-pressed,
.add_to_cart_button:not(.product_type_variable).mg-pressed {
	transform: scale(0.977);
}

/* A disabled add-to-cart must not look interactive. The parent theme already
 * dims it to 0.4; we simply suppress the press motion. */
.single_add_to_cart_button:disabled,
.single_add_to_cart_button.disabled {
	transform: none !important;
}

/* Respect the OS "reduce motion" setting: drop the movement entirely and
 * leave the button exactly as it was. */
@media (prefers-reduced-motion: reduce) {
	.mg-ripple {
		display: none;
		animation: none;
	}
	.single_add_to_cart_button,
	.add_to_cart_button:not(.product_type_variable),
	.single_add_to_cart_button.mg-pressed,
	.add_to_cart_button:not(.product_type_variable).mg-pressed {
		transition: none;
		transform: none;
	}
}

/* -------------------------------------------------------------------------
 * My-account navigation: same wave, lighter palette
 *
 * These are links, not buttons, and their resting fill is light grey, so the
 * wave is a dark wash rather than the white one used on the dark product-page
 * button. position/overflow already arrive from account.css.
 * ------------------------------------------------------------------------- */
.mg-side .woocommerce-MyAccount-navigation li a .mg-ripple {
	background: currentColor;
	--mg-ripple-peak: 0.14;
}

.mg-side .woocommerce-MyAccount-navigation li a {
	transition: transform 120ms ease-out, background 0.14s ease, color 0.14s ease;
}

.mg-side .woocommerce-MyAccount-navigation li a.mg-pressed {
	transform: scale(0.977);
}

@media (prefers-reduced-motion: reduce) {
	.mg-side .woocommerce-MyAccount-navigation li a {
		transition: none;
		transform: none;
	}
}
