/*
 * REACH Supply cart feedback, controls, and disclosure polish.
 *
 * RS-DS-016: AJAX-refreshed cart actions must retain visible affordances,
 * success notices remain centered, the cart shell stays borderless, and the
 * shipping disclosure provides readable controls with protected inner space.
 *
 * This presentation-only layer is scoped to the WooCommerce cart route.
 * WooCommerce remains authoritative for cart, shipping, tax, and totals.
 */

/* Remove the unnecessary outer frame around the item list and coupon row. */
body.reach-design-system.woocommerce-cart :where(
	.reach-cart-contents-card,
	.woocommerce-cart-form,
	.woocommerce-cart-form table.shop_table.cart,
	.woocommerce-cart-form table.shop_table.cart > tbody
) {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.cart td.actions {
	background: transparent !important;
	border: 0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	margin-top: var(--rs-space-2) !important;
	padding: var(--rs-space-2) 0 0 !important;
}

/* The remove action must stay visible after every WooCommerce AJAX refresh.
 * A CSS mask supplies the icon even when replacement markup contains only the
 * native text glyph and the older inline enhancer no longer runs. */
body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.shop_table.cart .product-remove > a.remove {
	align-items: center !important;
	background: var(--rs-color-error-soft) !important;
	border: 1px solid rgb(163 58 58 / 22%) !important;
	border-radius: var(--rs-radius-sm) !important;
	box-shadow: none !important;
	color: var(--rs-color-error) !important;
	display: grid !important;
	font-size: 0 !important;
	height: 2.125rem !important;
	justify-content: center !important;
	line-height: 0 !important;
	margin: 0 !important;
	max-height: 2.125rem !important;
	max-width: 2.125rem !important;
	min-height: 2.125rem !important;
	min-width: 2.125rem !important;
	opacity: 1 !important;
	padding: 0 !important;
	text-decoration: none !important;
	visibility: visible !important;
	width: 2.125rem !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.shop_table.cart .product-remove > a.remove > svg {
	display: none !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.shop_table.cart .product-remove > a.remove::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 7h16M9 7V4h6v3M7 7l1 13h8l1-13M10 11v5m4-5v5'/%3E%3C/svg%3E");
	-webkit-mask-position: center;
	-webkit-mask-repeat: no-repeat;
	-webkit-mask-size: contain;
	background-color: currentColor;
	content: "" !important;
	display: block !important;
	height: 1rem !important;
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 7h16M9 7V4h6v3M7 7l1 13h8l1-13M10 11v5m4-5v5'/%3E%3C/svg%3E");
	mask-position: center;
	mask-repeat: no-repeat;
	mask-size: contain;
	width: 1rem !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.shop_table.cart .product-remove > a.remove:hover,
body.reach-design-system.woocommerce-cart
.woocommerce-cart-form table.shop_table.cart .product-remove > a.remove:focus-visible {
	background: var(--rs-color-error) !important;
	border-color: var(--rs-color-error) !important;
	color: var(--rs-color-on-ink) !important;
}

/* Center simple success confirmations while preserving actions on notices that
 * contain a restore link or another button. */
body.reach-design-system.woocommerce-cart .woocommerce-notices-wrapper {
	box-sizing: border-box;
	margin-inline: auto !important;
	max-width: 100% !important;
	width: 100% !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-message:not(:has(.restore-item)):not(:has(.button)) {
	align-items: center !important;
	justify-content: center !important;
	margin-inline: auto !important;
	text-align: center !important;
}

/* Shipping estimator: one readable disclosure control with enough internal
 * spacing in both the collapsed and expanded states. */
body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping {
	background: var(--rs-color-surface-soft) !important;
	border: var(--rs-border-default) !important;
	border-radius: var(--rs-radius-md) !important;
	box-sizing: border-box !important;
	overflow: hidden !important;
	padding: var(--rs-space-3) !important;
	width: 100% !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-button {
	align-items: center !important;
	background: var(--rs-color-warning-soft) !important;
	border: 1px solid rgb(226 166 60 / 58%) !important;
	border-radius: 0.625rem !important;
	box-sizing: border-box !important;
	color: var(--rs-color-warning) !important;
	cursor: pointer;
	display: flex !important;
	font-size: 0.9375rem !important;
	font-weight: var(--rs-font-weight-bold) !important;
	gap: var(--rs-space-3) !important;
	justify-content: space-between !important;
	line-height: 1.35 !important;
	margin: 0 !important;
	max-width: 100% !important;
	min-height: 3rem !important;
	min-width: 0 !important;
	overflow-wrap: anywhere;
	padding: 0.75rem 0.875rem !important;
	text-align: left !important;
	text-decoration: none !important;
	white-space: normal !important;
	width: 100% !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-button::after {
	align-items: center;
	color: currentColor !important;
	display: inline-flex;
	flex: 0 0 auto;
	font-size: 1.125rem !important;
	font-weight: var(--rs-font-weight-bold);
	justify-content: center;
	line-height: 1;
	margin-left: auto;
	min-width: 1rem;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping.rs-cart-shipping-open
.shipping-calculator-form:not([hidden]) {
	border-top: var(--rs-border-default) !important;
	column-gap: var(--rs-space-3) !important;
	margin: var(--rs-space-3) 0 0 !important;
	padding: var(--rs-space-4) 0 0 !important;
	row-gap: 0.875rem !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-form :where(label, .form-row label) {
	color: var(--rs-color-ink) !important;
	display: block !important;
	font-size: var(--rs-font-size-sm) !important;
	font-weight: var(--rs-font-weight-bold) !important;
	line-height: 1.4 !important;
	margin: 0 0 0.375rem !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-form :where(
	input,
	select,
	.select2-container,
	.select2-selection--single
) {
	box-sizing: border-box !important;
	max-width: 100% !important;
	min-height: var(--rs-control-height) !important;
	min-width: 0 !important;
	width: 100% !important;
}

/* Normalize the native WooCommerce submit label even when the underlying
 * button text is "Update" in a theme-specific template. */
body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-form :where(
	button[name="calc_shipping"],
	button[type="submit"],
	.button
) {
	align-items: center !important;
	background: var(--rs-color-ink) !important;
	border: 1px solid var(--rs-color-ink) !important;
	border-radius: 0.625rem !important;
	box-sizing: border-box !important;
	color: var(--rs-color-on-ink) !important;
	display: inline-flex !important;
	font-size: 0 !important;
	font-weight: var(--rs-font-weight-bold) !important;
	justify-content: center !important;
	line-height: 1.2 !important;
	margin: 0 !important;
	min-height: 3rem !important;
	padding: 0.75rem 1rem !important;
	text-align: center !important;
	width: 100% !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-form :where(
	button[name="calc_shipping"],
	button[type="submit"],
	.button
)::before {
	content: "Calculate shipping" !important;
	font-size: 0.9375rem !important;
	line-height: 1.2 !important;
}

body.reach-design-system.woocommerce-cart
.woocommerce-shipping-calculator.rs-cart-shipping
.shipping-calculator-form :where(
	button[name="calc_shipping"],
	button[type="submit"],
	.button
)::after {
	content: none !important;
	display: none !important;
}

@media (max-width: 767px) {
	body.reach-design-system.woocommerce-cart .woocommerce-message {
		margin-bottom: var(--rs-space-4) !important;
		padding: 0.875rem var(--rs-space-4) !important;
	}

	body.reach-design-system.woocommerce-cart
	.woocommerce-shipping-calculator.rs-cart-shipping {
		padding: 0.875rem !important;
	}

	body.reach-design-system.woocommerce-cart
	.woocommerce-shipping-calculator.rs-cart-shipping
	.shipping-calculator-button {
		font-size: 1rem !important;
		min-height: 3.375rem !important;
		padding: 0.875rem 1rem !important;
	}

	body.reach-design-system.woocommerce-cart
	.woocommerce-shipping-calculator.rs-cart-shipping.rs-cart-shipping-open
	.shipping-calculator-form:not([hidden]) {
		margin-top: 0.875rem !important;
		padding-top: 1rem !important;
		row-gap: 1rem !important;
	}

	body.reach-design-system.woocommerce-cart
	.woocommerce-shipping-calculator.rs-cart-shipping
	.shipping-calculator-form :where(input, select) {
		font-size: 16px !important;
	}
}
