/*
 * MEC Timing: cart and checkout (WooCommerce shortcode pages: body.woocommerce-cart / .woocommerce-checkout).
 *
 * Layout and form styling only. Colours/fonts/spacing come from mec-tokens.css; button looks come from
 * mec-buttons.css (primary = Proceed to checkout / Place order, secondary = Update cart / Apply coupon).
 */

/* ---- Page frame and title ---- */
body.woocommerce-cart main.site-main,
body.woocommerce-checkout main.site-main {
	padding-block: var(--mec-space-6) var(--mec-space-24);
}
body.woocommerce-cart .wp-block-post-title,
body.woocommerce-checkout .wp-block-post-title {
	margin: 0 0 var(--mec-space-8);
	font-family: var(--mec-font-display);
	font-size: clamp(32px, 5vw, 46px);
	font-weight: 700;
	line-height: 1.08;
	text-transform: uppercase;
	color: var(--mec-ink);
}
body.woocommerce-cart .entry-content,
body.woocommerce-checkout .entry-content {
	color: var(--mec-ink);
	font-size: 16px;
	line-height: 1.6;
}
body.woocommerce-cart .entry-content a:where(:not(.button, .wp-element-button, .remove)),
body.woocommerce-checkout .entry-content a:where(:not(.button, .wp-element-button)) {
	color: var(--mec-orange-ink);
}
body.woocommerce-cart .entry-content a:where(:not(.button, .wp-element-button, .remove)):hover,
body.woocommerce-checkout .entry-content a:where(:not(.button, .wp-element-button)):hover {
	color: var(--mec-orange-ink-hover);
}

/* ---- Notices (info / success / error banners) ---- */
body.woocommerce-cart .wc-block-components-notice-banner,
body.woocommerce-checkout .wc-block-components-notice-banner,
body.woocommerce-cart .woocommerce-message,
body.woocommerce-cart .woocommerce-error,
body.woocommerce-checkout .woocommerce-error {
	display: flex;
	align-items: flex-start;
	gap: var(--mec-space-3);
	margin: 0 0 var(--mec-space-4);
	padding: var(--mec-space-4) var(--mec-space-5);
	list-style: none;
	background: var(--mec-surface-raised);
	color: var(--mec-ink);
	border: 1px solid var(--mec-border);
	border-left: 4px solid var(--mec-orange);
	border-radius: var(--mec-radius-lg);
	font-size: 15px;
}
body.woocommerce-cart .wc-block-components-notice-banner svg,
body.woocommerce-checkout .wc-block-components-notice-banner svg {
	flex: 0 0 24px;
	fill: var(--mec-orange-ink);
	background: none;
}
body.woocommerce-cart .wc-block-components-notice-banner.is-success,
body.woocommerce-checkout .wc-block-components-notice-banner.is-success {
	border-left-color: var(--mec-spruce);
}
body.woocommerce-cart .wc-block-components-notice-banner.is-error,
body.woocommerce-checkout .wc-block-components-notice-banner.is-error,
body.woocommerce-cart .woocommerce-error,
body.woocommerce-checkout .woocommerce-error {
	border-left-color: var(--mec-orange-ink);
}
body.woocommerce-cart .woocommerce-error li,
body.woocommerce-checkout .woocommerce-error li { margin: 0; }

/* ---- Shared form controls ---- */
body.woocommerce-cart .entry-content :is(input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], textarea, select),
body.woocommerce-checkout .entry-content :is(input[type="text"], input[type="email"], input[type="tel"], input[type="number"], input[type="password"], textarea, select) {
	width: 100%;
	box-sizing: border-box;
	min-height: 48px;
	padding: 0 var(--mec-space-4);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-lg);
	background-color: var(--mec-surface-raised);
	font: 400 16px/1.5 var(--mec-font-sans);
	color: var(--mec-ink);
}
body.woocommerce-checkout .entry-content textarea {
	min-height: 120px;
	padding: var(--mec-space-3) var(--mec-space-4);
}
body.woocommerce-cart .entry-content :is(input, textarea, select):focus-visible,
body.woocommerce-checkout .entry-content :is(input, textarea, select):focus-visible,
body.woocommerce-checkout .select2-container--focus .select2-selection,
body.woocommerce-checkout .select2-container--open .select2-selection {
	outline: 3px solid var(--mec-orange);
	outline-offset: 1px;
}

