/* =====================================================================
   Nexus mobile — primitives + motion for the mobile UI overhaul.
   Ported from docs/prototypes/concepts/bey-nexus/alt.css onto the --nx-*
   theme (css/game.css). Loaded last; every rule is scoped to body.mobile
   so pc.html is untouched.
   Spacing base 2px; steps 4/6/8/10/12/16. Tap targets >= 44px, CTAs 48px.
   ===================================================================== */

:root {
  --nx-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --nx-ease-snap: cubic-bezier(0.3, 1.6, 0.5, 1);
  --nx-dur-press: 140ms;
  --nx-dur-screen: 820ms;
  --nx-dur-stagger: 70ms;
  --nx-ease-smooth: cubic-bezier(0.45, 0, 0.2, 1);
}

/* ----- Type ----- */
body.mobile .nx-kicker {
  font: 600 0.62rem/1 var(--nx-u);
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--nx-c);
}
body.mobile .nx-h1 {
  font: 900 clamp(4rem, 19vw, 5.5rem)/0.78 var(--nx-d);
  letter-spacing: -0.05em;
  text-transform: uppercase;
  color: var(--nx-w);
}
body.mobile .nx-h2 {
  font: 800 2.15rem/0.88 var(--nx-d);
  text-transform: uppercase;
  color: var(--nx-w);
}
body.mobile .nx-muted { color: var(--nx-m); font-size: 0.8rem; }

/* ----- Top bar ----- */
body.mobile .nx-micro {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--nx-l);
  font: 700 0.58rem/1 var(--nx-u);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nx-w);
  flex: none;
}
body.mobile .nx-back {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--nx-w);
  font: 700 0.68rem/1 var(--nx-u);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
body.mobile .nx-back::before { content: '\2190'; font-size: 1rem; color: var(--nx-c); }

/* ----- Corner-bracket panel ----- */
body.mobile .nx-corner {
  position: relative;
  border: 1px solid var(--nx-l);
  background: rgba(17, 21, 32, 0.86);
  backdrop-filter: blur(14px);
}
body.mobile .nx-corner::before,
body.mobile .nx-corner::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--nx-c);
  pointer-events: none;
}
body.mobile .nx-corner::before { left: -1px; top: -1px; border-left: 2px solid; border-top: 2px solid; }
body.mobile .nx-corner::after { right: -1px; bottom: -1px; border-right: 2px solid; border-bottom: 2px solid; }

/* ----- CTA ----- */
body.mobile .nx-action {
  position: relative;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
  border: 0;
  background: var(--nx-w);
  color: var(--nx-v);
  font: 800 0.78rem/1 var(--nx-u);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  clip-path: var(--nx-cta);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.mobile .nx-action::after { content: '\2192'; font-size: 1.1rem; }
body.mobile .nx-action--primary { background: var(--nx-c); }
body.mobile .nx-action--hot { background: var(--nx-r); color: var(--nx-w); }
body.mobile .nx-action--acid { background: var(--nx-a); }
body.mobile .nx-action--ghost { background: transparent; color: var(--nx-w); box-shadow: inset 0 0 0 1px var(--nx-l); }
body.mobile .nx-action--ghost::after { display: none; }
body.mobile .nx-action:disabled,
body.mobile .nx-action[aria-disabled='true'] { opacity: 0.45; cursor: default; }
/* Impact flash: a white sheet across the CTA's own clipped shape. */
body.mobile .nx-action::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--nx-w);
  opacity: 0;
  pointer-events: none;
}
body.mobile .nx-action.nx-press::before { opacity: 0.55; }
body.mobile .nx-action.nx-release::before { animation: nx-impact 90ms linear backwards; }
body.mobile .nx-block { width: 100%; }

/* ----- Badges ----- */
body.mobile .nx-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid currentColor;
  color: var(--nx-c);
  font: 700 0.55rem/1 var(--nx-u);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
body.mobile .nx-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  background: var(--nx-g);
  color: var(--nx-v);
  font: 900 0.72rem/1 var(--nx-d);
  letter-spacing: 0.02em;
}

