/* ============ Elybean · motion ============
   Everything that moves lives behind html[data-motion="on"].
   Hidden-before-reveal states also require html.js, so the page stays readable if scripts fail. */

:root { --intro: 1.95s; }
html.seen { --intro: .1s; }

/* ---------- preloader ---------- */
.preloader { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bean); color: var(--ink); pointer-events: none; animation: pl-out .75s cubic-bezier(.75,0,.2,1) 1.75s forwards; }
.preloader::after { content: ''; position: absolute; left: 0; right: 0; bottom: -29px; height: 30px; background: var(--bean); transform: scaleY(-1);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 30'%3E%3Cpath d='M0 26h64v4H0z'/%3E%3Cpath d='M9 30C3 23 5 11 17 9c8-1 12 4 18 3 8-2 18-3 21 6 3 8-1 12-3 12Z'/%3E%3C/svg%3E") 0 100% / 64px 30px repeat-x;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 30'%3E%3Cpath d='M0 26h64v4H0z'/%3E%3Cpath d='M9 30C3 23 5 11 17 9c8-1 12 4 18 3 8-2 18-3 21 6 3 8-1 12-3 12Z'/%3E%3C/svg%3E") 0 100% / 64px 30px repeat-x; }
html.seen .preloader, html[data-motion="off"] .preloader, html:not([data-motion]) .preloader { display: none; }
.pl-inner { display: grid; justify-items: center; gap: 4px; position: relative; z-index: 1; }
.pl-inner img { width: 140px; animation: pl-bounce .5s cubic-bezier(.3,0,.6,1) infinite alternate; }
@property --pct { syntax: '<integer>'; initial-value: 0; inherits: false; }
.pl-count { font: 900 clamp(80px, 13vw, 160px)/1 Rubik, sans-serif; letter-spacing: -.05em; color: var(--cream); -webkit-text-stroke: .04em var(--ink); paint-order: stroke fill; text-shadow: .03em .05em 0 var(--ink); counter-reset: pct var(--pct); animation: pl-count 1.55s cubic-bezier(.3,.1,.3,1) forwards; font-variant-numeric: tabular-nums; }
.pl-count::before { content: counter(pct) '%'; }
.pl-lines { position: relative; height: 34px; width: 320px; }
.pl-lines span { position: absolute; inset: 0; text-align: center; font: 600 21px/1.4 var(--hand); opacity: 0; animation: pl-line .44s calc(var(--i) * .42s) both; }
.pl-lines span:last-child { animation-name: pl-line-last; }
.pl-rain i { position: absolute; top: -8%; left: calc(var(--i) * 7.2% + 1%); width: 34px; height: 22px; border-radius: 55% 45% 50% 50% / 60% 60% 40% 40%; border: 2.5px solid var(--ink); background: var(--gold); opacity: .9; animation: pl-fall 1.7s linear calc(var(--i) * -.37s) infinite; }
.pl-rain i:nth-child(3n) { background: var(--pink); }
.pl-rain i:nth-child(3n+1) { background: #fff; }
.pl-rain i:nth-child(4n) { background: var(--grass); }
@keyframes pl-out { to { transform: translateY(calc(-100% - 40px)); visibility: hidden; } }
@keyframes pl-bounce { from { transform: translateY(0) scale(1.06, .94); } to { transform: translateY(-26px) scale(.97, 1.03) rotate(6deg); } }
@keyframes pl-count { to { --pct: 100; } }
@keyframes pl-line { 0% { opacity: 0; transform: translateY(10px); } 20%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes pl-line-last { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pl-fall { from { transform: translateY(0) rotate(0deg); } to { transform: translateY(115vh) rotate(400deg); } }

/* ---------- tickers ---------- */
html[data-motion="on"] .ticker-track { animation: marquee 36s linear infinite; }
html[data-motion="on"] .tick-a .ticker-track { animation-duration: 26s; }
html[data-motion="on"] .tick-b .ticker-track { animation-duration: 30s; animation-direction: reverse; }
html[data-motion="on"] .ticker:hover .ticker-track { animation-play-state: paused; }
html[data-motion="on"] .tickers:not(.in-view) .ticker-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- hero ---------- */
html[data-motion="on"] .hero .wordmark { translate: 0 calc(var(--depart, 0) * 70px); }
html[data-motion="on"] .wordmark span {
  animation: letter-hop .9s cubic-bezier(.2,.9,.3,1.35) calc(var(--intro) + var(--i) * 65ms) both,
             letter-wave 7s ease-in-out calc(var(--intro) + 2.4s + var(--i) * 110ms) infinite;
  transition: transform .45s cubic-bezier(.3,1.9,.5,1);
}
html[data-motion="on"] .wordmark span:hover { transform: translateY(-.1em) scale(1.12, .86); }
@keyframes letter-hop { from { translate: 0 80%; scale: .5; opacity: 0; } 60% { opacity: 1; } to { translate: 0 0; scale: 1; opacity: 1; } }
@keyframes letter-wave { 0%, 12%, 100% { translate: 0 0; } 5% { translate: 0 -.09em; } }
html[data-motion="on"] .kicker { animation: drop-tag .7s cubic-bezier(.3,1.6,.5,1) calc(var(--intro) + .05s) both; }
@keyframes drop-tag { from { translate: 0 -40px; opacity: 0; rotate: 12deg; } }
html[data-motion="on"] .hero-sky { translate: 0 calc(var(--depart, 0) * 90px); }
html[data-motion="on"] .bean-button { animation: bean-pop 1s cubic-bezier(.3,1.55,.45,1) calc(var(--intro) + .4s) both; }
@keyframes bean-pop { from { translate: 0 70%; opacity: 0; } 30% { opacity: 1; } }
html[data-motion="on"] .hero.in-view .bean-button img:not(.jump) { animation: peek-bob 3.4s ease-in-out infinite; }
@keyframes peek-bob { 0%, 100% { transform: none; } 50% { transform: translateY(-3%) scale(1.01, 1.03); } }
@keyframes bean-bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-16px) rotate(3deg); } }
html[data-motion="on"] .bean-tilt { transform: rotate(calc(var(--mx, 0) * 3deg)); transition: transform .5s cubic-bezier(.2,.8,.3,1); }
html[data-motion="on"] .rays { animation: rays-in 1s ease-out calc(var(--intro) + .5s) both, spin 40s linear infinite; }
@keyframes rays-in { from { opacity: 0; scale: .4; } }
@keyframes spin { to { rotate: 360deg; } }
html[data-motion="on"] .chat { animation: chat-pop .5s cubic-bezier(.3,1.8,.5,1) both; }
html[data-motion="on"] .hero .chat:not(.reacted) { animation-delay: calc(var(--intro) + 1.1s); }
@keyframes chat-pop { from { scale: .3; opacity: 0; rotate: -10deg; } }
html[data-motion="on"] .hero-copy { animation: rise .8s cubic-bezier(.2,.8,.2,1) calc(var(--intro) + .55s) both; }
@keyframes rise { from { translate: 0 40px; opacity: 0; } }
html[data-motion="on"] .hero-tagline span:last-child { animation: wobble-in .8s cubic-bezier(.3,1.7,.5,1) calc(var(--intro) + .8s) both; }
@keyframes wobble-in { from { rotate: -6deg; scale: .7; } }
html[data-motion="on"] .drag { animation: sticker-in .7s cubic-bezier(.3,1.7,.5,1) calc(var(--intro) + 1s + var(--k, 0) * .1s) both, idle-float 4.2s ease-in-out calc(var(--k, 0) * -.7s) infinite alternate; }
.drag:nth-child(2) { --k: 1; } .drag:nth-child(3) { --k: 2; } .drag:nth-child(4) { --k: 3; } .drag:nth-child(5) { --k: 4; } .drag:nth-child(6) { --k: 5; }
html[data-motion="on"] .hero:not(.in-view) .drag, html[data-motion="on"] .drag.dragging { animation-play-state: paused; }
@keyframes sticker-in { from { scale: 0; opacity: 0; } }
html[data-motion="on"] .hero.in-view .hero-fly { animation: hero-fly 7s ease-in-out infinite, flutter-x .26s ease-in-out infinite alternate; }
@keyframes hero-fly { 0%, 100% { transform: translate(0, 0) rotate(-8deg); } 30% { transform: translate(60%, -70%) rotate(10deg); } 55% { transform: translate(150%, -40%) rotate(16deg); } 80% { transform: translate(40%, 20%) rotate(-4deg); } }
@keyframes flutter-x { from { scale: .7 1; } to { scale: 1 1; } }
@keyframes idle-float { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-10px) rotate(4deg); } }
@keyframes flutter { from { transform: scaleX(.7) rotate(-4deg); } to { transform: scaleX(1) rotate(3deg); } }
html[data-motion="on"] .drag { transition: scale .25s cubic-bezier(.3,1.8,.5,1); }
html[data-motion="on"] .drag:hover { scale: 1.08; }
html[data-motion="on"] .drag.dragging { scale: 1.15; }
html[data-motion="on"] .drag-hint:not(.gone) svg { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translate(4px, 4px); } }

