/* ============================================================================
   MK ARENA - DEPTH AND MOTION LAYER                           MG-817, 27 Oct 2026
   ----------------------------------------------------------------------------
   Loaded AFTER theme/mk-arena-theme.css and theme/mk-arena-brand.css on every
   themed Arena page. Neither of those files is edited.

   WHY THIS EXISTS
   Raj: "none of these pages has some kind of animations, movement effects, 3D
   effects. Normal 2010 kind of website it looks like ... ultra rich, premium,
   posh kind of screen and fluid kind of animations."

   He is right, and the diagnosis is sharper than "add animation". The screens
   were FLAT in three separate ways, and each one needs its own answer:

     1. NO DEPTH. Every panel sat on one tight shadow, the same at every height,
        with no colour in it. A real surface casts a ladder of shadows - a tight
        contact shadow, a mid spread, and a wide ambient one tinted by the light
        around it. Section 1 rebuilds the two shadow tokens the whole theme
        already routes through, so every card, sheet and button gains height in
        one move.
     2. NOTHING ARRIVES. Everything was simply there on load. A premium screen
        is choreographed: things rise into place, in order, on a spring. Section
        3 does that, driven by the companion script.
     3. NOTHING RESPONDS. A card did not know the pointer was on it. Section 4
        gives the pickable surfaces real 3D tilt with a specular highlight that
        follows the pointer, so the card feels like a lit object and not a
        rectangle.

   Plus: the ground now drifts (section 2), the ribbon band carries a sheen
   (section 5), the one gold button breathes (section 6), and the finish card
   is choreographed rather than simply shown (section 7).

   THE RULES THIS LAYER KEEPS
   - Only transform, opacity and filter are animated. Nothing here can cause a
     layout pass, so nothing here can cost a game a frame.
   - Nothing inside a live play surface moves. The script attaches to page
     furniture only and skips any element inside a canvas's own panel.
   - Every single effect is switched off under prefers-reduced-motion
     (section 8). That block is the last word in the file, on purpose.

   HOUSE RULE, carried from the theme file: never write a star next to a slash
   inside a comment. That closes the comment and the browser drops the next rule.
   ============================================================================ */


/* ------------------------------------------------------------ 1. DEPTH
   The theme routes every raised surface through two tokens, so redefining the
   two of them lifts the whole Arena at once - the same high-leverage move the
   brand sheet made with the ground colours.

   Each is a three-step ladder: a tight contact shadow that pins the card to the
   page, a mid shadow that gives it height, and a wide ambient one carrying a
   purple cast, because the light on these screens is the brand ribbon and a
   neutral grey ambient next to that reads as dirt. */
.ca{
  --ca-shadow-card:
    0 1px 2px rgba(18,38,111,.05),
    0 8px 18px -6px rgba(18,38,111,.13),
    0 24px 48px -20px rgba(113,57,211,.30);
  --ca-shadow-float:
    0 2px 4px rgba(18,38,111,.06),
    0 16px 32px -10px rgba(18,38,111,.17),
    0 44px 78px -26px rgba(113,57,211,.38);

  /* a glass rim: a bright hairline along the top inside edge and a soft dark
     one along the bottom. This is what makes a white panel read as a lit solid
     rather than a white rectangle. */
  --mo-glass: inset 0 1.5px 0 rgba(255,255,255,.95), inset 0 -1.5px 0 rgba(18,38,111,.05);

  --mo-spring: cubic-bezier(.22,1.22,.36,1);
  --mo-ease:   cubic-bezier(.16,.84,.44,1);
}

/* the rim, added without disturbing the box-shadow the theme composed */
.ca .ca-card, .ca .ca-win, .ca .ca-field, .ca .ca-marquee, .ca .ca-tile{
  position:relative;
}

/* a raised surface lifts a little further when the pointer is on it. The theme
   gave cards no hover state at all, which is most of why they read as printed. */
@media (hover:hover) and (pointer:fine){
  .ca .ca-card{ transition: transform 420ms var(--mo-spring), box-shadow 420ms var(--mo-ease); }
  .ca .ca-card:hover{ transform:translate3d(0,-3px,0); box-shadow:var(--ca-rim), var(--ca-shadow-float); }
}


