/* ==========================================================================
   Motion layer — shared by the builder, the viewer and the landing page
   Principles: motion explains cause and effect (what changed, where it came from),
   stays under ~600 ms, uses one family of easings, only animates transform / opacity,
   and disappears completely for people who ask for reduced motion.
   ========================================================================== */
:root { --e-out:cubic-bezier(.22,.9,.2,1); --e-spring:cubic-bezier(.34,1.56,.64,1); --e-io:cubic-bezier(.45,.05,.25,1); }

/* ---------- builder: first load ---------- */
@keyframes m-rise { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:none; } }
@keyframes m-slide-l { from { opacity:0; transform:translateX(-18px); } to { opacity:1; transform:none; } }
@keyframes m-fade { from { opacity:0; } to { opacity:1; } }
body.m-boot .brand { animation:m-slide-l .55s var(--e-out) both; }
body.m-boot .presets { animation:m-slide-l .55s .06s var(--e-out) both; }
body.m-boot details.sec-c { animation:m-slide-l .5s var(--e-out) both; animation-delay:calc(var(--i,0)*45ms + 120ms); }
body.m-boot .panel-foot { animation:m-rise .5s .45s var(--e-out) both; }
body.m-boot .pv-bar, body.m-boot .pv-meta { animation:m-rise .55s .15s var(--e-out) both; }
body.m-boot .mk-stage { animation:m-fade .8s .2s ease both; }
body.m-boot .mk-dev { animation:m-device .9s .25s var(--e-out) both; }
@keyframes m-device { from { opacity:0; translate:0 46px; rotate:-1.2deg; filter:blur(6px); } to { opacity:1; translate:0 0; rotate:0deg; filter:blur(0); } }

/* ---------- controls: feedback on every touch ---------- */
.chip, .btn, .vb-btn, .sw, .fn, .dev, .stl, .zmenu button, .pj-card { transition:transform .18s var(--e-out), background-color .16s, border-color .16s, box-shadow .2s, color .16s; }
.sw:hover, .fn:hover, .dev:hover, .stl:hover { transform:translateY(-2px); box-shadow:0 8px 18px rgba(20,20,20,.12); }
.chip:active, .btn:active, .vb-btn:active, .sw:active, .fn:active, .dev:active, .stl:active { transform:scale(.96); transition-duration:.06s; }
.chip.pop, .sw.pop, .fn.pop, .dev.pop, .stl.pop { animation:m-pop .42s var(--e-spring); }
@keyframes m-pop { 0% { transform:scale(.9); } 60% { transform:scale(1.06); } 100% { transform:scale(1); } }
.tg input[type=checkbox] { transition:transform .15s var(--e-spring); } .tg input:active { transform:scale(.85); }
.btn.primary { position:relative; overflow:hidden; }
.btn.primary::before { content:''; position:absolute; inset:0; background:linear-gradient(110deg,transparent 30%,rgba(255,255,255,.28) 50%,transparent 70%); transform:translateX(-120%); }
.btn.primary:hover::before { transform:translateX(120%); transition:transform .75s var(--e-io); }
.m-ripple { position:absolute; border-radius:50%; background:rgba(255,255,255,.4); transform:scale(0); animation:m-rip .6s var(--e-out) forwards; pointer-events:none; }
@keyframes m-rip { to { transform:scale(1); opacity:0; } }
/* accordion */
details.sec-c > summary { transition:background-color .15s; } details.sec-c > summary:hover { background:var(--hover); }
details.sec-c > summary::before { transition:transform .28s var(--e-out); }
details.sec-c.m-open > .sec-body > * { animation:m-rise .42s var(--e-out) both; animation-delay:calc(var(--j,0)*38ms + 60ms); }
.sec-body { overflow:hidden; }
/* page counter */
.stat b { display:inline-block; font-variant-numeric:tabular-nums; } .stat b.tick { animation:m-tick .4s var(--e-spring); }
@keyframes m-tick { 0% { transform:translateY(40%); opacity:.3; } 100% { transform:none; opacity:1; } }

