/**
 * Rachel Mizrahi — WooCommerce CART page.
 *
 * Loads after brand.css (which carries the shared tokens + a base "f. Cart page"
 * pass). This file only adds the sketch LAYOUT on top: line-item cards, a sticky
 * summary sidebar, quantity steppers, a prominent checkout button, a full-width
 * recommended-products row, and the warm empty-cart state. Pairs with
 * inc/woo-cart.php (hook re-arrangement).
 *
 * Everything is scoped to body.woocommerce-cart (WooCommerce's native cart body
 * class) so nothing leaks onto other Woo surfaces. Colours/fonts come from the
 * brand tokens in brand.css (:root) — no new palette is introduced, no dark
 * backgrounds. Direction-sensitive rules use logical properties so the layout
 * holds in RTL (Hebrew) and any future LTR locale. Motion is limited to
 * transform/opacity and disabled under prefers-reduced-motion.
 *
 * CONTENTS
 *   1. Page shell — two-column grid (items + sticky summary), full-width bands
 *   2. Line-item cards (the responsive cart table, reflowed)
 *   3. Quantity steppers
 *   4. Coupon / update-cart actions row
 *   5. Sticky summary sidebar + prominent checkout button
 *   6. Recommended products (full-width cross-sells)
 *   7. Empty-cart state
 *   8. Responsive: stack summary below the items
 *   9. Reduced motion
 */

/* ==========================================================================
   1. Page shell — two-column grid
   ==========================================================================
   div.woocommerce is the shortcode wrapper holding [notices] + the cart form +
   .cart-collaterals + (relocated) .cross-sells. :has() keeps the grid off the
   empty-cart branch, which has no form. */

.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
	grid-auto-flow: dense;
	gap: clamp(28px, 4vw, 56px);
	align-items: start;
}

/* Full-width bands: notices at the top, recommended products at the bottom. */
.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > .woocommerce-notices-wrapper,
.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > .cross-sells {
	grid-column: 1 / -1;
	margin: 0;
}

/* Item list = main column; summary = side column. */
.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > form.woocommerce-cart-form {
	grid-column: 1;
	margin: 0;
}

.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > .cart-collaterals {
	grid-column: 2;
	width: 100%;
	margin: 0;
}

/* Neutralise WooCommerce's default float/50% width on the collaterals. */
.woocommerce-cart .cart-collaterals,
.woocommerce-cart .cart-collaterals .cart_totals,
.woocommerce-cart .cart-collaterals .cross-sells {
	float: none;
	width: 100%;
}

/* ==========================================================================
   2. Line-item cards
   ==========================================================================
   Reflow the responsive cart table into airy, borderless cards — no template
   override. The table/tbody go block; the header row is hidden (labels live in
   the markup + aria); each cart_item row becomes a small grid. */

.woocommerce-cart .woocommerce-cart-form table.cart,
.woocommerce-cart .woocommerce-cart-form table.cart tbody {
	display: block;
	width: 100%;
	border: none;
}

.woocommerce-cart .woocommerce-cart-form table.cart thead {
	display: none;
}

/* Suppress the responsive-mode data-title labels (td::before) inside cards. */
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td::before {
	display: none !important;
	content: none !important;
}