/* ------------------------------------------------------------ 2. THE GROUND DRIFTS
   The brand sheet laid four colour pools on the ground, one per ribbon colour.
   Painted into the body background they were fixed, and a fixed gradient is the
   single most 2010 thing on a page.

   So the pools move out of the body and onto one composited layer behind
   everything, which drifts and breathes on a long cycle. The body keeps only
   the flat ground and the dot grid, which must not move or the dots crawl. */
body.ca{
  background-image:radial-gradient(rgba(18,38,111,.055) 1.2px, transparent 1.3px);
  background-size:22px 22px;
  background-attachment:scroll;
}

.mo-aura{
  position:fixed; inset:-25%; z-index:-1; pointer-events:none;
  background:
    radial-gradient(circle at 18% 14%, rgba(113,57,211,.22), transparent 38%),
    radial-gradient(circle at 82% 24%, rgba(59,124,255,.20),  transparent 36%),
    radial-gradient(circle at 22% 72%, rgba(35,199,160,.20),  transparent 36%),
    radial-gradient(circle at 80% 88%, rgba(16,192,93,.17),   transparent 36%);
  will-change:transform;
  animation: mo-drift 34s ease-in-out infinite alternate;
}
@keyframes mo-drift{
  0%   { transform:translate3d(0,0,0) scale(1); }
  33%  { transform:translate3d(2.5%,-2%,0) scale(1.06); }
  66%  { transform:translate3d(-2%,2.5%,0) scale(1.03); }
  100% { transform:translate3d(1.5%,1.5%,0) scale(1.08); }
}


/* ------------------------------------------------------------ 3. THINGS ARRIVE
   Nothing on these pages used to arrive - it was simply already there. The
   script marks page furniture .mo-rise, then adds .mo-in when it enters view,
   with --mo-d set from its position in the group so a row of cards lands one
   after another rather than all at once.

   Opacity settles faster than the transform: the card is readable before it has
   finished moving, which is what makes a stagger feel quick rather than slack. */
.ca .mo-rise{
  opacity:0; transform:translate3d(0,28px,0) scale(.962);
  will-change:transform, opacity;
}
.ca .mo-rise.mo-in{
  opacity:1; transform:none;
  transition: opacity 400ms var(--mo-ease) var(--mo-d,0ms),
              transform 780ms var(--mo-spring) var(--mo-d,0ms);
}
/* once it has landed it stops claiming a layer */
.ca .mo-rise.mo-done{ will-change:auto; }

/* the header and the hero do not wait to be scrolled to - they set the tone */
.ca .ca-top{ animation: mo-drop 620ms var(--mo-spring) both; }
@keyframes mo-drop{ from{ transform:translate3d(0,-100%,0); } to{ transform:none; } }


/* ------------------------------------------------------------ 4. 3D TILT
   The premium part. A pickable card tracks the pointer in three dimensions and
   carries a specular highlight that moves with it, so it reads as a lit solid
   being handled rather than a flat region being hovered.

   The script sets --mo-rx / --mo-ry (the rotation, capped well under 10deg -
   past that a card reads as a toy) and --mo-mx / --mo-my (where the light is).
   Returning to rest is a long spring; following the pointer is nearly
   instantaneous, because any easing there feels like lag. */
.ca .mo-tilt{
  transform-style:preserve-3d;
  transition: transform 560ms var(--mo-spring), box-shadow 320ms var(--mo-ease);
}
.ca .mo-tilt.mo-live{
  transition: transform 80ms linear, box-shadow 320ms var(--mo-ease);
  transform:
    perspective(1000px)
    rotateX(var(--mo-rx,0deg)) rotateY(var(--mo-ry,0deg))
    translate3d(0,-6px,0) scale(1.022);
  box-shadow: var(--ca-rim), var(--ca-shadow-float);
}

/* the specular highlight. It is its own element rather than a pseudo, because
   .ca-tile::after is already the NEW / TODAY flag and .ca-card::before is the
   brand sheet's ribbon band. */
