/*
 * Lynn's Engraving – Express Checkout buttons (Apple Pay, Google Pay, PayPal, Venmo):
 * one row, every visible button the same width and height, on Checkout and Cart (WooCommerce Blocks).
 *
 * DOM (WC 10.4.4 + Square 5.2.0 + PayPal Payments 3.4.1):
 *   ul.wc-block-components-express-payment__event-buttons
 *     li#express-payment-method-square-credit-card      <- ONE li for BOTH Square wallets
 *       div.apple-pay-button.wc-square-wallet-buttons    (display:none until Apple Pay is available)
 *       div                                             (Google Pay mounts its button here)
 *     li#express-payment-method-ppcp-gateway-paypal
 *     li#express-payment-method-ppcp-gateway-venmo
 * The Square li is flattened (display:contents) so Apple Pay and Google Pay become their own
 * equal-width flex items next to PayPal and Venmo.
 */
.wc-block-components-express-payment {
	--lynns-xp-height: 40px;
	--lynns-xp-gap: 8px;
	--lynns-xp-radius: 4px;
}

.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons {
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: stretch !important;
	gap: var(--lynns-xp-gap) !important;
	grid-template-columns: none !important;
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
	width: 100% !important;
}

.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons > li,
.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons > div {
	flex: 1 1 0 !important;
	min-width: 0 !important;
	max-width: none !important;
	width: auto !important;
	height: var(--lynns-xp-height) !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 0 !important;
	overflow: hidden;
	border-radius: var(--lynns-xp-radius);
	box-sizing: border-box;
}

/* Loading skeletons: same size as the real buttons (no jump when they load). */
.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons > li > .wc-block-components-skeleton__element {
	height: var(--lynns-xp-height) !important;
	border-radius: var(--lynns-xp-radius);
}

/* Square: flatten the shared li so Apple Pay and Google Pay are separate, equal items. */
.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons > #express-payment-method-square-credit-card {
	display: contents !important;
}
#express-payment-method-square-credit-card > div {
	flex: 1 1 0;
	min-width: 0 !important;
	width: auto !important;
	height: var(--lynns-xp-height) !important;
	min-height: 0 !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 0;
	border-radius: var(--lynns-xp-radius);
	overflow: hidden;
	box-sizing: border-box;
}
/* Google Pay container stays empty when Google Pay is unavailable: take no slot. */
#express-payment-method-square-credit-card > div:empty {
	display: none !important;
}
/* Apple Pay: Square sets display:block inline only when Apple Pay is available; do not touch display. */
#express-payment-method-square-credit-card > .apple-pay-button {
	border-radius: var(--lynns-xp-radius);
}
#express-payment-method-square-credit-card > div > div,
#express-payment-method-square-credit-card > div button,
#express-payment-method-square-credit-card #gpay-button-online-api-id {
	width: 100% !important;
	min-width: 0 !important;
	height: 100% !important;
	min-height: 0 !important;
	margin: 0 !important;
	border-radius: var(--lynns-xp-radius) !important;
	box-sizing: border-box;
}

/*
 * v1.2.5 – Apple Pay drawn as a plain 40px CSS box (padding: 0 on the outer flex/grid item so all 4 buttons
 * get identical flex/grid widths), with ::before matching Google Pay's inner button 1-to-1 (100% x 100%,
 * padding 11px 10% 9px desktop / 10px 7% 8px <480px phone, content-box origin, and 104x17 vector SVG).
 * Only applies when Square sets inline "display: block" (Apple Pay available), so Chrome/Firefox stay hidden.
 */
