/* Chrysalis v2: the WhatsApp button stays on screen, phones and computers (Claude, 21 Nov 2026). Switch and notes:
   inc/v2/v2-wa-show.php. Script: v2-wa-show.js. Loaded only while the switch is on, and never on the cart or the checkout
   (body.chv2-wa-show is not printed there, so those two pages keep today's rules). The same rules at every width.

   html.was-ready  the script has placed the button once (until then it waits, as phones do today; shown after 3 s anyway)
   html.was-hide   no place within 160 px clears the buy control or field under it: it steps aside, as before, until clear
   --was-lift      how far it has moved from its usual place, px: up (positive) to clear a buy control or a field; down
                   (negative) only on a phone product page while the buy bar is away, into the bar's empty lane

   Shown: the theme's own "off" states no longer apply (chrome.js's cl3-wa-off, the homepage's chv2-wa-off and hxp-wa-off, the
   product page's cl-wa--purchase-visible, the reading pages' pbm-rd fade and step-aside, the Library's lc-reading), and the
   phone account screens show it too (phone.css and v2-dark.css had it off there).
   Still hidden: while the age gate or a first-visit screen, the menu, the cart or search sheet, Build a Stack's sheet, the
   calculator's sheet, the install card or the phone keyboard is open. The words bubble (wa-tip.js) is untouched: it reads the
   button's own state, as before. Moving uses the separate translate property, so opacity keeps its own fade. */
:root{--was-glide:.32s;--was-fade:.25s}
@media (prefers-reduced-motion:reduce){:root{--was-glide:0s;--was-fade:0s}}
@keyframes chv2-wa-show-late{to{opacity:1;visibility:visible}}

/* its place: the usual spot, moved by --was-lift, in every state (so it never glides in from somewhere else); no other
   transform (the Library's reading step-aside and chrome.js's 8 px drop belonged to the old hiding) */
html body.chv2-wa-show .cl-wa.cl-wa{translate:0 calc(-1 * var(--was-lift,0px)) !important;transform:none !important}

/* until the script has placed it once (a moment after the page is read) */
html:not(.no-js):not(.was-ready) body.chv2-wa-show .cl-wa.cl-wa{opacity:0;visibility:hidden;transition:none;animation:chv2-wa-show-late 0s linear 3s forwards}

/* hidden while the gate or a first-visit screen, the menu, a sheet (cart, search, Build a Stack, the calculator's sheet, the
   install card) or the phone keyboard is open (a keyboard user who has tabbed to it keeps it) */
html:is(.cl-locked,.cl-menu-open,.cl-gate-pending,.ld3-gate-on,.ld3-intro,.cl-ov-open,.sx-open,.k3c1a-lock,.ao-hint-on,.cl3-pb-kb) body.chv2-wa-show .cl-wa.cl-wa:not(:focus-visible){
  opacity:0 !important;visibility:hidden !important;pointer-events:none !important}

/* shown */
html.was-ready:not(.was-hide):not(.cl-locked):not(.cl-menu-open):not(.cl-gate-pending):not(.ld3-gate-on):not(.ld3-intro):not(.cl-ov-open):not(.sx-open):not(.k3c1a-lock):not(.ao-hint-on):not(.cl3-pb-kb) body.chv2-wa-show .cl-wa.cl-wa{
  opacity:1 !important;visibility:visible !important;pointer-events:auto !important;
  transition:background-color .15s ease,opacity var(--was-fade) ease,transform var(--was-fade) ease,visibility 0s linear 0s,translate var(--was-glide) cubic-bezier(.2,.7,.2,1) !important}

/* stepped aside: no place within 160 px clears the control under it; a new place is taken at once, unseen */
html.was-ready.was-hide body.chv2-wa-show .cl-wa.cl-wa:not(:focus-visible){
  opacity:0 !important;visibility:hidden !important;pointer-events:none !important;transform:translateY(8px) !important;
  transition:opacity .2s ease,transform .2s ease,visibility 0s linear .2s,translate 0s !important}
@media (prefers-reduced-motion:reduce){
  html.was-ready.was-hide body.chv2-wa-show .cl-wa.cl-wa:not(:focus-visible){transition:none !important}
}

/* the phone account screens (signed in, sign-in, the account calculator) */
@media screen and (max-width:899.98px){
  body.chv2-wa-show:is(.cl-acp,.chv2-si,.chv2-ca) .cl-wa.cl-wa:not(#chv2-wa-show-x){display:grid !important}
}

/* 600 px and wider: the "Added to cart" message lifts the button above it (v2-fix2-fyd.js); it keeps doing so, from whichever of
   the two places is higher */
@media (min-width:600px){
  html.fyd-wa-up body.chv2-wa-show .cl-wa.cl-wa{translate:0 calc(-1 * max(var(--was-lift,0px),var(--fyd-wa-lift,0px))) !important}
}