.ca .mo-sheen{
  position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  z-index:2; opacity:0;
  background:radial-gradient(300px circle at var(--mo-mx,50%) var(--mo-my,0%),
                             rgba(255,255,255,.58), rgba(255,255,255,.10) 42%, transparent 66%);
  transition:opacity 300ms var(--mo-ease);
}
.ca .mo-tilt.mo-live .mo-sheen{ opacity:1; }

/* the content inside a tilting card is pushed forward, so the card has real
   thickness instead of being a rotated picture of a card */
.ca .mo-tilt.mo-live > :not(.mo-sheen){ transform:translateZ(26px); }
.ca .mo-tilt > :not(.mo-sheen){ transition:transform 560ms var(--mo-spring); }


/* ------------------------------------------------------------ 5. SURFACES THAT LIVE
   Small, long-cycle movement on the decoration. Each one is cheap, and together
   they are the difference between a screen that is on and a screen that is
   merely open. */

/* the ribbon band on every card carries a sheen that crosses it now and then */
.ca .ca-card::before, .ca .ca-win::before, .ca .ca-field::before, .ca .board::before{
  background-image:
    linear-gradient(100deg, transparent 38%, rgba(255,255,255,.85) 50%, transparent 62%),
    var(--ca-ribbon-edge);
  background-size:260% 100%, 100% 100%;
  background-repeat:no-repeat;
  animation: mo-sweep 5.2s var(--mo-ease) infinite;
}
@keyframes mo-sweep{
  0%,55% { background-position:150% 0, 0 0; }
  85%,100%{ background-position:-60% 0, 0 0; }
}

/* the hero's number balls bob, each on its own offset, so the cluster breathes
   instead of sitting */
.ca .ca-cluster .ca-ball{
  animation: mo-bob 3.8s ease-in-out infinite;
  animation-delay: calc(var(--mo-i,0) * 320ms);
}
@keyframes mo-bob{
  0%,100%{ transform:translate3d(0,0,0) rotate(0deg); }
  50%    { transform:translate3d(0,-9px,0) rotate(-3deg); }
}

/* the live dot on the board actually pulses now */
.ca .ca-live i, .ca .ac-live i{
  animation: mo-pulse 1.9s ease-in-out infinite;
}
@keyframes mo-pulse{
  0%,100%{ transform:scale(1);   opacity:1; }
  50%    { transform:scale(1.5); opacity:.55; }
}

/* a freshly arrived board row glows once rather than simply appearing */
.ca .mo-flash{ animation: mo-rowin 900ms var(--mo-ease) both; }
@keyframes mo-rowin{
  0%  { transform:translate3d(-14px,0,0); opacity:0; }
  60% { opacity:1; }
  100%{ transform:none; opacity:1; }
}


/* ------------------------------------------------------------ 6. THE ONE GOLD BUTTON
   Raj's rule is that gold marks the single thing on a screen the child is meant
   to press next. A mark that does not move is easy to walk past, so the one
   gold button breathes: its cast light swells and settles on a slow cycle.

   This is done with filter, never box-shadow, because the theme builds the
   button's whole pressed state out of box-shadow and overriding it here would
   silently kill the press. The theme's own .ca-shine sweep is left alone and
   now reads as the specular on a breathing object. */
.ca .ca-btn.gold{
  animation: mo-breathe 3.4s ease-in-out infinite;
}
@keyframes mo-breathe{
  0%,100%{ filter:drop-shadow(0 6px 14px rgba(217,159,0,.34)); }
  50%    { filter:drop-shadow(0 14px 30px rgba(217,159,0,.66)); }
}
.ca .ca-btn.gold:hover{ filter:brightness(1.05) drop-shadow(0 14px 30px rgba(217,159,0,.66)); animation:none; }

/* every button answers the finger on a spring rather than a step */
.ca .ca-btn{ transition: transform 300ms var(--mo-spring), filter 180ms linear; }
.ca .ca-btn:active{ transition-duration:70ms; }