/* The card. */
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item {
	display: grid;
	grid-template-columns: 96px minmax(0, 1fr) auto;
	grid-template-areas:
		"thumb name     remove"
		"thumb price    price"
		"thumb quantity subtotal";
	column-gap: clamp(14px, 2vw, 24px);
	row-gap: 8px;
	align-items: center;
	padding-block: clamp(18px, 3vw, 26px);
	border: none;
	border-block-end: 1px solid var(--rm-border-soft);
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item:first-child {
	border-block-start: 1px solid var(--rm-border-mid);
}

/* Cells lose the table padding/borders; each maps to a grid area. */
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td {
	display: block;
	padding: 0;
	border: none;
	background: transparent;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-thumbnail {
	grid-area: thumb;
	align-self: start;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name {
	grid-area: name;
	align-self: start;
	font-size: 1.02rem;
	line-height: 1.5;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-remove {
	grid-area: remove;
	justify-self: end;
	align-self: start;
	text-align: end;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-price {
	grid-area: price;
	align-self: start;
	font-size: 0.92rem;
	color: var(--rm-charcoal);
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-quantity {
	grid-area: quantity;
	justify-self: start;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-subtotal {
	grid-area: subtotal;
	justify-self: end;
	text-align: end;
	font-family: var(--rm-font-serif);
	font-size: 1.1rem;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-subtotal .amount {
	color: var(--rm-espresso);
	font-weight: 500;
}

/* Thumbnail: light frame in cream-warm. */
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-thumbnail img {
	width: 96px;
	height: auto;
	display: block;
	padding: 6px;
	background: var(--rm-cream-warm);
	border: 1px solid var(--rm-border-soft);
	border-radius: var(--rm-radius);
}

/* Product name (serif) inherits brand.css; variant meta reads quiet + small. */
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name > a {
	font-family: var(--rm-font-serif);
	font-size: 1.08rem;
	color: var(--rm-espresso);
	text-decoration: none;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name .variation,
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name dl.variation {
	margin-block: 6px 0;
	font-size: 0.82rem;
	color: var(--rm-charcoal);
	line-height: 1.5;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name dl.variation dt,
.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name dl.variation dd {
	display: inline;
	margin: 0;
	font-weight: 400;
}

.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-name dl.variation dd p {
	display: inline;
	margin: 0;
}

/* Quiet remove (×): small taupe glyph, grows to espresso on hover. */
.woocommerce-cart a.remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	font-size: 1.15rem;
	line-height: 1;
	color: var(--rm-charcoal) !important;
	background: transparent !important;
	border-radius: 50%;
	text-decoration: none;
	transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s var(--rm-ease);
}

.woocommerce-cart a.remove:hover,
.woocommerce-cart a.remove:focus-visible {
	color: var(--rm-espresso) !important;
	background: var(--rm-cream-warm) !important;
	transform: scale(1.08);
}

/* ==========================================================================
   3. Quantity steppers (rm-qty-btn injected by inc/woo-cart.php)
   ========================================================================== */

.woocommerce-cart .product-quantity .quantity {
	display: inline-flex;
	align-items: stretch;
	gap: 0;
	padding: 0;
	border: 1px solid var(--rm-border-mid);
	border-radius: 999px;
	background: transparent;
	overflow: hidden;
}

.woocommerce-cart .product-quantity .quantity .qty {
	width: 46px;
	min-height: 40px;
	padding: 0;
	border: none;
	background: transparent;
	text-align: center;
	color: var(--rm-espresso);
	font-family: var(--rm-font-body);
	font-size: 0.98rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	-moz-appearance: textfield;
	appearance: textfield;
}

.woocommerce-cart .product-quantity .quantity .qty:focus {
	outline: none;
	box-shadow: none;
	border: none;
}

.woocommerce-cart .product-quantity .quantity .qty::-webkit-outer-spin-button,
.woocommerce-cart .product-quantity .quantity .qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.woocommerce-cart .rm-qty-btn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: none;
	border-radius: 0;
	background: transparent;
	color: var(--rm-espresso);
	font-family: var(--rm-font-body);
	font-size: 1.2rem;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.woocommerce-cart .rm-qty-btn:hover {
	background: var(--rm-cream-warm);
	color: var(--rm-taupe);
}

/* Live-update busy state — cart.js toggles .rm-cart-updating on div.woocommerce
   while it POSTs the form and swaps the totals/table in place (no reload). */
.woocommerce-cart .woocommerce.rm-cart-updating {
	position: relative;
}

.woocommerce-cart .woocommerce.rm-cart-updating > form.woocommerce-cart-form,
.woocommerce-cart .woocommerce.rm-cart-updating > .cart-collaterals {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

/* ==========================================================================
   4. Coupon / update-cart actions row
   ========================================================================== */

.woocommerce-cart .woocommerce-cart-form table.cart tr:has(td.actions) {
	display: block;
}

.woocommerce-cart .woocommerce-cart-form td.actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-start;
	gap: 16px;
	padding: 22px 0 4px;
	border: none;
}

.woocommerce-cart .woocommerce-cart-form td.actions .coupon {
	display: flex;
	align-items: center;
	gap: 10px;
	flex: 1 1 240px;
	max-width: 420px;
}

.woocommerce-cart .woocommerce-cart-form td.actions .coupon .input-text {
	flex: 1 1 auto;
	min-height: 44px;
	margin-inline-end: 0;
}

.woocommerce-cart .woocommerce-cart-form td.actions .coupon .button {
	flex: none;
	min-height: 44px;
}

/* The cart auto-updates when a quantity changes (cart.js programmatically
   clicks this button), so the visible "עדכן עגלה / Update cart" control is
   redundant and confusing — hide it. IMPORTANT: display:none only, never remove
   from the DOM: cart.js still calls .click() on it to trigger the auto-update,
   and a display:none button is still clickable programmatically. With it gone,
   the actions row is just the coupon field + apply, aligned to the inline-start. */
.woocommerce-cart button[name="update_cart"] {
	display: none !important;
}

/* ==========================================================================
   5. Sticky summary sidebar
   ==========================================================================
   The base cream-warm tile styling comes from brand.css (section f). Here we
   add the stickiness + a prominent full-width checkout action. Top offset
   clears the ~64px sticky header. */

.woocommerce-cart .cart-collaterals .cart_totals {
	position: sticky;
	top: 88px;
}

.woocommerce-cart .cart-collaterals .cart_totals table.shop_table {
	display: table;
	width: 100%;
	margin: 0 0 4px;
}

.woocommerce-cart .cart-collaterals .cart_totals table.shop_table th,
.woocommerce-cart .cart-collaterals .cart_totals table.shop_table td {
	display: table-cell;
	padding: 12px 0;
}

.woocommerce-cart .cart-collaterals .cart_totals table.shop_table td {
	text-align: end;
}

/* Emphasise the grand-total row as the summary's focal figure. */
.woocommerce-cart .cart-collaterals .cart_totals .order-total th,
.woocommerce-cart .cart-collaterals .cart_totals .order-total td {
	padding-block: 16px;
	border-block-start: 1px solid var(--rm-border-mid);
	font-size: 1.05rem;
}

.woocommerce-cart .cart-collaterals .cart_totals .order-total .amount {
	font-size: 1.4rem;
}

/* Prominent primary action → checkout. */
.woocommerce-cart .wc-proceed-to-checkout {
	padding-top: 1.5em;
}

.woocommerce-cart .wc-proceed-to-checkout a.checkout-button {
	display: block;
	width: 100%;
	margin: 0;
	padding: 17px 28px;
	text-align: center;
	font-size: 1.05rem;
	letter-spacing: 0.08em;
}

/* ==========================================================================
   6. Recommended products — full-width band (relocated cross-sells)
   ==========================================================================
   Card look comes from brand.css (section d). Here we lay them on a real grid
   and add a centred serif heading with breathing room above. */

.woocommerce-cart .cross-sells {
	padding-block-start: clamp(32px, 5vw, 56px);
	border-block-start: 1px solid var(--rm-border-soft);
}

.woocommerce-cart .cross-sells > h2 {
	text-align: center;
	font-size: clamp(1.5rem, 3vw, 2rem);
	font-weight: 400;
	margin-block: 0 1.4em;
}

.woocommerce-cart .cross-sells ul.products {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: clamp(18px, 2.5vw, 36px);
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Cancel WooCommerce's float/clearfix so the grid governs layout. */
.woocommerce-cart .cross-sells ul.products::before,
.woocommerce-cart .cross-sells ul.products::after {
	content: none;
	display: none;
}

.woocommerce-cart .cross-sells ul.products li.product {
	width: 100% !important;
	margin: 0 !important;
	float: none !important;
	clear: none !important;
}

/* ==========================================================================
   7. Empty-cart state
   ==========================================================================
   Rendered on the no-form branch (div.woocommerce without a grid). Centred:
   lotus motif + warm line + sub-line + light "discover the shop" button. */

.woocommerce-cart .woocommerce:not(:has(.woocommerce-cart-form)) {
	max-width: 560px;
	margin-inline: auto;
	padding-block: clamp(32px, 8vw, 80px);
	text-align: center;
}

.rm-empty-cart-motif {
	margin: 0 auto 20px;
}

.rm-empty-cart-motif img {
	width: clamp(96px, 20vw, 132px);
	height: auto;
	opacity: 0.75;
}

.woocommerce-cart .cart-empty,
.woocommerce-cart p.cart-empty,
.woocommerce-cart .wc-empty-cart-message {
	font-family: var(--rm-font-serif);
	font-size: clamp(1.4rem, 3vw, 1.9rem);
	color: var(--rm-espresso);
	margin-block: 0 0.4em;
	background: transparent;
	border: none;
	padding: 0;
}

.rm-empty-cart-sub {
	color: var(--rm-body);
	font-size: 1.02rem;
	line-height: 1.7;
	margin-block: 0 1.8em;
}

.woocommerce-cart .return-to-shop {
	margin: 0;
}

/* Light (secondary) button for the empty state. */
.woocommerce-cart .return-to-shop .button {
	background-color: transparent !important;
	color: var(--rm-espresso) !important;
	border: 1px solid var(--rm-espresso) !important;
}

.woocommerce-cart .return-to-shop .button:hover {
	background-color: var(--rm-espresso) !important;
	color: var(--rm-cream) !important;
}

/* ==========================================================================
   8. Responsive — stack the summary below the items
   ========================================================================== */

@media (max-width: 980px) {
	.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) {
		grid-template-columns: minmax(0, 1fr);
	}

	.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > form.woocommerce-cart-form,
	.woocommerce-cart .woocommerce:has(.woocommerce-cart-form) > .cart-collaterals {
		grid-column: 1 / -1;
	}

	/* Summary flows below the items — no longer sticky. */
	.woocommerce-cart .cart-collaterals .cart_totals {
		position: static;
		top: auto;
	}

	.woocommerce-cart .cross-sells ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	/* Compact card: thumbnail beside a stacked body; qty + subtotal share the
	   last row so the card stays short and scannable. */
	.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item {
		grid-template-columns: 80px minmax(0, 1fr) auto;
		grid-template-areas:
			"thumb name     remove"
			"thumb price    price"
			"thumb quantity subtotal";
		column-gap: 14px;
		row-gap: 10px;
	}

	.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-quantity {
		justify-self: start;
		align-self: center;
	}

	.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-subtotal {
		justify-self: end;
		align-self: center;
		text-align: end;
	}

	.woocommerce-cart .woocommerce-cart-form table.cart tr.cart_item td.product-thumbnail img {
		width: 80px;
	}

	/* Bigger, comfortably tappable remove target on touch. */
	.woocommerce-cart a.remove {
		width: 40px;
		height: 40px;
		font-size: 1.3rem;
	}

	.woocommerce-cart .woocommerce-cart-form td.actions {
		flex-direction: column;
		align-items: stretch;
	}

	.woocommerce-cart .woocommerce-cart-form td.actions .coupon {
		max-width: none;
	}

	/* Full-width apply button in the coupon row on narrow screens. */
	.woocommerce-cart .woocommerce-cart-form td.actions .coupon .button {
		width: 100%;
		min-height: 44px;
	}

	/* Single-column recommended strip so cards don't get squeezed. */
	.woocommerce-cart .cross-sells ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px;
	}
}

/* ==========================================================================
   9. Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
	.woocommerce-cart a.remove,
	.woocommerce-cart .rm-qty-btn {
		transition: none;
	}

	.woocommerce-cart a.remove:hover,
	.woocommerce-cart a.remove:focus-visible {
		transform: none;
	}
}
