/* motion.css — site-wide motion and interaction feedback (js/ui/motion.js drives the JS half). Loaded last, after the
   page stylesheet, by every page (scripts/gen-pages.mjs).
   Rules for everything in this file:
   • transform / opacity only (filter sparingly); no width / height / top / box-shadow animation on many elements; no
     will-change; nothing here changes an element's size, so nothing shifts (CLS).
   • prefers-reduced-motion: reduce → base.css switches every CSS animation / transition off, and motion.js does not add
     the movement classes or Web Animations at all: the page shows its final state at once.
   • right-to-left (README §5.1): vertical motion needs nothing; every horizontal slide reads var(--mx) (1 LTR, -1 RTL).
     Fills (.seg > i …) are mirrored with the `scale` property, so the `transform` motion.js puts on them mirrors itself.
     Never put motion on the `scale` property (.rtl-flip uses it).
   • the signature cut corner (clip-path) clips shadows and outlines: glows are drawn inside (inset), presses scale the
     whole clipped box, so the corner keeps its shape. */
:root { --mx: 1; --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-io: cubic-bezier(.45, 0, .25, 1); --t-press: 90ms; }
[dir="rtl"] { --mx: -1; }

/* ───────── page enter: main fades in (the first paint is never blank: it starts from 0 for one frame only) ───────── */
.js main { animation: mo-page .26s ease-out; }
@keyframes mo-page { from { opacity: 0; } }

/* ───────── scroll reveal (motion.js adds .rv to blocks below the first screen, .in when they scroll into view) ───────── */
.rv { opacity: 0; transform: translateY(16px); }
.rv.in { opacity: 1; transform: none; transition: opacity .5s var(--ease-out) var(--rv-d, 0ms), transform .6s var(--ease-out) var(--rv-d, 0ms); }
.rv:focus-within { opacity: 1; transform: none; transition: none; } /* keyboard focus never lands on something invisible (instantly, not via .rv.in) */
@media print { .rv { opacity: 1 !important; transform: none !important; } .seg > i, .bar > i, .ranktable .hb i { transform: none !important; } }

/* ───────── buttons: lift on hover (mouse only), press to .97, a light sweep across primary buttons ───────── */
.btn { transition: transform .18s var(--ease-out), filter var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast); -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.97); transition-duration: var(--t-press); }
.btn-primary, .btn-pink, .btn-cyan { position: relative; isolation: isolate; }
.btn-primary::after, .btn-pink::after, .btn-cyan::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.5) 50%, transparent 65%); transform: translateX(calc(var(--mx) * -110%)); }
@media (hover: hover) and (pointer: fine) {
  .btn:not([disabled]):not([aria-disabled="true"]):hover { transform: translateY(-2px); }
  .btn:not([disabled]):hover:active { transform: translateY(-1px) scale(.97); }
  .btn-primary:hover::after, .btn-pink:hover::after, .btn-cyan:hover::after { transform: translateX(calc(var(--mx) * 110%)); transition: transform .7s var(--ease-io); }
  .btn-ghost:not([disabled]):hover { border-color: var(--lime-line); }
  /* arrows inside a button lean the way they point (translate composes with .rtl-flip's scale) */
  .btn .rtl-flip, .btn .icon.rtl-flip, .drawer nav a .icon, .sh-act .rtl-flip, .textlink .rtl-flip { transition: translate .2s var(--ease-out); }
  .btn:hover .rtl-flip, .drawer nav a:hover .icon, .sh-act:hover .rtl-flip, .textlink:hover .rtl-flip { translate: calc(var(--mx) * 3px) 0; }
}
.iconbtn, .linkbtn, .copy, .quick button, .sheet-x, .xchip, .agentchip, .langsw, .netsw summary { transition: transform .15s var(--ease-out), color var(--t-fast), border-color var(--t-fast), background-color var(--t-fast); -webkit-tap-highlight-color: transparent; }
:is(.iconbtn, .copy, .quick button, .sheet-x, .xchip, .agentchip, .langsw, .netsw summary):active { transform: scale(.94); transition-duration: var(--t-press); }