/* ------------------------------------------------------------ 7. THE FINISH CARD
   The happiest screen in the product was the least choreographed: the trophy,
   the title, the numbers and the buttons all landed in the same instant.

   Now the card rises, the trophy overshoots in after it, and the rows cascade.
   The order is the order a child reads in, which is what makes a sequence feel
   designed rather than merely delayed. */
   EVERY rule here is keyed on .ca-overlay.on - on the overlay OPENING, never on
   the card simply existing. The win card is in the DOM from first paint, hidden
   behind the overlay's own opacity. An animation with fill-mode "both" on a
   bare .ca-win would therefore run through at load, while nobody was looking,
   and leave transform:none pinned on the element forever - which would silently
   kill the theme's own scale(.85) -> scale(1) entrance. Keyed on .on it fires
   when the card is actually shown, which is the only moment it means anything.

   The theme's scale transition is left to do its own work; this layer adds the
   lift, the trophy and the cascade on top of it. */
.ca .ca-overlay.on .ca-win{ animation: mo-winin 620ms var(--mo-spring) both; }
@keyframes mo-winin{
  from{ opacity:0; }
  60% { opacity:1; }
  to  { opacity:1; }
}

.ca .ca-overlay.on .ca-win .trophy{ animation: mo-pop 900ms var(--mo-spring) 180ms both; }
@keyframes mo-pop{
  0%  { transform:scale(.2) translate3d(0,40px,0) rotate(-24deg); opacity:0; }
  55% { opacity:1; }
  100%{ transform:none; opacity:1; }
}

/* a halo that expands away from the trophy once, like a cheer */
.ca .ca-overlay.on .ca-win .trophy::before{
  content:""; position:absolute; inset:-14px; border-radius:50%;
  box-shadow:0 0 0 3px rgba(113,57,211,.45);
  animation: mo-halo 1200ms var(--mo-ease) 420ms both;
  pointer-events:none;
}
@keyframes mo-halo{
  0%  { transform:scale(.5); opacity:0; }
  30% { opacity:.9; }
  100%{ transform:scale(1.7); opacity:0; }
}

/* the rows of the card come in one after another */
.ca .ca-overlay.on .ca-win .rows li,
.ca .ca-overlay.on .ca-win .stat,
.ca .ca-overlay.on .ca-win .row > *{
  animation: mo-cascade 620ms var(--mo-spring) both;
  animation-delay: calc(420ms + var(--mo-i,0) * 90ms);
}
@keyframes mo-cascade{
  from{ transform:translate3d(0,16px,0); opacity:0; }
  to  { transform:none; opacity:1; }
}

/* a number that has just been earned counts up to itself rather than appearing.
   The script does the counting; this only keeps the digits from reflowing the
   card while they change width. */
.ca .mo-counting{ font-variant-numeric:tabular-nums; }


/* ------------------------------------------------------------ 8. OFF, WHEN ASKED
   One block, last in the file, that returns every screen in this layer to
   exactly where it was. A child who has asked their device for less movement
   gets the depth and the colour and none of the motion - not a degraded screen,
   a still one. */
@media (prefers-reduced-motion: reduce){
  .ca .mo-rise, .ca .mo-rise.mo-in{ opacity:1 !important; transform:none !important; transition:none !important; }
  .ca .ca-top, .ca .ca-win, .ca .ca-win .trophy,
  .ca .ca-win .rows li, .ca .ca-win .stat, .ca .ca-win .row > *,
  .ca .ca-btn.gold, .ca .ca-cluster .ca-ball, .ca .ca-live i, .ca .ac-live i,
  .ca .mo-flash, .mo-aura,
  .ca .ca-card::before, .ca .ca-win::before, .ca .ca-field::before{
    animation:none !important;
  }
  .ca .ca-win .trophy::before{ display:none; }
  .ca .ca-card::before, .ca .ca-win::before, .ca .ca-field::before{
    background-image:var(--ca-ribbon-edge); background-size:100% 100%;
  }
  .ca .mo-tilt, .ca .mo-tilt.mo-live{ transform:none !important; transition:none !important; }
  .ca .mo-tilt.mo-live > :not(.mo-sheen){ transform:none !important; }
  .ca .mo-sheen{ display:none; }
  .ca .ca-btn.gold{ filter:none; }
  .ca .ca-card:hover{ transform:none; }
}
