/* Neuro-Wallet — Gamification SaaS (emil-design-eng) */

:root {
  --wgs-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --wgs-ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --wgs-xp: var(--teal);
  --wgs-xp-2: #2DD4A8;
  --wgs-gold: var(--amber);
  --wgs-gold-dim: #FBEFD5;
  --wgs-violet: var(--violet);
  --wgs-surface: var(--s1);
  --wgs-border: var(--border-md);
  --wgs-shadow: 0 16px 40px -24px rgba(26, 184, 148, 0.30);
  --wgs-shadow-soft: 0 8px 24px -16px rgba(15, 23, 42, 0.12);
  --wgs-max: 760px;
}

body.wallet-gamify-saas {
  --brand-primary: var(--wgs-xp);
  --brand-primary-dim: var(--teal-dim);
}

body.wallet-gamify-saas .app-bg-ambient {
  background:
    radial-gradient(ellipse 70% 42% at 50% -8%, rgba(26, 184, 148, 0.14), transparent 58%),
    radial-gradient(ellipse 40% 30% at 100% 100%, rgba(110, 93, 184, 0.06), transparent 50%),
    var(--bg);
}

/* ── Layout shell ── */
body.wallet-gamify-saas .wallet-overview {
  max-width: var(--wgs-max);
  gap: 12px;
}

@media (min-width: 1024px) {
  body.shell-pro-active.wallet-gamify-saas .shell-pro-main {
    padding-top: 14px;
  }

  /* Tier 2: subnav is source of truth on overview */
  body.shell-pro-active.wallet-gamify-saas #app-bento-mount,
  body.shell-pro-active.wallet-gamify-saas #wallet-journey-nudge {
    display: none !important;
  }
}

/* ── Player HUD (gamification command bar) ── */
.wgs-hud {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--wgs-border);
  background:
    linear-gradient(135deg, rgba(26, 184, 148, 0.08), rgba(110, 93, 184, 0.04)),
    var(--wgs-surface);
  box-shadow: var(--wgs-shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  position: relative;
  overflow: hidden;
}

.wgs-hud::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--wgs-xp), var(--wgs-xp-2), var(--wgs-gold));
}

.wgs-hud-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.wgs-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: linear-gradient(145deg, var(--teal-dim), var(--s2));
  border: 1px solid rgba(26, 184, 148, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 160ms var(--wgs-ease-out);
}

.wgs-hud-player-meta {
  flex: 1;
  min-width: 0;
}

.wgs-hud-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.wgs-level-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0E7A63;
  background: linear-gradient(135deg, rgba(26,184,148,0.28), rgba(26,184,148,0.16));
}

.wgs-player-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.2;
  text-wrap: balance;
}

.wgs-xp-track {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--s2);
  overflow: hidden;
  margin-bottom: 4px;
}

.wgs-xp-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--wgs-xp), var(--wgs-xp-2) 55%, var(--wgs-violet));
  transition: width 720ms var(--wgs-ease-out);
  position: relative;
}

.wgs-xp-fill.is-animating::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: wgsXpShine 900ms var(--wgs-ease-out) 1;
}

@keyframes wgsXpShine {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

.wgs-xp-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.wgs-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.wgs-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--s1);
  text-align: center;
  transition: transform 140ms var(--wgs-ease-out), border-color 160ms ease;
}

.wgs-stat-pill:active {
  transform: scale(0.97);
}

.wgs-stat-pill.is-hot {
  border-color: rgba(212, 146, 10, 0.35);
  background: linear-gradient(180deg, #FBF3E0, var(--s1));
}

.wgs-stat-icon {
  font-size: 18px;
  line-height: 1;
}

.wgs-stat-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.wgs-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Plan tier — quest reward style */
.wgs-plan-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px dashed rgba(26, 184, 148, 0.35);
  background: var(--teal-dim);
}

.wgs-plan-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--s1);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.wgs-plan-copy {
  flex: 1;
  min-width: 0;
}

.wgs-plan-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wgs-xp);
  margin-bottom: 2px;
}

.wgs-plan-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}

.wgs-plan-desc {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.wgs-plan-cta {
  flex-shrink: 0;
  min-height: 34px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--wgs-xp), var(--wgs-xp-2));
  box-shadow: 0 6px 16px -8px rgba(26, 184, 148, 0.55);
  transition: transform 140ms var(--wgs-ease-out), filter 160ms ease;
}

.wgs-plan-cta:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .wgs-plan-cta:hover {
    filter: brightness(1.05);
  }
}

/* Game portal stage */
.wgs-game-stage {
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid rgba(26, 184, 148, 0.22);
  background: #14121C;
  box-shadow: var(--wgs-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  min-height: min(580px, calc(100dvh - 260px));
}

.wgs-game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.wgs-game-head-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: #ECE7F3;
  letter-spacing: 0.04em;
}

