/*
 * Cart page (Phase 3F — docs/CART-IMPLEMENTATION.md). Restyles WooCommerce's
 * own Cart Block (the real rendering system — verified via page-content
 * inspection, not a classic shortcode/template) using its documented,
 * stable CSS class names. No block markup is copied or rebuilt; every
 * class below is WooCommerce's own, confirmed live against the rendered
 * page before writing any rule.
 */

/* --- Page heading (printed by page.php's the_title(), not the block) --- */
/* Font styling is the site-wide default now (base.css); only this page's
   larger bottom margin is overridden here. */
body.woocommerce-cart h1,
body.woocommerce-checkout h1 {
	margin: 0 0 var(--space-6);
}

/* --- Sidebar layout (items | totals) --- */
.wc-block-cart__sidebar,
.wc-block-checkout__sidebar {
	background: var(--color-surface);
	border: var(--border-default);
	border-radius: var(--radius-lg);
	padding: var(--space-6);
}

.wc-block-cart__totals-title,
.wc-block-components-checkout-order-summary__title {
	font-family: var(--font-display);
	font-size: var(--text-h4);
	font-weight: var(--font-weight-semibold);
	margin: 0 0 var(--space-4);
}

/* --- Cart items table --- */
.wc-block-cart-items {
	width: 100%;
	border-collapse: collapse;
}

.wc-block-cart-items__header th {
	text-align: left;
	font-size: var(--text-xs);
	text-transform: uppercase;
	letter-spacing: var(--tracking-wide);
	color: var(--color-text-secondary);
	font-weight: var(--font-weight-semibold);
	padding-bottom: var(--space-3);
	border-bottom: var(--border-default);
}

.wc-block-cart-items__row {
	border-bottom: var(--border-default);
}

.wc-block-cart-item__image img {
	border-radius: var(--radius-md);
	border: var(--border-default);
	object-fit: contain;
	background: var(--color-surface);
}

.wc-block-components-product-name {
	font-family: var(--font-body);
	font-size: var(--text-base);
	font-weight: var(--font-weight-semibold);
	color: var(--color-text-primary);
	text-decoration: none;
	/* Long product names wrap safely rather than forcing the table wide. */
	overflow-wrap: anywhere;
}
.wc-block-components-product-name:hover { color: var(--color-brand-blue); text-decoration: underline; }

.wc-block-components-product-metadata__description {
	color: var(--color-text-secondary);
	font-size: var(--text-sm);
	line-height: var(--leading-relaxed);
}

.wc-block-components-product-price .wc-block-components-formatted-money-amount {
	font-variant-numeric: tabular-nums;
	color: var(--color-text-primary);
}

/* --- Quantity stepper (WooCommerce's own component, restyled) --- */
.wc-block-components-quantity-selector {
	display: inline-flex;
	align-items: stretch;
	border: var(--border-default);
	border-radius: var(--radius-md);
	overflow: hidden;
	width: auto;
}
.wc-block-components-quantity-selector__button {
	background: var(--color-surface);
	border: none;
	width: 36px;
	color: var(--color-text-primary);
	font-size: var(--text-base);
	cursor: pointer;
	transition: background-color var(--duration-base) var(--ease-standard);
}
.wc-block-components-quantity-selector__button:hover { background: var(--color-surface-sunken); }
.wc-block-components-quantity-selector__input {
	border: none;
	border-left: var(--border-default);
	border-right: var(--border-default);
	width: 44px;
	text-align: center;
	font-family: var(--font-data);
	font-size: var(--text-sm);
}

/* --- Remove link — a real, always-visible text control, never hover-only --- */
.wc-block-cart-item__remove-link {
	color: var(--color-text-secondary);
	font-size: var(--text-sm);
	text-decoration: underline;
	margin-top: var(--space-2);
	display: inline-block;
}
.wc-block-cart-item__remove-link:hover { color: var(--color-error); }

/* --- Coupon panel (shared component: cart sidebar + checkout sidebar) --- */
.wc-block-components-panel__button {
	font-size: var(--text-sm);
	font-weight: var(--font-weight-semibold);
	color: var(--color-brand-deep);
}
#coupon,
.wc-block-components-totals-coupon input[type="text"] {
	border: var(--border-default);
	border-radius: var(--radius-md);
	padding: var(--space-2) var(--space-3);
	font-family: var(--font-body);
	font-size: var(--text-sm);
}

/* --- Totals rows --- */
.wc-block-components-totals-item__label,
.wc-block-components-totals-item__description { color: var(--color-text-secondary); font-size: var(--text-sm); }
.wc-block-components-totals-item__value { font-variant-numeric: tabular-nums; color: var(--color-text-primary); }
.wc-block-components-totals-footer-item .wc-block-components-totals-item__label,
.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
	font-size: var(--text-h5);
	font-weight: var(--font-weight-bold);
	color: var(--color-text-primary);
}

/* Long shipping-method labels wrap correctly rather than overflowing the
   narrow sidebar column. */
.wc-block-components-totals-shipping .wc-block-components-totals-item__label { overflow-wrap: anywhere; }

