/* Better Homes: product card, used everywhere products are listed (category, shop and search pages,
 * "Recently viewed" and "You may also like" on product pages). Markup: template-parts/product-card.php,
 * behaviour: assets/js/product-card.js. Heart icons (--bh-heart-line / --bh-heart-fill): style.css. */

.bh-card,
.bh-card-section {
	--bh-card-ink: #242424;
	--bh-card-muted: #6b6b6b;
	--bh-card-accent: var(--wd-primary-color, #370d1d);
	--bh-card-sale: #c4314b;
}

.bh-card *,
.bh-card *::before,
.bh-card *::after {
	box-sizing: border-box;
}

/* ---------- Grid: 4 per row, 2 on tablets, 1 on phones ---------- */
.bh-card-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 28px 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bh-card-grid > li {
	margin: 0;
	list-style: none;
}

.bh-card-grid > li::before {
	display: none;
}

/* ---------- Card ---------- */
.bh-card {
	position: relative;
	font-family: "Poppins", "Poppins Fallback", Arial, Helvetica, sans-serif;
	color: var(--bh-card-ink);
	display: flex;
	flex-direction: column;
	min-width: 0;
	overflow: hidden;
	border: 1px solid #ececec;
	border-radius: 8px;
	background: #fff;
	cursor: pointer;
	transition: box-shadow .25s ease, transform .25s ease;
	-webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
	.bh-card:hover {
		box-shadow: 0 10px 28px rgba(0, 0, 0, .1);
	}

	.bh-card:hover .bh-card__img {
		transform: scale(1.03);
	}
}

.bh-card.is-new {
	animation: bh-card-fade .4s ease;
}

.bh-card__media {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f6f5f3;
}

.bh-card__media img,
.bh-card .bh-card__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 0;
	transition: transform .4s ease;
}

.bh-card__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	padding: 5px 10px;
	border-radius: 4px;
	background: var(--bh-card-sale);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.2;
}

.bh-card__body {
	position: relative;
	z-index: 1;
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	padding: 16px 16px 16px;
}

.bh-card__title {
	display: -webkit-box;
	min-height: calc(2 * 1.4em);
	margin: 0 0 10px;
	overflow: hidden;
	color: var(--bh-card-ink);
	font-family: inherit;
	font-size: 16px;
	font-weight: 500;
	line-height: 1.4;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.bh-card__title a,
.bh-card__title a:hover {
	color: inherit;
	text-decoration: none;
}

.bh-card__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 2px 8px;
	margin: 0 0 16px;
	line-height: 1.2;
}

.bh-card__from {
	color: var(--bh-card-muted);
	font-size: 14px;
}

.bh-card__now {
	color: var(--bh-card-ink);
	font-size: 20px;
	font-weight: 600;
}

.bh-card__now.is-sale {
	color: var(--bh-card-sale);
}

.bh-card__was {
	color: #8a8a8a;
	font-size: 15px;
	text-decoration: line-through;
}

.bh-card__actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: auto;
}

