/* ORVÉA fx: buttons — micro-interactions for every control.
   Everything hangs off ONE inherited switch, --fx-buttons-on (0 → 1): hover on
   fine pointers, :active on touch, :focus-visible on keyboards. Transforms and
   opacity only. All of it needs js/fx/buttons.js (letter spans, twin asterisk),
   so every rule sits under html.js and the plain page is left untouched. */

html.js :is(.pill,.link,.nav ul a,.nav-bag):is(:active,:focus-visible){--fx-buttons-on:1}
@media (hover:hover) and (pointer:fine){
  html.js :is(.pill,.link,.nav ul a,.nav-bag):hover{--fx-buttons-on:1}
}

/* ---------- letter roll: each letter slides up to a duplicate parked below its mask ---------- */
.fx-buttons-roll{display:inline-flex;overflow:hidden}
.fx-buttons-roll .fx-buttons-ch{position:relative;display:block;white-space:pre;
  transform:translate3d(0,calc(var(--fx-buttons-on,0)*-100%),0);
  /* stagger order: --fx-buttons-i on the way in, --fx-buttons-o on the way out */
  transition:transform .5s cubic-bezier(.6,0,.2,1) calc((var(--fx-buttons-on,0)*var(--fx-buttons-i,0) + (1 - var(--fx-buttons-on,0))*var(--fx-buttons-o,0))*20ms)}
.fx-buttons-roll .fx-buttons-ch::after{content:attr(data-ch);position:absolute;left:0;top:100%;color:var(--fx-buttons-label,currentColor)}
/* bag: the core greys every span in it, so hand "Bag" its ink back; the count answers in vermilion */
html.js .nav-bag>.fx-buttons-roll,html.js .nav-bag>.fx-buttons-roll>.fx-buttons-ch{color:inherit}
html.js .nav-bag>span:not(.fx-buttons-roll) .fx-buttons-ch::after{color:var(--verm)}

/* ---------- pill: the asterisk disc floods the button, the label flips behind the wave ---------- */
html.js .pill{position:relative;overflow:hidden;isolation:isolate;--fx-buttons-fill:var(--ink);--fx-buttons-label:var(--paper)}
html.js .closing .pill{--fx-buttons-fill:var(--chalk);--fx-buttons-label:var(--ink)} /* on the dark panel it inverts to chalk */
/* a circle centred on the disc, wide enough to cover any label; the pill radius clips it */
html.js .pill::before{content:"";position:absolute;z-index:-1;right:1.85em;top:50%;width:calc(200% + 2em);aspect-ratio:1;border-radius:50%;
  background:var(--fx-buttons-fill);
  transform:translate(50%,-50%) scale(var(--fx-buttons-on,0));
  /* timed so the wave front reaches each letter as it starts to roll (front at the first letter ~175 ms,
     at the far end ~390 ms); any faster and the ink label sits invisible on the ink fill until it flips */
  transition:transform .75s cubic-bezier(.4,.1,.3,1);
  will-change:transform} /* rastered once at full size, then only composited */
/* a tap only holds :active for ~100 ms, so on touch the wave leaves the disc at once to be seen at all */
@media (hover:none),(pointer:coarse){html.js .pill::before{transition-timing-function:cubic-bezier(.3,.6,.2,1)}
  /* ...and the label must keep up with it, or the ink letters vanish into the ink fill for the whole press */
  html.js .pill .fx-buttons-ch{transition:transform .34s cubic-bezier(.2,.7,.2,1) calc(var(--fx-buttons-o,0)*6ms)}}

/* the disc: swells on hover, squishes under the press, springs back on release */
html.js .pill-ast{position:relative;isolation:isolate;
  transform:scale(calc(1 + var(--fx-buttons-on,0)*.07));
  transition:transform .55s var(--spring)}
html.js .pill:active .pill-ast{transform:scale(.8);transition:transform .11s ease-out}
/* inverted disc face: vermilion pops in over the ink, the ink twin asterisk takes over */
html.js .pill-ast::before{content:"";position:absolute;inset:0;z-index:-1;border-radius:50%;background:var(--verm);
  transform:scale(var(--fx-buttons-on,0));
  transition:transform .5s var(--spring) .06s}
html.js .pill .pill-ast svg{grid-area:1/1;
  transform:rotate(calc(var(--fx-buttons-on,0)*360deg)); /* full turn, overshoots and settles */
  transition:transform .95s var(--spring),opacity .2s linear .08s}
html.js .pill .pill-ast svg:first-of-type{opacity:calc(1 - var(--fx-buttons-on,0))}
html.js .pill .pill-ast .fx-buttons-ast2{color:var(--ink);opacity:var(--fx-buttons-on,0)}

/* ---------- text link: vermilion rule draws over the hairline, asterisk takes a full turn ---------- */
html.js .link{position:relative}
html.js .link::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;background:var(--verm);
  transform:scaleX(var(--fx-buttons-on,0));transform-origin:0 50%;
  transition:transform .55s var(--out)}
html.js .link svg{transform:rotate(calc(var(--fx-buttons-on,0)*360deg));transition:transform .95s var(--spring)}

/* ---------- wordmark: a quick wave runs through the letters (class set by JS, always plays out) ---------- */
.fx-buttons-wave .fx-buttons-ch{display:inline-block}
.fx-buttons-go .fx-buttons-ch{animation:fx-buttons-wave .6s cubic-bezier(.3,.7,.3,1) calc(var(--fx-buttons-i,0)*45ms) both}
@keyframes fx-buttons-wave{
  35%{transform:translate3d(0,-.3em,0) rotate(-8deg)}
  70%{transform:translate3d(0,.05em,0) rotate(3deg)}
}

/* ---------- click burst: pooled asterisks and sparkles in one fixed layer ---------- */
.fx-buttons-burst{position:fixed;inset:0;z-index:60;overflow:hidden;pointer-events:none}
.fx-buttons-bit{position:absolute;left:-8px;top:-8px;width:16px;height:16px;color:var(--verm);opacity:0}
