/* ARENA motion layer — optional. Everything here only works while <html> has the "motion" class.
   To remove all of it: delete the two lines that load motion.css and motion.js in index.html. */

:root { --m-ease: cubic-bezier(.22, 1, .36, 1); --m-spring: cubic-bezier(.34, 1.4, .64, 1); }

/* ---------- on/off switch in the top bar ---------- */
.top .m-toggle { gap: 6px; }
.top .m-toggle .m-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--control); transition: background .2s; }
.top .m-toggle[aria-pressed="true"] .m-dot { background: var(--magenta); }
@media (max-width: 760px) { .top .m-toggle .m-label { display: none; } }

/* ---------- page opens: content rises in softly ---------- */
html.motion .m-enter > .page > * { animation: m-rise .5s var(--m-ease) both; }
html.motion .m-enter > .page > :nth-child(2) { animation-delay: .05s; }
html.motion .m-enter > .page > :nth-child(3) { animation-delay: .1s; }
html.motion .m-enter > .page > :nth-child(4) { animation-delay: .15s; }
html.motion .m-enter > .page > :nth-child(n+5) { animation-delay: .2s; }
@keyframes m-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* the striped pole slides in under the page title */
html.motion .m-enter .title-block .pole { animation: m-pole .9s var(--m-ease) both; }
@keyframes m-pole { from { clip-path: inset(0 100% 0 0); background-position: -60px 0; } to { clip-path: inset(0 0 0 0); background-position: 0 0; } }
html.motion[dir="rtl"] .m-enter .title-block .pole { animation-name: m-pole-rtl; }
@keyframes m-pole-rtl { from { clip-path: inset(0 0 0 100%); background-position: 60px 0; } to { clip-path: inset(0 0 0 0); background-position: 0 0; } }

/* list rows arrive one after the other (first 8 only) */
html.motion .m-enter .todo li, html.motion .m-enter tbody tr { animation: m-rise .45s var(--m-ease) both; }
html.motion .m-enter .todo li:nth-child(2), html.motion .m-enter tbody tr:nth-child(2) { animation-delay: .04s; }
html.motion .m-enter .todo li:nth-child(3), html.motion .m-enter tbody tr:nth-child(3) { animation-delay: .08s; }
html.motion .m-enter .todo li:nth-child(4), html.motion .m-enter tbody tr:nth-child(4) { animation-delay: .12s; }
html.motion .m-enter .todo li:nth-child(5), html.motion .m-enter tbody tr:nth-child(5) { animation-delay: .16s; }
html.motion .m-enter .todo li:nth-child(6), html.motion .m-enter tbody tr:nth-child(6) { animation-delay: .2s; }
html.motion .m-enter .todo li:nth-child(7), html.motion .m-enter tbody tr:nth-child(7) { animation-delay: .24s; }
html.motion .m-enter .todo li:nth-child(n+8), html.motion .m-enter tbody tr:nth-child(n+8) { animation-delay: .28s; }

/* chart bars grow from zero */
html.motion .m-enter .bar-fill { animation: m-grow-x .8s var(--m-ease) .15s both; transform-origin: left center; }
html.motion[dir="rtl"] .m-enter .bar-fill { transform-origin: right center; }
@keyframes m-grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
html.motion .m-enter .col-a, html.motion .m-enter .col-b { animation: m-grow-y .8s var(--m-ease) .15s both; transform-origin: bottom center; }
@keyframes m-grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- buttons: a firm, physical press ---------- */
html.motion .btn { transition: background .15s, border-color .15s, transform .12s var(--m-ease), box-shadow .12s; }
html.motion .btn.primary { box-shadow: inset 0 -3px 0 rgb(0 0 0 / .22), 0 1px 2px rgb(6 16 106 / .25); }
html.motion .btn.primary:active { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgb(0 0 0 / .22); }
html.motion .tile { transition: transform .15s var(--m-ease), box-shadow .15s; }
html.motion .tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgb(6 16 106 / .1); }
html.motion .tile:active { transform: translateY(0); }