.bh-card__cta,
.bh-card__wish > a {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 44px;
	padding: 8px 14px;
	overflow: hidden;
	border-radius: 6px;
	font-size: 15px;
	font-weight: 500;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.bh-card__cta,
.bh-card__cta:hover,
.bh-card__cta:focus {
	border: 1px solid var(--btn-accented-bgcolor, var(--bh-card-accent));
	background: var(--btn-accented-bgcolor, var(--bh-card-accent));
	color: var(--btn-accented-color, #fff);
}

@media (hover: hover) {
	.bh-card__cta:hover {
		border-color: var(--btn-accented-bgcolor-hover, var(--btn-accented-bgcolor, var(--bh-card-accent)));
		background: var(--btn-accented-bgcolor-hover, var(--btn-accented-bgcolor, var(--bh-card-accent)));
		color: var(--btn-accented-color-hover, #fff);
	}
}

/* Wishlist: Woodmart's button, restyled. Empty heart, filled once added. */
.bh-card__wish {
	margin: 0;
}

.bh-card__wish > a,
.bh-card__wish > a:hover,
.bh-card__wish > a:focus {
	border: 1px solid #cfcfcf;
	background: #fff;
	color: var(--bh-card-ink);
}

@media (hover: hover) {
	.bh-card__wish > a:hover {
		border-color: var(--bh-card-ink);
	}
}

.bh-card__wish .wd-action-icon {
	display: none;
}

.bh-card__wish > a::before {
	content: "";
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	background: currentColor;
	-webkit-mask: var(--bh-heart-line) center / contain no-repeat;
	mask: var(--bh-heart-line) center / contain no-repeat;
	transition: transform .2s ease;
}

.bh-card__wish > a.added::before {
	background: var(--bh-card-sale);
	-webkit-mask-image: var(--bh-heart-fill);
	mask-image: var(--bh-heart-fill);
	animation: bh-card-heart .35s ease;
}

.bh-card__wish > a.loading {
	opacity: .6;
	pointer-events: none;
}

.bh-card__wish > a.loading::after {
	display: none; /* Woodmart's own spinner */
}

@keyframes bh-card-heart {
	50% {
		transform: scale(1.3);
	}
}

/* ---------- Press effect ("colour goes out" from the tap, as on the option blocks) ---------- */
.bh-card-ripple {
	position: absolute;
	z-index: 3;
	border-radius: 50%;
	background: var(--bh-card-accent);
	opacity: .14;
	pointer-events: none;
	transform: scale(0);
	animation: bh-card-ripple .6s cubic-bezier(.22, .61, .36, 1) forwards;
}

@keyframes bh-card-ripple {
	to {
		opacity: 0;
		transform: scale(1);
	}
}

@keyframes bh-card-fade {
	from {
		opacity: 0;
	}
}

/* ---------- Product page sections: "Recently viewed", "You may also like" ---------- */
.bh-card-section {
	margin: 0 0 48px;
	font-family: "Poppins", "Poppins Fallback", Arial, Helvetica, sans-serif;
}

.bh-card-section__head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 6px 16px;
	margin: 0 0 20px;
}

.bh-card-section__title {
	margin: 0;
	color: var(--bh-card-ink);
	font-size: 24px;
	font-weight: 600;
	line-height: 1.3;
	text-align: start;
	text-transform: none;
}

.bh-card-section__action,
.bh-card-section__action:hover,
.bh-card-section__action:focus {
	min-height: 0;
	margin: 0;
	padding: 4px 0;
	border: 0;
	background: none;
	box-shadow: none;
	color: var(--bh-card-ink);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0;
	text-decoration: underline;
	text-transform: none;
	text-underline-offset: 3px;
	cursor: pointer;
}

/* Recently viewed: filled in by assets/js/recently-viewed.js, shown once it has products. */
.bh-recent[hidden] {
	display: none;
}

.bh-recent.is-in {
	animation: bh-card-fade .35s ease;
}

.bh-recent.is-out {
	opacity: 0;
	transition: opacity .25s ease;
}

/* ---------- Tablet ---------- */
@media (max-width: 1024px) {
	.bh-card-grid {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 22px 16px;
	}
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
	.bh-card-grid {
		grid-template-columns: minmax(0, 1fr);
		gap: 20px;
	}

	.bh-card__title {
		min-height: 0;
		font-size: 17px;
	}

	.bh-card-section {
		margin-bottom: 36px;
	}

	.bh-card-section__title {
		font-size: 21px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bh-card,
	.bh-card *,
	.bh-card-section {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- Out of stock ----------
 * Card: faded a little, "Out of stock" instead of "Find out more" (still opens the product).
 * Product page: the same button takes the place of Add to cart (inc/product-page.php). One muted
 * colour, so it is clearly not a button to buy with. */

.bh-card--oos .bh-card__media img {
	opacity: .85;
}

.bh-card--oos .bh-card__price {
	opacity: .85;
}

.bh-card__cta.bh-card__cta--oos,
.bh-card__cta.bh-card__cta--oos:hover,
.bh-card__cta.bh-card__cta--oos:focus {
	border-color: #e6dee2;
	background: #efe9ec;
	color: #6b5a62;
}

@media (hover: hover) {
	.bh-card__cta.bh-card__cta--oos:hover {
		border-color: #e3d9de;
		background: #e8e0e4;
		color: #574750;
	}
}

.bh-oos-btn,
.single_add_to_cart_button.bh-oos-btn,
.single_add_to_cart_button.bh-oos-btn:hover,
.single_add_to_cart_button.bh-oos-btn.disabled {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: var(--bh-cta-h, 44px);
	margin: 0;
	padding: var(--bh-cta-pad, 8px 14px);
	border: 1px solid #e6dee2;
	border-radius: var(--bh-cta-rad, 6px);
	background: #efe9ec;
	box-shadow: none;
	color: #6b5a62;
	font-family: var(--bh-cta-font, inherit);
	font-size: var(--bh-cta-fs, 15px);
	font-weight: var(--bh-cta-fw, 500);
	line-height: 1.2;
	text-transform: none;
	letter-spacing: normal;
	opacity: 1;
	cursor: not-allowed;
}

/* The button says it: WooCommerce's own "Out of stock" line is not repeated. */
.bh-product-oos .summary p.stock.out-of-stock,
.bh-product-oos .summary .woocommerce-variation-availability {
	display: none;
}