/* ---- CART: line items ---- */
body.woocommerce-cart table.shop_table {
	width: 100%;
	margin: 0;
	border-collapse: separate;
	border-spacing: 0;
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-2xl);
	background: var(--mec-surface-raised);
	overflow: hidden;
}
body.woocommerce-cart table.shop_table :is(th, td) {
	padding: var(--mec-space-4) var(--mec-space-5);
	border: 0;
	border-top: 1px solid var(--mec-border);
	text-align: left;
	vertical-align: middle;
	background: transparent;
}
body.woocommerce-cart table.cart thead th {
	border-top: 0;
	background: var(--mec-ink);
	color: var(--mec-surface);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
}
body.woocommerce-cart table.cart .product-remove { width: 48px; padding-inline-end: 0; }
body.woocommerce-cart table.cart .product-thumbnail { width: 96px; }
body.woocommerce-cart table.cart .product-thumbnail img {
	display: block;
	width: 80px;
	height: auto;
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-md);
}
body.woocommerce-cart table.cart .product-name a { font-weight: 700; text-decoration: none; }
body.woocommerce-cart table.cart .product-name a:hover { text-decoration: underline; }
body.woocommerce-cart table.cart :is(.product-price, .product-subtotal) {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
body.woocommerce-cart .subscription-details {
	display: block;
	font-size: 13px;
	color: var(--mec-ink-muted);
}
body.woocommerce-cart table.cart .quantity .qty { width: 72px; text-align: center; padding: 0 var(--mec-space-2); }
body.woocommerce-cart table.cart a.remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	font-size: 20px;
	line-height: 1;
	text-decoration: none;
	color: var(--mec-ink-muted);
}
body.woocommerce-cart table.cart a.remove:hover {
	background: var(--mec-surface-alt);
	color: var(--mec-orange-ink-hover);
}

/* Coupon + update row */
body.woocommerce-cart table.cart td.actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--mec-space-3);
	background: var(--mec-surface-alt);
}
body.woocommerce-cart table.cart td.actions .coupon {
	display: flex;
	flex-wrap: wrap;
	gap: var(--mec-space-3);
}
body.woocommerce-cart table.cart td.actions .coupon input { width: 220px; }
body.woocommerce-cart table.cart td.actions button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- CART: totals + cross-sells ---- */
body.woocommerce-cart .cart-collaterals {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
	gap: var(--mec-space-8);
	align-items: start;
	margin-top: var(--mec-space-8);
}
body.woocommerce-cart .cart-collaterals .cart_totals {
	grid-column: 2;
	grid-row: 1;
	float: none;
	width: auto;
	padding: var(--mec-space-7);
	background: var(--mec-surface-raised);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-2xl);
}
body.woocommerce-cart .cart-collaterals .cross-sells {
	grid-column: 1;
	grid-row: 1;
	float: none;
	width: auto;
}
body.woocommerce-cart :is(.cart_totals, .cross-sells) > h2 {
	margin: 0 0 var(--mec-space-4);
	font-family: var(--mec-font-heading);
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--mec-ink);
}
body.woocommerce-cart .cart_totals table.shop_table {
	border: 0;
	border-radius: 0;
	background: transparent;
}
body.woocommerce-cart .cart_totals table.shop_table :is(th, td) { padding: var(--mec-space-3) 0; }
body.woocommerce-cart .cart_totals table.shop_table td { text-align: right; font-variant-numeric: tabular-nums; }
body.woocommerce-cart .cart_totals tr:first-child :is(th, td) { border-top: 0; }
body.woocommerce-cart .cart_totals .order-total :is(th, td) {
	border-top: 2px solid var(--mec-ink);
	font-size: 20px;
}
body.woocommerce-cart .cart_totals small { font-weight: 400; color: var(--mec-ink-muted); }
body.woocommerce-cart .wc-proceed-to-checkout { margin-top: var(--mec-space-5); }
body.woocommerce-cart .wc-proceed-to-checkout .checkout-button { display: flex; width: 100%; }