/* ---------- chapter 02 · dictionary ---------- */
html.js[data-motion="on"] .cards li:not(.revealed) { opacity: 0; }
html[data-motion="on"] .cards li.revealed { animation: deal .8s cubic-bezier(.25,1.4,.45,1) calc(var(--i) * 60ms) both; }
@keyframes deal { from { opacity: 0; translate: 0 90px; rotate: calc(var(--i) * 9deg - 40deg); scale: .7; } }
html[data-motion="on"] .dictionary.in-view .dict-bean img { animation: bean-bob 3.4s ease-in-out infinite; }
html[data-motion="on"] .card:hover .card-art { translate: 0 -6px; rotate: -4deg; }
html[data-motion="on"] .dict-progress.done { animation: chat-pop .6s cubic-bezier(.3,1.8,.5,1); }

/* ---------- chapter 03 · trail ---------- */
html[data-motion="on"] .trail.in-view .trail-walker img { animation: walk .32s ease-in-out infinite alternate; }
@keyframes walk { from { rotate: -9deg; transform: translateY(0); } to { rotate: 9deg; transform: translateY(-7px); } }
html.js[data-motion="on"] .stop .postcard { transition: opacity .5s, scale .6s cubic-bezier(.3,1.6,.5,1), filter .5s; }
html.js[data-motion="on"] .stop:not(.reached) .postcard { opacity: .45; scale: .93; filter: saturate(.3); }
html[data-motion="on"] .stop.reached .prop { animation: prop-pop .7s cubic-bezier(.3,1.9,.5,1) both, prop-drift 3.2s ease-in-out .7s infinite alternate; }
@keyframes prop-pop { from { scale: 0; rotate: -40deg; } }
@keyframes prop-drift { from { transform: translateY(0) rotate(-10deg); } to { transform: translateY(-12px) rotate(10deg); } }
html[data-motion="on"] .stop.live.reached .status .dot { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #42cf7fcc; } 100% { box-shadow: 0 0 0 10px #42cf7f00; } }

/* ---------- free to boop ---------- */
html[data-motion="on"] .free-lines span { --dir: 1; translate: calc(max(0, .42 - var(--progress, .42)) * 110vw * var(--dir)) 0; }
html[data-motion="on"] .free-lines span:nth-child(2n) { --dir: -1; }
html[data-motion="on"] .freeboop.in-view .free-lines img { animation: spin-hop 2.4s cubic-bezier(.3,1.5,.5,1) infinite; }
@keyframes spin-hop { 0%, 60%, 100% { transform: none; } 75% { transform: translateY(-.3em) rotate(-20deg); } 88% { transform: translateY(0) rotate(8deg) scale(1.1, .9); } }

/* ---------- chapter 04 · bean jar ---------- */
html[data-motion="on"] .medal-hang { animation: swing 3.6s ease-in-out infinite alternate; }
html[data-motion="on"] .medal { animation: medal-turn 6s ease-in-out infinite; }
@keyframes swing { from { rotate: -10deg; } to { rotate: 10deg; } }
@keyframes medal-turn { 0%, 70%, 100% { transform: perspective(500px) rotateY(0deg); } 85% { transform: perspective(500px) rotateY(180deg); } 86% { transform: perspective(500px) rotateY(-180deg); } }
html[data-motion="on"] .feebar-wrap.revealed .feebar i { animation: grow 1.1s cubic-bezier(.2,.9,.3,1) calc(var(--i) * .18s) both; }
@keyframes grow { from { flex-grow: 0; } }
html[data-motion="on"] .beanjar.in-view .awning { animation: awning-sway 5s ease-in-out infinite; }
@keyframes awning-sway { 50% { transform: scaleY(1.06); } }
html[data-motion="on"] .beanjar.in-view .jar { animation: jar-idle 5s ease-in-out infinite; }
html[data-motion="on"] .jar.shake { animation: jar-shake .65s cubic-bezier(.3,1.6,.5,1); }
html[data-motion="on"] .jar.shake .jb { animation: bean-rattle .65s ease-in-out; }
@keyframes jar-idle { 0%, 80%, 100% { rotate: 0deg; } 86% { rotate: -2deg; } 92% { rotate: 2deg; } }
@keyframes jar-shake { 0%, 100% { rotate: 0deg; } 20% { rotate: -7deg; } 40% { rotate: 6deg; } 60% { rotate: -4deg; } 80% { rotate: 2deg; } }
@keyframes bean-rattle { 30% { translate: calc((var(--k) - 3) * 1.6px) calc(var(--k) * -2.4px); } 60% { translate: calc((3 - var(--k)) * 1.2px) calc(var(--k) * -1px); } }
html[data-motion="on"] .jar-button:hover .jar-lid { animation: lid-wiggle .5s ease-in-out; transform-box: fill-box; transform-origin: center; }
@keyframes lid-wiggle { 30% { rotate: -5deg; } 70% { rotate: 4deg; } }
html[data-motion="on"] .beanjar.in-view .jar-bean img { animation: bean-bob 2.8s ease-in-out infinite; }
html[data-motion="on"] .jar-says { animation: chat-pop .45s cubic-bezier(.3,1.8,.5,1) both; transform-origin: right bottom; }
html.js[data-motion="on"] .facts-label:not(.revealed) { opacity: 0; }
html[data-motion="on"] .facts-label.revealed { animation: label-in .8s cubic-bezier(.3,1.5,.5,1) both; }
html[data-motion="on"] .facts-label.revealed .fl-row { animation: rise .5s cubic-bezier(.2,.8,.2,1) calc(.3s + var(--i, 0) * 70ms) both; }
@keyframes label-in { from { opacity: 0; translate: 40px 30px; rotate: 9deg; } }
html.js[data-motion="on"] .sorter:not(.revealed), html.js[data-motion="on"] .menu-board:not(.revealed), html.js[data-motion="on"] .lid-card:not(.revealed) { opacity: 0; }
html[data-motion="on"] :is(.sorter, .menu-board, .lid-card).revealed { animation: rise .8s cubic-bezier(.2,.9,.3,1.15) both; }
html[data-motion="on"] .lid-card.revealed { animation-delay: .15s; }
html[data-motion="on"] .sorter.revealed .tube-fill { animation: fill-up 1.4s cubic-bezier(.2,.8,.3,1) .3s both; }
@keyframes fill-up { from { height: 0; } }
html[data-motion="on"] .jb-drop { animation: drop-in 1.15s cubic-bezier(.55,0,.75,.9) var(--d) both; }
@keyframes drop-in { 0% { opacity: 0; transform: translate(0, 0) rotate(0deg); } 12% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(var(--tx) * 33.3cqw), 200px) rotate(420deg); } }
html[data-motion="on"] .beanjar.in-view .flame i { animation: flicker .35s ease-in-out infinite alternate; }
html[data-motion="on"] .beanjar.in-view .flame i + i { animation-duration: .27s; }
@keyframes flicker { from { scale: .9 1.05; } to { scale: 1.05 .9; } }
html[data-motion="on"] .menu-board.revealed .menu-off s::after { animation: strike .5s cubic-bezier(.3,.9,.3,1) calc(.5s + var(--i, 0) * .15s) both; }
@keyframes strike { from { transform: scaleX(0); } }
html[data-motion="on"] .big-lid { transition: rotate .5s cubic-bezier(.3,1.6,.5,1); }
html[data-motion="on"] .lid-card:hover .big-lid { rotate: -14deg; }

