/**
 * WPS Cart — the block Cart page: row layout and the place of the promo code.
 *
 * Loaded only on the block Cart page. Scoped by the body classes
 * wps-cart-layout-<stacked|columns> and wps-cart-coupon-<totals|items>.
 * No colour of its own.
 */

/* --- Layout "columns": remove | image | product | price | quantity | total.
   Only when WooCommerce lays the cart out wide (.is-large); a narrow cart
   keeps the stacked rows. The product cell and its wrappers become
   display: contents, so their children sit in the row grid. The side
   columns span many zero-height rows (row gap 0): the name, the details
   and anything a plugin adds stack in the product column, while the price,
   the quantity, the remove button and the total stay centred beside them. */
body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items {
	display: block;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items :is(thead, tbody) {
	display: block;
}

body.wps-cart-layout-columns .wc-block-cart.is-large :is(.wc-block-cart-items__header, .wc-block-cart-items__row) {
	display: grid;
	grid-template-columns: 2.5em 80px minmax(0, 1fr) minmax(7em, auto) minmax(7.5em, auto) minmax(6em, auto);
	column-gap: calc(var(--wps-space-base, 4px) * 4);
	row-gap: 0;
	align-items: center;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__row {
	padding-block: calc(var(--wps-space-base, 4px) * 4);
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__row > td {
	padding: 0;
	border: 0;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__row + .wc-block-cart-items__row {
	border-block-start: 1px solid var(--wpscart-border, currentColor);
}

body.wps-cart-layout-columns .wc-block-cart.is-large :is(.wc-block-cart-item__product, .wc-block-cart-item__wrap, .wc-block-cart-item__quantity) {
	display: contents;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-item__wrap > * {
	grid-column: 3;
	margin: 0;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-item__image {
	grid-column: 2;
	grid-row: 1 / span 12;
	align-self: center;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-item__remove-link {
	grid-column: 1;
	grid-row: 1 / span 12;
	align-self: center;
	justify-self: center;
	margin: 0;
	color: var(--wps-error, currentColor);
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-item__wrap > .wc-block-cart-item__prices {
	grid-column: 4;
	grid-row: 1 / span 12;
	align-self: center;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 0;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-components-quantity-selector {
	grid-column: 5;
	grid-row: 1 / span 12;
	align-self: center;
	justify-self: center;
	margin: 0;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-item__total {
	grid-column: 6;
	grid-row: 1 / span 12;
	align-self: center;
	text-align: end;
}

/* The header: "Product" over the name, two generated captions for the price
   and the quantity (texts from the inline style), "Total" over the total. */
body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header > th {
	padding: 0;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header-image {
	grid-column: 3;
	grid-row: 1;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header-product {
	display: contents;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header-product::before {
	content: var(--wpscart-head-price);
	grid-column: 4;
	grid-row: 1;
	text-align: end;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header-product::after {
	content: var(--wpscart-head-qty);
	grid-column: 5;
	grid-row: 1;
	text-align: center;
}

body.wps-cart-layout-columns .wc-block-cart.is-large .wc-block-cart-items__header-total {
	grid-column: 6;
	grid-row: 1;
	text-align: end;
}

/* --- Promo code under the products: the native form in the totals is out;
   cart-coupon.js adds the same panel after the product rows. */
body.wps-cart-coupon-items .wp-block-woocommerce-cart .wp-block-woocommerce-cart-order-summary-coupon-form-block {
	display: none;
}

body.wps-cart-coupon-items .wps-cart-coupon {
	margin-block-start: calc(var(--wps-space-base, 4px) * 4);
}

.wps-cart-coupon__msg {
	margin: calc(var(--wps-space-base, 4px) * 2) 0 0;
	font-size: var(--wps-text-sm, 0.875rem);
}

.wps-cart-coupon__msg[data-state="error"] {
	color: var(--wps-error, #b32d2e);
}

.wps-cart-coupon__msg[data-state="ok"] {
	color: var(--wps-success, #1a7f37);
}

/* The chevron of the panel under the products, as on the native panel. */
.wps-cart-coupon .wc-block-components-panel__button::after {
	content: "";
	inline-size: 0.5em;
	block-size: 0.5em;
	margin-inline-start: auto;
	border-inline-end: 2px solid currentColor;
	border-block-end: 2px solid currentColor;
	transform: translateY(-25%) rotate(45deg);
	opacity: 0.6;
}

.wps-cart-coupon .wc-block-components-panel__button[aria-expanded="true"]::after {
	transform: translateY(25%) rotate(-135deg);
}