/* Cross-sell cards */
body.woocommerce-cart .cross-sells ul.products {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: var(--mec-space-5);
	margin: 0;
	padding: 0;
	list-style: none;
}
body.woocommerce-cart .cross-sells ul.products li.product {
	display: flex;
	flex-direction: column;
	gap: var(--mec-space-3);
	width: auto;
	margin: 0;
	padding: var(--mec-space-5);
	background: var(--mec-surface-raised);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-2xl);
}
body.woocommerce-cart .cross-sells li.product a.woocommerce-LoopProduct-link { display: flex; flex-direction: column; gap: var(--mec-space-2); text-decoration: none; color: var(--mec-ink); }
body.woocommerce-cart .cross-sells li.product img { width: 100%; height: auto; margin: 0; border-radius: var(--mec-radius-md); }
body.woocommerce-cart .cross-sells li.product .woocommerce-loop-product__title {
	margin: 0;
	font-family: var(--mec-font-heading);
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--mec-ink);
}
body.woocommerce-cart .cross-sells li.product .price { font-size: 15px; color: var(--mec-ink-muted); }
body.woocommerce-cart .cross-sells li.product .button { margin-top: auto; }

/* Empty cart */
body.woocommerce-cart .return-to-shop { margin-top: var(--mec-space-6); }

/* ---- CHECKOUT: layout ---- */
body.woocommerce-checkout form.checkout {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
	grid-template-rows: auto 1fr;
	gap: 0 var(--mec-space-14);
	align-items: start;
	margin-top: var(--mec-space-6);
}
body.woocommerce-checkout #customer_details { grid-column: 1; grid-row: 1 / span 2; float: none; width: auto; }
body.woocommerce-checkout #order_review_heading { grid-column: 2; grid-row: 1; }
body.woocommerce-checkout #order_review { grid-column: 2; grid-row: 2; }
body.woocommerce-checkout #customer_details :is(.col-1, .col-2) { float: none; width: auto; }
body.woocommerce-checkout #customer_details .col-2 { margin-top: var(--mec-space-8); }
body.woocommerce-checkout :is(.woocommerce-billing-fields, .woocommerce-shipping-fields, .woocommerce-additional-fields) > h3,
body.woocommerce-checkout #order_review_heading {
	margin: 0 0 var(--mec-space-5);
	font-family: var(--mec-font-heading);
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--mec-ink);
}

/* ---- CHECKOUT: fields ---- */
body.woocommerce-checkout .woocommerce-billing-fields__field-wrapper,
body.woocommerce-checkout .woocommerce-shipping-fields__field-wrapper,
body.woocommerce-checkout .woocommerce-additional-fields__field-wrapper {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--mec-space-4);
}
body.woocommerce-checkout .form-row {
	float: none;
	width: auto;
	margin: 0;
	padding: 0;
}
body.woocommerce-checkout .form-row-wide,
body.woocommerce-checkout #order_comments_field { grid-column: 1 / -1; }
body.woocommerce-checkout .form-row label {
	display: block;
	margin-bottom: 6px;
	font-size: 14px;
	font-weight: 700;
	color: var(--mec-ink);
}
body.woocommerce-checkout .form-row :is(.optional) { font-weight: 400; color: var(--mec-ink-muted); }
body.woocommerce-checkout .form-row :is(.required, abbr.required) { color: var(--mec-orange-ink); text-decoration: none; }
body.woocommerce-checkout .form-row.woocommerce-invalid input,
body.woocommerce-checkout .form-row.woocommerce-invalid select { border-color: var(--mec-orange-ink); }
body.woocommerce-checkout .woocommerce-input-wrapper { display: block; }

/* Select2 (country / province) */
body.woocommerce-checkout .select2-container { width: 100% !important; }
body.woocommerce-checkout .select2-container .select2-selection--single {
	display: flex;
	align-items: center;
	height: 48px;
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-lg);
	background: var(--mec-surface-raised);
}
body.woocommerce-checkout .select2-container .select2-selection__rendered {
	padding: 0 var(--mec-space-4);
	font-size: 16px;
	line-height: 1.5;
	color: var(--mec-ink);
}
body.woocommerce-checkout .select2-container .select2-selection__arrow { height: 46px; right: var(--mec-space-2); }
.select2-dropdown {
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-lg);
	background: var(--mec-surface-raised);
	color: var(--mec-ink);
	font-family: var(--mec-font-sans);
	overflow: hidden;
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected] {
	background: var(--mec-surface-alt);
	color: var(--mec-orange-ink);
}

