/**
 * WEPRO-CTA — Side CTA mobile scroll-away (v5.8.3)
 * ---------------------------------------------------------------------------
 * Loaded ONLY when the site opted in (`side_cta_scroll_hide`, via
 * Side_Cta_Scroll::maybe_enqueue), versioned by filemtime so it cache-busts
 * independently of the plugin version.
 *
 * ── THE TWO CLASSES, AND WHY IT TAKES BOTH ─────────────────────────────────
 *   `.weprocta-sc-scrollhide`  is written by the ENHANCER at init, and only
 *                              after it has confirmed a phone viewport and a
 *                              rail to act on. It is the proof that JavaScript
 *                              is alive on this page.
 *   `.weprocta-sc-away`        is the state itself.
 *
 * Requiring both means a stale cached copy of THIS FILE can never hide a rail
 * on a page whose script did not load: with no JS there is no marker class, so
 * every rule below is inert and the server-rendered rail stands. That is the
 * progressive-enhancement contract the rest of this rail already keeps —
 * JavaScript may only ever reduce something the server already painted in full.
 *
 * ── THE PHONE GATE IS ASSERTED HERE TOO ────────────────────────────────────
 * 768px is also `Side_Cta_Scroll::BREAKPOINT`. A media query cannot read a PHP
 * constant, so the two are kept in step by hand — change one, change the other.
 * The duplication is deliberate rather than lazy: it makes a desktop rail
 * impossible to hide even if the enhancer's own `matchMedia` guard were ever
 * broken by an edit, and it matches the 768px step the rail's phone layout
 * already uses in side-cta-secondary.css rather than inventing a third one.
 */

@media (max-width: 768px) {

	/*
	 * `visibility` IS THE ACCESSIBILITY HALF OF THIS FEATURE, not a
	 * belt-and-braces extra.
	 *
	 * A translated element is still in the box tree: it stays in the tab order
	 * and in the accessibility tree. Withdrawing the rail with `transform`
	 * alone would leave the tabs focusable and screen-reader-announced while
	 * sitting off-screen — a keyboard visitor would tab into the primary CTA
	 * and see focus disappear off the edge of the page, which is the classic
	 * focusable-but-invisible defect. `visibility: hidden` takes the rail out
	 * of both trees, so the withdrawn state is genuinely INERT rather than
	 * merely out of sight, and the enhancer never has to trap, restore or
	 * redirect focus. It also means the state can never be entered while focus
	 * is inside the rail — a hidden element cannot hold focus — so the "never
	 * withdraw a control the visitor is using" guarantee is structural here
	 * rather than a rule that has to be remembered.
	 *
	 * The visibility transition is DELAYED by the length of the movement on the
	 * way out, so the rail stays paintable while it travels, and is
	 * instantaneous on the way back so it is hittable the moment it returns.
	 */
	.weprocta-side-cta-stack.weprocta-sc-scrollhide {
		transition:
			transform 320ms cubic-bezier(0.25, 1, 0.5, 1),
			opacity 240ms ease,
			visibility 0s linear 0s;
	}

	/*
	 * THE TRANSFORM IS RESTATED IN FULL, NOT ADDED TO.
	 *
	 * `.weprocta-side-cta-stack` is centred with
	 * `transform: translateY(-50%) translateY(var(--wsc-offset-y, 0px))`
	 * (side-cta-secondary.css). `transform` is a single property, so a rule
	 * declaring only `translateX(...)` would REPLACE the centring and drop the
	 * rail half its own height down the page for the whole animation. Both
	 * original terms are therefore repeated here, INCLUDING the admin offset
	 * variable, so a site that has set a vertical offset keeps it while
	 * withdrawing.
	 *
	 * 120% rather than 100%: the tab carries an outward box-shadow that would
	 * otherwise stay smeared against the screen edge after the plate itself
	 * had left.
	 */
	.weprocta-side-cta-stack--right.weprocta-sc-scrollhide.weprocta-sc-away {
		transform:
			translateY(-50%)
			translateY(var(--wsc-offset-y, 0px))
			translateX(120%);
	}

	.weprocta-side-cta-stack--left.weprocta-sc-scrollhide.weprocta-sc-away {
		transform:
			translateY(-50%)
			translateY(var(--wsc-offset-y, 0px))
			translateX(-120%);
	}

	.weprocta-side-cta-stack.weprocta-sc-scrollhide.weprocta-sc-away {
		opacity: 0;
		visibility: hidden;
		transition:
			transform 320ms cubic-bezier(0.25, 1, 0.5, 1),
			opacity 240ms ease,
			visibility 0s linear 320ms;
	}

	/*
	 * Reduced motion.
	 *
	 * WHETHER the rail withdraws at all under this preference is a behavioural
	 * choice owned by the enhancer (`side_cta_reduced_motion`), exactly as it
	 * is for auto-collapse — encoding "never hide" in a media query here would
	 * make the site's 'instant' choice unreachable. What this block owns is the
	 * narrow visual half: a site that did choose 'instant' gets the state
	 * change without an animation.
	 */
	@media (prefers-reduced-motion: reduce) {
		.weprocta-side-cta-stack.weprocta-sc-scrollhide,
		.weprocta-side-cta-stack.weprocta-sc-scrollhide.weprocta-sc-away {
			transition: none;
		}
	}
}
