/* Ember & Twinkle: the magic layer.
   Everything here only switches on when js/magic.js adds class="magic" to <html>,
   which it never does for visitors who ask their device for reduced motion. */

/* ---- page arrives gently, leaves gently ---------------------------------- */
.magic body{animation:mg-pagein .55s ease-out both}
.magic body.mg-leaving{opacity:0;transform:translateY(6px);transition:opacity .22s ease-in, transform .22s ease-in}
@keyframes mg-pagein{from{opacity:0}to{opacity:1}}

/* ---- hero text floats in, one line after another ------------------------- */
.magic .front .inner > div:first-child > *,
.magic .page-hero .inner > div:first-child > *{animation:mg-rise .8s cubic-bezier(.2,.7,.2,1) both}
.magic .front .inner > div:first-child > :nth-child(2), .magic .page-hero .inner > div:first-child > :nth-child(2){animation-delay:.12s}
.magic .front .inner > div:first-child > :nth-child(3), .magic .page-hero .inner > div:first-child > :nth-child(3){animation-delay:.24s}
.magic .front .inner > div:first-child > :nth-child(4){animation-delay:.36s}
.magic .front .inner > div:first-child > :nth-child(5){animation-delay:.48s}
.magic .page-hero .art{animation:mg-pop 1s .2s cubic-bezier(.2,.8,.2,1.15) both}
.magic .front .scene{animation:mg-fadein 1.1s .15s ease-out both} /* the shop just glows into view: no sliding or bouncing */
@keyframes mg-fadein{from{opacity:0}to{opacity:1}}
@keyframes mg-rise{from{opacity:0;transform:translateY(18px);filter:blur(4px)}to{opacity:1;transform:none;filter:none}}
@keyframes mg-pop{from{opacity:0;transform:translateY(24px) scale(.94)}to{opacity:1;transform:none}}

/* ---- things drift up into view as you scroll ----------------------------- */
.magic .mg-rv{opacity:0;transform:translateY(26px) scale(.985);transition:opacity .7s ease, transform .8s cubic-bezier(.2,.7,.2,1)}
.magic .mg-rv.mg-in{opacity:1;transform:none}

/* ---- elves breathe, and hop when you say hello --------------------------- */
.magic .mg-elf{animation:mg-bob 4.2s ease-in-out infinite;transform-origin:50% 100%;transition:filter .3s}
.magic .mg-elf:hover, .magic a:hover .mg-elf, .magic .counter:hover .mg-elf, .magic .maproom:hover .mg-elf{animation:mg-hop .9s cubic-bezier(.3,.7,.3,1) both;filter:drop-shadow(0 0 34px rgba(255,210,122,.55))}
@keyframes mg-bob{0%,100%{transform:translateY(0) rotate(0)}50%{transform:translateY(-6px) rotate(-.8deg)}}
@keyframes mg-hop{0%{transform:translateY(0) scale(1,1)}18%{transform:translateY(2px) scale(1.04,.95)}45%{transform:translateY(-16px) scale(.97,1.04) rotate(-3deg)}70%{transform:translateY(0) scale(1.03,.97)}85%{transform:translateY(-4px) rotate(1.5deg)}100%{transform:none}}
.magic .mg-elf.mg-hopping{animation:mg-hop .9s cubic-bezier(.3,.7,.3,1) both}

/* ---- a sheen of light passes over cards on hover ------------------------- */
.magic .counter, .magic .maproom, .magic .place{position:relative}
.magic .counter::after, .magic .maproom::after, .magic .place::after{content:"";position:absolute;inset:0;pointer-events:none;z-index:3;
  background:linear-gradient(115deg, transparent 35%, rgba(255,244,214,.38) 48%, rgba(255,255,255,.12) 52%, transparent 65%);
  transform:translateX(-120%);transition:transform 0s}
.magic .counter:hover::after, .magic .maproom:hover::after, .magic .place:hover::after{transform:translateX(120%);transition:transform 1s ease}
.magic .place:hover{box-shadow:0 2px 4px rgba(42,35,29,.06),0 16px 40px rgba(42,35,29,.14)}
.magic .counter.mg-in, .magic .place.mg-in, .magic .maproom.mg-in{transition:opacity .7s ease, transform .3s ease, box-shadow .25s}
.magic .counter.mg-in:hover, .magic .place.mg-in:hover, .magic .maproom.mg-in:hover{transform:translateY(-4px)}

/* gold and primary buttons catch the light now and then */
.magic .btn.gold, .magic .btn.primary{position:relative;overflow:hidden}
.magic .btn.gold::after, .magic .btn.primary::after{content:"";position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%);transform:translateX(-130%);animation:mg-sheen 5.5s 1.6s ease-in-out infinite}
@keyframes mg-sheen{0%,72%{transform:translateX(-130%)}92%,100%{transform:translateX(130%)}}

/* the little star in the logo turns slowly when you point at it */
.magic .wordmark svg{transition:transform 1.2s cubic-bezier(.2,.8,.2,1)}
.magic .wordmark:hover svg{transform:rotate(180deg) scale(1.15)}

