/*
 * Agape WooCommerce donor journey
 *
 * This layer owns responsive composition around native WooCommerce state.
 * It must not replace product, cart, checkout, or payment behavior.
 */

.agape-mobile-checkout-summary {
	display: none;
}

/* Archive cards stay compact and uniform while WooCommerce owns their data. */
.agape-woo-archive .products,
.agape-woo-archive ul.products,
.agape-woo-archive .wc-block-product-template {
	display: grid !important;
	gap: clamp(0.8rem, 2vw, 1.25rem) !important;
	grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.agape-woo-archive .product,
.agape-woo-archive .wc-block-product {
	background: var(--agape-ui-surface, #fff);
	border: 1px solid var(--agape-ui-border, #dfe5df);
	border-radius: var(--agape-ui-radius, 8px);
	display: flex !important;
	flex-direction: column;
	margin: 0 !important;
	min-width: 0;
	overflow: hidden;
	padding: 0.75rem !important;
	width: auto !important;
}

.agape-woo-archive .product img,
.agape-woo-archive .wc-block-components-product-image img {
	aspect-ratio: 4 / 3;
	height: auto !important;
	object-fit: cover;
	width: 100% !important;
}

.agape-woo-archive .woocommerce-loop-product__title,
.agape-woo-archive .wc-block-components-product-name {
	display: -webkit-box;
	font-size: clamp(0.95rem, 1.5vw, 1.08rem) !important;
	line-height: 1.3 !important;
	margin: 0.65rem 0 0.35rem !important;
	overflow: hidden;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.agape-woo-archive .product .button,
.agape-woo-archive .wc-block-components-product-button {
	margin-top: auto !important;
	min-height: 42px;
	width: 100%;
}

/* Single donation item: media supports the decision without dominating it. */
.agape-woo-single div.product {
	align-items: start;
	display: grid !important;
	gap: clamp(1.25rem, 4vw, 3rem);
	grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
}

.agape-woo-single div.product > .woocommerce-product-gallery,
.agape-woo-single div.product > .summary {
	float: none !important;
	margin: 0 !important;
	min-width: 0;
	width: auto !important;
}

.agape-woo-single .woocommerce-product-gallery__image img {
	max-height: 520px;
	object-fit: cover;
}

.agape-woo-single .product_title {
	font-size: clamp(1.8rem, 3.5vw, 2.65rem) !important;
	line-height: 1.12 !important;
}

.agape-woo-single form.cart {
	align-items: stretch !important;
	display: grid !important;
	gap: 0.65rem !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agape-woo-single form.cart > .quantity,
.agape-woo-single form.cart .woocommerce-variation-add-to-cart > .quantity {
	grid-column: 1 / -1;
	justify-self: start;
}

.agape-woo-single form.cart > .variations,
.agape-woo-single form.cart > .single_variation_wrap {
	grid-column: 1 / -1;
}

.agape-woo-single form.cart .woocommerce-variation-add-to-cart {
	display: grid !important;
	gap: 0.65rem !important;
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agape-woo-single form.cart .quantity,
.agape-woo-single form.cart .button {
	float: none !important;
	margin: 0 !important;
	min-height: 46px;
}

.agape-woo-single form.cart .single_add_to_cart_button {
	grid-column: auto !important;
	justify-content: center;
	width: 100% !important;
}

.agape-cart-sync-blocker {
	align-items: center;
	background: rgba(255, 255, 255, 0.88);
	color: var(--agape-ink, #25312a);
	cursor: wait;
	display: flex;
	font-size: 0.95rem;
	font-weight: 650;
	gap: 0.65rem;
	inset: 0;
	justify-content: center;
	position: fixed;
	z-index: 100000;
}

.agape-cart-sync-blocker[hidden] {
	display: none;
}

.agape-cart-sync-blocker__spinner {
	animation: agape-cart-sync-spin 0.8s linear infinite;
	border: 3px solid rgba(67, 138, 44, 0.2);
	border-radius: 50%;
	border-top-color: var(--agape-action, #438a2c);
	height: 1.35rem;
	width: 1.35rem;
}

@keyframes agape-cart-sync-spin {
	to { transform: rotate(360deg); }
}

.agape-woo-single .related,
.agape-woo-single .upsells {
	grid-column: 1 / -1;
}

.agape-woo-single .related ul.products,
.agape-woo-single .upsells ul.products {
	display: grid !important;
	gap: 1rem;
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Keep cart review and checkout action together before recommendations. */
.agape-woo-cart-page,
.agape-woo-cart-page > .wp-block-post-content {
	box-sizing: border-box;
	width: 100%;
}

.agape-woo-cart-page {
	padding-inline: var(--agape-ui-page-x, clamp(1rem, 4vw, 2rem));
}

.agape-woo-cart-page > .wp-block-post-content {
	margin-inline: auto;
	max-width: 1180px;
}

body.woocommerce-cart .woocommerce {
	align-items: start;
	box-sizing: border-box;
	display: grid !important;
	gap: 1.25rem !important;
	grid-template-columns: minmax(0, 1fr) !important;
	margin-inline: auto;
	max-width: 1180px;
	width: 100%;
}

body.woocommerce-cart .woocommerce-notices-wrapper,
body.woocommerce-cart .agape-cart-breadcrumb {
	grid-column: 1 / -1 !important;
}

body.woocommerce-cart .woocommerce-notices-wrapper {
	order: 5;
}

body.woocommerce-cart .agape-cart-breadcrumb {
	order: 10;
}

body.woocommerce-cart .woocommerce-cart-form {
	grid-column: 1 !important;
	min-width: 0;
	order: 20;
}

body.woocommerce-cart .cart-collaterals {
	display: contents !important;
}

body.woocommerce-cart .cart_totals {
	align-self: start;
	float: none !important;
	grid-column: 1 !important;
	justify-self: end;
	margin: 0 !important;
	max-width: 420px;
	order: 30;
	position: static;
	width: 100% !important;
}

body.woocommerce-cart .cross-sells {
	grid-column: 1 !important;
	margin-top: 0.25rem !important;
	order: 40;
}

body.woocommerce-cart .woocommerce-info,
body.woocommerce-cart .return-to-shop,
body.woocommerce-cart .agape-empty-cart-guidance {
	box-sizing: border-box;
	margin-inline: auto;
	max-width: 760px;
	width: 100%;
}

body.woocommerce-cart .agape-empty-cart-guidance {
	color: var(--agape-muted, #667169);
	margin-block: 0.75rem 1rem;
	text-align: center;
}

body.woocommerce-cart .agape-empty-cart-guidance p {
	margin: 0;
}

body.woocommerce-cart .return-to-shop {
	text-align: center;
}

.agape-sticky-cart__recent {
	display: none;
}

body.woocommerce-cart .agape-sticky-cart,
body.woocommerce-checkout .agape-sticky-cart {
	display: none !important;
}

@media (max-width: 900px) {
	.agape-woo-archive .products,
	.agape-woo-archive ul.products,
	.agape-woo-archive .wc-block-product-template {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}

	.agape-woo-single div.product { grid-template-columns: minmax(0, 1fr); }
	.agape-woo-single .related ul.products,
	.agape-woo-single .upsells ul.products { grid-template-columns: repeat(3, minmax(0, 1fr)); }

	body.woocommerce-cart .woocommerce-cart-form,
	body.woocommerce-cart .cart_totals,
	body.woocommerce-cart .cross-sells {
		grid-column: 1 !important;
	}

	body.woocommerce-cart .cart_totals {
		max-width: none;
		position: static;
	}
}

@media (max-width: 860px) {
	/* Category context remains available through native breadcrumbs. */
	body.tax-product_cat .agape-shop-category-nav,
	body.tax-product_cat .agape-archive-cart-panel {
		display: none !important;
	}
}

@media (max-width: 760px) {
	.agape-woo-archive .products,
	.agape-woo-archive ul.products,
	.agape-woo-archive .wc-block-product-template,
	.agape-woo-single .related ul.products,
	.agape-woo-single .upsells ul.products {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}

	.agape-woo-archive .product,
	.agape-woo-archive .wc-block-product { padding: 0.55rem !important; }
	.agape-woo-archive .product .button { font-size: 0.78rem !important; padding-inline: 0.45rem !important; }
	.agape-woo-single .woocommerce-product-gallery__image img { max-height: 420px; }
	.agape-woo-single form.cart,
	.agape-woo-single form.cart .woocommerce-variation-add-to-cart {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	/* Direct checkout starts with cart context instead of a duplicate notice. */
	.woocommerce-checkout form.checkout .agape-mobile-checkout-summary {
		background: var(--agape-surface, #fff);
		border: 1px solid var(--agape-border, #dde5dc);
		border-radius: var(--agape-radius, 8px);
		display: block;
		grid-column: 1 !important;
		margin: 0 0 0.25rem;
		padding: 0.85rem;
	}

	.agape-mobile-checkout-summary__heading,
	.agape-mobile-checkout-summary__total,
	.agape-mobile-checkout-summary__items li,
	.agape-mobile-checkout-summary__actions {
		align-items: center;
		display: flex;
		gap: 0.75rem;
		justify-content: space-between;
	}

	.agape-mobile-checkout-summary__heading h2 {
		font-size: 1.2rem !important;
		margin: 0 !important;
	}

	.agape-mobile-checkout-summary__heading > span,
	.agape-mobile-checkout-summary__name small {
		color: var(--agape-muted, #667169);
		font-size: 0.82rem;
		white-space: nowrap;
	}

	.agape-mobile-checkout-summary__items {
		border-block: 1px solid var(--agape-border, #dde5dc);
		list-style: none;
		margin: 0.7rem 0;
		padding: 0.25rem 0;
	}

	.agape-mobile-checkout-summary__items li {
		padding: 0.45rem 0;
	}

	.agape-mobile-checkout-summary__name {
		min-width: 0;
		overflow-wrap: anywhere;
	}

	.agape-mobile-checkout-summary__items strong,
	.agape-mobile-checkout-summary__total strong {
		font-size: 0.9rem;
		white-space: nowrap;
	}

	.agape-mobile-checkout-summary__total {
		font-weight: 800;
	}

	.agape-mobile-checkout-summary__actions {
		justify-content: flex-start;
		margin-top: 0.75rem;
	}

	.agape-mobile-checkout-summary__actions a {
		color: var(--agape-action, #438a2c);
		font-size: 0.88rem;
		font-weight: 750;
		text-underline-offset: 0.18em;
	}

	.woocommerce-checkout .agape-checkout-breadcrumb .agape-cart-breadcrumb__actions,
	.woocommerce-checkout #order_review_heading,
	.woocommerce-checkout #order_review .woocommerce-checkout-review-order-table {
		display: none !important;
	}

	.woocommerce-checkout #order_review {
		margin-top: 0 !important;
	}

	/* One mobile cart tray replaces the competing add-to-cart toast. */
	.agape-cart-notice {
		display: none !important;
	}

	.agape-sticky-cart {
		align-items: center;
		border-radius: 10px !important;
		bottom: calc(5.25rem + env(safe-area-inset-bottom)) !important;
		display: grid !important;
		gap: 0.25rem 0.6rem !important;
		grid-template-columns: minmax(0, 1fr) auto auto !important;
		left: 0.65rem !important;
		max-width: none !important;
		padding: 0.55rem 0.6rem !important;
		right: 0.65rem !important;
		transform: none !important;
		width: auto !important;
	}

	.agape-sticky-cart[hidden] {
		display: none !important;
	}

	.agape-sticky-cart__recent {
		color: var(--agape-ink, #25312a);
		font-size: 0.82rem;
		font-weight: 750;
		grid-column: 1 / -1;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.agape-sticky-cart.is-expanded .agape-sticky-cart__recent {
		display: block;
	}

	.agape-sticky-cart__count,
	.agape-sticky-cart__total {
		font-size: 0.78rem !important;
		min-width: 0;
	}

	.agape-sticky-cart__count {
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.agape-sticky-cart__checkout {
		font-size: 0.72rem !important;
		grid-column: auto !important;
		justify-content: center;
		min-height: 36px !important;
		padding: 0.48rem 0.65rem !important;
		width: auto !important;
	}
}

@media (max-width: 359px) {
	.agape-woo-archive .products,
	.agape-woo-archive ul.products,
	.agape-woo-archive .wc-block-product-template,
	.agape-woo-single .related ul.products,
	.agape-woo-single .upsells ul.products {
		grid-template-columns: minmax(0, 1fr) !important;
	}
}