/* ----- Energy motifs ----- */
body.mobile .nx-slash {
  position: absolute;
  width: 140%;
  height: 44%;
  left: -20%;
  top: 29%;
  background: linear-gradient(90deg, var(--nx-r), #7d1635);
  transform: rotate(-12deg);
  opacity: 0.84;
  pointer-events: none;
}
body.mobile .nx-orbit {
  width: min(82vw, 330px);
  aspect-ratio: 1;
  border: 1px solid rgba(87, 233, 255, 0.4);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  animation: nx-spin 18s linear infinite;
}
body.mobile .nx-orbit::before {
  content: '';
  position: absolute;
  inset: 7%;
  border: 3px dashed rgba(255, 53, 94, 0.47);
  border-radius: 50%;
  animation: nx-spin-rev 12s linear infinite;
}
body.mobile .nx-orbit::after {
  content: '';
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border-top: 2px solid var(--nx-c);
  filter: drop-shadow(0 0 8px var(--nx-c));
}
body.mobile .nx-orbit > * { animation: nx-spin-rev 18s linear infinite; }
body.mobile .nx-gridfloor {
  position: absolute;
  inset: 44% -35% -25%;
  transform: perspective(250px) rotateX(58deg);
  background:
    linear-gradient(rgba(87, 233, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(87, 233, 255, 0.18) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(#000, transparent);
  pointer-events: none;
}
body.mobile .nx-scan { position: relative; isolation: isolate; }
body.mobile .nx-scan::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0.22;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.025) 3px 4px);
}

/* ----- Home tile (Smash-style chunky tile) ----- */
body.mobile .nx-tile {
  position: relative;
  overflow: hidden;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--nx-l);
  background: linear-gradient(150deg, var(--nx-p), var(--nx-v));
  color: var(--nx-w);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.mobile .nx-tile-icon {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 36px;
  height: 36px;
  color: var(--nx-c);
}
body.mobile .nx-tile-label {
  font: 900 2rem/0.85 var(--nx-d);
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
body.mobile .nx-tile--hero {
  min-height: 132px;
  background: linear-gradient(120deg, rgba(255, 53, 94, 0.35), transparent 60%), var(--nx-v2);
  border-color: rgba(255, 53, 94, 0.55);
}
body.mobile .nx-tile--hero .nx-tile-label { font-size: 3.4rem; }
body.mobile .nx-tile[aria-disabled='true'] { opacity: 0.5; filter: grayscale(0.6); cursor: default; }
body.mobile .nx-tile.nx-press { border-color: var(--nx-c); }

/* ----- Big-number mode list ----- */
body.mobile .nx-modelist { display: flex; flex-direction: column; }
body.mobile .nx-mode {
  position: relative;
  min-height: 72px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-top: 1px solid var(--nx-l);
  background: none;
  color: var(--nx-w);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body.mobile .nx-mode-num { font: 900 3.6rem/0.7 var(--nx-d); color: rgba(255, 255, 255, 0.08); }
body.mobile .nx-mode-label { font: 800 1.8rem/0.9 var(--nx-d); text-transform: uppercase; }
body.mobile .nx-mode-sub { display: block; margin-top: 4px; font: 400 0.68rem/1.2 var(--nx-u); color: var(--nx-m); }
body.mobile .nx-mode-arr { font-size: 1.5rem; color: var(--nx-c); }
body.mobile .nx-mode:first-child,
body.mobile .nx-mode.nx-press { background: linear-gradient(90deg, rgba(87, 233, 255, 0.13), transparent); }
body.mobile .nx-mode:first-child .nx-mode-num,
body.mobile .nx-mode.nx-press .nx-mode-num { color: var(--nx-c); text-shadow: 0 0 22px rgba(87, 233, 255, 0.33); }

/* =====================================================================
   Motion
   ===================================================================== */

/* Global press: composes with any existing transform via `scale`/`rotate`. */
body.mobile .nx-press {
  scale: 0.94;
  rotate: -0.6deg;
  filter: brightness(1.3);
  transition: scale var(--nx-dur-press) var(--nx-ease-out), rotate var(--nx-dur-press) var(--nx-ease-out), filter 60ms linear;
}
body.mobile .nx-release { animation: nx-release 320ms var(--nx-ease-snap) backwards; }

/* Screen swap: full-screen slash wipe covers the cut; incoming slides + staggers. */
body.mobile .nx-wipe {
  position: fixed;
  inset: -20% -60%;
  z-index: 9000;
  pointer-events: none;
  visibility: hidden;
  background: linear-gradient(90deg, transparent 0 30%, var(--nx-r) 30% 46%, var(--nx-w) 46% 47%, var(--nx-r) 47% 62%, transparent 62%);
  transform: skewX(-18deg) translateX(-110%);
}
body.mobile .nx-wipe--fwd { visibility: visible; animation: nx-wipe-fwd var(--nx-dur-screen) var(--nx-ease-smooth) backwards; }
body.mobile .nx-wipe--back {
  visibility: visible;
  background: linear-gradient(90deg, transparent 0 30%, var(--nx-c) 30% 46%, var(--nx-w) 46% 47%, var(--nx-c) 47% 62%, transparent 62%);
  animation: nx-wipe-back var(--nx-dur-screen) var(--nx-ease-smooth) backwards;
}
body.mobile .nx-swap-in--fwd { animation: nx-in-fwd var(--nx-dur-screen) var(--nx-ease-smooth) backwards; }
body.mobile .nx-swap-in--back { animation: nx-in-back var(--nx-dur-screen) var(--nx-ease-smooth) backwards; }
body.mobile .nx-swap-out--fwd { animation: nx-out-fwd var(--nx-dur-screen) var(--nx-ease-out) backwards; }
body.mobile .nx-swap-out--back { animation: nx-out-back var(--nx-dur-screen) var(--nx-ease-out) backwards; }
body.mobile .nx-stagger > * {
  animation: nx-rise var(--nx-dur-screen) var(--nx-ease-smooth) backwards;
  animation-delay: calc(var(--nx-i, 0) * var(--nx-dur-stagger) + 80ms);
}
body.mobile .nx-fade-in { animation: nx-fade 120ms linear backwards; }

@keyframes nx-spin { to { transform: rotate(360deg); } }
@keyframes nx-spin-rev { to { transform: rotate(-360deg); } }
@keyframes nx-impact { from { opacity: 0.9; } to { opacity: 0; } }
@keyframes nx-release {
  0% { scale: 0.94; filter: brightness(1.3); box-shadow: 0 0 0 0 rgba(87, 233, 255, 0.6); }
  45% { scale: 1.04; }
  100% { scale: 1; filter: none; box-shadow: 0 0 0 14px rgba(87, 233, 255, 0); }
}
@keyframes nx-wipe-fwd { from { transform: skewX(-18deg) translateX(-110%); } to { transform: skewX(-18deg) translateX(110%); } }
@keyframes nx-wipe-back { from { transform: skewX(18deg) translateX(110%); } to { transform: skewX(18deg) translateX(-110%); } }
@keyframes nx-in-fwd { from { translate: 6% 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@keyframes nx-in-back { from { translate: -6% 0; opacity: 0; } to { translate: 0 0; opacity: 1; } }
@keyframes nx-out-fwd { from { translate: 0 0; opacity: 1; } to { translate: -6% 0; opacity: 0; } }
@keyframes nx-out-back { from { translate: 0 0; opacity: 1; } to { translate: 6% 0; opacity: 0; } }
@keyframes nx-rise { from { translate: 0 12px; opacity: 0; filter: blur(2px); } to { translate: 0 0; opacity: 1; filter: none; } }
@keyframes nx-fade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  body.mobile .nx-orbit,
  body.mobile .nx-orbit::before,
  body.mobile .nx-orbit > * { animation: none; }
  body.mobile .nx-press { scale: none; rotate: none; transition: filter 60ms linear; }
  body.mobile .nx-release,
  body.mobile .nx-stagger > *,
  body.mobile .nx-swap-in--fwd,
  body.mobile .nx-swap-in--back,
  body.mobile .nx-swap-out--fwd,
  body.mobile .nx-swap-out--back { animation: none; }
  body.mobile .nx-wipe { display: none; }
}