/* ---------- FAQ ---------- */
html.js[data-motion="on"] .faq details:not(.revealed) { opacity: 0; }
html[data-motion="on"] .faq details.revealed { animation: faq-in .6s cubic-bezier(.2,.9,.3,1.1) calc(var(--i) * 50ms) both; }
@keyframes faq-in { from { opacity: 0; translate: 40px 0; } }
html[data-motion="on"] .faq details[open] p { animation: rise .45s cubic-bezier(.2,.8,.2,1); }
html[data-motion="on"] .faq.in-view .faq-bean { animation: ponder 3.6s ease-in-out infinite; }
@keyframes ponder { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg) translateY(-6px); } }

/* ---------- finale ---------- */
html[data-motion="on"] .finale.in-view .finale-plane { animation: fly-across 16s linear infinite; }
@keyframes fly-across { 0% { transform: translate(-30vw, 30px) rotate(-6deg); } 50% { transform: translate(50vw, -10px) rotate(3deg); } 100% { transform: translate(110vw, 40px) rotate(-4deg); } }
html.js[data-motion="on"] .finale:not(.revealed) .shout span { opacity: 0; }
html[data-motion="on"] .finale.revealed .shout span { animation: shout-in .8s cubic-bezier(.3,1.7,.5,1) calc(var(--i) * .14s) both; }
@keyframes shout-in { from { opacity: 0; translate: 0 60%; scale: .6; } }
html[data-motion="on"] .finale.in-view .shout span:nth-child(2) { animation: shout-in .8s cubic-bezier(.3,1.7,.5,1) .14s both, letter-wave 4s ease-in-out 1.4s infinite; }
html[data-motion="on"] .finale-word { transition: letter-spacing .6s cubic-bezier(.3,1.5,.5,1); }
html[data-motion="on"] .finale-word:hover { letter-spacing: -.04em; }

