/**
 * Cart page. Restyles WooCommerce's own real cart/cart.php output only
 * (table, coupon form, cart totals sidebar, empty-cart notice) — no cart
 * markup is generated by this theme. There is no woocommerce/cart.php
 * template override (WooCommerce never loads a top-level cart.php/
 * checkout.php override for the classic shortcode Cart/Checkout pages —
 * see includes/class-woocommerce-support.php's docblock); every selector
 * below is scoped with the real body.woocommerce-cart class WooCommerce
 * itself adds via body_class() whenever is_cart() is true, and the step
 * indicator is injected via the real woocommerce_before_cart hook.
 *
 * WooCommerce wraps the [woocommerce_cart] shortcode's real output in one
 * <div class="woocommerce"> (core's shortcode_wrapper()), containing, in
 * order: .woocommerce-notices-wrapper, the step indicator (.k-cart-steps,
 * from woocommerce_before_cart), the real .woocommerce-cart-form, and, as
 * a sibling, the real .cart-collaterals (which itself contains
 * .cart_totals). The two-column grid below targets .woocommerce itself,
 * so the notices wrapper and step indicator are pinned full-width above
 * the two real columns; it falls back to a single stacked column if
 * .cart-collaterals is ever absent (e.g. the empty-cart state).
 */

/* Phase 6.2: page.php no longer prints the generic WordPress page title on
   Cart/Checkout (see includes/class-woocommerce-support.php's docblock),
   so the real heading here is the "Your bag" <h1> injected by
   Karataki\WooCommerce_Support::cart_heading() on woocommerce_before_cart —
   a direct child of .woocommerce, not of #main. */
body.woocommerce-cart .k-cart-heading {
	font-family: var(--k-font-serif);
	font-weight: 400;
	font-size: clamp(28px, 3.4vw, 46px);
	margin: 0 0 clamp(20px, 2.6vw, 32px);
}

/* Every direct child of .woocommerce defaults to column 1 (the product
   column) unless explicitly placed in column 2 below — this is the fix
   for Phase 6.2's "#customer_details pushed right" class of bug: relying
   on implicit grid auto-placement across a mix of full-width banners
   (notices, the step indicator), the heading, and the two real columns
   scrambles their order the moment any one of them is a loose sibling
   instead of exactly two children. Explicit placement for every child
   removes that ambiguity entirely. */
body.woocommerce-cart .woocommerce {
	display: grid;
	grid-template-columns: 1.6fr 1fr;
	gap: clamp(20px, 3vw, 48px);
	align-items: start;
	padding: clamp(20px, 2.6vw, 32px) 0 clamp(60px, 8vw, 110px);
}

body.woocommerce-cart .woocommerce > * {
	grid-column: 1;
	min-width: 0;
}

body.woocommerce-cart .woocommerce > .woocommerce-notices-wrapper,
body.woocommerce-cart .woocommerce > .k-cart-steps {
	grid-column: 1 / -1;
}

body.woocommerce-cart .woocommerce > .cart-collaterals {
	grid-column: 2;
}

body.woocommerce-cart .woocommerce > .woocommerce-notices-wrapper:empty {
	display: none;
}

@media (max-width: 899px) {
	body.woocommerce-cart .woocommerce {
		grid-template-columns: 1fr;
	}

	body.woocommerce-cart .woocommerce > .cart-collaterals {
		grid-column: 1;
	}
}

/* Item table --------------------------------------------------------- */

body.woocommerce-cart table.cart {
	width: 100%;
	border-collapse: collapse;
}

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

/* The real WC 11.1 DOM order for a cart row is product-remove,
   product-thumbnail, product-name, product-price, product-quantity,
   product-subtotal (remove comes FIRST, before the thumbnail) — every
   cell below gets an explicit grid-column/grid-row rather than relying on
   that order, which is what actually broke this layout before (implicit
   auto-placement scattered the six real cells across the wrong tracks).
   Column 3 exists only so the quantity stepper (col 2) and the real
   Remove link (col 3) can sit beside each other on row 2 without a
   wrapper element — two separate <td>s can't share one flex row any
   other way. */
body.woocommerce-cart table.cart tr.cart_item {
	display: grid;
	grid-template-columns: 96px 1fr auto auto;
	column-gap: 14px;
	row-gap: 10px;
	align-items: start;
	padding: 20px 0;
	border-top: 1px solid var(--k-border-hairline-strong);
}

body.woocommerce-cart table.cart td {
	border: 0;
	padding: 0;
}

body.woocommerce-cart td.product-thumbnail {
	grid-column: 1;
	grid-row: 1 / span 2;
	width: 96px;
}