/* ───────── cards: lift + inner lime edge on hover (mouse), a small press on touch ───────── */
:is(.hm-feat, .hm-vcard, .hm-steps > li, .hm-tl-i, .card, .step, .mini, .dx-card, .ag-pillar, .rs-flow li) { transition: transform .25s var(--ease-out), box-shadow .25s ease, border-color .25s ease; }
@media (hover: hover) and (pointer: fine) {
  :is(.hm-feat, .hm-vcard, .hm-steps > li, .hm-tl-i, .card, .step, .mini, .dx-card, .ag-pillar):hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px var(--lime-line), inset 0 -40px 60px -50px var(--lime-a); }
  :root[data-theme="light"] :is(.hm-feat, .hm-vcard, .hm-steps > li, .hm-tl-i, .card, .step, .mini, .dx-card, .ag-pillar):hover { box-shadow: inset 0 0 0 1px var(--lime-line); }
}
/* tap feedback for every tappable row / tile (phones show no hover) */
:is(a.act-a, .db-cell.has-link, .mini, .hm-pills a, .lang-grid .lang-opt, .drawer nav a, a.nsi, .more-panel a, .wallet-menu button, .wallet-menu a, .walletlist button, .tabs [role="tab"], .car-th, .ag-pillar) { -webkit-tap-highlight-color: transparent; }
:is(a.act-a, .hm-pills a, .lang-grid .lang-opt, .drawer nav a, a.nsi, .more-panel a, .wallet-menu button, .wallet-menu a, .walletlist button, .tabs [role="tab"], .car-th) { transition: transform .15s var(--ease-out), background-color var(--t-fast), color var(--t-fast), border-color var(--t-fast); }
:is(a.act-a, .hm-pills a, .lang-grid .lang-opt, .drawer nav a, a.nsi, .more-panel a, .wallet-menu button, .wallet-menu a, .walletlist button, .tabs [role="tab"], .car-th):active { transform: scale(.98); transition-duration: var(--t-press); }
.db-cell.has-link:active, .mini:active, .ag-pillar:active { transform: scale(.985); transition-duration: var(--t-press); }
.db-cell.has-link { transition: background var(--t-fast), transform .15s var(--ease-out); }

/* ───────── top bar: darker + a lime hairline once the page scrolls (height never changes) ───────── */
.top { transition: background-color .25s ease, border-color .25s ease; }
.top::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 1px; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: linear-gradient(90deg, transparent, var(--lime-line) 30%, var(--cyan-line) 70%, transparent); }
.is-scrolled .top { background: color-mix(in srgb, var(--top-bg) 70%, var(--bg)); border-bottom-color: var(--line-2); }
.is-scrolled .top::after { opacity: 1; }
.top .brand .mark { transition: transform .3s var(--ease-out); }
.is-scrolled .top .brand .mark { transform: scale(.88); }
@media (hover: hover) and (pointer: fine) { .top .brand:hover .mark { transform: rotate(-8deg) scale(1.06); } }
.nav > a::before { content: ""; position: absolute; inset-inline: 11px; bottom: 2px; height: 1px; background: var(--muted); transform: scaleX(0); transition: transform .22s var(--ease-out); }
.nav > a:hover::before { transform: scaleX(1); }
.nav > a[aria-current="page"]::before { display: none; }
@media (min-width: 900px) and (max-width: 1199px) { .nav > a::before { inset-inline: 8px; } }

/* ───────── menus (<details>): drop in; chevrons turn ───────── */
details[open] > :is(.more-panel, .netsw-menu) { animation: mo-drop .18s var(--ease-out); transform-origin: top; }
.wallet-menu { animation: mo-drop .18s var(--ease-out); transform-origin: top; }
@keyframes mo-drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
:is(.nav summary, .langsw, .fold summary, .rs-view summary) .icon:last-child { transition: transform .2s var(--ease-out); }
details[open] > summary:is(.langsw) .icon:last-child, .nav details[open] > summary .icon:last-child, .fold[open] > summary .icon:last-child { transform: rotate(180deg); }
/* folds open with a short fade-down */
:is(.accordion details[open] > div, .accordion details[open] > p, .hm-tl-d[open] > ul, .fold[open] > .in, .auto[open] > p, .dg[open] > :not(summary)) { animation: mo-unfold .24s var(--ease-out); }
@keyframes mo-unfold { from { opacity: 0; transform: translateY(-4px); } }
.accordion summary::after, .hm-tl-d summary::after { transition: transform .2s var(--ease-out); }
.accordion details[open] summary::after, .hm-tl-d[open] summary::after { transform: rotate(180deg); }

/* ───────── phone drawer + sheets + one-time language hint ───────── */
.drawer-scrim { animation: mo-fade .22s ease-out; }
.drawer { animation: mo-sheet .32s var(--ease-out); }
.is-closing > .drawer-scrim { animation: mo-fade-out .2s ease-in forwards; }
.is-closing > .drawer { animation: mo-sheet-out .22s ease-in forwards; }
.drawer nav a { animation: mo-rise .36s var(--ease-out) backwards; }
.drawer nav a:nth-child(2) { animation-delay: 30ms; } .drawer nav a:nth-child(3) { animation-delay: 60ms; } .drawer nav a:nth-child(4) { animation-delay: 90ms; }
.drawer nav a:nth-child(5) { animation-delay: 120ms; } .drawer nav a:nth-child(6) { animation-delay: 150ms; } .drawer nav a:nth-child(n+7) { animation-delay: 180ms; }
@keyframes mo-fade { from { opacity: 0; } }
@keyframes mo-fade-out { to { opacity: 0; } }
@keyframes mo-sheet { from { transform: translateY(100%); } }
@keyframes mo-sheet-out { to { transform: translateY(100%); } }
@keyframes mo-rise { from { opacity: 0; transform: translateY(8px); } }
.sheet-bg { animation: mo-fade .2s ease-out; }
.sheet { animation: mo-sheet .3s var(--ease-out); }
@media (min-width: 600px) { .sheet { animation: mo-pop .24s var(--ease-out); } }
@keyframes mo-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.langhint { animation: mo-rise .4s var(--ease-out) .5s backwards; }

