/**
 * GLOBAL PRODUCT CARD.
 *
 * The ONE visual system for every product card on the site (Best Sellers,
 * Featured Products, Shop, categories, search, related, upsells).
 * Page stylesheets may only size/position the card in their layout context
 * (slider flex-basis, grid placement) — never restyle card internals here.
 *
 * Companion script: assets/js/product-card.js (AJAX, toast, animations).
 */

/* ============================================
   Card shell
   ============================================ */

.product-card {
	position: relative;
	min-width: 0;
	display: flex;
	flex-direction: column;
	background: #ffffff;
	border-radius: 24px;
	padding: 12px;
	box-shadow: 0 0 25px -5px rgb(0 0 0 / 12%);
	transition:
		box-shadow var(--transition-normal),
		transform var(--transition-normal);
	height: auto;
	gap: 10px;
}

.product-card:hover {
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.1);
	transform: translateY(-2px);
}

/* ============================================
   Image (dominant, unchanged behaviour)
   ============================================ */

.product-card__image-link {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 16px;
	overflow: hidden;
	background: var(--color-surface);
}

.product-card__image {
	display: block;
	width: 100%;
	height: 100%;
}

.product-card__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 16px;
	object-position: center;
	transition: transform var(--transition-normal);
}

.product-card:hover .product-card__image img {
	transform: scale(1.025);
}

/* ============================================
   Content + title (2-line rhythm)
   ============================================ */

.product-card__content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-width: 0;
	padding: 0 4px;
}

.product-card__title {
	font-family: var(--font-body);
	font-size: 1rem;
	font-weight: 700;
	line-height: 1.35;
	margin: 0 0 8px;
	/* Two-line clamp keeps every card in a row on the same rhythm. */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 2.7em;
}

.product-card__title a {
	color: var(--color-text);
	text-decoration: none;
}

.product-card__title a:hover,
.product-card__title a:focus-visible {
	color: var(--color-primary);
}

.product-card__title a:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
	border-radius: 2px;
}

/* ============================================
   Price + cart: ALWAYS one row
   ============================================ */

.product-card__bottom {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: nowrap;
	gap: 8px;
	margin-top: auto;
	min-width: 0;
}

.product-card__price {
	min-width: 0;
	flex: 1 1 auto;
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	column-gap: 6px;
	row-gap: 2px;
	font-size: 0.9375rem;
	color: var(--color-text);
}

.product-card__price:empty {
	display: none;
}

.product-card__sale-price,
.product-card__regular-price,
.product-card__range-price {
	font-weight: 700;
	white-space: nowrap;
}

/* MRP: clearly smaller than the selling price, muted, diagonal strike
   (semantic <del> kept). Higher specificity beats generic `.price del`
   theme/WooCommerce rules so the hierarchy always holds. */
.product-card__price .product-card__mrp {
	position: relative;
	display: inline-block;
	font-size: 0.78em;
	font-weight: 400;
	color: var(--color-text-muted);
	text-decoration: none;
	white-space: nowrap;
}

.product-card__price .product-card__mrp::after {
	content: "";
	position: absolute;
	left: -3px;
	right: -3px;
	top: 50%;
	height: 1px;
	background: currentColor;
	opacity: 0.85;
	transform: rotate(-8deg);
	transform-origin: center;
	pointer-events: none;
}

/* ============================================
   Cart icon button
   ============================================ */

.product-card__cart {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
}

.product-card__cart-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #111111;
	color: #ffffff;
	cursor: pointer;
	text-decoration: none;
	transition:
		background-color var(--transition-fast),
		transform var(--transition-fast),
		opacity var(--transition-fast);
}

.product-card__cart-btn svg {
	width: 20px;
	height: 20px;
	flex: none;
	transition:
		opacity var(--transition-fast),
		transform var(--transition-fast);
}

.product-card__cart-btn:hover {
	background: var(--color-primary);
	color: #ffffff;
}

.product-card__cart-btn:active {
	transform: scale(0.93);
}

.product-card__cart-btn:focus-visible {
	outline: 2px solid var(--color-primary);
	outline-offset: 2px;
}

