/**
 * AutoLocator ambient backdrop — mesh, floating orbs, glitter sparkles.
 * Shared by Next.js marketing site, upgrade checkout, and static auth pages.
 */

.ambient-scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-scene .mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(59, 130, 246, 0.24), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 8%, rgba(168, 85, 247, 0.2), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(34, 197, 94, 0.1), transparent 45%),
    radial-gradient(ellipse 40% 30% at 70% 55%, rgba(99, 102, 241, 0.08), transparent 50%);
}

.ambient-grid {
  position: absolute;
  inset: -50%;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent 72%);
  animation: grid-drift 48s linear infinite;
}

.ambient-orbs {
  position: absolute;
  inset: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  will-change: transform;
}

.orb--blue {
  width: min(42vw, 420px);
  height: min(42vw, 420px);
  top: -8%;
  left: -6%;
  background: rgba(59, 130, 246, 0.35);
  animation: orb-float-a 22s ease-in-out infinite;
}

.orb--purple {
  width: min(36vw, 360px);
  height: min(36vw, 360px);
  top: 12%;
  right: -8%;
  background: rgba(168, 85, 247, 0.32);
  animation: orb-float-b 26s ease-in-out infinite;
}

.orb--green {
  width: min(28vw, 280px);
  height: min(28vw, 280px);
  bottom: -6%;
  left: 35%;
  background: rgba(34, 197, 94, 0.22);
  animation: orb-float-c 30s ease-in-out infinite;
}

.ambient-sparkles {
  position: absolute;
  inset: 0;
}

.sparkle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px 1px rgba(255, 255, 255, 0.45);
  opacity: 0;
  animation: sparkle-twinkle var(--sparkle-duration, 4s) ease-in-out infinite;
  animation-delay: var(--sparkle-delay, 0s);
}

.sparkle::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(191, 219, 254, 0.9), transparent 70%);
}

.sparkle--lg {
  width: 4px;
  height: 4px;
  box-shadow: 0 0 10px 2px rgba(196, 181, 253, 0.55);
}

.sparkle--pro {
  background: #ddd6fe;
  box-shadow: 0 0 8px 1px rgba(168, 85, 247, 0.5);
}

/* Sparkle positions — deterministic layout */
.sparkle:nth-child(1)  { top: 8%;  left: 12%; --sparkle-duration: 3.2s; --sparkle-delay: 0.1s; }
.sparkle:nth-child(2)  { top: 15%; left: 78%; --sparkle-duration: 4.1s; --sparkle-delay: 0.8s; }
.sparkle:nth-child(3)  { top: 22%; left: 45%; --sparkle-duration: 3.8s; --sparkle-delay: 1.4s; }
.sparkle:nth-child(4)  { top: 31%; left: 88%; --sparkle-duration: 5s;   --sparkle-delay: 0.3s; }
.sparkle:nth-child(5)  { top: 38%; left: 6%;  --sparkle-duration: 4.4s; --sparkle-delay: 2.1s; }
.sparkle:nth-child(6)  { top: 44%; left: 62%; --sparkle-duration: 3.5s; --sparkle-delay: 1.1s; }
.sparkle:nth-child(7)  { top: 52%; left: 28%; --sparkle-duration: 4.8s; --sparkle-delay: 0.5s; }
.sparkle:nth-child(8)  { top: 58%; left: 92%; --sparkle-duration: 3.9s; --sparkle-delay: 1.9s; }
.sparkle:nth-child(9)  { top: 64%; left: 18%; --sparkle-duration: 4.2s; --sparkle-delay: 2.6s; }
.sparkle:nth-child(10) { top: 71%; left: 55%; --sparkle-duration: 3.6s; --sparkle-delay: 0.7s; }
.sparkle:nth-child(11) { top: 76%; left: 82%; --sparkle-duration: 5.2s; --sparkle-delay: 1.3s; }
.sparkle:nth-child(12) { top: 84%; left: 38%; --sparkle-duration: 4s;   --sparkle-delay: 2.3s; }
.sparkle:nth-child(13) { top: 12%; left: 33%; --sparkle-duration: 4.6s; --sparkle-delay: 3s; }
.sparkle:nth-child(14) { top: 27%; left: 71%; --sparkle-duration: 3.3s; --sparkle-delay: 1.7s; }
.sparkle:nth-child(15) { top: 48%; left: 8%;  --sparkle-duration: 4.9s; --sparkle-delay: 0.9s; }
.sparkle:nth-child(16) { top: 61%; left: 74%; --sparkle-duration: 3.7s; --sparkle-delay: 2.8s; }
.sparkle:nth-child(17) { top: 89%; left: 64%; --sparkle-duration: 4.3s; --sparkle-delay: 1.5s; }
.sparkle:nth-child(18) { top: 5%;  left: 56%; --sparkle-duration: 5.1s; --sparkle-delay: 0.2s; }
.sparkle:nth-child(19) { top: 35%; left: 22%; --sparkle-duration: 3.4s; --sparkle-delay: 2.4s; }
.sparkle:nth-child(20) { top: 55%; left: 48%; --sparkle-duration: 4.7s; --sparkle-delay: 1.2s; }
.sparkle:nth-child(21) { top: 68%; left: 4%;  --sparkle-duration: 3.9s; --sparkle-delay: 3.2s; }
.sparkle:nth-child(22) { top: 18%; left: 94%; --sparkle-duration: 4.5s; --sparkle-delay: 0.6s; }
.sparkle:nth-child(23) { top: 42%; left: 36%; --sparkle-duration: 5.3s; --sparkle-delay: 2s; }
.sparkle:nth-child(24) { top: 80%; left: 14%; --sparkle-duration: 3.8s; --sparkle-delay: 1.8s; }

