/* AJ mascot — three small placements on the home page. Nothing else is styled here.
 *
 *   .ajm--hero     waving, in the slot the hero character already uses
 *   .ajm--digital  beside the Premium Accounts heading (desktop)
 *   .ajm--victory  beside the games heading
 *
 * The poses are static images; all movement is CSS transforms on wrappers.
 * Every element is out of flow (position: absolute), so no existing box moves.
 */

.ajm {
  --ajm-glow: rgba(46, 161, 255, .30);
  --ajm-cast: drop-shadow(0 8px 12px rgba(2, 6, 23, .4));
  position: absolute;
  z-index: 5;
  display: block;
  margin: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
html[data-theme="light"] .ajm {
  --ajm-glow: rgba(37, 99, 235, .20);
  --ajm-cast: drop-shadow(0 8px 12px rgba(30, 58, 138, .2));
}

.ajm__float,
.ajm__react { display: block; width: 100%; height: 100%; }
.ajm__img { display: block; width: 100%; height: auto; filter: var(--ajm-cast); -webkit-user-drag: none; }

.ajm__glow {
  position: absolute;
  z-index: -1;
  inset: -8% -10% -4%;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--ajm-glow), transparent 72%);
  animation: ajm-glow 5.6s ease-in-out infinite alternate;
}

/* idle: a slow float with a slight sway from the feet */
.ajm__float {
  transform-origin: 50% 90%;
  animation: ajm-float 3.4s ease-in-out infinite alternate;
}
/* reaction layer: hover / pointer nearby */
.ajm__react { transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
.ajm.is-near .ajm__react { transform: translateY(-4px) rotate(-3deg) scale(1.04); }

@keyframes ajm-float {
  from { transform: translate3d(0, 3px, 0) rotate(calc(var(--ajm-sway, 1.2deg) * -1)); }
  to   { transform: translate3d(0, -4px, 0) rotate(var(--ajm-sway, 1.2deg)); }
}
@keyframes ajm-glow { from { opacity: .6; } to { opacity: 1; } }
@keyframes ajm-in {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

/* off-screen: no work (class toggled by aj-mascot.js) */
.ajm-js .ajm:not(.is-visible) * { animation-play-state: paused !important; }
/* scroll entrance, section mascots only */
.ajm-js .ajm[data-ajm-enter]:not(.is-in) { opacity: 0; }
.ajm[data-ajm-enter].is-in { animation: ajm-in .7s cubic-bezier(.2, .8, .2, 1) both; }

/* ---------- 1. Home hero: waving ----------
   Same box rules as the hero character it stands in for, so the hero, the
   banner, the arrows and the heading spacing are exactly as they were. */
.aj-hero-stage > .aj-hero-boy { display: none; }
.ajm--hero {
  --ajm-sway: 2deg;
  right: 0;
  top: calc(100% + 4px);
  width: 84px;
  aspect-ratio: 346 / 428;
  animation: ajm-in .9s cubic-bezier(.2, .8, .2, 1) .2s both;
}
@media (min-width: 640px) and (max-width: 1023.98px) { .ajm--hero { width: 104px; } }
@media (min-width: 1024px) {
  .ajm--hero {
    top: auto;
    right: auto;
    bottom: -14px;
    width: 190px;
    left: max(-60px, calc((100% - 100vw) / 2 + 4px));
  }
}
@media (min-width: 1700px) {
  .ajm--hero { width: 230px; left: max(-250px, calc((100% - 100vw) / 2 + 10px)); }
}

/* ---------- 2 + 3. Beside a section heading ----------
   Anchored to the heading's own text block, standing on its baseline and
   rising into the gap above it, so cards and grids are never touched. */
#premium-accounts > .ds-section-head > div:first-child,
#all-games > .ds-section-head > div:first-child { position: relative; }
.ajm--digital,
.ajm--victory {
  left: calc(100% + 12px);
  bottom: 0;
  pointer-events: auto;
}
.ajm--digital { width: 52px; aspect-ratio: 340 / 421; }
/* Smaller, and a touch lower, than the Premium one: the gap above this heading is tighter,
   and AJ must stay clear of the product cards above even at the top of the celebration. */
.ajm--victory { width: 40px; bottom: -4px; aspect-ratio: 368 / 453; --ajm-sway: .8deg; }
@media (hover: hover) and (pointer: fine) {
  .ajm--digital:hover .ajm__react,
  .ajm--victory:hover .ajm__react { transform: translateY(-3px) rotate(-4deg) scale(1.06); }
}
/* Phones and tablets: the hero mascot already stands beside this heading. */
@media (max-width: 1023.98px) { .ajm--digital { display: none; } }

/* Premium Accounts: soft light from the card AJ is holding */
.ajm__cardglow {
  position: absolute;
  z-index: -1;
  left: 46%;
  top: 12%;
  width: 66%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(56, 189, 248, .5), transparent 72%);
  animation: ajm-glow 2.8s ease-in-out infinite alternate;
}

/* Games: one short celebration on first view, then calm */
.ajm--victory.is-celebrating .ajm__react {
  animation: ajm-celebrate 1.2s cubic-bezier(.34, 1.4, .64, 1) .1s 1 both;
}
@keyframes ajm-celebrate {
  0%   { transform: translateY(0) rotate(0) scale(1); }
  25%  { transform: translateY(-6px) rotate(-6deg) scale(1.06); }
  50%  { transform: translateY(0) rotate(3deg) scale(.98); }
  70%  { transform: translateY(-3px) rotate(-2deg) scale(1.02); }
  100% { transform: translateY(0) rotate(0) scale(1); }
}
.ajm__gem {
  position: absolute;
  left: 50%;
  top: 30%;
  width: var(--sz, 7px);
  aspect-ratio: 1 / .9;
  clip-path: polygon(24% 0, 76% 0, 100% 34%, 50% 100%, 0 34%);
  background: linear-gradient(180deg, #7dd3fc 0 34%, #2f7df0 35% 100%);
  opacity: 0;
  animation: ajm-gem .95s cubic-bezier(.2, .8, .2, 1) var(--delay, 0s) 1 both;
}
@keyframes ajm-gem {
  0%   { opacity: 0; transform: translate3d(0, 0, 0) scale(.3); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--bx), var(--by), 0) rotate(var(--br)) scale(1); }
}

@media (max-width: 767px) {
  .ajm__img { filter: none; }
  .ajm__glow, .ajm__cardglow { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ajm, .ajm * { animation: none !important; transition: none !important; }
  .ajm-js .ajm[data-ajm-enter]:not(.is-in) { opacity: 1; }
  .ajm.is-near .ajm__react { transform: none; }
  .ajm__gem { display: none; }
}
@media print { .ajm { display: none !important; } }

/* ---------- Header logo: AJ's face in the brand mark ----------
   Size and position are inline on the element itself, so the logo is correct
   even on a page that does not load this file. Only motion lives here. */
.ajm-logo { transform-origin: 50% 100%; animation: aj-brand-sway 3.5s ease-in-out .8s infinite; }
.ajm-logo__tilt { transform-origin: 50% 60%; transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
.aj-nav-brand:hover .ajm-logo__tilt,
.aj-nav-brand:focus-visible .ajm-logo__tilt { transform: rotate(-8deg) scale(1.08); }
@media (prefers-reduced-motion: reduce) {
  .ajm-logo { animation: none; }
  .ajm-logo__tilt { transition: none; }
}