.wgs-game-head-sub {
  margin: 2px 0 0;
  font-size: 10px;
  color: rgba(237, 232, 243, 0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wgs-game-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
  animation: wgsLivePulse 1.4s var(--wgs-ease-out) infinite;
}

@keyframes wgsLivePulse {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

.wgs-game-open {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #5EEAD4;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(94, 234, 212, 0.25);
  transition: transform 140ms var(--wgs-ease-out), background 160ms ease;
}

.wgs-game-open:active {
  transform: scale(0.97);
}

.wgs-game-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.wgs-game-body iframe {
  width: 100%;
  min-height: 480px;
  height: 100%;
  border: 0;
  display: block;
  opacity: 1;
  transition: opacity 200ms var(--wgs-ease-out), filter 200ms var(--wgs-ease-out);
}

.wgs-game-stage.is-loading .wgs-game-body iframe {
  opacity: 0.4;
  filter: blur(2px);
}

.wgs-game-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #14121C;
  z-index: 1;
  transition: opacity 200ms var(--wgs-ease-out);
}

.wgs-game-stage.is-live .wgs-game-loading {
  opacity: 0;
  pointer-events: none;
}

.wgs-loader-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: #34D399;
  animation: wgsSpin 680ms linear infinite;
}

@keyframes wgsSpin {
  to { transform: rotate(360deg); }
}

.wgs-loader-text {
  font-size: 12px;
  color: rgba(237, 232, 243, 0.55);
}

/* Secondary panels */
.wgs-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .wgs-secondary {
    grid-template-columns: 1fr 1fr;
  }
}

.wgs-panel-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.wgs-panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--s1);
  overflow: hidden;
  box-shadow: var(--wgs-shadow-soft);
}

.wgs-vela-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.wgs-vela-balance {
  font-size: 22px;
  font-weight: 800;
  color: var(--wgs-xp);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.wgs-achievement {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 160ms ease;
}

.wgs-achievement:last-child {
  border-bottom: none;
}

.wgs-achievement.is-unlocked {
  background: linear-gradient(90deg, var(--teal-dim), transparent);
}

.wgs-achievement-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--s2);
  transition: transform 200ms var(--wgs-ease-out);
}

.wgs-achievement.is-unlocked .wgs-achievement-badge {
  border-color: rgba(26, 184, 148, 0.35);
  background: var(--teal-dim);
}

.wgs-achievement.is-locked .wgs-achievement-badge {
  filter: grayscale(1);
  opacity: 0.45;
}

.wgs-achievement-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}

.wgs-achievement.is-locked .wgs-achievement-title {
  color: var(--text-3);
}

.wgs-achievement-desc {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.wgs-achievement-status {
  font-size: 11px;
  font-weight: 700;
  color: var(--wgs-xp);
  flex-shrink: 0;
}

.wgs-achievement.is-locked .wgs-achievement-status {
  color: var(--text-3);
  background: var(--s2);
  padding: 3px 8px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
}

/* Microapp host — wallet gamification shell */
body.wallet-gamify-saas.microapp-host::before {
  background:
    radial-gradient(ellipse 60% 40% at 50% -6%, rgba(26, 184, 148, 0.12), transparent 55%),
    radial-gradient(ellipse 35% 28% at 100% 100%, rgba(110, 93, 184, 0.06), transparent 50%);
}

body.wallet-gamify-saas.microapp-host .microapp-stage {
  border-color: rgba(26, 184, 148, 0.22);
  box-shadow: var(--wgs-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.wallet-gamify-saas.microapp-host .microapp-stage-head {
  background: linear-gradient(180deg, var(--teal-dim), var(--s1));
}

body.wallet-gamify-saas.microapp-host .microapp-stage-icon {
  background: linear-gradient(145deg, var(--teal-dim), rgba(26,184,148,0.18));
  border: 1px solid rgba(26, 184, 148, 0.2);
}

body.wallet-gamify-saas .microapp-chip.is-active,
body.wallet-gamify-saas .microapp-chips--wallet .microapp-chip.is-active {
  border-color: var(--wgs-xp);
  background: var(--teal-dim);
  color: #0E7A63;
}

/* Mount motion — once per load */
@keyframes wgsMountIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.wallet-gamify-saas.is-ready .wgs-hud {
  animation: wgsMountIn 260ms var(--wgs-ease-out) forwards;
}

body.wallet-gamify-saas.is-ready .wgs-game-stage {
  animation: wgsMountIn 280ms var(--wgs-ease-out) 80ms forwards;
  opacity: 0;
}

body.wallet-gamify-saas.is-ready .wgs-stat-pill {
  opacity: 0;
  animation: wgsMountIn 220ms var(--wgs-ease-out) forwards;
}

body.wallet-gamify-saas.is-ready .wgs-stat-pill:nth-child(1) { animation-delay: 40ms; }
body.wallet-gamify-saas.is-ready .wgs-stat-pill:nth-child(2) { animation-delay: 75ms; }
body.wallet-gamify-saas.is-ready .wgs-stat-pill:nth-child(3) { animation-delay: 110ms; }

body.wallet-gamify-saas.is-stat-ready .wgs-stat-val.is-pop {
  animation: wgsStatPop 320ms var(--wgs-ease-out);
}

@keyframes wgsStatPop {
  0% { transform: scale(0.96); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  body.wallet-gamify-saas.is-ready .wgs-hud,
  body.wallet-gamify-saas.is-ready .wgs-game-stage,
  body.wallet-gamify-saas.is-ready .wgs-stat-pill {
    animation: none;
    opacity: 1;
  }

  .wgs-xp-fill { transition: width 0.2s ease; }
  .wgs-xp-fill.is-animating::after { animation: none; }
  .wgs-game-live-dot { animation: none; opacity: 0.8; }
  .wgs-loader-ring { animation-duration: 1.2s; }
  .wgs-game-body iframe,
  .wgs-game-stage.is-loading .wgs-game-body iframe {
    opacity: 1;
    filter: none;
  }
}