/* The real WC thumbnail <img> carries real width="300" height="300" HTML
   attributes (square, from the woocommerce_thumbnail image size) — those
   map to a low-priority "presentational hint" for the height property,
   but since nothing here declared an author height at all, that hint was
   winning outright and aspect-ratio had no auto dimension left to act on,
   stretching the image tall and narrow. Declaring height: auto explicitly
   overrides that hint so aspect-ratio (with the explicit width) computes
   the real 96×120 box as intended. */
body.woocommerce-cart td.product-thumbnail img {
	width: 96px;
	height: auto;
	aspect-ratio: 4 / 5;
	object-fit: cover;
	background: var(--k-color-surface-light);
}

body.woocommerce-cart td.product-name {
	grid-column: 2 / span 2;
	grid-row: 1;
	font-size: 14px;
	font-weight: 500;
}

body.woocommerce-cart td.product-name a {
	color: var(--k-color-text);
}

body.woocommerce-cart td.product-name .variation {
	margin: 6px 0 0;
	font-size: 11px;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: var(--k-color-muted-2);
}

body.woocommerce-cart td.product-name dd {
	margin: 0;
}

body.woocommerce-cart td.product-price {
	display: none;
}

body.woocommerce-cart td.product-subtotal {
	grid-column: 4;
	grid-row: 1;
	font-size: 14px;
	text-align: right;
}

body.woocommerce-cart td.product-quantity {
	grid-column: 2;
	grid-row: 2;
	justify-self: start;
}

body.woocommerce-cart td.product-quantity .quantity {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--k-border-cta);
}

body.woocommerce-cart td.product-quantity .qty {
	width: 44px;
	height: 32px;
	border: 0;
	background: transparent;
	color: var(--k-color-text);
	text-align: center;
	font: inherit;
	appearance: textfield;
}

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

body.woocommerce-cart .quantity__step {
	width: 32px;
	height: 32px;
	flex: none;
	background: transparent;
	border: 0;
	color: var(--k-color-text);
	cursor: pointer;
	font-size: 14px;
}

body.woocommerce-cart td.product-remove {
	grid-column: 3;
	grid-row: 2;
	align-self: center;
	white-space: nowrap;
}

/* The real WC remove link's own text node is the "×" glyph, with its
   accessible name carried by WooCommerce's own real aria-label — that
   real aria-label is left untouched (so assistive tech still announces
   it correctly). Its visual glyph is hidden here (font-size: 0) in favour
   of a generated "Remove" label matching the reference, which is CSS
   content and so is never read as extra/duplicate text by AT. */
body.woocommerce-cart td.product-remove a.remove {
	display: inline-block;
	background: transparent;
	color: var(--k-color-muted-2);
	font-size: 0;
	letter-spacing: .1em;
	text-decoration: none;
	line-height: 1;
}

body.woocommerce-cart td.product-remove a.remove::before {
	content: "Remove";
	font-size: 11px;
	letter-spacing: .1em;
	text-transform: uppercase;
}

body.woocommerce-cart td.product-remove a.remove:hover,
body.woocommerce-cart td.product-remove a.remove:focus-visible {
	color: var(--k-color-accent);
}

/* Coupon + update-cart row ------------------------------------------- */

body.woocommerce-cart tr:has(.coupon),
body.woocommerce-cart .actions {
	display: block;
	margin-top: 28px;
	padding-top: 20px;
	border-top: 1px solid var(--k-border-hairline-strong);
}

body.woocommerce-cart .coupon {
	display: flex;
	gap: 10px;
	max-width: 380px;
	flex-wrap: wrap;
}

/* The real coupon field's own <label> is screen-reader-text ("Coupon:")
   — left hidden (see base/layout.css) rather than un-hidden with
   different visible text, which would fight the real accessible name.
   The visible "Discount code" heading below is decorative ::before
   content on the row itself, matching the approved reference's own
   literal label text without touching the real form control's a11y name. */
body.woocommerce-cart tr:has(.coupon)::before {
	content: "Discount code";
	display: block;
	font-size: 11px;
	letter-spacing: .16em;
	text-transform: uppercase;
	color: var(--k-color-muted-2);
	margin-bottom: 12px;
}

body.woocommerce-cart .coupon #coupon_code {
	flex: 1;
	background: transparent;
	border: 1px solid var(--k-border-cta);
	padding: 13px 14px;
	font-size: 13px;
	color: var(--k-color-text);
}

body.woocommerce-cart .coupon #coupon_code:focus-visible {
	outline: none;
	border-color: var(--k-color-accent);
}

body.woocommerce-cart .coupon button[name="apply_coupon"] {
	padding: 0 22px;
	background: transparent;
	border: 1px solid var(--k-border-cta);
	color: var(--k-color-text);
	font-size: 11px;
	letter-spacing: .14em;
	text-transform: uppercase;
	cursor: pointer;
}

