/* Gambit Motion — entrances, reveals, living heroes, nav indicators, tilt,
   ripples and ambient light. Everything switches off under reduced motion. */

:root { --gp-ease: cubic-bezier(.2, .9, .3, 1); --gp-spring: cubic-bezier(.3, 1.35, .5, 1); }

/* ambient light: two slow colour fields behind the whole app */
html.gp-motion body::before {
  content: ""; position: fixed; inset: -20vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(38vmax 38vmax at 18% 12%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(42vmax 42vmax at 86% 78%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 70%);
  animation: gp-ambient 38s ease-in-out infinite alternate;
}
@keyframes gp-ambient { 0% { transform: translate3d(0, 0, 0) rotate(0); } 50% { transform: translate3d(4vmax, -3vmax, 0) rotate(8deg); } 100% { transform: translate3d(-3vmax, 4vmax, 0) rotate(-6deg); } }

/* entrance and scroll reveal */
.gp-reveal { opacity: 0; transform: translateY(16px) scale(.985); }
.gp-reveal.gp-in { opacity: 1; transform: none; transition: opacity .55s var(--gp-ease), transform .65s var(--gp-ease); transition-delay: var(--gp-d, 0ms); }
.gp-pop { animation: gp-pop .5s var(--gp-ease) both; animation-delay: var(--gp-d, 0ms); }
@keyframes gp-pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* sliding nav indicator */
.modes.gp-has-pill { position: relative; }
.modes.gp-has-pill .mode-btn { position: relative; z-index: 1; transition: color .25s ease; }
.modes.gp-has-pill .mode-btn.is-active { background: transparent; box-shadow: none; }
.gp-pill { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: var(--rad-2); background: var(--raised); box-shadow: var(--shadow-1); transition: transform .45s var(--gp-spring), width .45s var(--gp-spring), opacity .2s; z-index: 0; pointer-events: none; }
#tabbar { position: fixed; }
.gp-tabpill { position: absolute; top: 0; left: 0; width: 28px; height: 3px; border-radius: 0 0 var(--rad-0) var(--rad-0); background: var(--ink); transition: transform .45s var(--gp-spring), opacity .2s; pointer-events: none; }
.tab.is-active .ico, .tab.is-active .gp-tab-av { animation: gp-tab .45s var(--gp-spring); }
@keyframes gp-tab { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-3px) scale(1.12); } 100% { transform: translateY(-1px) scale(1); } }

/* living heroes: a slow camera drift, floating motes and pointer parallax */
.home-hero.gp-alive { background: linear-gradient(90deg, var(--bg-deep) 0%, rgb(var(--bg-deep-rgb)/.9) 30%, rgb(var(--bg-deep-rgb)/.4) 60%, rgb(var(--bg-deep-rgb)/.05) 100%); }
.gp-on-hero.gp-alive { background: linear-gradient(90deg, var(--bg-deep) 0%, rgb(var(--bg-deep-rgb)/.9) 32%, rgb(var(--bg-deep-rgb)/.25) 64%, transparent 100%); }
.gp-hero-bg {
  position: absolute; inset: -6%; z-index: -2; pointer-events: none;
  background: url("../art/hero.webp") 78% 62% / cover no-repeat;
  transform: translate3d(calc(var(--px, 0) * -18px), calc(var(--py, 0) * -12px), 0) scale(1.06);
  transition: transform .9s var(--gp-ease);
  animation: gp-drift 26s ease-in-out infinite alternate;
}
.gp-hero-bg.online { background-image: url("../art/online.webp"); background-position: 80% 50%; }
@keyframes gp-drift { from { scale: 1; } to { scale: 1.08; } }
.gp-alive > :not(.gp-hero-bg):not(.gp-motes) { position: relative; z-index: 1; }
.gp-motes { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.gp-motes i { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%; opacity: 0; animation: gp-mote var(--t) linear infinite; animation-delay: var(--dl); }
.gp-motes.gold i { background: var(--gold); box-shadow: 0 0 8px 2px rgb(var(--gold-rgb)/.55); }
.gp-motes.blue i { background: var(--info); box-shadow: 0 0 8px 2px rgb(var(--info-rgb)/.6); }
@keyframes gp-mote { 0% { transform: translate(0, 0); opacity: 0; } 12% { opacity: .9; } 70% { opacity: .55; } 100% { transform: translate(28px, -150px); opacity: 0; } }
@media (max-width: 599px) {
  .home-hero.gp-alive { background: linear-gradient(180deg, rgb(var(--bg-deep-rgb)/.55), rgb(var(--bg-deep-rgb)/.92) 70%); }
  .gp-hero-bg { background-position: 70% 40%; }
  .gp-on-hero.gp-alive { background: linear-gradient(180deg, rgb(var(--bg-deep-rgb)/.1) 0%, rgb(var(--bg-deep-rgb)/.6) 45%, var(--bg-deep) 92%); }
  .gp-hero-bg.online { background-position: 72% 30%; }
}

/* tilt with a moving sheen */
.gp-tilting { transform: perspective(800px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)) translateY(-3px) !important; transition: transform .12s ease-out, box-shadow .2s !important; }
.atl-card, .atl-col, .start-tile, .gp-pool, .atl-drop-hero, .gp-friend, .atl-spot-card, .gp-join, .bot-tile, .gp-ach-card { transform-style: preserve-3d; will-change: transform; }
.gp-tilting::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgb(var(--glint-rgb)/.22), transparent 45%);
  mix-blend-mode: soft-light;
}
.start-tile, .gp-friend, .gp-join, .bot-tile, .gp-ach-card { position: relative; }

