/* ------------------------------------------------------------------ *
 * Side-cart: Advanced Coupons deal breakdown.
 *
 * ACFW appends its per-item summary INTO FunnelKit's coupon amount cell:
 *
 *   <div class="fkcart-summary-amount">-<ul class="acfw-bogo-summary">…</ul></div>
 *
 * That cell is `display:flex; align-items:center` and (via the child theme's
 * price rule) `white-space: nowrap`, so the list sits on the same line as the
 * amount and the product name runs off the right edge of the panel.
 *
 * Fix: drop the cell onto its own full-width line and lay each deal out as a
 * name/price pair — name free to wrap, price never.
 *
 * The `-` in the markup above is hardcoded by FunnelKit's own template
 * (templates/cart/order-summary.php) and is meaningless once bootstrap.php has
 * removed the always-zero BOGO amount. It is a bare text node with no element
 * to target, so `font-size: 0` on the cell swallows it and the element children
 * get their size back. Normal (non-BOGO) coupon rows keep their minus sign —
 * they never carry one of these lists, so `:has()` leaves them alone.
 *
 * `:has()` is the load-bearing selector here. Where it is unsupported the row
 * simply renders as it does today: no regression, just no fix.
 * ------------------------------------------------------------------ */

#fkcart-modal .fkcart-coupon-applied:has(.acfw-bogo-summary),
#fkcart-modal .fkcart-coupon-applied:has(.acfw-add-products-summary),
#fkcart-modal .fkcart-coupon-applied:has(.acfw-shipping-overrides-summary) {
	flex-wrap: wrap;
}

#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-bogo-summary),
#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-add-products-summary),
#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-shipping-overrides-summary) {
	flex: 1 0 100%;
	display: block;
	min-width: 0;
	/* Beat the child theme's `#fkcart-modal .fkcart-summary-amount { white-space: nowrap }`. */
	white-space: normal;
	/* Swallows FunnelKit's hardcoded "-" text node. */
	font-size: 0;
}

#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-bogo-summary) > *,
#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-add-products-summary) > *,
#fkcart-modal .fkcart-coupon-applied .fkcart-summary-amount:has(.acfw-shipping-overrides-summary) > * {
	font-size: 14px;
}

#fkcart-modal .acfw-bogo-summary,
#fkcart-modal .acfw-add-products-summary,
#fkcart-modal .acfw-shipping-overrides-summary {
	/* ACFW hardcodes style="margin: 10px" on the <ul>. */
	margin: 6px 0 0 !important;
	padding: 0;
	width: 100%;
	list-style: none;
}

#fkcart-modal .acfw-bogo-summary li,
#fkcart-modal .acfw-add-products-summary li,
#fkcart-modal .acfw-shipping-overrides-summary li {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 12px;
	line-height: 1.35;
	color: var(--fkcart-secondary-text-color, #6b6b6b);
}

#fkcart-modal .acfw-bogo-summary li + li,
#fkcart-modal .acfw-add-products-summary li + li,
#fkcart-modal .acfw-shipping-overrides-summary li + li {
	margin-top: 2px;
}

/* Product names are long and localized — let them wrap instead of overflowing. */
#fkcart-modal .acfw-bogo-summary .label,
#fkcart-modal .acfw-add-products-summary .label,
#fkcart-modal .acfw-shipping-overrides-summary .label {
	flex: 1 1 auto;
	min-width: 0;
	text-align: left;
	white-space: normal;
	overflow-wrap: anywhere;
}

#fkcart-modal .acfw-bogo-summary .discount,
#fkcart-modal .acfw-add-products-summary .discount,
#fkcart-modal .acfw-shipping-overrides-summary .discount {
	flex: 0 0 auto;
	white-space: nowrap;
	font-weight: 500;
	color: var(--fkcart-coupon-text-price-color, #5ba238);
}
