/* ======================================
   BASE VARIABLES (Immersive Cinema Design System)
====================================== */
:root {
  /* Cinematic Theater Canvas (Light Mode - Crisp Gallery Theme) */
  --preloader-bg: #f8fafc;
  --dot-color: rgba(0, 71, 187, 0.05);
  --glow-color: rgba(0, 71, 187, 0.04);
  --flare-color-1: rgba(0, 71, 187, 0.02);
  --flare-color-2: rgba(67, 176, 231, 0.015);
  
  /* Shifting Nebulae Glows */
  --aurora-color-1: rgba(0, 71, 187, 0.04);
  --aurora-color-2: rgba(67, 176, 231, 0.03);
  
  /* Projector Dust particles */
  --dust-color: rgba(0, 71, 187, 0.12);

  /* Branding & Interface Elements */
  --text-primary: #0047BB;
  --text-secondary: #475569;
  --shine-color: #93c5fd;
  --title-glow: transparent;
  --logo-halo: transparent;
  
  --bar-bg: rgba(0, 71, 187, 0.03);
  --bar-border: rgba(0, 71, 187, 0.08);
  --bar-fill: linear-gradient(90deg, #0047BB, #0066FF);
  --bar-glow: 0 2px 8px rgba(0, 71, 187, 0.08);
  --text-under: #0047BB;
  --text-over: #ffffff;
  --lock-under: #0047BB;
  --lock-over: #ffffff;
  --bar-width: 340px;
  --bar-height: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Cinematic Theater Canvas (Dark Mode - Deep Midnight Sci-Fi) */
    --preloader-bg: #020306; /* Deeper black for maximum contrast */
    --dot-color: rgba(255, 255, 255, 0.04);
    --glow-color: rgba(59, 130, 246, 0.09);
    --flare-color-1: rgba(59, 130, 246, 0.04);
    --flare-color-2: rgba(168, 85, 247, 0.03);

    /* Shifting Nebulae Glows */
    --aurora-color-1: rgba(59, 130, 246, 0.15);
    --aurora-color-2: rgba(168, 85, 247, 0.12);
    
    /* Projector Dust particles */
    --dust-color: rgba(255, 255, 255, 0.15);

    /* Branding & Interface Elements (Neon Accents) */
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --shine-color: #60a5fa;
    --title-glow: 0 0 24px rgba(59, 130, 246, 0.35);
    --logo-halo: radial-gradient(circle, rgba(59, 130, 246, 0.22) 0%, transparent 70%);

    --bar-bg: rgba(255, 255, 255, 0.04);
    --bar-border: rgba(255, 255, 255, 0.08);
    --bar-fill: linear-gradient(90deg, #2563eb, #3b82f6, #60a5fa);
    --bar-glow: 0 0 16px rgba(59, 130, 246, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.2);
    --text-under: #94a3b8;
    --text-over: #ffffff;
    --lock-under: #60a5fa;
    --lock-over: #ffffff;
  }
}

/* ======================================
   GLOBAL STYLES & RESET
====================================== */
body {
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  overflow: hidden;
}

#preloader {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100dvh;
  background-color: var(--preloader-bg);
  /* Atmospheric technical dot grid */
  background-image: radial-gradient(var(--dot-color) 1.5px, transparent 1.5px);
  background-size: 32px 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

/* Ambient Radial Spotlight */
#preloader::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100vw; height: 100vh;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--glow-color) 0%, transparent 65%);
  z-index: -2;
  pointer-events: none;
  animation: glowPulse 10s ease-in-out infinite alternate;
}

@keyframes glowPulse {
  0% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(0.9);
  }
  100% {
    opacity: 1.2;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Cinematic Conic Spotlight Beam */
#preloader::after {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(
    from 0deg at 50% 50%,
    transparent 0%,
    var(--flare-color-1) 12%,
    transparent 24%,
    var(--flare-color-2) 48%,
    transparent 64%,
    var(--flare-color-1) 78%,
    transparent 92%
  );
  animation: rotateFlare 38s linear infinite;
  pointer-events: none;
  z-index: -2;
}

