/**
 * Style 4 — isolated CSS, namespaced under .vynox-s4-card. The product
 * image fills the entire card as a background (unlike Styles 1/2/3's
 * square media box + separate white body below); a bottom gradient scrim
 * keeps the overlaid title/price/rating legible against any photo. Badge
 * sits top-left, wishlist top-right, both floating directly on the image.
 *
 * Reads the SAME --vynox-override-* variables the other styles do (see
 * Controls::register_style_controls()), except title/price default to
 * white here (this style's content always sits over an image+scrim, not
 * a plain card background) — still overridable from the Style tab like
 * every other style.
 *
 * The cart button is icon-only, anchored bottom-right; "View Cart" reveals
 * to its left on a successful add — same dynamic pattern as Styles 2/3
 * (WooCommerce's own wc-add-to-cart.js injects the
 * "<a class='added_to_cart wc-forward'>" link; nothing removes it here),
 * and driven by the same shared --vynox-cart-pill-bg custom property the
 * "View Cart Button" Style-tab section controls (see
 * Controls::register_cart_button_controls()).
 */

.vynox-s4-card {
	--vynox-s4-radius: 16px;
	--vynox-s4-title-color: var( --vynox-override-title-color, #ffffff );
	--vynox-s4-price-color: var( --vynox-override-price-color, #ffffff );
	--vynox-s4-price-strike-color: var( --vynox-override-price-strike-color, rgba( 255, 255, 255, 0.65 ) );
	--vynox-s4-badge-bg: var( --vynox-override-badge-bg, var( --wp--preset--color-primary, #2e7d32 ) );
	--vynox-s4-badge-text: var( --vynox-override-badge-text, var( --wp--preset--color-base, #ffffff ) );
	--vynox-s4-icon-color: var( --vynox-override-title-color, #1a1a1a );
	--vynox-s4-star-color: var( --vynox-override-star-color, #f5b301 );

	position: relative;
	aspect-ratio: 3 / 4;
	height: 100%;
	min-height: 320px;
	border-radius: var( --vynox-s4-radius );
	overflow: hidden;
	box-shadow: rgba(0, 0, 0, 0.05) 0px 6px 24px 0px, rgba(0, 0, 0, 0.08) 0px 0px 0px 1px;
	transition: box-shadow 0.25s ease;
}

.vynox-s4-card:hover {
	box-shadow: #e8751824 0px 6px 24px 0px, #e8751845 0px 0px 0px 1px;
}

.vynox-s4-card__img-link {
	position: absolute;
	inset: 0;
	display: block;
}

.vynox-s4-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}

.vynox-s4-card:hover .vynox-s4-card__img {
	transform: scale( 1.04 );
}

/* Bottom scrim — keeps the overlaid title/price/rating legible against
   any product photo, regardless of how light/dark it is. */
.vynox-s4-card__scrim {
	position: absolute;
	inset: 0;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.75 ) 0%, rgba( 0, 0, 0, 0.35 ) 35%, transparent 65% );
	pointer-events: none;
	z-index: 1;
}

.vynox-s4-card__badge {
	position: absolute;
	top: 14px;
	left: 14px;
	background: var( --vynox-s4-badge-bg );
	color: var( --vynox-s4-badge-text );
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	padding: 6px 10px;
	border-radius: 999px;
	z-index: 2;
}

.vynox-s4-card__wishlist {
	position: absolute;
	top: 14px;
	right: 14px;
	z-index: 2;
}

.vynox-s4-card__wishlist button,
.vynox-s4-card__wishlist a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border-radius: 50%;
	background: rgba( 255, 255, 255, 0.9 );
	color: var( --vynox-s4-icon-color );
	border: none;
	cursor: pointer;
	box-shadow: 0 2px 8px rgba( 0, 0, 0, 0.2 );
	transition: background 0.2s ease, color 0.2s ease;
}

/* ---------- Bottom content (title / price / rating), overlaid on the scrim ---------- */

.vynox-s4-card__content {
	position: absolute;
	left: 16px;
	right: 84px;
	bottom: 20px;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.vynox-s4-card__title {
	color: var( --vynox-s4-title-color );
	text-decoration: none;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.4 );
}

.vynox-s4-card__title:hover {
	text-decoration: underline;
}

.vynox-s4-card__price {
	font-size: 16px;
	font-weight: 700;
	color: var( --vynox-s4-price-color );
	text-shadow: 0 1px 3px rgba( 0, 0, 0, 0.4 );
}

.vynox-s4-card__price del {
	color: var( --vynox-s4-price-strike-color );
	font-weight: 400;
	font-size: 14px;
	margin-right: 6px;
	text-decoration: line-through;
}

.vynox-s4-card__price ins {
	text-decoration: none;
}

.vynox-s4-card__rating {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: rgba( 255, 255, 255, 0.85 );
}

.vynox-s4-card__rating .star-rating {
	color: var( --vynox-s4-star-color );
	font-size: 14px;
}

/* ---------- Cart FAB, anchored over the bottom-right corner ---------- */

.vynox-s4-card__cart-wrap {
	position: absolute;
	right: 16px;
	bottom: 20px;
	z-index: 2;
}

/* :not(.added_to_cart) — see style-2/style.css for why this exclusion is
   required: without it this rule also matches the "View Cart" link
   WooCommerce injects as a sibling inside .vynox-s4-card__cart-wrap. */
.vynox-s4-card__cart-wrap a:not( .added_to_cart ) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border-radius: 50%;
	background: var( --wp--preset--color-base, #ffffff );
	color: var( --vynox-s4-icon-color );
	border: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.3 );
	transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.vynox-s4-card__cart-wrap a:not( .added_to_cart ):hover {
	transform: translateY( -2px );
}

/* "View Cart" flyout — WooCommerce injects <a class="added_to_cart
   wc-forward"> as a sibling of the cart FAB after a successful add. Kept
   (not removed, unlike Style 1) and styled as a black pill to the left of
   the FAB, same shared --vynox-cart-pill-bg custom property Styles 2/3
   use, so the "View Cart Button" Style-tab section drives all three from
   one set of controls. */
.vynox-s4-card__cart-wrap .added_to_cart {
	--vynox-cart-pill-bg: #000;
	position: absolute;
	top: 50%;
	right: 100%;
	transform: translateY( -50% );
	margin-right: 10px;
	width: auto;
	height: auto;
	display: inline-block;
	background: var( --vynox-cart-pill-bg );
	color: #fff;
	white-space: nowrap;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	padding: 9px 16px;
	border-radius: 999px;
	text-decoration: none;
	box-shadow: 0 4px 14px rgba( 0, 0, 0, 0.3 );
	z-index: 3;
}

.vynox-s4-card__cart-wrap .added_to_cart::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 100%;
	transform: translateY( -50% );
	border: 5px solid transparent;
	border-left-color: var( --vynox-cart-pill-bg );
}

/* "Processing" state for the icon-only Add to Cart button — WooCommerce's
   own wc-add-to-cart.js adds/removes the ".loading" class while the AJAX
   request is in flight. */
.vynox-s4-card__cart-wrap a.loading {
	position: relative;
	pointer-events: none;
}

.vynox-s4-card__cart-wrap a.loading svg {
	visibility: hidden;
}

.vynox-s4-card__cart-wrap a.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid rgba( 0, 0, 0, 0.15 );
	border-top-color: var( --vynox-s4-icon-color );
	border-radius: 50%;
	animation: vynox-s4-cart-spin 0.6s linear infinite;
}

@keyframes vynox-s4-cart-spin {
	to { transform: rotate( 360deg ); }
}