#express-payment-method-square-credit-card > .apple-pay-button {
	height: var(--lynns-xp-height) !important;
	margin: 0 !important;
	padding: 0 !important;
	box-shadow: none !important;
	border-radius: var(--lynns-xp-radius) !important;
	overflow: hidden !important;
}
#express-payment-method-square-credit-card > .apple-pay-button[style*="display: block"] {
	--lynns-ap-svg: url("data:image/svg+xml,%3Csvg%20width%3D%22104%22%20height%3D%2217%22%20viewBox%3D%220%200%20104%2017%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22%23FFF%22%20fill-rule%3D%22evenodd%22%20transform%3D%22translate(1.68,0)%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm7.36%201.68c-.868%200-1.528-.259-1.981-.777-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322zm7.878-.616L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zM40.7%204.824a1%201%200%200%201-.735-.301%201%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301zm-.77%201.036h1.54V13h-1.54V5.86zm6.464%207.252c-.317%200-.616-.051-.896-.154a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21zm2.782-10.136h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976z%22%2F%3E%3Cpath%20d%3D%22M12.152%206.896c-.948%200-2.415-1.078-3.96-1.04-2.04.027-3.91%201.183-4.961%203.014-2.117%203.675-.546%209.103%201.519%2012.09%201.013%201.454%202.208%203.09%203.792%203.039%201.52-.065%202.09-.987%203.935-.987%201.831%200%202.35.987%203.96.948%201.637-.026%202.676-1.48%203.676-2.948%201.156-1.688%201.636-3.325%201.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04%202.48-4.494%202.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675%201.09-4.61%201.09zM15.53%203.83c.843-1.012%201.4-2.427%201.245-3.83-1.207.052-2.662.805-3.532%201.818-.78.896-1.454%202.338-1.273%203.714%201.338.104%202.715-.688%203.559-1.701%22%20fill-rule%3D%22nonzero%22%20transform%3D%22translate(61.36,%20-0.15)%20scale(0.5563)%22%2F%3E%3Cpath%20d%3D%22M81.795%202.629v4.097h2.554c.608%200%201.11-.203%201.509-.607a1.96%201.96%200%200%200%20.613-1.442c0-.546-.205-1.022-.613-1.427-.398-.415-.901-.622-1.51-.622h-2.553zm0%205.539v4.753H80.27V1.186h4.045c1.028%200%201.901.34%202.62%201.016.73.677%201.094%201.503%201.094%202.475%200%20.994-.364%201.825-1.094%202.49-.708.668-1.581%201-2.62%201h-2.52v.001zm7.775%202.294c0%20.394.17.722.507.984.337.262.732.393%201.185.393.641%200%201.213-.235%201.716-.704.503-.47.754-1.022.754-1.655-.476-.372-1.139-.557-1.99-.557-.62%200-1.135.148-1.55.443-.414.295-.621.66-.621%201.096m1.973-5.834c1.128%200%202.018.298%202.67.893.652.596.978%201.413.978%202.45v4.95h-1.459v-1.115h-.066c-.63.918-1.47%201.377-2.52%201.377-.896%200-1.645-.262-2.247-.787-.602-.524-.904-1.18-.904-1.966%200-.831.318-1.491.953-1.983.636-.492%201.484-.738%202.545-.738.906%200%201.653.164%202.238.492v-.345c0-.524-.21-.97-.63-1.335a2.175%202.175%200%200%200-1.475-.55c-.852%200-1.525.356-2.023%201.067L88.261%206.2c.74-1.049%201.835-1.573%203.283-1.573m12.021.263l-5.09%2011.57h-1.576l1.89-4.048L95.44%204.89h1.658l2.421%205.77h.033l2.355-5.77z%22%20transform%3D%22translate(-3.07,%200)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
	-webkit-appearance: none !important;
	appearance: none !important;
	display: block !important;
	position: relative !important;
	width: auto !important;
	min-width: 0 !important;
	max-width: none !important;
	height: var(--lynns-xp-height) !important;
	min-height: 0 !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	box-sizing: border-box !important;
	background: #000 !important;
	cursor: pointer;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}
#express-payment-method-square-credit-card > .apple-pay-button[style*="display: block"]::before {
	content: "" !important;
	display: block !important;
	width: 100% !important;
	height: 100% !important;
	margin: 0 !important;
	padding: 11px 10% 9px !important;
	box-sizing: border-box !important;
	background-image: var(--lynns-ap-svg) !important;
	background-origin: content-box !important;
	background-position: center center !important;
	background-repeat: no-repeat !important;
	background-size: contain !important;
	pointer-events: none !important;
}
#express-payment-method-square-credit-card > .apple-pay-button.wc-square-wallet-button-white[style*="display: block"],
#express-payment-method-square-credit-card > .apple-pay-button.wc-square-wallet-button-white-outline[style*="display: block"] {
	--lynns-ap-svg: url("data:image/svg+xml,%3Csvg%20width%3D%22104%22%20height%3D%2217%22%20viewBox%3D%220%200%20104%2017%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22%23000%22%20fill-rule%3D%22evenodd%22%20transform%3D%22translate(1.68,0)%22%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm7.36%201.68c-.868%200-1.528-.259-1.981-.777-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322zm7.878-.616L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zM40.7%204.824a1%201%200%200%201-.735-.301%201%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301zm-.77%201.036h1.54V13h-1.54V5.86zm6.464%207.252c-.317%200-.616-.051-.896-.154a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21zm2.782-10.136h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976z%22%2F%3E%3Cpath%20d%3D%22M12.152%206.896c-.948%200-2.415-1.078-3.96-1.04-2.04.027-3.91%201.183-4.961%203.014-2.117%203.675-.546%209.103%201.519%2012.09%201.013%201.454%202.208%203.09%203.792%203.039%201.52-.065%202.09-.987%203.935-.987%201.831%200%202.35.987%203.96.948%201.637-.026%202.676-1.48%203.676-2.948%201.156-1.688%201.636-3.325%201.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04%202.48-4.494%202.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675%201.09-4.61%201.09zM15.53%203.83c.843-1.012%201.4-2.427%201.245-3.83-1.207.052-2.662.805-3.532%201.818-.78.896-1.454%202.338-1.273%203.714%201.338.104%202.715-.688%203.559-1.701%22%20fill-rule%3D%22nonzero%22%20transform%3D%22translate(61.36,%20-0.15)%20scale(0.5563)%22%2F%3E%3Cpath%20d%3D%22M81.795%202.629v4.097h2.554c.608%200%201.11-.203%201.509-.607a1.96%201.96%200%200%200%20.613-1.442c0-.546-.205-1.022-.613-1.427-.398-.415-.901-.622-1.51-.622h-2.553zm0%205.539v4.753H80.27V1.186h4.045c1.028%200%201.901.34%202.62%201.016.73.677%201.094%201.503%201.094%202.475%200%20.994-.364%201.825-1.094%202.49-.708.668-1.581%201-2.62%201h-2.52v.001zm7.775%202.294c0%20.394.17.722.507.984.337.262.732.393%201.185.393.641%200%201.213-.235%201.716-.704.503-.47.754-1.022.754-1.655-.476-.372-1.139-.557-1.99-.557-.62%200-1.135.148-1.55.443-.414.295-.621.66-.621%201.096m1.973-5.834c1.128%200%202.018.298%202.67.893.652.596.978%201.413.978%202.45v4.95h-1.459v-1.115h-.066c-.63.918-1.47%201.377-2.52%201.377-.896%200-1.645-.262-2.247-.787-.602-.524-.904-1.18-.904-1.966%200-.831.318-1.491.953-1.983.636-.492%201.484-.738%202.545-.738.906%200%201.653.164%202.238.492v-.345c0-.524-.21-.97-.63-1.335a2.175%202.175%200%200%200-1.475-.55c-.852%200-1.525.356-2.023%201.067L88.261%206.2c.74-1.049%201.835-1.573%203.283-1.573m12.021.263l-5.09%2011.57h-1.576l1.89-4.048L95.44%204.89h1.658l2.421%205.77h.033l2.355-5.77z%22%20transform%3D%22translate(-3.07,%200)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
	background: #fff !important;
}
#express-payment-method-square-credit-card > .apple-pay-button.wc-square-wallet-button-white-outline[style*="display: block"] {
	border: 1px solid #000 !important;
}
#express-payment-method-square-credit-card > .apple-pay-button[style*="display: block"] > * {
	display: none !important;
}
/*
 * Google Pay: "Buy with G Pay" is a background SVG (gstatic dark/en.svg, background-size:contain,
 * content-box) inside button#gpay-button-online-api-id; Google pads it 12px 15% 10px (18px tall glyph
 * area). Less padding = a slightly bigger wording (20px tall on desktop, ~10-15% wider on phones).
 */
