/* ═══════════════════════════════════════════════════════
   SVS DigiCorp — 3D Logo Preloader
   Fingerprint logo with 3D cube morph, particles & glow
   ═══════════════════════════════════════════════════════ */

/* ── Hide body until preloader is ready (prevents flash) ── */
body.preloader-active {
  overflow: hidden;
}

/* ── Preloader Overlay ── */
#svs-preloader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0e1a 0%, #111833 40%, #0d1028 100%);
  overflow: hidden;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#svs-preloader.preloader-exit {
  opacity: 0;
  transform: scale(1.15);
  filter: blur(10px);
  pointer-events: none;
}

#svs-preloader.preloader-hidden {
  display: none;
}

/* ── Background Grid Pattern ── */
#svs-preloader::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(224, 31, 36, 0.06) 1px, transparent 0);
  background-size: 40px 40px;
  animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* ── 3D Scene Container ── */
.preloader-scene {
  perspective: 800px;
  width: 180px;
  height: 180px;
  position: relative;
}

/* ── 3D Cube ── */
.preloader-cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: cubeRotate 4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes cubeRotate {
  0%   { transform: rotateX(0deg) rotateY(0deg); }
  25%  { transform: rotateX(90deg) rotateY(0deg); }
  50%  { transform: rotateX(90deg) rotateY(90deg); }
  75%  { transform: rotateX(180deg) rotateY(90deg); }
  100% { transform: rotateX(360deg) rotateY(360deg); }
}

/* ── Cube Faces ── */
.cube-face {
  position: absolute;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: visible;
  border-radius: 22px;
  border: 1.5px solid rgba(224, 31, 36, 0.2);
  background: rgba(10, 14, 26, 0.85);
  box-shadow:
    inset 0 0 40px rgba(224, 31, 36, 0.08),
    0 0 30px rgba(224, 31, 36, 0.05);
}

.cube-face img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(224, 31, 36, 0.5));
  animation: logoGlow 2s ease-in-out infinite alternate;
}

@keyframes logoGlow {
  0%   { filter: drop-shadow(0 0 15px rgba(224, 31, 36, 0.4)) brightness(0.9); }
  100% { filter: drop-shadow(0 0 35px rgba(130, 46, 107, 0.7)) brightness(1.2); }
}

/* Face positions */
.cube-face--front  { transform: translateZ(90px); }
.cube-face--back   { transform: rotateY(180deg) translateZ(90px); }
.cube-face--right  { transform: rotateY(90deg) translateZ(90px); }
.cube-face--left   { transform: rotateY(-90deg) translateZ(90px); }
.cube-face--top    { transform: rotateX(90deg) translateZ(90px); }
.cube-face--bottom { transform: rotateX(-90deg) translateZ(90px); }

/* ── Pulse Rings ── */
.preloader-rings {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.pulse-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
  animation: ringPulse 3s ease-out infinite;
}

.pulse-ring:nth-child(1) {
  width: 220px;
  height: 220px;
  border-color: rgba(224, 31, 36, 0.35);
  animation-delay: 0s;
}

.pulse-ring:nth-child(2) {
  width: 280px;
  height: 280px;
  border-color: rgba(130, 46, 107, 0.25);
  animation-delay: 0.7s;
}

.pulse-ring:nth-child(3) {
  width: 340px;
  height: 340px;
  border-color: rgba(224, 31, 36, 0.15);
  animation-delay: 1.4s;
}

