/**
 * Product cards + shop/category grids — laptops-computer.co.ke
 *
 * Matches pdtcardlayout.png: image, uppercase category eyebrow, 3-line title,
 * large price with (Ex VAT), green stock line, two outlined action buttons,
 * and a borderless wishlist link.
 *
 * Markup comes from woocommerce/content-product.php in this child theme.
 */

/* =========================================================================
 * GRID
 * ====================================================================== */

ul.products {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--lc-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 600px) {
	ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 993px) {
	ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: var(--lc-gap-lg) var(--lc-gap);
	}

	ul.products.columns-3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	ul.products.columns-5 {
		grid-template-columns: repeat(5, minmax(0, 1fr));
	}
}

/* Neutralise the parent/Woo float-and-percentage-width grid. */
ul.products li.product {
	width: auto !important;
	margin: 0 !important;
	float: none !important;
	clear: none !important;
}

/* =========================================================================
 * CARD
 * ====================================================================== */

.lc-card {
	position: relative;
	display: flex;
	flex-direction: column;
	padding: 0;
	border: 1px solid var(--lc-line);
	border-radius: var(--lc-radius);
	background: var(--lc-surface);
	text-align: left;
	transition: border-color .18s, box-shadow .18s;
}

.lc-card:hover {
	border-color: var(--lc-line-strong);
	box-shadow: var(--lc-shadow);
}

/* ---- media ------------------------------------------------------------- */

.lc-card__media {
	position: relative;
	display: block;
	padding: 18px;
	text-align: center;
}

.lc-card__media img {
	display: block;
	width: 100%;
	height: 190px;
	margin: 0 auto;
	object-fit: contain;
}

.lc-card__sale {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	padding: 4px 10px;
	border-radius: var(--lc-radius-pill);
	background: var(--lc-primary);
	color: #fff;
	font-size: var(--lc-fs-xs);
	font-weight: 700;
	line-height: 1.4;
	text-transform: uppercase;
	letter-spacing: .04em;
}

/* ---- body -------------------------------------------------------------- */

.lc-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 8px;
	padding: 0 16px 16px;
}

.lc-card__cat {
	color: var(--lc-muted);
	font-size: var(--lc-fs-xs);
	font-weight: 500;
	line-height: 1.35;
	text-transform: uppercase;
	letter-spacing: .06em;
}

.lc-card__title {
	margin: 0;
	font-size: var(--lc-fs-md);
	font-weight: 700;
	line-height: 1.4;
}

.lc-card__title a {
	display: -webkit-box;
	overflow: hidden;
	color: var(--lc-ink);
	text-decoration: none;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
}

.lc-card__title a:hover {
	color: var(--lc-primary);
}

/* ---- price ------------------------------------------------------------- */

.lc-card__price {
	display: flex;
	align-items: baseline;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: auto;
	padding-top: 4px;
	color: var(--lc-ink);
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
}

.lc-card__price .woocommerce-Price-amount {
	color: var(--lc-ink);
	font-weight: 700;
}

.lc-card__price del {
	color: var(--lc-faint);
	font-size: 15px;
	font-weight: 500;
}

.lc-card__price ins {
	background: none;
	text-decoration: none;
}

.lc-price__vat {
	color: var(--lc-muted);
	font-size: var(--lc-fs-sm);
	font-weight: 400;
	white-space: nowrap;
}

/* ---- stock ------------------------------------------------------------- */

.lc-card__stock {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: var(--lc-fs-sm);
	font-weight: 500;
}

.lc-card__stock.is-in {
	color: var(--lc-in-stock);
}

.lc-card__stock.is-out {
	color: var(--lc-out-stock);
}

/* =========================================================================
 * ACTIONS
 * ====================================================================== */

.lc-card__actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-top: 6px;
}

/*
 * Shoptimizer reveals loop buttons on hover:
 *   ul.products li.product .button{position:absolute;bottom:0;height:40px;opacity:0}
 *   ul.products li.product:hover .button{opacity:1}
 * That takes them out of flow and hides them, which is wrong for this card —
 * the reference shows both buttons permanently, stacked and in flow.
 *
 * The parent selector scores (0,3,2); a plain .lc-card__actions a.button
 * scores lower and loses, so these five properties are forced. Everything
 * else about the buttons is styled normally below.
 */
ul.products li.product .lc-card__actions a.button,
ul.products li.product .lc-card__actions .added_to_cart,
ul.products li.product .lc-card__compare a {
	position: relative !important;
	bottom: auto !important;
	width: 100% !important;
	height: auto !important;
	opacity: 1 !important;
	/*
	 * display:block comes from the same parent rule and beats a plain
	 * .lc-card__actions selector; without flex the icon and label cannot be
	 * centred as a pair. The colours are forced because the customizer prints
	 * its green button skin (#3BB54A) inline, after this file — playbook §6.1.
	 */
	display: flex !important;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	line-height: 1.2 !important;
	border: 1.5px solid var(--lc-primary) !important;
	background: var(--lc-surface) !important;
	color: var(--lc-primary) !important;
}