/* ---------- preview: device ---------- */
.mk-page.mk-in { animation:m-page .5s var(--e-out) both; }
@keyframes m-page { from { opacity:0; transform:translateX(calc(var(--dx,0)*22px)) scale(.992); filter:blur(3px); } to { opacity:1; transform:none; filter:blur(0); } }
.mk-screen::after { content:''; position:absolute; inset:-20% -60%; z-index:5; pointer-events:none; background:linear-gradient(105deg,transparent 42%,rgba(255,255,255,.16) 50%,transparent 58%); transform:translateX(-70%); opacity:0; }
.mk-screen.sweep::after { animation:m-sweep .9s var(--e-io); }
@keyframes m-sweep { 0% { transform:translateX(-70%); opacity:1; } 100% { transform:translateX(70%); opacity:0; } }
.mk-stage:not(.mk-3d):not(.zoomed):not(.panning) .mk-dev:not(.m-still) { animation:m-float 7s ease-in-out infinite; }
@keyframes m-float { 0%,100% { translate:0 0; } 50% { translate:0 -5px; } }
body.m-boot .mk-dev { animation:m-device .9s .25s var(--e-out) both !important; }

/* ---------- viewer: turning pages ---------- */
.vstage .pl-scale { animation:m-turn .34s var(--e-out) both; }
@keyframes m-turn { from { opacity:0; transform:translateX(calc(var(--dir,0)*34px)) scale(.992); } to { opacity:1; transform:none; } }
#viewer:not([hidden]) .vbar { animation:m-drop .45s var(--e-out) both; }
@keyframes m-drop { from { opacity:0; transform:translateY(-100%); } to { opacity:1; transform:none; } }
.outline a { transition:background-color .15s, padding-left .2s var(--e-out); } .outline a:hover { padding-left:26px; }
.vzbadge, #toast { transition-timing-function:var(--e-out); }

/* ---------- dialogs ---------- */
dialog[open] { animation:m-dlg .38s var(--e-out); }
dialog[open]::backdrop { animation:m-fade .3s ease; }
@keyframes m-dlg { from { opacity:0; transform:translateY(18px) scale(.97); } to { opacity:1; transform:none; } }
.bar i { background-size:200% 100%; animation:m-flow 1.6s linear infinite; }
@keyframes m-flow { to { background-position:-200% 0; } }
.done-ic { animation:m-pop .6s var(--e-spring); }

/* ---------- landing ---------- */
.m-pre { opacity:0; transform:translateY(26px); }
.m-in { opacity:1; transform:none; transition:opacity .75s var(--e-out), transform .75s var(--e-out); transition-delay:calc(var(--d,0)*70ms); }
.hero.m-ready .hero-copy > * { animation:m-rise .8s var(--e-out) both; animation-delay:calc(var(--k,0)*90ms + 80ms); }
.hero.m-ready .hero-art { animation:m-device .95s .2s var(--e-out) both; }
.chips-float .fc { animation:m-float 5.5s ease-in-out infinite; } .chips-float .fc:nth-child(2) { animation-delay:-1.8s; } .chips-float .fc:nth-child(3) { animation-delay:-3.4s; }
.hero-art .stage { transition:transform .25s var(--e-out); transform-style:preserve-3d; will-change:transform; }
.nav { transition:box-shadow .3s, background-color .3s, padding .3s; } .nav.on { box-shadow:0 6px 24px rgba(20,20,20,.08); }
.grid article, .plan, .vars figure, .styles figure, .steps li { transition:transform .3s var(--e-out), box-shadow .3s; }
.grid article:hover, .plan:hover, .vars figure:hover, .styles figure:hover { transform:translateY(-5px); box-shadow:0 14px 34px rgba(20,20,20,.12); }
.grid article i { display:inline-block; transition:transform .4s var(--e-spring); } .grid article:hover i { transform:scale(1.25) rotate(-6deg); }
.faq details > p { animation:m-rise .35s var(--e-out); }
.nav-links a { position:relative; } .nav-links a::after { content:''; position:absolute; left:0; right:0; bottom:-4px; height:2px; background:var(--acc); transform:scaleX(0); transform-origin:left; transition:transform .3s var(--e-out); } .nav-links a:hover::after, .nav-links a.cur::after { transform:scaleX(1); }

@media (prefers-reduced-motion:reduce) {
  .m-pre { opacity:1; transform:none; }
  .mk-dev, .chips-float .fc { animation:none !important; }
  .hero-art .stage { transform:none !important; }
}