/* click ripples */
.gp-ripple-host { position: relative; overflow: hidden; isolation: isolate; }
.gp-ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .16; transform: scale(0); animation: gp-ripple .62s var(--gp-ease) forwards; z-index: 0; }
@keyframes gp-ripple { to { transform: scale(1); opacity: 0; } }

/* buttons: a light sweep on primary actions */
.btn-primary, .atl-btn.gold { position: relative; overflow: hidden; }
.btn-primary::before, .atl-btn.gold::before {
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgb(var(--glint-rgb)/.28), transparent); transform: skewX(-18deg);
}
.btn-primary:hover::before, .atl-btn.gold:hover::before { animation: gp-sweep .8s var(--gp-ease); }
@keyframes gp-sweep { to { left: 130%; } }
.btn-primary:active, .btn-soft:active, .atl-btn:active { transform: scale(.97); }

/* toasts slide in */
.toast:not([hidden]) { animation: gp-toast .4s var(--gp-spring); }
@keyframes gp-toast { from { opacity: 0; transform: translate(-50%, 18px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* chips and pills respond */
.lvl-chip, .atl-chip, .engine-chip { transition: transform .2s var(--gp-spring), background .15s; }
.lvl-chip:hover, .atl-chip:hover { transform: translateY(-1px) scale(1.04); }
.atl-chip .atl-crown { transition: transform .4s var(--gp-spring); }
.atl-chip:hover .atl-crown { transform: rotate(-12deg) scale(1.15); }

/* the board settles in when a view opens */
.app.board-view .board-box { animation: gp-board .55s var(--gp-ease); }
@keyframes gp-board { from { opacity: 0; transform: scale(.975) translateY(6px); } to { opacity: 1; transform: none; } }

/* progress bars fill on arrival */
.hh-bar i, .course-bar i, .gp-ach-bar i, .gp-ach-prog i { animation: gp-fill 1.1s var(--gp-ease) both; transform-origin: left; }
@keyframes gp-fill { from { transform: scaleX(0); } }

/* a slow shine on legendary/exclusive tags */
.atl-rar-tag.r-legendary, .atl-rar-tag.r-exclusive { background-size: 200% 100% !important; animation: gp-tagshine 3.5s linear infinite; }
@keyframes gp-tagshine { from { background-position: 0 0; } to { background-position: 200% 0; } }

@media (prefers-reduced-motion: reduce) {
  html.gp-motion body::before, .gp-hero-bg, .gp-motes, .gp-pill, .gp-tabpill, .tab.is-active .ico, .toast:not([hidden]), .app.board-view .board-box, .hh-bar i, .course-bar i, .gp-ach-bar i, .gp-ach-prog i, .atl-rar-tag { animation: none !important; transition: none !important; }
  .gp-motes { display: none; }
  .gp-reveal { opacity: 1; transform: none; }
}

/* Wide screens: the hero is a long strip, so size the art by height and keep
   the whole knight in frame, just left of the XP ring. The card height is fixed
   so the image width is known (16:9) and its left edge can be faded out. */
@media (min-width: 900px) {
  .home-hero { box-sizing: border-box; height: 236px; }
  .home-hero:not(.gp-alive) {
    background:
      linear-gradient(90deg, var(--bg-deep) 0%, rgb(var(--bg-deep-rgb)/.9) 30%, rgb(var(--bg-deep-rgb)/.4) 60%, rgb(var(--bg-deep-rgb)/.05) 100%),
      linear-gradient(90deg, var(--bg-deep) calc(100% - 726px), transparent calc(100% - 560px)),
      url("../art/hero.webp") right 0 top 60% / auto 172% no-repeat, var(--bg-deep);
  }
  /* bg layer is 116% of 236px tall = 274px; image 150% = 411 x 731px, flush with the card's right edge */
  .home-hero .gp-hero-bg {
    inset: -8% -24px -8% -6%;
    background:
      linear-gradient(90deg, var(--bg-deep) calc(100% - 759px), transparent calc(100% - 590px)),
      url("../art/hero.webp") right 24px top 62% / auto 150% no-repeat, var(--bg-deep);
    transform-origin: calc(100% - 204px) 56%;
  }
}