ul.products li.product .lc-card__actions a.button:hover,
ul.products li.product .lc-card__compare a:hover {
	background: var(--lc-primary) !important;
	color: #fff !important;
}

/*
 * Shared outlined-button treatment for both the WooCommerce add-to-cart link
 * and the YITH compare link. Selectors are deliberately specific: the parent
 * theme styles .button heavily and Kirki prints customizer CSS after our file
 * (playbook §6.1), so these need the weight.
 */
.lc-card__actions a.button,
.lc-card__actions .lc-card__compare a {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	min-height: 44px;
	margin: 0;
	padding: 10px 14px;
	border: 1.5px solid var(--lc-primary);
	border-radius: var(--lc-radius-sm);
	background: var(--lc-surface);
	color: var(--lc-primary);
	font-size: var(--lc-fs-md);
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	text-transform: none;
	letter-spacing: 0;
	transition: background-color .18s, color .18s;
}

.lc-card__actions a.button:hover,
.lc-card__actions .lc-card__compare a:hover {
	background: var(--lc-primary);
	color: #fff;
}

/*
 * Cart glyph before both labels, recoloured on hover.
 *
 * display:block is required — a pseudo-element defaults to inline, and
 * width/height are ignored on non-replaced inline boxes, so the icon computes
 * to 18x18 but paints nothing.
 */
.lc-card__actions a.button::before,
.lc-card__actions .lc-card__compare a::before {
	display: block;
	width: 18px;
	height: 18px;
	flex: none;
	background: no-repeat center / contain
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230037AA' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.4'/%3E%3Ccircle cx='18' cy='20' r='1.4'/%3E%3Cpath d='M2.5 3h2.2l2.4 11.2a1.6 1.6 0 0 0 1.6 1.3h8.9a1.6 1.6 0 0 0 1.6-1.25L21 7H6'/%3E%3C/svg%3E");
	content: "";
}

.lc-card__actions a.button:hover::before,
.lc-card__actions .lc-card__compare a:hover::before {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='20' r='1.4'/%3E%3Ccircle cx='18' cy='20' r='1.4'/%3E%3Cpath d='M2.5 3h2.2l2.4 11.2a1.6 1.6 0 0 0 1.6 1.3h8.9a1.6 1.6 0 0 0 1.6-1.25L21 7H6'/%3E%3C/svg%3E");
}

/* WooCommerce's AJAX "added" state. */
.lc-card__actions a.added_to_cart {
	min-height: 0;
	margin-top: 4px;
	border: 0;
	background: none;
	color: var(--lc-primary);
	font-size: var(--lc-fs-sm);
	text-decoration: underline;
}

.lc-card__actions a.added_to_cart::before {
	content: none;
}

.lc-card__actions a.button.loading {
	opacity: .7;
}

/* ---- wishlist ---------------------------------------------------------- */

.lc-card__wishlist {
	display: flex;
	justify-content: center;
	margin-top: 10px;
}

.lc-card__wishlist .yith-wcwl-add-to-wishlist {
	margin: 0;
}

/*
 * Shoptimizer's hover-reveal also catches the wishlist link (it computed
 * opacity:0 with a 0px-tall wrapper). Force it visible and in flow.
 */
ul.products li.product .lc-card__wishlist,
ul.products li.product .lc-card__wishlist .yith-wcwl-add-to-wishlist,
ul.products li.product .lc-card__wishlist a {
	height: auto !important;
	opacity: 1 !important;
	visibility: visible !important;
}

ul.products li.product .lc-card__wishlist a {
	display: inline-flex !important;
	position: relative !important;
	align-items: center;
	gap: 8px;
	width: auto !important;
	color: var(--lc-primary) !important;
	font-size: var(--lc-fs-md);
	font-weight: 500;
	text-decoration: none;
}

.lc-card__wishlist a:hover {
	color: var(--lc-primary-dark);
	text-decoration: underline;
}

/*
 * YITH already renders its own heart: <svg class="yith-wcwl-icon-svg"> plus a
 * <span>Add to wishlist</span>, and the SVG uses stroke="currentColor". Style
 * THAT rather than adding a ::before glyph — drawing our own gave two
 * overlapping hearts (playbook gotcha #3).
 */
/*
 * YITH's plugin CSS also paints a heart via a ::before on the link, absolutely
 * positioned — it landed on top of the label as a second, gold heart. The
 * inline <svg> above is the one we keep, so this pseudo-element goes.
 */
ul.products li.product .lc-card__wishlist a::before,
ul.products li.product .lc-card__wishlist a::after {
	display: none !important;
	content: none !important;
}

ul.products li.product .lc-card__wishlist a .yith-wcwl-icon-svg {
	display: block !important;
	width: 20px;
	height: 20px;
	flex: none;
	color: currentColor;
}

ul.products li.product .lc-card__wishlist a span {
	display: inline !important;
	color: inherit;
	font-size: var(--lc-fs-md);
	font-weight: 500;
	white-space: nowrap;
}

/* Feedback text YITH appends after adding. */
.lc-card__wishlist .yith-wcwl-add-to-wishlist .feedback {
	display: none;
}