@keyframes ringPulse {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ── Orbital Particles ── */
.preloader-orbit {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.orbit-track {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(224, 31, 36, 0.1);
}

.orbit-track:nth-child(1) {
  width: 260px;
  height: 260px;
  animation: orbitSpin 6s linear infinite;
}

.orbit-track:nth-child(2) {
  width: 320px;
  height: 320px;
  animation: orbitSpin 8s linear infinite reverse;
  border-color: rgba(130, 46, 107, 0.12);
}

.orbit-track:nth-child(3) {
  width: 380px;
  height: 380px;
  animation: orbitSpin 10s linear infinite;
  border-color: rgba(224, 31, 36, 0.08);
}

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

.orbit-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e01f24, #822e6b);
  box-shadow: 0 0 12px rgba(224, 31, 36, 0.6), 0 0 24px rgba(224, 31, 36, 0.3);
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
}

.orbit-track:nth-child(2) .orbit-dot {
  width: 4px;
  height: 4px;
  top: auto;
  bottom: -2px;
  background: linear-gradient(135deg, #822e6b, #e01f24);
  box-shadow: 0 0 10px rgba(130, 46, 107, 0.6), 0 0 20px rgba(130, 46, 107, 0.3);
}

.orbit-track:nth-child(3) .orbit-dot {
  width: 5px;
  height: 5px;
  top: 50%;
  left: -2px;
  transform: translateY(-50%);
  background: linear-gradient(135deg, #e01f24, #822e6b);
  box-shadow: 0 0 8px rgba(224, 31, 36, 0.5);
}

/* ── Brand Text ── */
.preloader-brand {
  margin-top: 50px;
  text-align: center;
  position: relative;
  z-index: 2;
}

.preloader-brand-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 6px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #e01f24 0%, #822e6b 50%, #e01f24 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: textShimmer 3s ease-in-out infinite;
  position: relative;
}

@keyframes textShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Glitch effect on brand name */
.preloader-brand-name::before,
.preloader-brand-name::after {
  content: 'SVS DIGICORP';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  background: inherit;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0;
}

.preloader-brand-name::before {
  animation: glitch1 4s ease-in-out infinite;
  color: #e01f24;
}

.preloader-brand-name::after {
  animation: glitch2 4s ease-in-out infinite;
  color: #822e6b;
}

@keyframes glitch1 {
  0%, 85%, 100% { opacity: 0; transform: translate(0); }
  86% { opacity: 0.6; transform: translate(-2px, 1px); }
  87% { opacity: 0; transform: translate(0); }
  92% { opacity: 0.4; transform: translate(2px, -1px); }
  93% { opacity: 0; }
}

@keyframes glitch2 {
  0%, 88%, 100% { opacity: 0; transform: translate(0); }
  89% { opacity: 0.5; transform: translate(2px, -1px); }
  90% { opacity: 0; transform: translate(0); }
  95% { opacity: 0.3; transform: translate(-1px, 2px); }
  96% { opacity: 0; }
}

.preloader-tagline {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  margin-top: 10px;
  animation: tagFade 2s ease-in-out infinite alternate;
}

@keyframes tagFade {
  0%   { opacity: 0.25; }
  100% { opacity: 0.55; }
}

/* ── Loading Bar ── */
.preloader-progress {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.preloader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e01f24, #822e6b, #e01f24);
  background-size: 200% 100%;
  border-radius: 2px;
  animation: progressFill 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards,
             progressShimmer 1.5s ease-in-out infinite;
}

@keyframes progressFill {
  0%   { width: 0%; }
  20%  { width: 25%; }
  50%  { width: 55%; }
  80%  { width: 85%; }
  100% { width: 100%; }
}

@keyframes progressShimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ── Floating Particles (Background) ── */
.preloader-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(224, 31, 36, 0.4);
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .preloader-scene {
    width: 130px;
    height: 130px;
  }

  .cube-face {
    width: 130px;
    height: 130px;
    border-radius: 16px;
  }

  .cube-face img {
    width: 80px;
    height: 80px;
  }

  .cube-face--front  { transform: translateZ(65px); }
  .cube-face--back   { transform: rotateY(180deg) translateZ(65px); }
  .cube-face--right  { transform: rotateY(90deg) translateZ(65px); }
  .cube-face--left   { transform: rotateY(-90deg) translateZ(65px); }
  .cube-face--top    { transform: rotateX(90deg) translateZ(65px); }
  .cube-face--bottom { transform: rotateX(-90deg) translateZ(65px); }

  .pulse-ring:nth-child(1) { width: 160px; height: 160px; }
  .pulse-ring:nth-child(2) { width: 200px; height: 200px; }
  .pulse-ring:nth-child(3) { width: 240px; height: 240px; }

  .orbit-track:nth-child(1) { width: 190px; height: 190px; }
  .orbit-track:nth-child(2) { width: 230px; height: 230px; }
  .orbit-track:nth-child(3) { width: 270px; height: 270px; }

  .preloader-brand-name {
    font-size: 1.3rem;
    letter-spacing: 4px;
  }

  .preloader-brand {
    margin-top: 35px;
  }

  .preloader-progress {
    width: 150px;
    bottom: 30px;
  }
}
