/* "Your text goes in…" demo cards (Mail / Slack) as a looping story.
   Same pattern as sims.css: pure CSS keyframes on one shared 10s timeline (--dt),
   percentages below are points on it. Every element keeps its static slot the
   whole loop — only opacity, transform, colors and background-size animate, so
   the card never changes size.
   Storyboard: 0–3% rough draft · 3–31% cursor drags the highlight (demo-anim.js) ·
   31–38% Beam rises · 38–44% target chip selects with a press ·
   48–57% draft fades into into the improved text IN THE SAME BOX ·
   56–64% "replaced in place" + Applied reveal · hold · 88–100% fade back. */
.et2 .demo-anim{--dt:10s}
.et2 .demo-anim .swap .draft,.et2 .demo-anim .swap .fixed,.et2 .demo-anim .sel-text,
.et2 .demo-anim .beam,.et2 .demo-anim .chip.on,.et2 .demo-anim .chip.on .num,
.et2 .demo-anim .arrow-row,.et2 .demo-anim .after,.et2 .demo-anim .cur{
  animation-duration:var(--dt);animation-iteration-count:infinite;animation-timing-function:ease-in-out}

/* --skip (set per card by demo-anim.js, % of the loop as a number) starts
   the card past its idle lead-in; negative delay = begin that far in. */
.et2 .demo-anim *{animation-delay:calc(var(--dt) * var(--skip, 0) / -100)}

/* Held on the first frame until the card scrolls into view (demo-anim.js). */
.et2 .demo-anim.is-waiting *{animation-play-state:paused}

/* Draft and improved text share one grid cell: the box is sized by the longer
   of the two up front, so the swap can never reflow the card. */
.et2 .demo-anim .swap{display:grid}
.et2 .demo-anim .swap>*{grid-area:1/1}
.et2 .demo-anim .swap .draft{animation-name:da-draft}
.et2 .demo-anim .swap .fixed{color:var(--ink);opacity:0;animation-name:da-fixed}

/* Selection drawn as two background layers (underline + wash) so it can sweep
   with background-size. Default box-decoration-break:slice lays the wrapped
   fragments out as one line, so the sweep runs line 1 then line 2 like a real
   drag. The transparent 2px border keeps the static box metrics; the underline
   layer paints into it (border-box origin), matching the old border-bottom. */
.et2 .demo-anim .sel-text{
  border-bottom-color:transparent;background-color:transparent;
  background-image:linear-gradient(var(--purple),var(--purple)),linear-gradient(var(--purple-wash),var(--purple-wash));
  background-origin:border-box;background-clip:border-box;background-repeat:no-repeat;
  background-position:0 100%,0 0;background-size:100% 2px,100% 100%;
  animation-name:da-sel}

.et2 .demo-anim .beam{animation-name:da-beam}
/* Target chip starts as a plain chip (values copied from .et2 .beam .chip),
   then takes its selected state (.chip.on) with a small press. */
.et2 .demo-anim .chip.on{animation-name:da-chip}
.et2 .demo-anim .chip.on .num{animation-name:da-num}
.et2 .demo-anim .arrow-row,.et2 .demo-anim .after{animation-name:da-after}

/* Cursor: drags across the draft in step with the highlight sweep, rises to
   the target chip as the Beam appears, presses it at 41% (the chip's press),
   then fades out and returns. Its keyframes hold real pixel stops measured
   from the live text and chip, so demo-anim.js writes them (var() inside
   @keyframes is unreliable in Safari). Hidden until measured so it never
   flashes at 0,0. Cursor SVG and size are shared with sims.css. */
.et2 .demo-anim .cur{left:0;top:0;opacity:0}

/* Draft and improved text swap out-then-in (never both half-visible, which
   reads as a smudge). The highlight resets at 91% while neither text shows, so
   the draft returns un-highlighted (step 1) rather than flashing selected. */
@keyframes da-draft{0%,48%{opacity:1}52%,92%{opacity:0}98%,100%{opacity:1}}
@keyframes da-fixed{0%,52%{opacity:0}57%,88%{opacity:1}92%,100%{opacity:0}}
@keyframes da-sel{0%,8%{background-size:0% 2px,0% 100%}24%,90%{background-size:100% 2px,100% 100%}91%,100%{background-size:0% 2px,0% 100%}}
@keyframes da-beam{0%,31%{opacity:0;transform:translateY(8px)}38%,88%{opacity:1;transform:translateY(0)}96%,100%{opacity:0;transform:translateY(8px)}}
@keyframes da-chip{
  0%,38%{color:rgba(0,0,0,.82);background-color:rgba(0,0,0,.045);border-color:rgba(0,0,0,.08);box-shadow:0 0 0 3px rgba(94,92,230,0);transform:scale(1)}
  41%{transform:scale(.96)}
  44%,90%{color:#4846C8;background-color:rgba(94,92,230,.12);border-color:rgba(94,92,230,.40);box-shadow:0 0 0 3px rgba(94,92,230,.08);transform:scale(1)}
  97%,100%{color:rgba(0,0,0,.82);background-color:rgba(0,0,0,.045);border-color:rgba(0,0,0,.08);box-shadow:0 0 0 3px rgba(94,92,230,0);transform:scale(1)}}
@keyframes da-num{
  0%,38%{color:rgba(0,0,0,.40);background-color:rgba(0,0,0,.05)}
  44%,90%{color:#4846C8;background-color:rgba(94,92,230,.16)}
  97%,100%{color:rgba(0,0,0,.40);background-color:rgba(0,0,0,.05)}}
@keyframes da-after{0%,56%{opacity:0;transform:translateY(4px)}64%,88%{opacity:1;transform:translateY(0)}96%,100%{opacity:0;transform:translateY(4px)}}

/* Motion-sensitive viewers get the full static composition: highlighted draft,
   Beam with the chip selected, and the Applied result. */
@media (prefers-reduced-motion:reduce){
  .et2 .demo-anim *{animation:none!important}
  .et2 .demo-anim .swap .fixed{opacity:0}
  .et2 .demo-anim .cur{display:none}
}
