/* =============================================================
 * HalalEco Loop Cart
 * Everything is scoped under .hlc-* or under the WooCommerce
 * product-loop item, so nothing else on the site is affected.
 * ============================================================= */

:root {
	--hlc-accent: #4b8b1f;
	--hlc-accent-dark: #3d7419;
	--hlc-accent-soft: #e8f0e0;
	--hlc-border: #e4e4e4;
	--hlc-ink: #1f2320;
	--hlc-muted: #4a4f4b;
}

/* -------------------------------------------------------------
 * 1 + 2. Suppress the theme's own title / price / add-to-cart
 * inside the loop card. We re-render them in .hlc-foot.
 * ----------------------------------------------------------- */
.woocommerce ul.products li.product .hlc-foot ~ .button,
ul.products li.product > .product-content > h2.product_title,
ul.products li.product > .product-content > .woocommerce-loop-product__title,
ul.products li.product > .product-content > .price,
ul.products li.product > h2.woocommerce-loop-product__title,
ul.products li.product > .price,
ul.products li.product > .product-content > a.button,
ul.products li.product > a.button,
ul.products li.product .add_to_cart_button,
ul.products li.product .added_to_cart,
ul.products li.product .hqs {          /* legacy halaleco-qty-stepper markup */
	display: none !important;
}

/* -------------------------------------------------------------
 * 2. Card footer: one flex row under the image
 * ----------------------------------------------------------- */
.hlc-foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px 14px;
	text-align: left;
	box-sizing: border-box;
}

.hlc-foot__info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;          /* lets long titles ellipsize instead of pushing the button */
	flex: 1 1 auto;
}

.hlc-foot__title {
	font-size: 15px;
	line-height: 1.35;
	font-weight: 500;
	color: var(--hlc-ink);
	text-decoration: none;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.hlc-foot__title:hover,
.hlc-foot__title:focus-visible { color: var(--hlc-accent); }

.hlc-foot__price {
	font-size: 15px;
	font-weight: 600;
	color: var(--hlc-muted);
	line-height: 1.35;
}
.hlc-foot__price del { opacity: .55; font-weight: 400; margin-right: 4px; }
.hlc-foot__price ins { text-decoration: none; color: var(--hlc-accent); }

/* -------------------------------------------------------------
 * 2. Circular cart button (44x44, 1px light grey, white bg)
 * ----------------------------------------------------------- */
.hlc-cartwrap {
	position: relative;
	flex: 0 0 auto;
	line-height: 0;
}

.hlc-cart {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	margin: 0;
	border: 1px solid var(--hlc-border);
	border-radius: 50%;
	background: #fff;
	color: var(--hlc-ink);
	cursor: pointer;
	box-shadow: none;
	transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .12s ease;
	-webkit-appearance: none;
	appearance: none;
}
.hlc-cart:hover { border-color: #cfcfcf; }
.hlc-cart:active { transform: scale(.94); }
.hlc-cart:focus-visible {
	outline: 2px solid var(--hlc-accent);
	outline-offset: 2px;
}

/* 4. In cart -> filled with the accent colour */
.hlc-cart.is-active,
.hlc-cartwrap.is-active .hlc-cart {
	background: var(--hlc-accent);
	border-color: var(--hlc-accent);
	color: #fff;
}

/* 4. Count badge, top-right of the icon */
.hlc-badge {
	position: absolute;
	top: -5px;
	right: -5px;
	min-width: 21px;
	height: 21px;
	padding: 0 5px;
	box-sizing: border-box;
	display: none;
	align-items: center;
	justify-content: center;
	border-radius: 999px;
	border: 2px solid #fff;
	background: var(--hlc-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	font-family: inherit;
	pointer-events: none;
}
.hlc-cartwrap.is-active .hlc-badge { display: inline-flex; }

/* -------------------------------------------------------------
 * 3. Hover popup — rounded pill directly above the icon.
 * The offset is PADDING on .hlc-pop, not margin, so the pointer
 * never leaves the hover container on the way up.
 * ----------------------------------------------------------- */
.hlc-pop {
	position: absolute;
	right: -2px;
	bottom: 100%;
	padding-bottom: 8px;   /* invisible hover bridge */
	z-index: 30;
	opacity: 0;
	visibility: hidden;
	transform: translateY(5px);
	transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
	pointer-events: none;
	line-height: 0;
}

.hlc-pop__inner {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 5px;
	border-radius: 999px;
	background: #fff;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .16), 0 1px 3px rgba(0, 0, 0, .08);
	white-space: nowrap;
}

.hlc-cartwrap.is-open .hlc-pop {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
	transition-delay: 0s;
}

/* Pointer devices: plain CSS hover, no JS needed */
@media (hover: hover) and (pointer: fine) {
	.hlc-cartwrap:not(.hlc-cartwrap--link):hover .hlc-pop {
		opacity: 1;
		visibility: visible;
		transform: translateY(0);
		pointer-events: auto;
		transition-delay: 0s;
	}
}

/* − and + buttons inside the pill */
.hlc-step {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color .15s ease, opacity .15s ease, transform .1s ease;
	-webkit-appearance: none;
	appearance: none;
}
.hlc-step:active { transform: scale(.9); }
.hlc-step:focus-visible { outline: 2px solid var(--hlc-accent); outline-offset: 2px; }

.hlc-step--minus { background: var(--hlc-accent-soft); color: var(--hlc-accent); }
.hlc-step--minus:hover { background: #dbe7cf; }

.hlc-step--plus { background: var(--hlc-accent); color: #fff; }
.hlc-step--plus:hover { background: var(--hlc-accent-dark); }

.hlc-step[disabled],
.hlc-step[aria-disabled="true"] { opacity: .4; cursor: default; pointer-events: none; }

.hlc-qty {
	min-width: 22px;
	text-align: center;
	font-size: 16px;
	font-weight: 600;
	line-height: 1;
	color: var(--hlc-ink);
	font-variant-numeric: tabular-nums;
	user-select: none;
}

/* Busy state while a request is in flight */
.hlc-cartwrap.is-busy .hlc-pop__inner { opacity: .75; }

/* -------------------------------------------------------------
 * 7. Touch devices — no hover, JS toggles .is-open on tap
 * ----------------------------------------------------------- */
@media (hover: none) {
	.hlc-pop__inner { padding: 6px; gap: 12px; }
	.hlc-step { width: 38px; height: 38px; }
}

@media (max-width: 480px) {
	.hlc-foot { padding: 10px 10px 12px; gap: 8px; }
	.hlc-foot__title { font-size: 14px; }
	.hlc-foot__price { font-size: 14px; }
}

/* Make sure the popup is never clipped by the card or the grid */
.woocommerce ul.products li.product,
ul.products li.product,
ul.products li.product .product-content { overflow: visible; }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
	.hlc-pop, .hlc-cart, .hlc-step { transition: none !important; }
}

/* Screen-reader-only announcer (WooCommerce ships this class, redeclared for safety) */
.hlc-cartwrap .screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0);
	white-space: nowrap; border: 0;
}