@keyframes rotateFlare {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#preloader.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* ======================================
   CINEMATIC AMBIENT NEBULAE/AURORA GLOWS
====================================== */
.aurora-glow-1,
.aurora-glow-2 {
  position: absolute;
  width: 80vw;
  height: 80vw;
  border-radius: 50%;
  filter: blur(120px);
  -webkit-filter: blur(120px);
  opacity: 0.8;
  pointer-events: none;
  z-index: -2;
}

.aurora-glow-1 {
  top: -20%; left: -20%;
  background: radial-gradient(circle, var(--aurora-color-1) 0%, transparent 70%);
  animation: floatGlow1 22s ease-in-out infinite alternate;
}

.aurora-glow-2 {
  bottom: -20%; right: -20%;
  background: radial-gradient(circle, var(--aurora-color-2) 0%, transparent 70%);
  animation: floatGlow2 26s ease-in-out infinite alternate;
}

@keyframes floatGlow1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(15%, 20%) scale(1.25); }
}

@keyframes floatGlow2 {
  0% { transform: translate(0, 0) scale(1.2); }
  100% { transform: translate(-20%, -15%) scale(0.9); }
}

/* ======================================
   VOLUMETRIC THEATER DUST PARTICLES (Projector light motes)
====================================== */
.dust-container {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.dust {
  position: absolute;
  background: var(--dust-color);
  border-radius: 50%;
  filter: blur(1px);
  -webkit-filter: blur(1px);
  animation: drift 18s linear infinite;
  opacity: 0;
}

.dust-1 { width: 4px; height: 4px; left: 15%; top: 100%; animation-duration: 20s; }
.dust-2 { width: 7px; height: 7px; left: 55%; top: 100%; animation-duration: 24s; animation-delay: -5s; filter: blur(2px); opacity: 0.08; }
.dust-3 { width: 3px; height: 3px; left: 35%; top: 100%; animation-duration: 16s; animation-delay: -2s; }
.dust-4 { width: 9px; height: 9px; left: 75%; top: 100%; animation-duration: 30s; animation-delay: -8s; filter: blur(3px); opacity: 0.06; }

@keyframes drift {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0;
  }
  15% {
    opacity: 0.65;
  }
  85% {
    opacity: 0.65;
  }
  100% {
    transform: translateY(-110dvh) translateX(60px) scale(1.4);
    opacity: 0;
  }
}

