/*
 * Components: sticky mobile CTA. Loaded when a block carries the class
 * "revsults-sticky-cta" (parts/sticky-cta.html -> pattern revsults/sticky-cta;
 * inc/assets.php entry "sticky-cta"). Hidden on desktop; on phones and
 * tablets a fixed bar at the bottom with full-width buttons, and the footer
 * and the page's scroll-padding get room so content and keyboard focus stay
 * clear of it (limits below). No motion, so nothing to guard for
 * reduced-motion users.
 */

/* Doubled class: core's "body .is-layout-flex { display: flex }" (0,1,1)
   must not beat the desktop hide. */
.revsults-sticky-cta.revsults-sticky-cta {
	display: none;
}

@media (max-width: 999px) {
	.revsults-sticky-cta.revsults-sticky-cta {
		position: fixed;
		inset: auto 0 0 0;
		z-index: 60;
		display: flex;
		align-items: center;
		gap: 10px;
		box-sizing: border-box;
		width: 100%;
		max-width: none;
		margin: 0;
		padding: 10px 16px;
		padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
		background-color: var(--wp--preset--color--base-2);
		border-top: var(--wp--custom--border--width, 1px) solid var(--wp--preset--color--border);
		box-shadow: 0 -8px 24px -12px color-mix(in srgb, var(--wp--preset--color--contrast) 25%, transparent);
	}

	.revsults-sticky-cta > * {
		margin: 0;
	}

	.revsults-sticky-cta .wp-block-buttons {
		display: flex;
		flex: 1 1 auto;
		flex-wrap: nowrap;
		gap: 10px;
		width: 100%;
	}

	.revsults-sticky-cta .wp-block-button {
		flex: 1 1 0;
		min-width: 0;
		margin: 0;
	}

	.revsults-sticky-cta .wp-block-button__link {
		width: 100%;
		padding: 13px 16px;
		font-size: var(--wp--preset--font-size--small);
		white-space: nowrap;
	}

	/* The bar's room: under the footer, and in the root's scroll-padding.
	   Whatever the browser scrolls into view, keyboard focus or an anchor,
	   it keeps out of that room (WCAG 2.4.11, technique C43; the header's
	   scroll-padding-top is in base.css). Limits: Firefox scrolls only an
	   element that is almost entirely outside it, so part of a tall control
	   can stay under the bar, never all of it; iOS and iPadOS never scroll
	   the page for a focused form control (UIKit moves text fields itself
	   and leaves buttons and checkboxes where they are).
	   One row of buttons is under 72px at the default text size and under
	   4.5rem at larger ones; a child with a taller bar sets
	   settings.custom.layout.stickyCtaHeight (DESIGN-SYSTEM.md 2.6). Like
	   the header's, the padding stops at 35% of the viewport, so a short or
	   zoomed viewport still scrolls by pages. :where() keeps the rule at
	   zero specificity: a child's own root scroll-padding wins. */
	:where(:root:has(.revsults-sticky-cta)) {
		--revsults-sticky-cta-space: calc(var(--wp--custom--layout--sticky-cta-height, max(72px, 4.5rem)) + env(safe-area-inset-bottom, 0px));
		scroll-padding-bottom: min(calc(var(--revsults-sticky-cta-space) + 1rem), 35%);
	}

	:root:has(.revsults-sticky-cta) .wp-site-blocks > footer {
		padding-bottom: var(--revsults-sticky-cta-space);
	}

	/* Core's overlay menu lives in the header's stacking context (z-index
	   50), under the bar, which covered its last links in a phone held
	   sideways: the bar steps aside while the menu is open. */
	.has-modal-open .revsults-sticky-cta.revsults-sticky-cta {
		display: none;
	}
}

/* Firefox for Android keeps the root's scroll-padding inside what the
   on-screen keyboard leaves, though the bar then sits behind the keyboard.
   In a phone held sideways the header's and the bar's padding fill that
   strip, and Firefox centred the caret under the header: while a text
   field has focus there, the bar's padding goes. */
@media (max-width: 999px) and (max-height: 500px) and (pointer: coarse) {
	:where(:root:has(.revsults-sticky-cta):has(:read-write:focus)) {
		scroll-padding-bottom: auto;
	}
}

/* Site Editor: show the part in the flow so it can be edited. */
.editor-styles-wrapper .revsults-sticky-cta.revsults-sticky-cta {
	position: static;
	display: flex;
	gap: 10px;
	box-shadow: none;
}
