/**
 * Checkout two-column layout — loads after WooCommerce Blocks to override container queries.
 */

body.theme-checkout .theme-checkout-content,
body.theme-checkout .entry-content.theme-checkout-content,
.theme-checkout .theme-checkout-content,
body.woocommerce-checkout .theme-checkout-content,
body.theme-checkout-page .entry-content.theme-checkout-content {
	--theme-checkout-form: minmax(0, 7fr);
	--theme-checkout-summary: minmax(0, 5fr);
}

.theme-checkout .theme-checkout-content .wp-block-woocommerce-checkout,
body.woocommerce-checkout .theme-checkout-content .wp-block-woocommerce-checkout,
body.theme-checkout-page .entry-content.theme-checkout-content .wp-block-woocommerce-checkout {
	container-type: normal !important;
	width: 100% !important;
	max-width: none !important;
}

.theme-checkout .theme-checkout-content .wc-block-checkout,
body.woocommerce-checkout .theme-checkout-content .wc-block-checkout {
	max-width: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

/* Grid layout root (class added via PHP + JS for Blocks hydration) */
.theme-checkout-columns,
body.theme-checkout .entry-content .wc-block-components-sidebar-layout,
body.theme-checkout .entry-content .wc-block-checkout.wc-block-components-sidebar-layout,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout,
.theme-checkout .theme-checkout-content .wc-block-checkout.is-large,
.theme-checkout .theme-checkout-content .wc-block-checkout.wc-block-components-sidebar-layout,
body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout,
body.woocommerce-checkout .theme-checkout-content .wc-block-checkout.wc-block-components-sidebar-layout,
body.theme-checkout-page .entry-content.theme-checkout-content .wc-block-components-sidebar-layout {
	display: grid !important;
	grid-template-columns: 1fr !important;
	grid-template-areas: "summary" "form" !important;
	row-gap: 2.5rem !important;
	column-gap: 0 !important;
	width: 100% !important;
	max-width: none !important;
	margin: 0 !important;
	flex-direction: unset !important;
	flex-wrap: nowrap !important;
	align-items: start !important;
}

.theme-checkout-columns > .wc-block-components-main,
.theme-checkout-columns > .wc-block-checkout__main,
.theme-checkout-columns > .wp-block-woocommerce-checkout-fields-block,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-components-main,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-checkout__main,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wp-block-woocommerce-checkout-fields-block,
.theme-checkout .theme-checkout-content .wc-block-checkout > .wc-block-checkout__main,
.theme-checkout .theme-checkout-content .wc-block-checkout > .wc-block-components-main,
body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-components-main,
body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-checkout__main,
body.woocommerce-checkout .theme-checkout-content .wc-block-checkout > .wc-block-checkout__main {
	grid-area: form !important;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	flex: unset !important;
	order: unset !important;
}

.theme-checkout-columns > .wc-block-components-sidebar,
.theme-checkout-columns > .wc-block-checkout__sidebar,
.theme-checkout-columns > .wp-block-woocommerce-checkout-totals-block,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-components-sidebar,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-checkout__sidebar,
.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wp-block-woocommerce-checkout-totals-block,
.theme-checkout .theme-checkout-content .wc-block-checkout > .wc-block-checkout__sidebar,
.theme-checkout .theme-checkout-content .wc-block-checkout > .wc-block-components-sidebar,
body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-components-sidebar,
body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout > .wc-block-checkout__sidebar,
body.woocommerce-checkout .theme-checkout-content .wc-block-checkout > .wc-block-checkout__sidebar {
	grid-area: summary !important;
	width: 100% !important;
	max-width: 100% !important;
	min-width: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	flex: unset !important;
	order: unset !important;
}

@media (min-width: 768px) {
	.theme-checkout-columns,
	body.theme-checkout .entry-content .wc-block-components-sidebar-layout,
	body.theme-checkout .entry-content .wc-block-checkout.wc-block-components-sidebar-layout,
	.theme-checkout .theme-checkout-content .wc-block-components-sidebar-layout,
	.theme-checkout .theme-checkout-content .wc-block-checkout.wc-block-components-sidebar-layout,
	body.woocommerce-checkout .theme-checkout-content .wc-block-components-sidebar-layout,
	body.woocommerce-checkout .theme-checkout-content .wc-block-checkout.wc-block-components-sidebar-layout,
	body.theme-checkout-page .entry-content.theme-checkout-content .wc-block-components-sidebar-layout {
		grid-template-columns: var(--theme-checkout-form) var(--theme-checkout-summary) !important;
		grid-template-areas: "form summary" !important;
		column-gap: 3.5rem !important;
	}
}

/* Classic shortcode checkout — two columns via grid; order review wrapped in .theme-checkout-order-review */
body.theme-checkout form.checkout.woocommerce-checkout,
body.woocommerce-checkout form.checkout.woocommerce-checkout,
.theme-checkout form.checkout.woocommerce-checkout {
	display: grid !important;
	grid-template-columns: 1fr !important;
	column-gap: 3.5rem !important;
	row-gap: 2rem !important;
	width: 100% !important;
	max-width: none !important;
	align-items: start !important;
}

body.theme-checkout form.checkout > .woocommerce-form-coupon-toggle,
body.theme-checkout form.checkout > form.checkout_coupon,
body.theme-checkout form.checkout > .woocommerce-NoticeGroup,
body.theme-checkout form.checkout > .woocommerce-notices-wrapper,
body.woocommerce-checkout form.checkout > .woocommerce-form-coupon-toggle,
body.woocommerce-checkout form.checkout > form.checkout_coupon {
	grid-column: 1 / -1 !important;
	width: 100% !important;
}

@media (max-width: 767px) {
	body.theme-checkout form.checkout .theme-checkout-fields-column,
	body.woocommerce-checkout form.checkout .theme-checkout-fields-column {
		grid-column: 1 !important;
		grid-row: 2 !important;
	}

	body.theme-checkout form.checkout .theme-checkout-order-review,
	body.woocommerce-checkout form.checkout .theme-checkout-order-review {
		grid-column: 1 !important;
		grid-row: 1 !important;
	}
}

@media (min-width: 768px) {
	body.theme-checkout form.checkout.woocommerce-checkout,
	body.woocommerce-checkout form.checkout.woocommerce-checkout,
	.theme-checkout form.checkout.woocommerce-checkout {
		grid-template-columns: var(--theme-checkout-form) var(--theme-checkout-summary) !important;
	}

	body.theme-checkout form.checkout .theme-checkout-fields-column,
	body.woocommerce-checkout form.checkout .theme-checkout-fields-column {
		grid-column: 1 !important;
		grid-row: 1 !important;
		width: 100% !important;
		min-width: 0 !important;
		margin: 0 !important;
	}

	body.theme-checkout form.checkout #customer_details,
	body.woocommerce-checkout form.checkout #customer_details {
		width: 100% !important;
		float: none !important;
		margin: 0 !important;
	}

	body.theme-checkout form.checkout .theme-checkout-order-review,
	body.woocommerce-checkout form.checkout .theme-checkout-order-review {
		grid-column: 2 !important;
		grid-row: 1 !important;
		width: 100% !important;
		min-width: 0 !important;
		align-self: start !important;
	}
}