/* ───────── bottom tabs: one lime bar slides to the tapped tab ───────── */
.tabs-bottom { --n: 5; --i: 0; }
.tb-ind { position: absolute; top: -1px; inset-inline-start: 0; width: calc(100% / var(--n)); height: 2px; pointer-events: none; opacity: 0;
  transform: translateX(calc(var(--i) * var(--mx) * 100%)); transition: transform .32s var(--ease-out), opacity .2s ease; }
.tb-ind::before { content: ""; position: absolute; inset-block: 0; inset-inline: 30%; background: var(--lime); box-shadow: var(--glow-lime); }
.tabs-bottom.has-ind .tb-ind.on { opacity: 1; }
.tabs-bottom.has-ind [aria-current="page"]::before { display: none; }
.tabs-bottom a .icon, .tabs-bottom button .icon { transition: transform .2s var(--ease-out); }
.tabs-bottom a:active .icon, .tabs-bottom button:active .icon { transform: translateY(1px) scale(.88); transition-duration: var(--t-press); }
.tabs-bottom .is-going { color: var(--lime-ink); }
.tabs-bottom .is-going .icon { transform: translateY(-2px); }

/* ───────── numbers: rolling values keep their box (motion.js locks the width while it counts) ───────── */
.mo-roll { display: inline-block; white-space: nowrap; }
/* countdown: only the digits that change flip in (motion.js); the HH:MM:SS run is its own left-to-right island */
.cd-hms { unicode-bidi: isolate; white-space: nowrap; }
.cd-d { display: inline-block; }

/* ───────── fills: the moving highlight on live bars runs on transform (it sat on background-position) ───────── */
.seg.live > i { overflow: hidden; } /* the shine stays inside the fill, never over the empty track */
.seg.live > i::after { inset: 0; background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%); background-size: auto; animation: mo-shine 2.4s linear infinite; }
@keyframes mo-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.ranktable .hb { overflow: hidden; }

/* ───────── skeleton: a light band sweeps across (transform), the block itself stays still ───────── */
.sk { position: relative; overflow: hidden; background: var(--panel-2); animation: none; }
.sk::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--glass-2), transparent); transform: translateX(-100%); animation: mo-sweep 1.4s ease-in-out infinite; }
[dir="rtl"] .sk::after { animation-direction: reverse; }
@keyframes mo-sweep { to { transform: translateX(100%); } }
.skeleton .sk.line:nth-child(2)::after { animation-delay: .08s; } .skeleton .sk.line:nth-child(3)::after { animation-delay: .16s; } .skeleton .sk.line:nth-child(4)::after { animation-delay: .24s; }

/* ───────── activity feed: new rows drop in with a short lime wash; launch / big reveals pulse their marker ───────── */
.act-i.new { animation: mo-row .5s var(--ease-out); }
.act-i.new .act-a { animation: mo-wash 1.6s ease-out; }
.act-i.new.hot .act-k { animation: mo-ping .7s var(--ease-out) 2; }
@keyframes mo-row { from { opacity: 0; transform: translateY(-10px); } }
@keyframes mo-wash { from { background-color: var(--lime-a); } }
@keyframes mo-ping { 0%, 100% { transform: rotate(45deg) scale(1); } 50% { transform: rotate(45deg) scale(1.9); } }
.act-i.hot .act-a { transition: background-color .3s ease; }

/* ───────── toasts slide down in and fade up out; copy buttons morph to a check ───────── */
.toast { animation: mo-toast .26s var(--ease-out); }
.toast.out { animation: mo-toast-out .2s ease-in forwards; }
@keyframes mo-toast { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
@keyframes mo-toast-out { to { opacity: 0; transform: translateY(-8px); } }
.copy.is-done, .btn-ghost.is-done { color: var(--lime-ink); }
.mo-lbl { display: inline-block; }
.is-done .mo-lbl::before { content: "✓"; display: inline-block; margin-inline-end: .35em; animation: mo-check .35s var(--ease-out); }
@keyframes mo-check { from { opacity: 0; transform: scale(.3) rotate(-20deg); } }

/* ───────── empty states: one calm line with a dim marker ───────── */
p.empty, .hm-msg { animation: mo-fade .3s ease-out; }
p.empty:not(.bad-ink)::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-inline-end: 8px; vertical-align: 2px; background: var(--dim); transform: rotate(45deg); }