/* --- Primary CTA — "Proceed to Checkout" / "Place Order" --- */
.wc-block-cart__submit-button,
.wc-block-components-checkout-place-order-button {
	background: var(--color-brand-blue) !important;
	border-radius: var(--radius-md) !important;
	font-weight: var(--font-weight-semibold) !important;
	min-height: 48px;
	transition: background-color var(--duration-base) var(--ease-standard), transform var(--duration-fast) var(--ease-out) !important;
}
.wc-block-cart__submit-button:hover,
.wc-block-components-checkout-place-order-button:hover {
	background: var(--color-brand-bright) !important;
	transform: translateY(-1px);
}
.wc-block-cart__submit-button:focus-visible,
.wc-block-components-checkout-place-order-button:focus-visible {
	outline: none;
	box-shadow: var(--shadow-focus);
}

/* --- Notices (guest-checkout note, coupon errors, etc.) — real WooCommerce
   notices, mapped onto the design system's alert tokens. --- */
.wc-block-components-notices .wc-block-components-notice-banner,
.wc-block-store-notice-snackbar,
.wc-block-checkout__guest-checkout-notice {
	border-radius: var(--radius-md);
	font-size: var(--text-sm);
}

/* --- Empty cart (see docs/CART-IMPLEMENTATION.md §8) --- */
.wc-block-cart-empty__title,
.wp-block-woocommerce-empty-cart-block h2 {
	font-family: var(--font-display);
	font-size: var(--text-h2);
}
.wp-block-woocommerce-empty-cart-block { text-align: center; padding-block: var(--space-8); }
.wp-block-woocommerce-empty-cart-block .wc-block-cart__empty-cart__title { margin-bottom: var(--space-4); }

/* Real "Continue Shopping" + category buttons added to the empty-cart
   block content (docs/CART-IMPLEMENTATION.md §8) — core button blocks,
   restyled to the brand palette instead of the editor's default black. */
.wp-block-woocommerce-empty-cart-block .wp-block-button__link {
	background: var(--color-brand-blue);
	border-radius: var(--radius-md);
	font-weight: var(--font-weight-semibold);
	transition: background-color var(--duration-base) var(--ease-standard);
}
.wp-block-woocommerce-empty-cart-block .wp-block-button__link:hover { background: var(--color-brand-bright); }
/* color: brand-deep, not brand-blue — this button sits directly on the
   page's sunken background, where brand-blue text measures only 4.44:1
   (found via axe-core, Phase 3I), under the 4.5:1 AA minimum. Same fix
   already applied to My Account's equivalent links in Phase 3G
   (docs/MY-ACCOUNT-QA.md). Border stays brand-blue — border contrast isn't
   subject to the same text-contrast requirement. */
.wp-block-woocommerce-empty-cart-block .is-style-outline .wp-block-button__link {
	background: transparent;
	color: var(--color-brand-deep);
	border: var(--border-width-sm) solid var(--color-brand-blue);
}
.wp-block-woocommerce-empty-cart-block .is-style-outline .wp-block-button__link:hover { background: color-mix(in srgb, var(--color-brand-blue) 8%, white); }

/* Cross-sell rail ("New in store" / "You may be interested in…") uses the
   same core .wp-block-button__link markup as the Continue Shopping/
   category buttons above (verified via DOM inspection) — the rule above
   already covers both "You may be interested in…" (inside the filled-cart
   product-collection block) and "New in store" (inside the empty-cart
   block), so no separate selector is needed. */
.wp-block-woocommerce-cart .wp-block-button__link.add_to_cart_button {
	background: var(--color-brand-blue);
	border-radius: var(--radius-md);
	font-weight: var(--font-weight-semibold);
}
.wp-block-woocommerce-cart .wp-block-button__link.add_to_cart_button:hover { background: var(--color-brand-bright); }

/* --- Responsive: stack sidebar under items on narrow widths ---
   WooCommerce's own cart.css already has a real container-width-based
   responsive system for this exact table (JS adds .is-mobile/.is-small/
   .is-medium to the block based on its rendered width, then CSS keys off
   those classes — not a standard viewport media query), via a rule with
   real specificity: `.wc-block-cart table.wc-block-cart-items
   .wc-block-cart-items__row { display: grid; grid-template-columns: 80px
   132px; }`. A first attempt to override this with an equally-simple
   `display: block` rule was silently losing to that higher-specificity,
   unconditional rule — confirmed by finding the exact same overflowing
   58–71px-wide price cell persisted after the change. `!important` here
   is deliberate: it's the only reliable way to win against a third-party
   component's own responsive system without matching (and keeping in
   sync with) its exact selector chain. */
@media (max-width: 767px) {
	.wc-block-cart-items__header-image,
	.wc-block-cart-items__header-product { display: none; }
	.wc-block-cart-items,
	.wc-block-cart-items__row,
	.wc-block-cart-items__row td {
		display: block !important;
		grid-template-columns: none !important;
		width: 100% !important;
	}
	.wc-block-cart-item__image { margin-bottom: var(--space-2); }
	.wc-block-cart-item__image img { max-width: 120px; }
	.wc-block-cart-item__total {
		text-align: left !important;
		justify-content: flex-start !important;
	}
}