/* ---------- dialogs open with a soft lift ---------- */
html.motion .overlay.m-in { animation: m-fade .2s ease-out both; }
html.motion .overlay.m-in .dialog { animation: m-pop .35s var(--m-ease) both; }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-pop { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@media (max-width: 760px) { @keyframes m-pop { from { transform: translateY(100%); } } }

/* ---------- toast grows out of a small pill ("island") ---------- */
html.motion .toast.m-in { animation: m-island .5s var(--m-spring) both; }
@keyframes m-island {
  0% { clip-path: inset(0 calc(50% - 22px) round 99px); opacity: .6; transform: translateY(12px); color: transparent; }
  45% { color: transparent; }
  100% { clip-path: inset(0 0 round 12px); opacity: 1; transform: none; }
}

/* ---------- receipt comes out of a printer, then gets stamped ---------- */
html.motion .m-printer { position: relative; max-width: 640px; padding-top: 14px; overflow: hidden; }
html.motion .m-printer::before { content: ""; position: absolute; inset-inline: -6px; top: 0; height: 14px; border-radius: 8px; background: linear-gradient(var(--heading), #1E2A8C); box-shadow: 0 4px 8px rgb(6 16 106 / .25); z-index: 2; }
html.motion .m-printer::after { content: ""; position: absolute; inset-inline: 10px; top: 9px; height: 3px; border-radius: 3px; background: #000048; z-index: 3; }
html.motion .m-printer > .receipt { position: relative; animation: m-feed 1.5s steps(14, end) .15s both, m-settle .3s var(--m-ease) 1.65s both; }
@keyframes m-feed { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes m-settle { from { transform: translateY(-2px); } to { transform: none; } }
html.motion .m-stamp {
  position: absolute; inset-inline-start: 50%; bottom: 26px; z-index: 4; pointer-events: none;
  border: 3px solid var(--blue); color: var(--blue); border-radius: 8px; padding: 4px 16px 6px;
  font-weight: 800; font-size: calc(24px * var(--scale)); letter-spacing: .04em; line-height: 1.2; text-align: center;
  transform: rotate(-11deg); opacity: .82; mix-blend-mode: multiply; background: transparent;
  animation: m-stamp .45s cubic-bezier(.5, 0, .75, 0) 1.95s both;
}
html.motion .m-stamp.bad { border-color: var(--danger); color: var(--danger); }
@media (max-width: 560px) { html.motion .m-stamp { inset-inline-start: 36%; bottom: 16px; } }
html.motion .m-stamp small { display: block; font-family: var(--brand); font-size: .55em; letter-spacing: .2em; font-weight: 600; }
@keyframes m-stamp { from { opacity: 0; transform: rotate(-4deg) scale(2.4); } 85% { opacity: .9; transform: rotate(-11deg) scale(.96); } to { opacity: .82; transform: rotate(-11deg) scale(1); } }
html.motion .m-printer .foot img { animation: m-seal .4s var(--m-spring) 1.75s both; }
@keyframes m-seal { from { opacity: 0; transform: scale(1.6); } }
html.motion .m-static > .receipt, html.motion .m-static .m-stamp, html.motion .m-static .foot img { animation: none; }
@media print { html .dialog > .m-printer:not(.paper-wrap):not(.card-stage):not(.print-area) { display: block !important; } .m-printer { overflow: visible !important; padding: 0 !important; max-width: none !important; } .m-printer::before, .m-printer::after, .m-stamp { display: none !important; } .m-printer > .receipt { animation: none !important; } }

/* ---------- dangerous actions: press and hold ---------- */
html.motion .btn.m-hold { position: relative; overflow: hidden; isolation: isolate; touch-action: none; user-select: none; -webkit-user-select: none; }
html.motion .btn.m-hold .m-fill { position: absolute; inset: 0; background: #F1C3BD; transform: scaleX(0); transform-origin: left center; z-index: -1; transition: transform .25s ease-out; }
html.motion[dir="rtl"] .btn.m-hold .m-fill { transform-origin: right center; }
html.motion .btn.m-hold.holding .m-fill { transform: scaleX(1); transition: transform 1.1s linear; }
html.motion .btn.m-hold.holding { border-color: var(--danger); }
html.motion .btn.m-hold.done { color: var(--white); border-color: var(--danger); }
html.motion .btn.m-hold.done .m-fill { transform: scaleX(1); transition: none; background: var(--danger); }
html.motion .m-hold-hint { font-size: var(--fs-meta); color: var(--muted); margin: -6px 0 0; }
html.motion .m-hold-hint.nudge { color: var(--danger); animation: m-nudge .35s ease-out; }
@keyframes m-nudge { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* ---------- opening screen: the horse head appears, the pole slides in ---------- */
.m-splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--frame); animation: m-splash-out .45s ease-in 1.5s both; pointer-events: none; }
.m-splash .m-mark { display: grid; justify-items: center; gap: 18px; }
.m-splash img { width: 120px; height: 120px; animation: m-reveal 1s var(--m-ease) both; }
.m-splash .pole { width: 160px; animation: m-pole .8s var(--m-ease) .5s both; }
@keyframes m-reveal { from { clip-path: circle(0% at 50% 60%); opacity: .4; } to { clip-path: circle(75% at 50% 60%); opacity: 1; } }
@keyframes m-splash-out { to { opacity: 0; visibility: hidden; } }

/* ---------- confetti for a certificate (brand colours, once) ---------- */
.m-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* people who asked their phone or PC for less motion get none of this */
@media (prefers-reduced-motion: reduce) {
  html.motion *, html.motion *::before, html.motion *::after, .m-splash, .m-splash * { animation: none !important; transition: none !important; }
  .m-splash { display: none; }
}

/* printing never shows movement: a page printed mid-animation could come out blank */
@media print {
  html.motion *, html.motion *::before, html.motion *::after { animation: none !important; transition: none !important; }
  .m-splash, .m-confetti { display: none !important; }
}