/* ======================================
   CINEMATIC CONTENT WRAPPER
====================================== */
.loader-wrapper {
  position: relative;
  text-align: center;
  width: 90%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
  z-index: 2;
  /* Cinematic camera pull-back and focus reveal */
  animation: cameraPull 2.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cameraPull {
  0% {
    opacity: 0;
    transform: scale(1.15) translateY(30px);
    filter: blur(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

/* ======================================
   PIXAR LUXO JR. STYLE HOPPING LOGO & PULSING HALO
====================================== */
.logo-container {
  position: relative;
  perspective: 1000px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

/* Pulsing ambient logo halo (Dark Mode exclusive accent) */
.logo-container::after {
  content: '';
  position: absolute;
  top: 45%; left: 50%;
  width: 130px; height: 130px;
  transform: translate(-50%, -50%);
  background: var(--logo-halo);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  animation: haloPulse 4s ease-in-out infinite alternate;
  animation-delay: 2.4s; /* starts after logo lands */
}

@keyframes haloPulse {
  0% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.85);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.logo {
  height: 100px;
  width: auto;
  object-fit: contain;
  margin-bottom: 32px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.05));
  transform-origin: bottom center;
  animation: logoHop 2.4s cubic-bezier(0.28, 0.11, 0.32, 1) forwards;
}

@media (prefers-color-scheme: dark) {
  .logo {
    filter: brightness(0) invert(1) drop-shadow(0 8px 24px rgba(59, 130, 246, 0.25));
  }
}

@keyframes logoHop {
  0% {
    transform: translate3d(-280px, -220px, 0) scale3d(1, 1, 1) rotate(-40deg);
    opacity: 0;
  }
  25% {
    /* First landing (squash) */
    transform: translate3d(-140px, 0, 0) scale3d(1.3, 0.7, 1) rotate(-15deg);
    opacity: 1;
  }
  38% {
    /* High rebound/jump (stretch) */
    transform: translate3d(-70px, -130px, 0) scale3d(0.8, 1.3, 1) rotate(5deg);
  }
  50% {
    /* Settle landing (squash) */
    transform: translate3d(0, 0, 0) scale3d(1.3, 0.7, 1) rotate(0deg);
  }
  62% {
    /* Settle rebound */
    transform: translate3d(0, -25px, 0) scale3d(0.9, 1.15, 1) rotate(0deg);
  }
  72% {
    /* Settle */
    transform: translate3d(0, 0, 0) scale3d(1.05, 0.95, 1) rotate(0deg);
  }
  80% {
    /* Head-Tilt look at screen */
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(15deg);
  }
  88% {
    /* Straighten */
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(0deg);
  }
  100% {
    transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(0deg);
  }
}

/* ======================================
   CINEMATIC BRAND TITLE & TEXT SHINE
====================================== */
.brand-title {
  font-family: 'Urbanist', sans-serif;
  font-size: clamp(32px, 7vw, 42px);
  font-weight: 800;
  margin: 0 0 8px 0;
  letter-spacing: -1px;
  
  /* Metallic Text Reflection */
  background: linear-gradient(120deg, var(--text-primary) 30%, var(--shine-color) 50%, var(--text-primary) 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transform-origin: center center;
  
  /* Dynamic Text Shadow Glow */
  text-shadow: var(--title-glow);
  
  /* Combined Reveal & Infinite Shine */
  animation: 
    titleReveal 2.4s cubic-bezier(0.25, 1, 0.5, 1) forwards,
    shineSweep 4.5s linear infinite;
  animation-delay: 0s, 2.4s;
}

@keyframes titleReveal {
  0% {
    opacity: 0;
    transform: scale(0.65) translateY(30px);
    filter: blur(12px);
  }
  50% {
    opacity: 0;
    transform: scale(0.65) translateY(30px);
    filter: blur(12px);
  }
  52% {
    /* Spring open from impact thud */
    opacity: 1;
    transform: scale(1.3, 0.7) translateY(12px);
    filter: blur(0);
  }
  62% {
    transform: scale(0.85, 1.25) translateY(-6px);
  }
  72% {
    transform: scale(1.1, 0.9) translateY(0);
  }
  80% {
    transform: scale(1, 1);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

@keyframes shineSweep {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.subtitle {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 5px;
  color: var(--text-secondary);
  font-weight: 700;
  margin: 0 0 52px 0;
  opacity: 0;
  animation: fadeIn 1.2s ease-out forwards;
  animation-delay: 1.6s;
}

/* ======================================
   GLOWING PROGRESS PILL WITH LASER SHINE
====================================== */
.progress-container {
  position: relative;
  width: var(--bar-width);
  height: var(--bar-height);
  background-color: var(--bar-bg);
  border: 1px solid var(--bar-border);
  border-radius: calc(var(--bar-height) / 2);
  overflow: hidden;
  margin-bottom: 36px;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.12), inset 0 1px 2px rgba(0, 0, 0, 0.1);
  z-index: 2;
  opacity: 0;
  transform: translateY(20px);
  animation: slideUpFade 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  animation-delay: 1.8s;
  transition: all 0.3s ease;
}

.progress-text-under {
  position: absolute;
  top: 0; left: 0;
  width: var(--bar-width);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-under);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  pointer-events: none;
  z-index: 1;
}

.progress-text-under .lock-icon {
  color: var(--lock-under);
}

.progress-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: var(--bar-fill);
  border-radius: calc(var(--bar-height) / 2);
  overflow: hidden;
  z-index: 2;
  width: 0%;
  box-shadow: var(--bar-glow);
  transition: width 0.1s linear;
}

/* Glowing Neon Laser Shine Pulse sliding continuously */
.progress-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 80px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: barShine 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes barShine {
  0% { transform: translateX(-80px); }
  100% { transform: translateX(340px); }
}

.progress-text-over {
  position: absolute;
  top: 0; left: 0;
  width: var(--bar-width);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-over);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  pointer-events: none;
}

.progress-text-over .lock-icon {
  color: var(--lock-over);
}

.lock-icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.5px;
  flex-shrink: 0;
}

/* ======================================
   CONNECTION STATUS & LABELS
====================================== */
.connection-status {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
  margin: 0 0 8px 0;
  height: 18px; /* reserve space to prevent layout shifts */
  z-index: 2;
  opacity: 0;
  animation: fadeIn 1s ease-out forwards;
  animation-delay: 2.0s;
  transition: color 0.3s ease;
}

.percentage {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 700;
  margin: 0;
  z-index: 2;
  opacity: 0;
  animation: fadeIn 1s ease-out forwards;
  animation-delay: 2.0s;
  transition: color 0.3s ease;
}

/* ======================================
   SHARED TRANSITION KEYFRAMES
====================================== */
@keyframes fadeIn {
  to { opacity: 1; }
}

@keyframes slideUpFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ======================================
   RESPONSIVE DESIGN ON VIEWPORT ADAPTABILITY
====================================== */
@media (max-width: 768px) {
  :root {
    --bar-width: 280px;
    --bar-height: 24px;
  }

  /* Make mobile layout follow system light/dark theme canvas cleanly */
  #preloader {
    background-image: radial-gradient(var(--dot-color) 1.5px, transparent 1.5px);
  }

  .logo {
    height: 80px;
    margin-bottom: 24px;
    animation: logoHopMobile 2.4s cubic-bezier(0.28, 0.11, 0.32, 1) forwards;
  }

  @keyframes logoHopMobile {
    0% {
      transform: translate3d(-180px, -180px, 0) scale3d(1, 1, 1) rotate(-40deg);
      opacity: 0;
    }
    25% {
      /* First landing (squash) */
      transform: translate3d(-90px, 0, 0) scale3d(1.3, 0.7, 1) rotate(-15deg);
      opacity: 1;
    }
    38% {
      /* High rebound/jump (stretch) */
      transform: translate3d(-45px, -90px, 0) scale3d(0.8, 1.3, 1) rotate(5deg);
    }
    50% {
      /* Settle landing (squash) */
      transform: translate3d(0, 0, 0) scale3d(1.3, 0.7, 1) rotate(0deg);
    }
    62% {
      /* Settle rebound */
      transform: translate3d(0, -15px, 0) scale3d(0.9, 1.15, 1) rotate(0deg);
    }
    72% {
      /* Settle */
      transform: translate3d(0, 0, 0) scale3d(1.05, 0.95, 1) rotate(0deg);
    }
    80% {
      /* Head-Tilt look at screen */
      transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(15deg);
    }
    88% {
      /* Straighten */
      transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(0deg);
    }
    100% {
      transform: translate3d(0, 0, 0) scale3d(1, 1, 1) rotate(0deg);
    }
  }

  .brand-title {
    font-size: 30px;
  }

  .subtitle {
    font-size: 11.5px;
    letter-spacing: 4px;
    margin-bottom: 40px;
  }

  .progress-text-under,
  .progress-text-over {
    font-size: 9px;
  }

  .lock-icon {
    width: 11px;
    height: 11px;
  }

  @keyframes barShine {
    0% { transform: translateX(-80px); }
    100% { transform: translateX(280px); }
  }
}

/* ======================================
   PRELOADER SHAKE ANIMATION (Feedback on back-button click)
 ====================================== */
@keyframes shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-24px, 0, 0); }
  30% { transform: translate3d(20px, 0, 0); }
  45% { transform: translate3d(-16px, 0, 0); }
  60% { transform: translate3d(12px, 0, 0); }
  75% { transform: translate3d(-6px, 0, 0); }
  90% { transform: translate3d(2px, 0, 0); }
}

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
  backface-visibility: hidden;
  perspective: 1000px;
}

