/**
 * Style 2 — isolated CSS, namespaced under .vynox-s2-card. Same card body
 * (title/price/rating) as Style 1; the difference is the action icons:
 * a vertical top-right stack instead of a bottom hover-bar. The wishlist
 * heart stays visible by default; the cart and compare icons only reveal
 * on hover (or on focus, for keyboard users; always visible on touch
 * devices, which can't hover — see the @media (hover: none) block below).
 *
 * Reads the SAME --vynox-override-* variables Style 1 does (see
 * Controls::register_style_controls()), so the Style tab's color/
 * typography controls affect whichever style is actually selected.
 */

.vynox-s2-card {
	--vynox-s2-radius: 10px;
	--vynox-s2-card-bg: var( --vynox-override-card-bg, var( --wp--preset--color-base, #ffffff ) );
	--vynox-s2-border-color: var( --vynox-override-border-color, var( --wp--preset--color-contrast-2, #e5e5e5 ) );
	--vynox-s2-title-color: var( --vynox-override-title-color, var( --wp--preset--color-contrast, #1a1a1a ) );
	--vynox-s2-price-color: var( --vynox-override-price-color, var( --wp--preset--color-primary, #2e7d32 ) );
	--vynox-s2-price-strike-color: var( --vynox-override-price-strike-color, var( --wp--preset--color-contrast-3, #999999 ) );
	--vynox-s2-badge-bg: var( --vynox-override-badge-bg, var( --wp--preset--color-primary, #2e7d32 ) );
	--vynox-s2-badge-text: var( --vynox-override-badge-text, var( --wp--preset--color-base, #ffffff ) );
	--vynox-s2-icon-color: var( --vynox-override-title-color, var( --wp--preset--color-contrast, #1a1a1a ) );
	--vynox-s2-icon-active-color: var( --vynox-override-price-color, var( --wp--preset--color-primary, #2e7d32 ) );
	--vynox-s2-star-color: var( --vynox-override-star-color, #f5b301 );

	position: relative;
	display: flex;
	flex-direction: column;
	background: var( --vynox-s2-card-bg );
	border-radius: var( --vynox-s2-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;
	height: 100%;
	padding: 15px;
}

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

.vynox-s2-card__media {
	position: relative;
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

.vynox-s2-card__img-link {
	display: block;
	width: 100%;
	height: 100%;
}

.vynox-s2-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 10px !important;
	transition: transform 0.35s ease;
}

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

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

/* ---------- Top-right icon stack ---------- */

.vynox-s2-card__icons {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.vynox-s2-card__icon-btn {
	position: relative;
	display: inline-flex;
}

/* :not(.added_to_cart) is required here — without it, this rule also
   matches the "View Cart" link WooCommerce injects as a sibling inside
   .vynox-s2-card__icon-btn--cart, forcing it into a 34px circle and
   clipping its text (the exact breakage reported: a tiny black circle
   with "View cart" overflowing out of it). */
.vynox-s2-card .vynox-s2-card__icon-btn a:not( .added_to_cart ),
.vynox-s2-card .vynox-s2-card__icon-btn button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border-radius: 50%;
	background: var( --wp--preset--color-base, #ffffff );
	color: var( --vynox-s2-icon-color );
	border: none;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.15 );
	transition: background 0.2s ease, color 0.2s ease;
}

/* Wishlist stays visible by default; cart + compare only reveal on
   hover/focus, matching the vertical reveal in the reference design. */
.vynox-s2-card__icon-btn--cart,
.vynox-s2-card__icon-btn--compare {
	opacity: 0;
	transform: translateX( 8px );
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.vynox-s2-card:hover .vynox-s2-card__icon-btn--cart,
.vynox-s2-card:hover .vynox-s2-card__icon-btn--compare,
.vynox-s2-card:focus-within .vynox-s2-card__icon-btn--cart,
.vynox-s2-card:focus-within .vynox-s2-card__icon-btn--compare {
	opacity: 1;
	transform: translateX( 0 );
	pointer-events: auto;
}

.vynox-s2-card__icon-btn--compare button.is-active {
	background: var( --vynox-s2-icon-active-color );
	color: var( --wp--preset--color-base, #ffffff );
}

/* "View Cart" flyout — WooCommerce injects <a class="added_to_cart
   wc-forward"> as a sibling of the cart icon after a successful add.
   Kept (not removed, unlike Style 1) and styled as a black pill to the
   left of the icon, with a small pointer, instead of raw inline text.
   Background is a custom property (not a plain "background:#000") so the
   Style tab's "View Cart Button" section (shown for Style 2/3, see
   Controls::register_cart_button_controls()) can override it, and so the
   pointer triangle below automatically stays the same color as the pill
   without a separate control. */
.vynox-s2-card__icon-btn--cart .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.2 );
	z-index: 3;
}

.vynox-s2-card__icon-btn--cart .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 );
}

/* Touch devices can't hover — keep every icon visible and tappable. */
@media ( hover: none ) {
	.vynox-s2-card__icon-btn--cart,
	.vynox-s2-card__icon-btn--compare {
		opacity: 1;
		transform: none;
		pointer-events: auto;
	}
}

/* "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-s2-card__icon-btn--cart a.loading {
	position: relative;
	pointer-events: none;
}

.vynox-s2-card__icon-btn--cart a.loading svg {
	visibility: hidden;
}

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

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

/* ---------- Body (identical structure/behavior to Style 1) ---------- */

.vynox-s2-card__body {
	padding: 15px 0 0 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.vynox-s2-card__body .vynox-s2-card__title {
	color: var( --vynox-s2-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;

	/* Reserve space for exactly 2 lines so cards with short titles still align. */
	min-height: calc( 16px * 1.35 * 2 );
}

.vynox-s2-card__title:hover {
	color: var( --vynox-s2-price-color );
}

.vynox-s2-card__price {
	font-size: 16px;
	font-weight: 700;
	color: var( --vynox-s2-price-color );
}

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

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

.vynox-s2-card__rating {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: var( --vynox-s2-price-strike-color );
}

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