.sparkle:nth-child(3n) { animation-name: sparkle-drift; }
.sparkle:nth-child(5n) { animation-name: sparkle-pulse; }
.sparkle:nth-child(7n).sparkle--lg { animation-name: sparkle-drift; }

/* Floating accent shapes */
.ambient-shapes {
  position: absolute;
  inset: 0;
}

.shape {
  position: absolute;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 16px;
  backdrop-filter: blur(2px);
  opacity: 0.35;
}

.shape--ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  top: 18%;
  right: 12%;
  border-color: rgba(59, 130, 246, 0.2);
  animation: shape-spin 40s linear infinite;
}

.shape--diamond {
  width: 64px;
  height: 64px;
  bottom: 22%;
  left: 10%;
  transform: rotate(45deg);
  border-color: rgba(168, 85, 247, 0.25);
  animation: shape-float 18s ease-in-out infinite;
}

.shape--pill {
  width: 140px;
  height: 48px;
  top: 62%;
  right: 18%;
  border-radius: 999px;
  border-color: rgba(34, 197, 94, 0.2);
  animation: shape-float 24s ease-in-out infinite reverse;
}

/* Shared motion keyframes */
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes grid-drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to { transform: translate(48px, 48px) rotate(0.5deg); }
}

@keyframes orb-float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(6%, 4%) scale(1.06); }
  66% { transform: translate(-3%, 7%) scale(0.96); }
}

@keyframes orb-float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40% { transform: translate(-5%, 6%) scale(1.08); }
  70% { transform: translate(4%, -4%) scale(0.94); }
}

@keyframes orb-float-c {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, -5%) scale(1.05); }
}

@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.4); }
  45% { opacity: 0.9; transform: scale(1); }
  55% { opacity: 0.35; transform: scale(0.85); }
}

@keyframes sparkle-drift {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
  40% { opacity: 1; transform: translateY(-12px) scale(1); }
  60% { opacity: 0.4; transform: translateY(-18px) scale(0.8); }
}

@keyframes sparkle-pulse {
  0%, 100% { opacity: 0; transform: scale(0.3); }
  50% { opacity: 0.75; transform: scale(1.2); }
}

@keyframes shape-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes shape-float {
  0%, 100% { transform: translateY(0) rotate(45deg); }
  50% { transform: translateY(-20px) rotate(50deg); }
}

.shape--ring {
  animation-name: shape-spin;
  transform: none;
}

.shape--pill {
  animation-name: shape-float-pill;
}

@keyframes shape-float-pill {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

/* Upgrade-page motion utilities */
.fade-up {
  animation: fade-up 0.65s ease both;
}

.fade-up-delay-1 { animation-delay: 0.08s; }
.fade-up-delay-2 { animation-delay: 0.16s; }
.fade-up-delay-3 { animation-delay: 0.24s; }

.glass-surface {
  background: rgba(18, 26, 39, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.14);
  backdrop-filter: blur(12px);
}

.gradient-border {
  border-radius: calc(var(--radius, 16px) + 2px);
  padding: 1px;
  background: linear-gradient(145deg, rgba(59, 130, 246, 0.5), rgba(168, 85, 247, 0.35));
}

.gradient-border-inner {
  border-radius: var(--radius, 16px);
  background: var(--surface, #121a27);
}

@media (prefers-reduced-motion: reduce) {
  .ambient-grid,
  .orb,
  .sparkle,
  .shape {
    animation: none !important;
  }

  .fade-up {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}
