/**
 * Product lists in the shop: the compact rows (shop, category, product search) and the featured
 * product band on the shop page.
 *
 * @package DeWittePrins\Theme
 * @since   0.1.0
 */

/* Compact list: rows between hairlines, no photos. */
.shop-list {
	margin-block-start: var(--wp--preset--spacing--50);
}

.shop-list .wc-block-product-template {
	display: block;
	margin: 0;
	padding: 0;
	border-block-start: 1px solid var(--wp--custom--color--line);
	list-style: none;
}

.shop-list .wc-block-product-template > li {
	margin: 0;
	padding: 0;
	border-block-end: 1px solid var(--wp--custom--color--line);
	text-align: start;
}

.product-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: center;
	gap: var(--wp--preset--spacing--30) var(--wp--preset--spacing--50);
	padding-block: var(--wp--preset--spacing--40);
}

.product-row > *,
.product-row__text > *,
.product-row__buy > * {
	margin: 0;
}

.product-row .product-row__title {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	line-height: 1.35;
}

.product-row .product-row__title a {
	color: var(--wp--custom--color--heading);
	text-decoration: none;
}

.product-row .product-row__title a:hover,
.product-row .product-row__title a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.product-row .product-row__summary {
	margin-block-start: 0.25rem;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

.product-row .product-row__summary .wp-block-post-excerpt__excerpt {
	margin: 0;
}

.product-row__buy {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: var(--wp--preset--spacing--20) var(--wp--preset--spacing--40);
}

.product-row .product-row__price {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 700;
	text-align: end;
	white-space: nowrap;
}

.product-row .product-row__button {
	margin: 0;
}

.product-row .product-row__button .wp-block-button__link {
	min-inline-size: 10rem;
	min-block-size: 2.75rem;
	padding-block: 0.5rem;
	font-size: var(--wp--preset--font-size--small);
}

/* The "View cart" link WooCommerce adds after a successful click, as a small link under the button. */
.product-row .added_to_cart {
	display: block;
	margin-block-start: 0.25rem;
	font-size: var(--wp--preset--font-size--x-small);
	text-align: center;
}

.shop-list__empty {
	padding-block: var(--wp--preset--spacing--50);
	color: var(--wp--preset--color--muted);
}

/* Phone: text first, then price and button on one line. */
@media (max-width: 47.99rem) {
	.product-row {
		grid-template-columns: minmax(0, 1fr);
	}

	.product-row__buy {
		justify-content: space-between;
	}

	.product-row .product-row__button .wp-block-button__link {
		min-inline-size: 9rem;
	}
}

/* Heading above the full list on the shop page. */
.shop-main .shop-all__heading {
	margin-block-start: var(--wp--preset--spacing--70);
}

/*
 * Featured product: a wide tint plane with the image beside the text from 48rem, the image on top
 * on a phone. Empty when no product is featured, so the collection takes no space then.
 */
.shop-featured {
	margin-block-start: var(--wp--preset--spacing--60);
}

.shop-featured .wc-block-product-template {
	display: block;
	margin: 0;
	padding: 0;
	list-style: none;
}

.shop-featured .wc-block-product-template > li {
	margin: 0;
	text-align: start;
}

.shop-featured__item {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	overflow: hidden;
	overflow-wrap: break-word;
	border: 1px solid var(--wp--custom--color--rim);
	border-radius: var(--wp--preset--border-radius--large);
	background: var(--wp--preset--color--tint);
}

.shop-featured__item > * {
	margin: 0;
}

.shop-featured .shop-featured__image {
	margin: 0;
}

.shop-featured .shop-featured__image img {
	display: block;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	border-radius: 0;
}

.shop-featured__text {
	padding: var(--wp--preset--spacing--50);
}

.shop-featured__text > * {
	margin-block: 0;
}

.shop-featured__text > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

.shop-featured .shop-featured__title {
	font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
	font-weight: 360;
	line-height: 1.2;
}

.shop-featured .shop-featured__title a {
	color: var(--wp--custom--color--heading);
	text-decoration: none;
}

.shop-featured .shop-featured__summary {
	font-size: var(--wp--preset--font-size--large);
}

.shop-featured .shop-featured__summary .wp-block-post-excerpt__excerpt {
	margin: 0;
}

.shop-featured .shop-featured__price {
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
}

.shop-featured .shop-featured__button {
	margin-block-start: var(--wp--preset--spacing--40);
}

@media (min-width: 48rem) {
	.shop-featured__item {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
		align-items: center;
	}

	/*
	 * Side by side the image fills the whole left half of the band, top to bottom, instead of a 3:2
	 * picture centred beside a taller text. Placed absolutely, so the inline aspect ratio WooCommerce
	 * puts on the img no longer decides the height; the text decides it, with a floor for short texts.
	 */
	.shop-featured .shop-featured__image {
		position: relative;
		align-self: stretch;
		min-block-size: 18rem;
	}

	.shop-featured .shop-featured__image > a,
	.shop-featured .shop-featured__image img {
		position: absolute;
		inset: 0;
	}

	.shop-featured__text {
		padding: var(--wp--preset--spacing--60);
	}
}

/*
 * WooCommerce puts a notices box as the first child of each product (for "added to cart" and
 * errors). It spans the whole row and takes no room while empty.
 */
.product-row > .wc-block-components-notices,
.shop-featured__item > .wc-block-components-notices {
	grid-column: 1 / -1;
}

.product-row > .wc-block-components-notices:empty,
.shop-featured__item > .wc-block-components-notices:empty {
	display: none;
}

/*
 * Product buttons in lists: WooCommerce removes the border, which leaves the open theme button
 * without its rim. Restored here; the featured band uses the solid button, its one main action.
 */
.wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button {
	border: 1px solid var(--wp--custom--color--rim);
	border-radius: var(--wp--preset--border-radius--medium);
	font-weight: 700;
}

.wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button:hover,
.wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button:focus-visible {
	border-color: var(--wp--preset--color--accent);
	background: var(--wp--preset--color--accent);
	color: var(--wp--custom--color--on-accent);
}

.shop-featured .wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button {
	border-color: var(--wp--preset--color--accent);
	background: var(--wp--preset--color--accent);
	color: var(--wp--custom--color--on-accent);
}

/* Related products: three quiet cards under a product page; one column on a phone. */
.product-related {
	margin-block-start: var(--wp--preset--spacing--80);
	padding-block-start: var(--wp--preset--spacing--60);
	border-block-start: 1px solid var(--wp--custom--color--line);
}

.product-related .product-related__list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
	gap: var(--wp--preset--spacing--40);
	margin: var(--wp--preset--spacing--40) 0 0;
	padding: 0;
	list-style: none;
}

.product-related .product-related__list > li {
	display: flex;
	margin: 0;
	text-align: start;
}

.product-card {
	position: relative;
	box-sizing: border-box;
	inline-size: 100%;
	padding: var(--wp--preset--spacing--40);
	border: 1px solid var(--wp--custom--color--line);
	border-radius: var(--wp--preset--border-radius--large);
	background: var(--wp--preset--color--surface);
}

.product-card > * {
	margin: 0;
}

.product-card .product-card__title {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	line-height: 1.35;
}

.product-card .product-card__title a {
	color: var(--wp--custom--color--heading);
	text-decoration: none;
}

.product-card .product-card__title a::after {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	content: "";
}

.product-card:has(a:focus-visible) {
	outline: 3px solid var(--wp--custom--color--ring);
	outline-offset: 2px;
}

.product-card .product-card__title a:focus-visible {
	outline: none;
}

.product-card .product-card__price {
	margin-block-start: var(--wp--preset--spacing--20);
	font-weight: 700;
}

.product-card > .wc-block-components-notices:empty {
	display: none;
}