body.woocommerce-cart .coupon button[name="apply_coupon"]:hover,
body.woocommerce-cart .coupon button[name="apply_coupon"]:focus-visible {
	border-color: var(--k-color-accent);
	color: var(--k-color-accent);
}

body.woocommerce-cart button[name="update_cart"] {
	margin-top: 14px;
	padding: 13px 22px;
	background: transparent;
	border: 1px solid var(--k-border-cta);
	color: var(--k-color-text);
	font-size: 11px;
	letter-spacing: .14em;
	text-transform: uppercase;
	cursor: pointer;
}

body.woocommerce-cart button[name="update_cart"]:disabled {
	opacity: .4;
	cursor: not-allowed;
}

/* Order summary sidebar ----------------------------------------------- */

body.woocommerce-cart .cart-collaterals {
	position: sticky;
	top: 120px;
}

body.woocommerce-cart .cart_totals {
	border: 1px solid var(--k-border-hairline-strong);
	padding: clamp(22px, 2.6vw, 32px);
}

/* Real WC heading text is "Cart totals" — kept as the real accessible
   name (font-size: 0 hides it visually only; screen readers still read
   text content regardless of font-size, unlike display:none) while
   "Order summary" (the approved reference's own literal label) shows via
   ::before — same established pattern as the real Remove link above. */
body.woocommerce-cart .cart_totals > h2 {
	font-size: 0;
	margin: 0;
}

body.woocommerce-cart .cart_totals > h2::before {
	content: "Order summary";
	display: block;
	font-size: 11px;
	font-weight: 500;
	letter-spacing: .18em;
	text-transform: uppercase;
	color: var(--k-color-muted-2);
}

body.woocommerce-cart .cart_totals table {
	width: 100%;
	border-collapse: collapse;
	margin-top: 18px;
}

body.woocommerce-cart .cart_totals tr {
	display: flex;
	justify-content: space-between;
	font-size: 13px;
}

body.woocommerce-cart .cart_totals tr + tr {
	margin-top: 10px;
}

body.woocommerce-cart .cart_totals th,
body.woocommerce-cart .cart_totals td {
	border: 0;
	padding: 0;
	font-weight: 400;
}

body.woocommerce-cart .cart_totals tr.order-total {
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--k-border-hairline-strong);
	font-family: var(--k-font-serif);
	font-size: 19px;
}

body.woocommerce-cart .cart_totals .woocommerce-remove-coupon {
	margin-left: 8px;
	color: var(--k-color-muted-2);
}

body.woocommerce-cart .wc-proceed-to-checkout {
	margin-top: 22px;
}

body.woocommerce-cart .wc-proceed-to-checkout .checkout-button {
	display: block;
	width: 100%;
	text-align: center;
	padding: 17px;
	font-size: 12px;
	font-weight: 500;
	letter-spacing: .2em;
	text-transform: uppercase;
	background: var(--k-color-text);
	color: var(--k-color-bg);
	transition: background var(--k-duration-base);
}

body.woocommerce-cart .wc-proceed-to-checkout .checkout-button:hover,
body.woocommerce-cart .wc-proceed-to-checkout .checkout-button:focus-visible {
	background: var(--k-color-accent);
	outline: none;
}

body.woocommerce-cart button[name="update_cart"]:focus-visible {
	outline: none;
	border-color: var(--k-color-accent);
	color: var(--k-color-accent);
}

/* Cross-sells: real WooCommerce data (only appears if the products in
   cart have real cross-sell relationships configured) — left in place
   (not removed just because it's absent from the reference mock) and
   given minimal, consistent spacing rather than a full bespoke layout. */
body.woocommerce-cart .cross-sells {
	margin-top: clamp(40px, 5vw, 64px);
	padding-top: 28px;
	border-top: 1px solid var(--k-border-hairline-strong);
}

/* Empty cart ----------------------------------------------------------- */

body.woocommerce-cart .cart-empty {
	text-align: center;
	padding: clamp(60px, 9vw, 120px) 20px 0;
	font-size: 11px;
	letter-spacing: .06em;
	color: var(--k-color-muted-2);
	grid-column: 1 / -1;
}

body.woocommerce-cart .return-to-shop {
	text-align: center;
	grid-column: 1 / -1;
}

body.woocommerce-cart .return-to-shop .wc-backward {
	display: inline-block;
	margin-top: 22px;
	padding: 15px 30px;
	border: 1px solid var(--k-border-cta);
	color: var(--k-color-text);
	font-size: 11px;
	letter-spacing: .2em;
	text-transform: uppercase;
}

body.woocommerce-cart .wc-backward:hover,
body.woocommerce-cart .wc-backward:focus-visible {
	border-color: var(--k-color-accent);
	color: var(--k-color-accent);
}
