/*
 * Express checkout buttons (Stripe: Apple Pay, Google Pay, Link; PayPal: PayPal, Pay in 4) on product pages, the cart
 * and checkout: side by side instead of one per line, and their space held while they load so nothing below them moves.
 * express-buttons.js keeps it held while Stripe rebuilds them after every cart or checkout update.
 */

/*
 * Stripe makes each button at least 260px wide, which put them one per line on phones and in the product column.
 * 110px fits "Buy with Apple Pay" (Stripe draws nothing below ~100px), so 3 share a row from 346px and wrap 2 + 1 below.
 * "body" outranks Stripe's same rules, which product pages load after this file.
 */
body #wc-stripe-express-checkout-element {
	gap: 8px;
}
body #wc-stripe-express-checkout-element > div {
	flex: 1 1 110px;
	min-width: 110px;
	min-height: 48px;
}
/*
 * Google Pay's button lightens on hover; Apple Pay's and Link's don't, and their insides are Stripe's frames, out of
 * reach. Fade their boxes instead: black to ~#333, close to Google's #3c4043, and Link's green a shade lighter.
 */
body #wc-stripe-express-checkout-element > div {
	transition: opacity 0.15s;
}
body #wc-stripe-express-checkout-element > :is(#wc-stripe-express-checkout-element-applePay, #wc-stripe-express-checkout-element-link):hover {
	opacity: 0.8;
}

/*
 * Stripe prints its buttons' box and the checkout's "— OR —" hidden (style="...display:none;") and shows them once its
 * script has loaded, seconds later. Keep their room until then, and (.ufs-xc-hold) while Stripe rebuilds the buttons;
 * a hide() by Stripe itself writes "display: none" and isn't overridden. .ufs-xc-done: Stripe has no buttons to show.
 * Before Stripe adds the buttons' boxes, two blank ones (110px and 2 x 110px + gap) wrap like its usual three do.
 */
#wc-stripe-express-checkout-element:not(.ufs-xc-done)[style*="display:none"],
#wc-stripe-express-checkout-element.ufs-xc-hold[style*="display: none"] {
	display: flex !important;
	visibility: hidden;
}
#wc-stripe-express-checkout-element:not(.ufs-xc-done)[style*="display:none"]:not(:has(> div))::before,
#wc-stripe-express-checkout-element.ufs-xc-hold[style*="display: none"]:not(:has(> div))::before {
	content: "";
	flex: 1 1 110px;
	min-width: 110px;
	height: 48px;
}
#wc-stripe-express-checkout-element:not(.ufs-xc-done)[style*="display:none"]:not(:has(> div))::after,
#wc-stripe-express-checkout-element.ufs-xc-hold[style*="display: none"]:not(:has(> div))::after {
	content: "";
	flex: 1 1 228px;
	min-width: 228px;
	height: 48px;
}
#wc-stripe-express-checkout-button-separator:not(.ufs-xc-done)[style*="display:none"],
#wc-stripe-express-checkout-button-separator.ufs-xc-hold[style*="display: none"] {
	display: block !important;
	visibility: hidden;
}

/* PayPal and Pay in 4 side by side (PayPal stacks them 14px apart), with room for them in the cart before they load */
.ppc-button-wrapper > #ppc-button-ppcp-gateway-v6 {
	flex-flow: row wrap;
	gap: 8px;
}
.ppc-button-wrapper > #ppc-button-ppcp-gateway-v6 > * {
	flex: 1 1 110px;
	min-width: 110px;
}
.wc-proceed-to-checkout .ppc-button-wrapper {
	min-height: 48px;
	margin-top: 8px;
}
/* PayPal's "Pay in 4 interest-free payments of $x. Learn more" above the cart's checkout button: 1 line, 2 on phones */
.wc-proceed-to-checkout .ppcp-messages {
	min-height: var(--ufs-xc-msg, 21px);
}
@media (max-width: 767px) {
	.wc-proceed-to-checkout .ppcp-messages {
		min-height: var(--ufs-xc-msg, 41px);
	}
}

/*
 * The same line under the product page's buttons (shown for every price), which pushed the delivery box and the rest of
 * the column down when it arrived. It wraps to 2 lines in a column narrower than ~365px (phones, tablets), and is 4px
 * taller for a moment while it draws.
 */
.single-product .summary.entry-summary {
	container-type: inline-size;
}
.single-product .summary > .ppcp-messages {
	min-height: 25px;
}
@container (max-width: 365px) {
	.single-product .summary > .ppcp-messages {
		min-height: 46px;
	}
}