/* ---------- buddy ---------- */
html[data-motion="on"] .buddy.show img { animation: bean-bob 2.8s ease-in-out infinite; }
html[data-motion="on"] .buddy-say { animation: chat-pop .45s cubic-bezier(.3,1.8,.5,1) both, say-out .4s ease-in 3.2s forwards; transform-origin: right bottom; }
html[data-motion="on"] .buddy:hover .buddy-say { animation: chat-pop .3s both; }
@keyframes say-out { to { opacity: 0; scale: .6; } }

/* ---------- token page ---------- */
html[data-motion="on"] .tokenmain .wordmark span { animation: letter-hop .9s cubic-bezier(.2,.9,.3,1.35) calc(var(--i) * 70ms) both; }
html.js[data-motion="on"] .token-content section:not(.revealed) { opacity: 0; }
html[data-motion="on"] .token-content section.revealed { animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
html[data-motion="on"] .burn-tiles li { transition: rotate .3s cubic-bezier(.3,1.8,.5,1); }
html[data-motion="on"] .burn-tiles li:hover { rotate: -2deg; }

/* ---------- motion off ---------- */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }
html[data-motion="off"] { scroll-behavior: auto; }
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
  html:not([data-motion="on"]) *, html:not([data-motion="on"]) *::before, html:not([data-motion="on"]) *::after { animation: none !important; transition: none !important; }
}

/* Layers that move while scrolling get their own GPU layer, so scrolling never repaints them. */
html[data-motion="on"] :is(.hero-sky, .hero .wordmark, .free-lines span) { will-change: translate; }
html[data-motion="on"] .rays { will-change: rotate; }