/* Login / coupon toggles */
body.woocommerce-checkout :is(.woocommerce-form-login-toggle, .woocommerce-form-coupon-toggle) .wc-block-components-notice-banner { margin-bottom: var(--mec-space-3); }
body.woocommerce-checkout :is(form.woocommerce-form-login, form.checkout_coupon) {
	margin: 0 0 var(--mec-space-6);
	padding: var(--mec-space-6);
	background: var(--mec-surface-raised);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-2xl);
}
body.woocommerce-checkout form.checkout_coupon { display: flex; flex-wrap: wrap; gap: var(--mec-space-3); align-items: center; }
body.woocommerce-checkout form.checkout_coupon > p { margin: 0; }
body.woocommerce-checkout form.checkout_coupon > p:first-child { flex: 1 1 100%; }
body.woocommerce-checkout form.checkout_coupon .form-row-first { flex: 1 1 220px; }
body.woocommerce-checkout form.checkout_coupon .clear { display: none; }
body.woocommerce-checkout form.woocommerce-form-login .form-row { display: block; margin-bottom: var(--mec-space-4); }
body.woocommerce-checkout .password-input { position: relative; display: block; }
body.woocommerce-checkout .show-password-input { position: absolute; right: var(--mec-space-3); top: 50%; transform: translateY(-50%); }

/* ---- CHECKOUT: order review card ---- */
body.woocommerce-checkout #order_review {
	padding: var(--mec-space-7);
	background: var(--mec-surface-raised);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-2xl);
}
body.woocommerce-checkout table.woocommerce-checkout-review-order-table {
	width: 100%;
	margin: 0 0 var(--mec-space-5);
	border: 0;
	border-collapse: collapse;
}
body.woocommerce-checkout table.woocommerce-checkout-review-order-table :is(th, td) {
	padding: var(--mec-space-3) 0;
	border: 0;
	border-top: 1px solid var(--mec-border);
	text-align: left;
	vertical-align: top;
	background: transparent;
	font-size: 15px;
}
body.woocommerce-checkout table.woocommerce-checkout-review-order-table thead th {
	padding-top: 0;
	border-top: 0;
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--mec-ink-muted);
}
body.woocommerce-checkout table.woocommerce-checkout-review-order-table :is(.product-total, tfoot td) { text-align: right; font-variant-numeric: tabular-nums; }
body.woocommerce-checkout table.woocommerce-checkout-review-order-table .product-quantity { font-weight: 400; color: var(--mec-ink-muted); }
body.woocommerce-checkout .wcs-checkout-item-price,
body.woocommerce-checkout .subscription-details { font-size: 13px; color: var(--mec-ink-muted); }
body.woocommerce-checkout table.woocommerce-checkout-review-order-table .order-total :is(th, td) {
	border-top: 2px solid var(--mec-ink);
	font-size: 20px;
}

/* ---- CHECKOUT: payment ---- */
body.woocommerce-checkout #payment { background: transparent; border-radius: 0; }
body.woocommerce-checkout #payment ul.payment_methods {
	margin: 0 0 var(--mec-space-5);
	padding: 0;
	border: 0;
	list-style: none;
}
body.woocommerce-checkout #payment li.wc_payment_method {
	margin: 0 0 var(--mec-space-3);
	padding: var(--mec-space-4);
	border: 1px solid var(--mec-border);
	border-radius: var(--mec-radius-lg);
	background: var(--mec-surface);
}
body.woocommerce-checkout #payment li.wc_payment_method:has(input:checked) { border-color: var(--mec-ink); }
body.woocommerce-checkout #payment li.wc_payment_method > label {
	display: inline-flex;
	align-items: center;
	gap: var(--mec-space-3);
	margin: 0;
	font-weight: 700;
	cursor: pointer;
}
body.woocommerce-checkout #payment li.wc_payment_method input[type="radio"] { accent-color: var(--mec-orange-ink); margin-inline-end: var(--mec-space-2); }
body.woocommerce-checkout #payment .stripe-cards-icon { max-height: 24px; width: auto; }
body.woocommerce-checkout #payment div.payment_box {
	margin: var(--mec-space-4) 0 0;
	padding: 0;
	background: transparent;
	color: var(--mec-ink-muted);
	font-size: 15px;
}
body.woocommerce-checkout #payment div.payment_box::before { display: none; }
body.woocommerce-checkout #payment .place-order { margin: 0; padding: 0; }
body.woocommerce-checkout .woocommerce-privacy-policy-text { font-size: 14px; color: var(--mec-ink-muted); }
body.woocommerce-checkout .woocommerce-privacy-policy-text p { margin: 0 0 var(--mec-space-4); }
body.woocommerce-checkout #place_order { display: flex; width: 100%; float: none; }