#express-payment-method-square-credit-card .gpay-button-fill > .gpay-button.long,
#express-payment-method-square-credit-card .gpay-button-fill > .gpay-button.buy,
#express-payment-method-square-credit-card #gpay-button-online-api-id.gpay-button {
	padding: 11px 10% 9px !important;
	background-size: contain !important;
	background-position: center center !important;
}

/* PayPal / Venmo (height 40 comes natively from the block's buttonHeight; this keeps the box exact). */
.wc-block-components-express-payment li[id^="express-payment-method-ppcp-"] > div,
.wc-block-components-express-payment li[id^="express-payment-method-ppcp-"] .paypal-buttons {
	width: 100% !important;
	min-width: 0 !important;
	height: var(--lynns-xp-height) !important;
	margin: 0 !important;
}

/* Cart sidebar variant: same single row (WC stacks these with 12px bottom padding by default). */
.wc-block-components-express-payment--cart .wc-block-components-express-payment__event-buttons > li,
.wc-block-components-express-payment--cart .wc-block-components-express-payment__event-buttons > div {
	padding-bottom: 0 !important;
}

/*
 * Phones. PayPal/Venmo SDK buttons need >= ~75px width. On this theme the checkout box is
 * ~268px wide on a 390px phone, so:
 *  - 2 or 3 buttons (e.g. Android: Google Pay, PayPal, Venmo): one row, ~80px each.
 *  - 4 buttons (iPhone with Apple Pay + Google Pay + PayPal + Venmo) would be ~56px each and
 *    PayPal/Venmo clip, so they become an equal 2 x 2 grid (same width/height for all four).
 *  - Very small phones (< 360px): equal 2-column grid.
 */
@media (max-width: 479px) {
	.wc-block-components-express-payment {
		--lynns-xp-gap: 6px;
	}
	#express-payment-method-square-credit-card > .apple-pay-button[style*="display: block"]::before,
	#express-payment-method-square-credit-card .gpay-button-fill > .gpay-button.long,
	#express-payment-method-square-credit-card .gpay-button-fill > .gpay-button.buy,
	#express-payment-method-square-credit-card #gpay-button-online-api-id.gpay-button {
		padding: 10px 7% 8px !important;
	}
	.wc-block-components-express-payment--checkout .wc-block-components-express-payment__content {
		padding-left: 8px !important;
		padding-right: 8px !important;
	}
	.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons:has(.apple-pay-button[style*="display: block"]):has(#express-payment-method-square-credit-card > div:not(.apple-pay-button):not(:empty)):has(li[id^="express-payment-method-ppcp-"] + li[id^="express-payment-method-ppcp-"]) {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}
@media (max-width: 359px) {
	.wc-block-components-express-payment .wc-block-components-express-payment__event-buttons {
		display: grid !important;
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}
}