.product-card__cart-btn.is-disabled {
	background: var(--color-surface-dark, #eef0f2);
	color: var(--color-text-muted);
	cursor: not-allowed;
}

/* Loading: icon fades, ring spinner takes its place. */
.product-card__cart-btn.is-loading {
	pointer-events: none;
}

.product-card__cart-btn.is-loading svg {
	opacity: 0;
	transform: scale(0.6);
}

.product-card__cart-btn.is-loading::after {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #ffffff;
	animation: vpure-cart-spin 0.7s linear infinite;
}

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

/* Success / error states (icon swapped by JS). */
.product-card__cart-btn.is-success {
	background: var(--color-accent-green, #72a032);
}

.product-card__cart-btn.is-success svg {
	animation: vpure-cart-pop 0.35s ease;
}

.product-card__cart-btn.is-error {
	background: var(--color-primary-dark, #b7191f);
}

@keyframes vpure-cart-pop {
	0% {
		transform: scale(0.5);
	}
	60% {
		transform: scale(1.18);
	}
	100% {
		transform: scale(1);
	}
}

/* WooCommerce injects an inline "View cart" text link after successful AJAX
   add. Feedback lives on the button + header badge instead, so the card row
   stays clean with zero text. Belt-and-braces with the JS removal. */
.product-card .added_to_cart.wc-forward {
	display: none;
}

/* ============================================
   Layout contexts (sizing only, no visuals)
   ============================================ */

/* Homepage best-sellers slider sizing lives in homepage.css; grid + misc: */
.shop-products-grid .product-card {
	flex: none;
	width: 100%;
	height: 100%;
	scroll-snap-align: none;
}

.search .product-card {
	max-width: 340px;
}

/* ============================================
   Responsive: shrink, never wrap
   ============================================ */

@media (max-width: 47.99em) {
	.product-card {
		padding: 10px;
		gap: 8px;
		border-radius: 20px;
	}

	.product-card__content {
		padding: 0 2px;
	}

	.product-card__title {
		font-size: 0.875rem;
		margin-bottom: 6px;
	}

	.product-card__bottom {
		gap: 6px;
	}

	.product-card__price {
		font-size: 0.875rem;
		column-gap: 5px;
	}

	.product-card__cart-btn {
		width: 40px;
		height: 40px;
	}

	.product-card__cart-btn svg {
		width: 18px;
		height: 18px;
	}

	.product-card__cart-btn.is-loading::after {
		width: 16px;
		height: 16px;
	}
}

/* ============================================
   Header cart badge flash (top-bar feedback)
   ============================================ */

.site-header__cart-count.is-flash,
.site-header__cart.is-flash .site-header__cart-count {
	animation: vpure-badge-flash 0.6s ease;
}

.site-header__cart-count.is-flash-error,
.site-header__cart.is-flash-error .site-header__cart-count {
	animation: vpure-badge-flash-error 0.6s ease;
}

@keyframes vpure-badge-flash {
	0% {
		transform: scale(1);
	}
	35% {
		transform: scale(1.5);
	}
	100% {
		transform: scale(1);
	}
}

@keyframes vpure-badge-flash-error {
	0%,
	100% {
		transform: translateX(0);
	}
	25% {
		transform: translateX(-3px);
	}
	75% {
		transform: translateX(3px);
	}
}

/* ============================================
   Reduced motion
   ============================================ */

@media (prefers-reduced-motion: reduce) {
	.product-card,
	.product-card__image img,
	.product-card__cart-btn,
	.product-card__cart-btn svg {
		transition: none;
	}

	.product-card:hover {
		transform: none;
	}

	.product-card:hover .product-card__image img {
		transform: none;
	}

	.product-card__cart-btn.is-loading::after {
		animation-duration: 1.4s;
	}

	.product-card__cart-btn.is-success svg {
		animation: none;
	}

	.site-header__cart-count.is-flash,
	.site-header__cart-count.is-flash-error,
	.site-header__cart.is-flash .site-header__cart-count,
	.site-header__cart.is-flash-error .site-header__cart-count {
		animation: none;
	}
}