/* ───────── home hero: mascot layers (motion.js splits the art only when motion is allowed) ───────── */
.hm-hero-art { --px: 0; --py: 0; --hx: 1; }
.hm-lyr { position: absolute; inset: 0; pointer-events: none; transform: translate3d(calc(var(--px) * var(--d, 0px)), calc(var(--py) * var(--d, 0px)), 0); transition: transform .6s var(--ease-out); }
.hm-lyr img { position: absolute; inset: 0; }
.hm-lyr-lines { --d: -14px; }
.hm-lyr-fly { --d: 9px; animation: mo-float 4.4s ease-in-out infinite alternate; }
.hm-lyr-lines img { opacity: 0; animation: mo-drift 2.6s linear infinite; }
.hm-lyr-lines img + img { animation-delay: -1.3s; }
.hm-lyr-flame { animation: mo-flicker .7s linear infinite; }
@keyframes mo-float { from { translate: 0 4px; } to { translate: 0 -8px; } }
@keyframes mo-drift { 0% { opacity: 0; translate: 0 0; } 25%, 70% { opacity: 1; } 100% { opacity: 0; translate: calc(var(--hx) * -26px) 8px; } }
@keyframes mo-flicker { 0%, 100% { opacity: 1; } 18% { opacity: .78; } 36% { opacity: .96; } 55% { opacity: .7; } 78% { opacity: .92; } }
.hm-hero.is-off :is(.hm-lyr-fly, .hm-lyr-lines img, .hm-lyr-flame) { animation-play-state: paused; }
@media (max-width: 599px) { @keyframes mo-drift { 0% { opacity: 0; translate: 0 0; } 25%, 70% { opacity: 1; } 100% { opacity: 0; translate: calc(var(--hx) * -14px) 5px; } } }
/* the art is mirrored on wide RTL screens (home.css), so the speed lines stream the other way */
@media (min-width: 900px) { [dir="rtl"] .hm-hero-art { --hx: -1; } }
/* hero copy arrives in a short cascade on first paint only: motion.js adds html.mo-ready once it is over, so a block
   that is moved, re-shown or filled later (chips after the first chain read) never plays it again */
.js:not(.mo-ready) .hm-hero-copy > * { animation: mo-rise .5s var(--ease-out) backwards; }
.js:not(.mo-ready) .hm-hero-copy > :nth-child(2) { animation-delay: 40ms; } .js:not(.mo-ready) .hm-hero-copy > :nth-child(3) { animation-delay: 80ms; }
.js:not(.mo-ready) .hm-hero-copy > :nth-child(4) { animation-delay: 120ms; } .js:not(.mo-ready) .hm-hero-copy > :nth-child(5) { animation-delay: 160ms; }
.js:not(.mo-ready) .hm-hero-copy > :nth-child(n+6) { animation-delay: 200ms; }
.hm-pills a { transition: transform .15s var(--ease-out), background-color var(--t-fast), border-color var(--t-fast); }
@media (hover: hover) and (pointer: fine) { .hm-pills a:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.3); } }

/* ───────── reduced motion: final state, no movement (base.css already stops CSS animations / transitions; motion.js
   adds no .rv, no rolling numbers, no flips and no hero layers) ───────── */
@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1; transform: none; }
  :is(.btn, .iconbtn, .linkbtn, .copy, .quick button, .sheet-x, .xchip, .agentchip, .langsw, .netsw summary, a.act-a, .db-cell.has-link, .mini, .hm-pills a,
    .lang-grid .lang-opt, .drawer nav a, a.nsi, .more-panel a, .wallet-menu button, .wallet-menu a, .walletlist button, .tabs [role="tab"], .car-th, .ag-pillar,
    .hm-feat, .hm-vcard, .hm-steps > li, .hm-tl-i, .card, .step, .dx-card):is(:hover, :active),
  .tabs-bottom :is(a, button) .icon, .top .brand .mark { transform: none !important; }
  .btn .rtl-flip, .drawer nav a .icon, .sh-act .rtl-flip, .textlink .rtl-flip { translate: none !important; }
  .btn-primary::after, .btn-pink::after, .btn-cyan::after, .sk::after, .nav > a::before { display: none; }
  /* hero split into layers before the setting changed: the speed lines stay visible, still (one copy) */
  .hm-lyr-lines img:first-child { opacity: 1; }
  .hm-lyr-lines img + img { display: none; }
}
