/*
 * Product card (shop, category and search pages). Owner-approved mockups of 2026-11-11.
 * Equal-height cards (flat on white since 2026-11-14: no shadow, square corners, a hairline border, the photo edge to edge and the text inset 10px), 3:4 photo with a label on it, one-line title, price, then rating and a
 * bare icon button. Display only: WooCommerce's own blocks still do the adding to cart.
 *
 * ICONS: change one by replacing its file in assets/icons/ (same name, single colour, 24 x 24 grid) or by
 * pointing one of these variables at a new file. Colours come from the rules below, not from the files.
 */
:root {
	--mw-icon-cart: url("../icons/cart.svg");
	--mw-icon-options: url("../icons/options.svg");
	--mw-icon-sold-out: url("../icons/cart-sold-out.svg");
	--mw-icon-added: url("../icons/added.svg");
	--mw-icon-star: url("../icons/star.svg");
	--mw-card-icon-size: 24px;
	--mw-card-tap: 36px;
}

/* ---------- Card ---------- */
.wc-block-product-template > li {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	padding: 0;
	background-color: var(--wp--preset--color--base);
	border: 1px solid color-mix(in srgb, var(--wp--preset--color--border-strong) 35%, #fff);
	border-radius: 0;
	box-shadow: none;
}

/* The empty photo (WooCommerce's grey placeholder) takes a warm cream tint until real photos are added. */
.wc-block-product-template > li:has(img.woocommerce-placeholder) .wc-block-components-product-image a {
	background-color: color-mix(in srgb, var(--wp--preset--color--secondary) 9%, #fff);
}

.wc-block-product-template > li img.woocommerce-placeholder {
	mix-blend-mode: multiply;
}

.wc-block-product-template > li .wc-block-components-product-image {
	position: relative;
	margin: 0;
}

.wc-block-product-template > li .wc-block-components-product-image a {
	position: relative;
	display: block;
}

.wc-block-product-template > li .wc-block-components-product-image img {
	display: block;
	width: 100%;
	object-position: center top;
}

/* WooCommerce's empty badge container would add height under the photo (badges are our own labels). */
.wc-block-product-template > li .wc-block-components-product-image__inner-container {
	display: none;
}

/* Second photo on hover (desktop mice only). */
.wc-block-product-template > li .wc-block-components-product-image img.mw-card__hover {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center top;
	opacity: 0;
	transition: opacity 0.25s ease;
	pointer-events: none;
}

@media (hover: hover) {
	.wc-block-product-template > li:hover .wc-block-components-product-image img.mw-card__hover {
		opacity: 1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mw-card__hover {
		transition: none;
	}
}

/* Labels on the photo: one at the top-left, the product type at the bottom-left. */
.mw-card__label,
.mw-card__type {
	position: absolute;
	left: 0;
	z-index: 2;
	color: var(--wp--preset--color--contrast);
	font-size: 0.6875rem;
	font-weight: 500;
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
	pointer-events: none;
}

.mw-card__label {
	top: 0;
	padding: 7px 18px 7px 10px;
	background-color: rgb(255 255 255 / 0.8);
	clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

.mw-card__label--sale {
	background-color: var(--wp--preset--color--primary);
	color: #fff;
}

.mw-card__label--sold-out {
	background-color: var(--wp--preset--color--text-muted);
	color: #fff;
}

.mw-card__label--exclusive,
.mw-card__label--new {
	box-shadow: inset 3px 0 0 var(--wp--preset--color--secondary);
}

.mw-card__type {
	bottom: 10px;
	padding: 4px 14px 4px 8px;
	background-color: rgb(255 255 255 / 0.8);
	clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 100%, 0 100%);
}

/* ---------- Text ---------- */
.wc-block-product-template > li .wp-block-post-title {
	margin: 10px 0 2px;
	padding-inline: 10px;
	overflow: hidden;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	text-align: start;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wc-block-product-template > li .wp-block-post-title a {
	display: block;
	overflow: hidden;
	text-decoration: none;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.wc-block-product-template > li .wp-block-woocommerce-product-price,
.wc-block-product-template > li .wc-block-components-product-price {
	margin: 0;
	text-align: start;
}

.wc-block-product-template > li .wp-block-woocommerce-product-price {
	padding-inline: 10px;
}

.wc-block-product-template > li .wc-block-components-product-price {
	min-height: 1.5em;
	font-size: var(--wp--preset--font-size--small);
}

/* ---------- Action row: rating on the left, icon button on the right ---------- */
.wc-block-product-template > li .mw-card__act {
	box-sizing: border-box;
	align-items: center;
	margin: auto 0 0;
	padding: 6px 10px 10px;
	min-height: calc(var(--mw-card-tap) + 16px);
	gap: 8px;
}

.mw-card__rate {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 0.75rem;
	white-space: nowrap;
}

.mw-card__star {
	width: 14px;
	height: 14px;
	background-color: var(--wp--preset--color--secondary);
	-webkit-mask: var(--mw-icon-star) center / contain no-repeat;
	mask: var(--mw-icon-star) center / contain no-repeat;
}

.mw-card__rate-count {
	color: var(--wp--preset--color--text-muted);
}

/* The button wrapper always sits at the right end. */
.mw-card__act .wp-block-woocommerce-product-button,
.mw-card__act .mw-card__soldout {
	margin-inline-start: auto;
}

/* ---------- Icon button (no background, no border) ---------- */
.mw-card__act .wc-block-components-product-button {
	margin: 0;
	margin-inline-start: auto;
}

.mw-card__act .wc-block-components-product-button__button,
.mw-card__soldout {
	position: relative;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mw-card-tap);
	min-width: var(--mw-card-tap);
	height: var(--mw-card-tap);
	min-height: var(--mw-card-tap);
	margin: 0;
	padding: 0;
	background: none;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: var(--wp--preset--color--contrast);
	font-size: 0;
	line-height: 0;
	text-decoration: none;
	cursor: pointer;
}

.mw-card__act .wc-block-components-product-button__button::before,
.mw-card__soldout::before {
	content: "";
	display: block;
	width: var(--mw-card-icon-size);
	height: var(--mw-card-icon-size);
	background-color: currentColor;
	-webkit-mask: var(--mw-icon-options) center / contain no-repeat;
	mask: var(--mw-icon-options) center / contain no-repeat;
}

/* The label is hidden visually; the button keeps its aria-label ("Add to cart: product name"). */
.mw-card__act .wc-block-components-product-button__button > span {
	display: none;
}

/* Simple product in stock: shopping cart, drawn like the wishlist heart (charcoal line, same thickness and size). */
.mw-card__act .wc-block-components-product-button__button.add_to_cart_button::before {
	-webkit-mask-image: var(--mw-icon-cart);
	mask-image: var(--mw-icon-cart);
}

/* Variable, grouped and external products: choose options (charcoal). */
.mw-card__act .wc-block-components-product-button__button:not(.add_to_cart_button) {
	color: var(--wp--preset--color--contrast);
}

/* Added: green tick. WooCommerce reveals its "View cart" link after adding (span after the button); that is the cue. */
.mw-card__act .wc-block-components-product-button:has(> button + span:not([hidden])) .wc-block-components-product-button__button {
	color: var(--wp--preset--color--success);
}

.mw-card__act .wc-block-components-product-button:has(> button + span:not([hidden])) .wc-block-components-product-button__button::before {
	-webkit-mask-image: var(--mw-icon-added);
	mask-image: var(--mw-icon-added);
}

.mw-card__act .wc-block-components-product-button__button.loading {
	opacity: 0.5;
}

/* WooCommerce adds a "View cart" link after adding; the mini cart drawer already shows it. */
.wc-block-product-template .mw-card__act .wc-block-components-product-button .added_to_cart,
.wc-block-product-template .mw-card__act .wc-block-components-product-button > span {
	display: none;
}

/* Sold out: grey, not interactive. */
.mw-card__soldout {
	color: #8c8681;
	cursor: default;
}

.mw-card__soldout::before {
	-webkit-mask-image: var(--mw-icon-sold-out);
	mask-image: var(--mw-icon-sold-out);
}

.mw-card__act .wc-block-components-product-button__button:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 0;
	border-radius: 4px;
}

/* Hover label (mouse only) so an icon on its own is never a mystery. */
@media (hover: hover) {
	.mw-card__act .wc-block-components-product-button__button::after,
	.mw-card__soldout::after {
		content: "Choose options";
		position: absolute;
		right: 0;
		bottom: calc(100% + 4px);
		padding: 4px 8px;
		background-color: var(--wp--preset--color--contrast);
		border-radius: 3px;
		color: #fff;
		font-size: 0.75rem;
		line-height: 1.2;
		white-space: nowrap;
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.15s ease;
		z-index: 3;
	}

	.mw-card__act .wc-block-components-product-button__button.add_to_cart_button::after {
		content: "Add to cart";
	}

	.mw-card__act .wc-block-components-product-button:has(> button + span:not([hidden])) .wc-block-components-product-button__button::after {
		content: "Added";
	}

	.mw-card__soldout::after {
		content: "Sold out";
	}

	.mw-card__act .wc-block-components-product-button__button:hover::after,
	.mw-card__act .wc-block-components-product-button__button:focus-visible::after,
	.mw-card__soldout:hover::after {
		opacity: 1;
	}
}

/* ---------- Phones ---------- */
@media (max-width: 767px) {
	:root {
		--mw-card-tap: 34px;
	}

	.wc-block-product-template > li .wp-block-post-title {
		font-size: 0.8125rem;
	}
}

/* ---------- Load More ---------- */
.mw-load-more-wrap {
	display: flex;
	justify-content: center;
	margin-block: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
}

.mw-load-more {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 160px;
	min-height: 40px;
	padding: 0 24px;
	background-color: var(--wp--preset--color--base);
	border: 2px solid var(--wp--preset--color--secondary);
	border-radius: 999px;
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
}

.mw-load-more:hover,
.mw-load-more:focus-visible {
	background-color: var(--wp--preset--color--surface);
}

.mw-load-more:focus-visible {
	outline: 2px solid var(--wp--preset--color--contrast);
	outline-offset: 2px;
}


/* ---------- "New in store" row on the empty Cart page ----------
   The cards are printed by mw_card_new_in_store() with the same markup as the shop card, so everything above
   applies. Only the grid is set here (the shop's grid rules are for Product Collection blocks and skip the cart):
   2 columns up to 767px, 3 from 768px, 4 from 1024px, with the shop's gap. */
.mw-new__list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: clamp(0.75rem, 0.35rem + 1.7vw, 2rem);
	margin: 0;
	padding: 0;
	list-style: none;
}

@media (min-width: 768px) {
	.mw-new__list {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.mw-new__list {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

.mw-new__list > li {
	min-width: 0;
	margin: 0;
	overflow-wrap: break-word;
}

/* In the shop, WordPress adds flex-layout classes to this row; the row is printed by PHP here, so it is set explicitly. */
.mw-new__list .mw-card__act {
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
}

/* Added from the New in store row (script-made, since no product form is involved). */
.mw-card__act .wc-block-components-product-button__button.add_to_cart_button.mw-added {
	color: var(--wp--preset--color--success);
}

.mw-card__act .wc-block-components-product-button__button.add_to_cart_button.mw-added::before {
	-webkit-mask-image: var(--mw-icon-added);
	mask-image: var(--mw-icon-added);
}
