/* ===== Motion =====
   Everything that moves is in this block. People who ask their device for reduced motion
   get none of it: every element is simply in its final state straight away.
   Only transform and opacity are animated (plus the timer ring). */
@media (prefers-reduced-motion:no-preference){
  /* -- reminders: knob slides, bell rings once, settings rise in -- */
  .rm-sw::after{transition:transform .22s var(--ease-spring)}
  .rm-bell i{transition:transform .3s var(--ease-spring) .1s,opacity .2s ease .1s}
  .rm-bell.rm-ring .ico{animation:rmRing .8s var(--ease-out)}
  @keyframes rmRing{15%{transform:rotate(18deg)}35%{transform:rotate(-15deg)}55%{transform:rotate(10deg)}75%{transform:rotate(-5deg)}}
  .rm-body.rm-in{animation:rmIn .18s var(--ease-out) backwards}
  @keyframes rmIn{from{opacity:0;transform:translateY(-6px)}}
  .rm-exp .ico{transition:transform .18s var(--ease-out)}
  .rm-chip,.rm-day span,.rm-allow,.rm-cb,.rm-exp{transition:transform .08s}
  .rm-chip:active,.rm-day:active span,.rm-allow:active,.rm-cb:active,.rm-exp:active{transform:scale(.95)}
  /* -- water row, water toast, guard note -- */
  .wt-plus span,.wt-done{transition:transform .08s}
  .wt-plus:active span,.wt-done:active{transform:scale(.94)}
  .wt-toast{transition:transform .3s var(--ease-out),opacity .25s ease,visibility 0s linear .3s}
  .wt-toast.on{transition:transform .3s var(--ease-out),opacity .25s ease,visibility 0s}
  .g-msg{animation:rmIn .18s var(--ease-out) backwards}
  /* -- views and tabs -- */
  .view.on{animation:viewIn .2s var(--ease-out)}
  .tab.tab-in{animation:tabIn .2s var(--ease-out)}
  .tour-slide{animation:viewIn .3s var(--ease-out)}
  @keyframes viewIn{from{opacity:0;transform:translateY(10px)}}
  @keyframes tabIn{from{opacity:0;transform:translateY(8px)}}

  /* -- landing: first visit only (class "intro" is set once by show()) -- */
  #v-land.intro{animation:none}
  .intro .hdr{animation:fade .4s ease-out backwards}
  .intro .hero{animation:rise .45s var(--ease-out) backwards}
  .intro .hero-art{animation:popIn .55s var(--ease-spring) .12s backwards}
  .intro .big-title{animation:rise .45s var(--ease-out) .28s backwards}
  .intro .tagline{animation:rise .45s var(--ease-out) .36s backwards}
  .intro .hero-copy .btn{animation:rise .45s var(--ease-out) .44s backwards}
  .intro .hero-note{animation:rise .45s var(--ease-out) .52s backwards}
  .intro .speech{animation:bubble .4s var(--ease-spring) .62s backwards}
  @keyframes fade{from{opacity:0}}
  /* first look at the calendar only: streak tiles pop in one after another (--el = time already played, so a re-render never restarts it) */
  .cal-intro .dt.done,.cal-intro .dt.frz{animation:calPop .42s var(--ease-spring) calc(var(--i,0)*24ms + 120ms - var(--el,0ms)) backwards}
  .cal-intro .cd.jr::before,.cal-intro .cd.jl::after{animation:fade .3s ease-out calc(var(--i,0)*24ms + 260ms - var(--el,0ms)) backwards}
  @keyframes calPop{from{opacity:0;transform:scale(.5)}}
  .cal-grid.cal-in,.cal-info.cal-in{animation:fade .2s ease-out}   /* month change / day tap only, never on a plain re-render */
  @keyframes rise{from{opacity:0;transform:translateY(14px)}}
  @keyframes popIn{0%{opacity:0;transform:scale(.6) translateY(20px)}60%{opacity:1}}
  @keyframes bubble{from{opacity:0;transform:scale(.5)}}
  /* idle: Spark floats (the .bob group inside every mascot) and slowly breathes on the landing */
  .bob{animation:bob 3.2s ease-in-out infinite}
  @keyframes bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
  #landSpark svg{transform-origin:50% 96%;animation:breathe 5.5s ease-in-out .8s infinite}
  @keyframes breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.025)}}
  .sheet:not(.on) .bob,.full:not(.on) .bob,.coach:not(.on) .bob,.buddy:not(.on) .bob{animation:none}   /* hidden mascots rest */

  /* -- scroll reveal (classes rv / rv-in are added by JS, so nothing is hidden without it) -- */
  .rv{opacity:0;transform:translateY(16px)}
  .rv.rv-in{opacity:1;transform:none;transition:opacity .45s ease-out var(--d,0ms),transform .45s var(--ease-out) var(--d,0ms)}

  /* -- sheets, dialogs, full-screen overlays -- */
  .sheet{transition:opacity var(--t-med) ease,visibility 0s linear var(--t-med)}
  .sheet.on{transition:opacity var(--t-med) ease,visibility 0s}
  .panel{transition:transform var(--t-med) ease-in}
  .sheet.on .panel{transition:transform .32s var(--ease-out)}
  .full{transform:translateY(12px);transition:opacity .2s ease,transform .2s ease,visibility 0s linear .2s}
  .full.on{transform:none;transition:opacity .2s ease,transform .22s var(--ease-out),visibility 0s}

  /* -- toast, coach, buddy -- */
  .toast{transition:transform .3s var(--ease-out),opacity .25s ease}
  .coach{transition:transform .5s var(--ease-spring),visibility 0s linear .5s}
  .coach.on{transition:transform .5s var(--ease-spring),visibility 0s}
  .coach-bub{transition:opacity .25s ease,transform .25s var(--ease-out)}
  .coach.on .coach-bub{transition-delay:.3s}
  .buddy{transition:transform .5s var(--ease-spring),visibility 0s linear .5s}
  .buddy.on{transition:transform .5s var(--ease-spring),visibility 0s}

  /* -- progress: bars and the trail slide with transform -- */
  .bar i{transition:transform .6s var(--ease-out)}
  .trail .road i,.trail .walker{transition:transform .6s cubic-bezier(.5,0,.3,1)}
  .walker.walking .mascot{animation:hop .3s ease-in-out 2}
  @keyframes hop{50%{transform:translateY(-9px) rotate(-5deg)}}
  #arc{transition:stroke-dashoffset 1s linear}

  /* -- ticking a step or a habit (classes set by the click handlers, never by a plain re-render) -- */
  .just-on .ck,.just-on .hk{animation:ckPop .42s var(--ease-spring)}
  .just-off .ck,.just-off .hk{animation:ckOff .2s ease-out}
  .just-off .t{animation:fade .2s ease-out}
  .step.sweeping .t{text-decoration-color:transparent}
  .strike{animation:sweep .26s ease-out backwards}
  @keyframes ckPop{0%{transform:scale(.6)}55%{transform:scale(1.22)}100%{transform:scale(1)}}
  @keyframes ckOff{from{transform:scale(.88)}}
  @keyframes sweep{from{transform:scaleX(0)}}
  .confetti{display:block;animation:fall .6s cubic-bezier(.2,.6,.4,1) forwards}
  @keyframes fall{0%{opacity:0;transform:translateY(-10px) scale(.4)}20%{opacity:1}100%{transform:translateY(24vh) rotate(200deg) scale(1);opacity:0}}

  /* -- numbers that change, tab icon, mascot reactions -- */
  .bump{display:inline-block;animation:bump .36s var(--ease-spring)}
  .pill.bump{display:flex}
  .stat b.bump{display:block}
  @keyframes bump{0%{transform:scale(1)}40%{transform:scale(1.28)}100%{transform:scale(1)}}
  .nav button.on svg{animation:navPop .3s var(--ease-spring)}
  @keyframes navPop{from{transform:scale(.8) translateY(2px)}}
  .mascot.react{animation:reactHop .45s var(--ease-out)}
  @keyframes reactHop{0%{transform:translateY(0) scale(1)}35%{transform:translateY(-9px) scale(1.05)}70%{transform:translateY(0) scale(.98)}100%{transform:none}}
  /* -- Spark tab cards: save tick pulses once per save, chips arrive once when the card is first seen -- */
  .save-tick.pulse{animation:tickPop .5s var(--ease-spring)}
  .save-tick.pulse::after{animation:tickRing .6s var(--ease-out)}
  @keyframes tickPop{0%{transform:scale(1)}40%{transform:scale(1.3)}100%{transform:scale(1)}}
  @keyframes tickRing{0%{opacity:.7;transform:scale(1)}100%{opacity:0;transform:scale(2.1)}}
  .chip{transition:transform .08s}
  .chips-in .chip,.sheet.on .chip{animation:chipIn .34s var(--ease-spring) backwards}
  .chips-in .chip:nth-child(2),.sheet.on .chip:nth-child(2){animation-delay:70ms}
  .chips-in .chip:nth-child(3),.sheet.on .chip:nth-child(3){animation-delay:140ms}
  .chips-in .bubble{animation:bubbleIn .3s var(--ease-out) backwards;transform-origin:0 100%}
  @keyframes chipIn{from{opacity:0;transform:translateY(8px) scale(.9)}}
  @keyframes bubbleIn{from{opacity:0;transform:scale(.92)}}
  .poke{animation:poke .5s}
  @keyframes poke{30%{transform:translateY(-14px) scale(1.06)}60%{transform:translateY(0) scale(.97)}}
}


/* fix: Spark's sparks float */
.spk{transform-box:fill-box;transform-origin:center;animation:spk 2.4s ease-in-out infinite}
@keyframes spk{0%,100%{opacity:.35;transform:translateY(0) scale(.8)}50%{opacity:1;transform:translateY(-8px) scale(1.15)}}
@media (prefers-reduced-motion:reduce){.spk{animation:none}}
