/* ===========================================================================
 * MOOS Tweaks — floating cart bar.
 *
 * Three rules. All of them fix behaviour around Blocksy's `.ct-floating-bar`
 * rather than restyling it, so the bar stays visually identical to stock.
 *
 * Loaded only on views where the bar can exist — see MOOS_Floating_Bar::enqueue().
 * ======================================================================== */

/* ---------------------------------------------------------------------------
 * 1. Hidden at the footer.
 *
 * Specificity has to beat `.ct-drawer-canvas[data-floating-bar=yes]
 * .ct-floating-bar` from floating-bar.min.css, which is (0,3,0). The selector
 * below is also (0,3,0), so on a tie the winner is whichever stylesheet loads
 * last — and load order across LiteSpeed's combining is not something worth
 * betting on. Hence !important, deliberately.
 *
 * The transform repeats Blocksy's own resting position (--translate-offset,
 * set per bar position in dynamic-styles.php) so the bar slides back out the
 * way it came in rather than just dissolving. The 0.2s opacity/transform
 * transition already on .ct-floating-bar carries both properties for free.
 * ------------------------------------------------------------------------ */
.ct-drawer-canvas .ct-floating-bar.moos-fb-hidden {
	opacity: 0 !important;
	transform: translateY(var(--translate-offset, -70px)) !important;
	pointer-events: none !important;
}

/* ---------------------------------------------------------------------------
 * 2. An invisible bar must not eat clicks.
 *
 * THE BUG this replaces: the bar is `position: fixed` across the full width at
 * the top of the viewport, and Blocksy only sets `display: none` once
 * data-floating-bar="no". On first paint the attribute is absent entirely —
 * neither "yes" nor "no" — so the bar is merely `opacity: 0`: invisible, laid
 * out, and swallowing every click in a 70px strip under the header. That is
 * what the old JS in class-moos-site-tweaks.php was papering over with
 * transitionrun / transitionend listeners.
 *
 * Stated as CSS it needs no script, no listeners, and it holds on the very
 * first frame instead of after the first transition event. "Not fully shown"
 * covers the absent attribute, "no", and Blocksy's two transient states
 * ("no:updating", "yes:start"), all of which are drawn at opacity 0.
 * ------------------------------------------------------------------------ */
.ct-drawer-canvas:not([data-floating-bar="yes"]) .ct-floating-bar {
	pointer-events: none;
}

/* ---------------------------------------------------------------------------
 * 3. Mobile product pages: the bar is there from the first frame.
 *
 * Stock behaviour is scroll-gated. Blocksy registers a dynamic chunk whose
 * intersection target is `.single-product #main-container
 * .single_add_to_cart_button`; only once that button has scrolled out the
 * bottom does floating-cart.js stamp data-floating-bar="yes" on the drawer
 * canvas. Before that the attribute is absent and the bar sits at opacity 0,
 * and once you scroll back up it becomes "no", which floating-bar.min.css
 * draws as display: none.
 *
 * On a phone that means the add-to-cart affordance is missing exactly when the
 * page first lands. Forcing the three properties the chunk drives — display,
 * opacity, transform — pins the bar open regardless of what the attribute
 * currently says. pointer-events has to come back too, because rule 2 above
 * kills it on every state other than "yes".
 *
 * :not(.moos-fb-hidden) is load-bearing. This selector is (0,4,1) against rule
 * 1's (0,3,0), so without the exclusion it would outrank the footer fade-out
 * even though that rule is !important. Excluding the class instead means the
 * footer behaviour is untouched: when moos-floating-bar.js adds moos-fb-hidden
 * these declarations simply stop matching and rule 1 takes over.
 *
 * Desktop is deliberately left scroll-gated — there the summary is in view for
 * far longer and the bar would just be in the way.
 * ------------------------------------------------------------------------ */
@media (max-width: 767px) {
	body.single-product .ct-drawer-canvas .ct-floating-bar:not(.moos-fb-hidden) {
		display: flex !important;
		opacity: 1 !important;
		transform: translateY(0) !important;
		pointer-events: auto !important;
	}
}
