/* =========================================================================
   APC UPS Shop Kenya — product cards (shop, taxonomies, search, Elementor)
   -------------------------------------------------------------------------
   Card anatomy, per the supplied mockup:

     li.product
       .woocommerce-image__wrapper        padded, contain-fit image
       .woocommerce-card__header
         p.product__categories            small uppercase label
         .woocommerce-loop-product__title clamped to 3 lines
         span.price  + small.woocommerce-price-suffix
         p.apc-stock                      green tick
         .apc-card__actions               add to cart · compare · wishlist
   ========================================================================= */

:root {
	--apc-icon-cart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='21' r='1'/%3E%3Ccircle cx='20' cy='21' r='1'/%3E%3Cpath d='M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6'/%3E%3C/svg%3E");
	--apc-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

/* -------------------------------------------------------------------------
   Card shell
   ---------------------------------------------------------------------- */

/* The li keeps every layout property Shoptimizer gives it (width, float,
   gutter padding). It only becomes a flex container so .apc-card can stretch
   to the full height of the row. */
body ul.products li.product {
	display: flex;
	align-self: stretch;
}

body ul.products li.product .apc-card {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	background: #fff;
	border: 1px solid var(--apc-line);
	border-radius: var(--apc-radius);
	overflow: hidden;
	text-align: left;
	transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

body ul.products li.product .apc-card:hover {
	border-color: var(--apc-line-strong);
	box-shadow: var(--apc-shadow);
	transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
	body ul.products li.product .apc-card,
	body ul.products li.product .apc-card:hover {
		transition: none;
		transform: none;
	}
}

/* -------------------------------------------------------------------------
   Image
   ---------------------------------------------------------------------- */

body ul.products li.product .woocommerce-image__wrapper {
	padding: 22px 22px 4px;
	background: #fff;
}

body ul.products li.product .woocommerce-image__wrapper img {
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	mix-blend-mode: multiply; /* kills the grey box on non-transparent JPEGs */
}

/* -------------------------------------------------------------------------
   Body — grows so every card's action stack lines up at the bottom
   ---------------------------------------------------------------------- */

body ul.products li.product .woocommerce-card__header {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	padding: 4px 18px 18px;
}

body ul.products li.product p.product__categories {
	margin: 0 0 7px;
	font-size: 11px;
	font-weight: 500;
	line-height: 1.35;
	letter-spacing: .07em;
	text-transform: uppercase;
	color: var(--apc-muted);
}

body ul.products li.product p.product__categories a {
	color: inherit;
	text-decoration: none;
}

body ul.products li.product p.product__categories a:hover {
	color: var(--apc-red);
}

body ul.products li.product .woocommerce-loop-product__title {
	margin: 0 0 10px;
	padding: 0;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.4;
	letter-spacing: -.005em;

	/* Three lines keeps titles of wildly different lengths on a shared
	   baseline without hard-cropping most of them. */
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(3 * 1.4 * 15px);
}

body ul.products li.product .woocommerce-loop-product__title a {
	color: var(--apc-ink);
	text-decoration: none;
}

body ul.products li.product .woocommerce-loop-product__title a:hover {
	color: var(--apc-red);
}

/* -------------------------------------------------------------------------
   Price
   ---------------------------------------------------------------------- */

body ul.products li.product span.price {
	display: block;
	margin: 0 0 8px;
	font-size: 20px;
	font-weight: 800;
	line-height: 1.25;
	letter-spacing: -.02em;
	color: var(--apc-ink);
}

body ul.products li.product span.price .woocommerce-Price-currencySymbol {
	font-weight: 700;
}

body ul.products li.product span.price small.woocommerce-price-suffix {
	margin-left: 4px;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0;
	color: var(--apc-muted);
	/* Keep "( Ex VAT )" intact — in narrow columns (5-up on the homepage) it
	   otherwise breaks after "Ex". */
	white-space: nowrap;
}

body ul.products li.product span.price del {
	font-size: 15px;
	font-weight: 500;
	color: var(--apc-muted);
}

body ul.products li.product span.price ins {
	text-decoration: none;
	color: var(--apc-red);
}

/* -------------------------------------------------------------------------
   Stock badge
   ---------------------------------------------------------------------- */

body ul.products li.product p.apc-stock {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0 0 14px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
}

body ul.products li.product p.apc-stock::before {
	content: "";
	width: 14px;
	height: 14px;
	flex: none;
	background: currentColor;
	-webkit-mask: var(--apc-icon-check) center / contain no-repeat;
	mask: var(--apc-icon-check) center / contain no-repeat;
}

body ul.products li.product p.apc-stock--in {
	color: var(--apc-green);
}

body ul.products li.product p.apc-stock--out {
	color: var(--apc-muted);
}

body ul.products li.product p.apc-stock--out::before {
	opacity: .55;
}

/* -------------------------------------------------------------------------
   Action stack
   ---------------------------------------------------------------------- */

body ul.products li.product .apc-card__actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: auto; /* pins the stack to the bottom of the card */
}

/* Add to cart + Compare share one outlined charcoal treatment. Shoptimizer
   reveals the loop button on hover on some layouts — force it visible. */
body ul.products li.product .apc-card__actions .button,
body ul.products li.product .apc-card__actions a.compare {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 14px;
	background: #fff;
	border: 1px solid var(--apc-ink);
	border-radius: var(--apc-radius-sm);
	color: var(--apc-ink);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0;
	text-align: center;
	text-decoration: none;
	opacity: 1;
	visibility: visible;
	position: static;
	transform: none;
	transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}

body ul.products li.product .apc-card__actions .button::before,
body ul.products li.product .apc-card__actions a.compare::before {
	content: "";
	width: 17px;
	height: 17px;
	flex: none;
	background: currentColor;
	-webkit-mask: var(--apc-icon-cart) center / contain no-repeat;
	mask: var(--apc-icon-cart) center / contain no-repeat;
}

/* Add to cart is the primary action — it goes red on hover. */
body ul.products li.product .apc-card__actions a.add_to_cart_button:hover,
body ul.products li.product .apc-card__actions a.add_to_cart_button:focus-visible {
	background: var(--apc-red);
	border-color: var(--apc-red);
	color: #fff;
}

/* Compare is secondary — charcoal fill. */
body ul.products li.product .apc-card__actions a.compare:hover,
body ul.products li.product .apc-card__actions a.compare:focus-visible {
	background: var(--apc-ink);
	border-color: var(--apc-ink);
	color: #fff;
}

/* AJAX states */
body ul.products li.product .apc-card__actions a.add_to_cart_button.loading {
	opacity: .65;
	pointer-events: none;
}

body ul.products li.product .apc-card__actions a.added_to_cart {
	min-height: 0;
	padding: 2px 0 0;
	border: 0;
	background: none;
	color: var(--apc-red);
	font-size: 13px;
	text-decoration: underline;
	text-underline-offset: 2px;
}

body ul.products li.product .apc-card__actions a.added_to_cart::before {
	display: none;
}

/* -------------------------------------------------------------------------
   Wishlist — a plain text link, per the mockup. YITH ships its own heart
   icon, so none is added here (adding one would double it up).
   ---------------------------------------------------------------------- */

body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist,
body ul.products li.product .apc-card__actions .yith-add-to-wishlist-button-block {
	margin: 2px 0 0;
	text-align: center;
	font-size: 14px;
}

body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist a,
body ul.products li.product .apc-card__actions .yith-add-to-wishlist-button-block a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: var(--apc-ink-soft);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
}