/* Terms text pulled into the checkout from the Terms page must not carry page-section padding */
body.woocommerce-checkout .woocommerce-terms-and-conditions .mec-section { padding: var(--mec-space-4) !important; }
body.woocommerce-checkout .woocommerce-terms-and-conditions { border: 1px solid var(--mec-border); border-radius: var(--mec-radius-lg); background: var(--mec-surface-raised); font-size: 14px; }
body.woocommerce-checkout .woocommerce-terms-and-conditions .mec-h2 { font-size: 20px; margin-bottom: var(--mec-space-4) !important; }
body.woocommerce-checkout .woocommerce-terms-and-conditions-checkbox-text { font-size: 14px; }
body.woocommerce-checkout .woocommerce-form__label-for-checkbox { display: flex; gap: var(--mec-space-3); align-items: flex-start; font-weight: 400; }
body.woocommerce-checkout .woocommerce-form__input-checkbox { width: 20px; min-height: 20px; margin-top: 2px; accent-color: var(--mec-orange-ink); }

/* ---- Tablet / mobile ---- */
@media (max-width: 960px) {
	body.woocommerce-cart .cart-collaterals,
	body.woocommerce-checkout form.checkout { grid-template-columns: minmax(0, 1fr); }
	body.woocommerce-cart .cart-collaterals .cart_totals,
	body.woocommerce-cart .cart-collaterals .cross-sells { grid-column: 1; grid-row: auto; }
	body.woocommerce-checkout #customer_details,
	body.woocommerce-checkout #order_review_heading,
	body.woocommerce-checkout #order_review { grid-column: 1; grid-row: auto; }
	body.woocommerce-checkout #order_review_heading { margin-top: var(--mec-space-8); }
}
@media (max-width: 640px) {
	body.woocommerce-checkout .woocommerce-billing-fields__field-wrapper,
	body.woocommerce-checkout .woocommerce-shipping-fields__field-wrapper { grid-template-columns: minmax(0, 1fr); }
	body.woocommerce-checkout .form-row-first,
	body.woocommerce-checkout .form-row-last { grid-column: 1 / -1; }

	/* Cart rows become stacked cards using each cell's data-title */
	body.woocommerce-cart table.cart thead { display: none; }
	body.woocommerce-cart table.cart,
	body.woocommerce-cart table.cart tbody,
	body.woocommerce-cart table.cart tr,
	body.woocommerce-cart table.cart td { display: block; }
	body.woocommerce-cart table.cart tr.cart_item { position: relative; padding: var(--mec-space-4); border-top: 1px solid var(--mec-border); }
	body.woocommerce-cart table.cart tr.cart_item:first-child { border-top: 0; }
	body.woocommerce-cart table.cart tr.cart_item td { padding: var(--mec-space-2) 0; border: 0; }
	body.woocommerce-cart table.cart td[data-title]::before {
		content: attr(data-title) ": ";
		font-size: 12px;
		font-weight: 700;
		letter-spacing: 0.08em;
		text-transform: uppercase;
		color: var(--mec-ink-muted);
	}
	body.woocommerce-cart table.cart td.product-remove { position: absolute; top: var(--mec-space-3); right: var(--mec-space-3); width: auto; padding: 0; }
	body.woocommerce-cart table.cart td.product-thumbnail { width: auto; }
	body.woocommerce-cart table.cart td.product-name[data-title]::before { display: none; }
	body.woocommerce-cart table.cart td.actions { display: flex; padding: var(--mec-space-4); }
	body.woocommerce-cart table.cart td.actions .coupon,
	body.woocommerce-cart table.cart td.actions .coupon input { width: 100%; }
	body.woocommerce-cart .cart_totals table.shop_table tr { display: table-row; }
	body.woocommerce-cart .cart_totals table.shop_table :is(th, td) { display: table-cell; }
	body.woocommerce-cart .cart_totals table.shop_table td[data-title]::before { display: none; }
	body.woocommerce-checkout #order_review,
	body.woocommerce-cart .cart-collaterals .cart_totals { padding: var(--mec-space-5); }
}