/* ---- shooting stars over the night sky ----------------------------------- */
.mg-shoot{position:absolute;height:2px;width:120px;border-radius:2px;z-index:1;pointer-events:none;
  background:linear-gradient(90deg, rgba(255,240,200,0), rgba(255,240,200,.95));filter:drop-shadow(0 0 6px rgba(255,220,150,.9));
  transform-origin:100% 50%}

/* ---- the shopfront comes alive ------------------------------------------- */
.mg-shop{position:absolute;pointer-events:none;z-index:2}
.mg-shop .glow{position:absolute;border-radius:50%;mix-blend-mode:screen;pointer-events:none}
.mg-shop .win{background:radial-gradient(closest-side, rgba(255,196,110,.55), rgba(255,170,80,.18) 60%, transparent);animation:mg-flicker 3.4s infinite}
.mg-shop .win.b{animation-duration:4.1s;animation-delay:-1.3s}
.mg-shop .lamp{background:radial-gradient(closest-side, rgba(255,214,140,.85), rgba(255,170,80,.25) 55%, transparent);animation:mg-flicker 2.3s infinite}
.mg-shop .lamp.bright{animation:mg-flare 1.4s ease-out}
.mg-shop .hot{position:absolute;pointer-events:auto;cursor:pointer;background:none;border:0;border-radius:40%;padding:0}
.mg-shop .hot:focus-visible{outline:2px dashed var(--gold-2);outline-offset:3px}
@keyframes mg-flicker{0%,100%{opacity:.75}12%{opacity:.95}20%{opacity:.6}33%{opacity:.9}47%{opacity:.7}60%{opacity:1}74%{opacity:.68}88%{opacity:.88}}
@keyframes mg-flare{0%{opacity:1;transform:scale(1)}30%{opacity:1;transform:scale(2.4)}100%{opacity:.8;transform:scale(1)}}
@keyframes mg-ring{0%,100%{transform:rotate(0)}20%{transform:rotate(-1.4deg)}40%{transform:rotate(1.2deg)}60%{transform:rotate(-.8deg)}80%{transform:rotate(.5deg)}}
.mg-note{position:absolute;font-size:28px;font-weight:600;color:var(--gold-2);pointer-events:none;z-index:5;text-shadow:0 0 8px rgba(255,210,122,.8);font-family:var(--display)}

/* ---- sparkle bursts (clicks, results, the countdown) --------------------- */
.mg-burst{position:fixed;left:0;top:0;pointer-events:none;z-index:9998}

/* ---- results arrive in a dusting of magic -------------------------------- */
.magic .mg-dust{animation:mg-dust .9s cubic-bezier(.2,.7,.2,1) both}
@keyframes mg-dust{0%{opacity:0;transform:translateY(14px) scale(.97);filter:blur(6px) brightness(1.6)}60%{filter:blur(0) brightness(1.15)}100%{opacity:1;transform:none;filter:none}}

/* ---- the countdown number ------------------------------------------------- */
.magic .sleeps b{cursor:pointer;transition:transform .2s}
.magic .sleeps b:hover{transform:scale(1.12) rotate(-6deg)}
.magic .sleeps b.mg-pop{animation:mg-numpop .6s cubic-bezier(.3,1.6,.5,1)}
@keyframes mg-numpop{0%{transform:scale(1)}40%{transform:scale(1.35) rotate(8deg)}100%{transform:scale(1)}}

/* ---- an elf peeks in to say hello (once per page, big screens) ------------ */
.mg-peek{position:fixed;left:24px;bottom:0;z-index:9000;display:flex;align-items:flex-end;gap:6px;transform:translateY(110%);transition:transform .9s cubic-bezier(.3,1.4,.5,1);pointer-events:none}
.mg-peek.up{transform:translateY(30%);pointer-events:auto}
.mg-peek img{height:170px;width:auto;cursor:pointer;filter:drop-shadow(0 6px 18px rgba(0,0,0,.25))}
.mg-peek .say{background:var(--paper);color:var(--ink);border:1px solid var(--line);border-radius:16px 16px 16px 4px;padding:10px 14px;font-size:14px;max-width:220px;box-shadow:var(--shadow);margin-bottom:120px;opacity:0;transition:opacity .4s .5s}
.mg-peek.up .say{opacity:1}
.mg-peek .say b{font-family:var(--display)}
/* Twinkle walks in from the side with his lantern instead of popping up */
.mg-peek.mg-walk{transform:translate(-320px,6%);transition:transform 2.8s linear}
.mg-peek.mg-walk.up{transform:translate(0,6%)}
.mg-peek.mg-walk .say{transition-delay:2.9s}
.mg-peek.away{transform:translateY(110%)!important;transition:transform .9s ease-in!important}
@media (max-width:900px){.mg-peek{display:none}}

@media (prefers-reduced-motion: reduce){
  .mg-shop .glow{animation:none!important}
}
.mg-shop .piece{position:absolute;height:auto;pointer-events:none;display:block}
.mg-shop .piece[hidden]{display:none}