body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist a:hover,
body ul.products li.product .apc-card__actions .yith-add-to-wishlist-button-block a:hover {
	color: var(--apc-red);
}

body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist svg,
body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist i,
body ul.products li.product .apc-card__actions .yith-add-to-wishlist-button-block svg,
body ul.products li.product .apc-card__actions .yith-add-to-wishlist-button-block i {
	width: 18px;
	height: 18px;
	font-size: 18px;
}

/* YITH's feedback text ("Product added!") shouldn't restyle the row. */
body ul.products li.product .apc-card__actions .yith-wcwl-add-to-wishlist .feedback {
	display: block;
	font-size: 12px;
	color: var(--apc-muted);
}

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

   Note there are deliberately no grid rules here. Shoptimizer's own gutter
   (negative margin on the ul, padding on the li) is left untouched; the card
   paints on the .apc-card wrapper instead, so the two never collide.
   ---------------------------------------------------------------------- */

@media (max-width: 767px) {
	body ul.products li.product .woocommerce-image__wrapper {
		padding: 14px 14px 2px;
	}

	body ul.products li.product .woocommerce-card__header {
		padding: 4px 13px 14px;
	}

	body ul.products li.product .woocommerce-loop-product__title {
		font-size: 14px;
		min-height: calc(3 * 1.4 * 14px);
	}

	body ul.products li.product span.price {
		font-size: 17px;
	}

	body ul.products li.product .apc-card__actions .button,
	body ul.products li.product .apc-card__actions a.compare {
		min-height: 40px;
		font-size: 13px;
	}
}
