/* ============================================
   SPYDEY OFFICIAL — Loader Styling
   loader.css | Cinematic Futuristic Technical Intro
   ============================================ */

/* === LOADER OVERLAY === */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 1s cubic-bezier(0.4, 0, 0.2, 1),
              transform 1s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, transform;
  overflow: hidden;
}

.loader.loaded {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.06);
  pointer-events: none;
}

/* === SUBTLE GRAIN TEXTURE === */
.loader::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 6;
  opacity: 0.65;
}

/* === CRT SCANLINES EFFECT === */
.loader-scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.3) 50%);
  background-size: 100% 4px;
  z-index: 5;
  pointer-events: none;
  opacity: 0.2;
}

/* === AMBIENT RED GLOW === */
.loader::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  height: 480px;
  background: radial-gradient(circle, rgba(230, 57, 70, 0.12) 0%, rgba(230, 57, 70, 0.03) 45%, transparent 70%);
  filter: blur(60px);
  z-index: 2;
  animation: ambientPulse 4s ease-in-out infinite;
}

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

/* === PROGRESS BAR (Top) === */
.loader-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-red), var(--accent-red-hover));
  z-index: 20;
  box-shadow: 0 0 20px var(--accent-red-glow), 0 0 60px rgba(230, 57, 70, 0.2);
}

/* === TOP-LEFT SCANNING METRICS === */
.loader-scanning-container {
  position: absolute;
  top: 40px;
  left: 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  font-family: 'Space Mono', monospace;
}

.loader-scanning {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-secondary);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}

.loader-scanning::before {
  content: '[';
  color: var(--accent-red);
}

.loader-scanning::after {
  content: ']';
  color: var(--accent-red);
  animation: scanningBlink 1.2s step-end infinite;
}

@keyframes scanningBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.loader-scan-bar-bg {
  width: 130px;
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-full);
}

.loader-scan-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
  animation: scanBarMove 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes scanBarMove {
  0% { left: -40%; }
  100% { left: 100%; }
}

/* === TOP-RIGHT PERCENTAGE & GLOBE === */
.loader-header-right {
  position: absolute;
  top: 40px;
  right: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10;
  font-family: 'Space Mono', monospace;
}

.loader-percent {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.01);
}

.loader-globe-wrapper {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
}

.loader-globe {
  width: 100%;
  height: 100%;
  animation: globeSpin 16s linear infinite;
}

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

/* === TECHNICAL SIDE PANELS === */
.loader-tech-left {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}

.loader-tech-block {
  width: 6px;
  height: 3px;
  background: var(--text-muted);
  opacity: 0.25;
}

.loader-tech-block:nth-child(2) { opacity: 0.45; width: 10px; }
.loader-tech-block:nth-child(3) { opacity: 0.7; width: 13px; background: var(--accent-red); }
.loader-tech-block:nth-child(4) { opacity: 0.35; width: 8px; }

.loader-tech-left span {
  font-family: 'Space Mono', monospace;
  font-size: 0.5rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  writing-mode: vertical-lr;
  margin-top: 16px;
  opacity: 0.45;
}

.loader-tech-right {
  position: absolute;
  right: 40px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 10;
}

.loader-tech-right span {
  font-family: 'Space Mono', monospace;
  font-size: 0.5rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  writing-mode: vertical-rl;
  opacity: 0.45;
}

.loader-tech-line {
  width: 1px;
  height: 80px;
  background: linear-gradient(to bottom, transparent, var(--text-muted), transparent);
  opacity: 0.25;
}

/* === VISUAL AREA (Character, Orbit, Rings) === */
.loader-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  perspective: 1200px;
}

/* Orbits */
.loader-orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.05);
  pointer-events: none;
  z-index: 1;
}

.loader-orbit-1 {
  width: 440px;
  height: 440px;
  animation: orbitCW 24s linear infinite;
}

.loader-orbit-2 {
  width: 490px;
  height: 490px;
  border-color: rgba(230, 57, 70, 0.05);
  animation: orbitCCW 32s linear infinite;
}

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

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

/* SVG Text Rings (Tilted 3D wrapping) */
.loader-ring {
  position: absolute;
  width: 530px;
  height: 530px;
  pointer-events: none;
  z-index: 3;
  transform: rotateX(72deg) rotateY(-12deg) rotateZ(0deg);
  transform-style: preserve-3d;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-ring-outer {
  animation: ringRotate3D 45s linear infinite;
}

.loader-ring-inner {
  animation: ringRotate3DInner 35s linear infinite;
}

@keyframes ringRotate3D {
  0% { transform: rotateX(72deg) rotateY(-12deg) rotateZ(0deg); }
  100% { transform: rotateX(72deg) rotateY(-12deg) rotateZ(360deg); }
}

@keyframes ringRotate3DInner {
  0% { transform: rotateX(72deg) rotateY(-12deg) rotateZ(0deg); }
  100% { transform: rotateX(72deg) rotateY(-12deg) rotateZ(-360deg); }
}

.loader-ring-circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.015);
  stroke-width: 1px;
}

.loader-ring-text {
  font-family: 'Space Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4.5px;
  fill: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.loader-ring-text-inner {
  font-size: 9.5px;
  letter-spacing: 3.5px;
  fill: rgba(255, 255, 255, 0.35);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
}

/* === CHARACTER IMAGE === */
.loader-character {
  max-height: 54vh;
  max-width: 54vw;
  object-fit: contain;
  filter: drop-shadow(0 0 60px rgba(230, 57, 70, 0.2))
          drop-shadow(0 30px 60px rgba(0, 0, 0, 0.85));
  animation: characterEntrance 1.2s cubic-bezier(0.16, 1, 0.3, 1) both,
             characterFloat 4s ease-in-out 1.2s infinite;
  position: relative;
  z-index: 2;
}

@keyframes characterEntrance {
  0% {
    opacity: 0;
    transform: scale(0.85) translateY(24px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes characterFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* === BRAND GLITCH TEXT === */
.loader-brand {
  margin-top: 36px;
  font-family: 'Oswald', sans-serif;
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 14px;
  color: #ffffff;
  position: relative;
  z-index: 10;
  animation: brandEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both;
  text-align: center;
}

.loader-brand::after {
  content: '';
  display: block;
  width: 0;
  height: 2px;
  background: var(--accent-red);
  margin: 12px auto 0;
  animation: brandLine 1s cubic-bezier(0.4, 0, 0.2, 1) 1.4s forwards;
  box-shadow: 0 0 12px var(--accent-red-glow);
}

@keyframes brandEntrance {
  0% {
    opacity: 0;
    transform: translateY(16px);
    letter-spacing: 24px;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 14px;
  }
}

@keyframes brandLine {
  0%   { width: 0; }
  100% { width: 60px; }
}

.loader-brand::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  color: var(--accent-red);
  z-index: -1;
  opacity: 0;
  animation: subtleGlitch 4s ease-in-out 2s infinite;
}

@keyframes subtleGlitch {
  0%, 92%, 100% { opacity: 0; transform: translate(0); }
  93%           { opacity: 0.5; transform: translate(-2px, 1px); }
  95%           { opacity: 0; transform: translate(2px, -1px); }
  96%           { opacity: 0.3; transform: translate(-1px, 0); }
  97%           { opacity: 0; transform: translate(0); }
}

/* === STATUS BAR === */
.loader-status {
  margin-top: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
}

.loader-status-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
  animation: dotPulse 1.2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* === BOTTOM TECHNICAL DETAILS === */
.loader-tech-bottom {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
  font-family: 'Space Mono', monospace;
  pointer-events: none;
}

.loader-tech-coords {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.5rem;
  letter-spacing: 2px;
  color: var(--text-muted);
  opacity: 0.45;
}

.loader-tech-serial {
  font-size: 0.6rem;
  letter-spacing: 3px;
  color: var(--text-secondary);
  opacity: 0.6;
  text-align: center;
  max-width: 90vw;
}

.loader-logo-sub {
  color: var(--text-muted);
  opacity: 0.25;
}

/* === RESPONSIVE LAYOUTS === */
@media (max-width: 1024px) {
  .loader-character {
    max-height: 46vh;
    max-width: 50vw;
  }

  .loader-orbit-1 { width: 380px; height: 380px; }
  .loader-orbit-2 { width: 420px; height: 420px; }
  .loader-ring { width: 460px; height: 460px; }
}

@media (max-width: 768px) {
  .loader-tech-left,
  .loader-tech-right,
  .loader-tech-coords,
  .loader-logo-sub {
    display: none;
  }

  .loader-scanning-container {
    top: 24px;
    left: 24px;
  }

  .loader-header-right {
    top: 24px;
    right: 24px;
  }

  .loader-character {
    max-height: 42vh;
    max-width: 70vw;
  }

  .loader-brand {
    margin-top: 24px;
    letter-spacing: 10px;
    font-size: clamp(1.1rem, 4vw, 1.6rem);
  }

  @keyframes brandEntrance {
    0% { opacity: 0; transform: translateY(16px); letter-spacing: 18px; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 10px; }
  }

  .loader-orbit-1 { width: 320px; height: 320px; }
  .loader-orbit-2 { width: 360px; height: 360px; }
  .loader-ring { width: 400px; height: 400px; }
  .loader-ring-text { font-size: 10px; letter-spacing: 3.5px; }
  .loader-ring-text-inner { font-size: 8px; letter-spacing: 2.5px; }

  .loader-tech-bottom {
    bottom: 24px;
  }

  .loader-tech-serial {
    font-size: 0.5rem;
    letter-spacing: 1.5px;
  }

  .loader::before {
    width: 320px;
    height: 320px;
  }
}

@media (max-width: 480px) {
  .loader-scanning-container {
    top: 20px;
    left: 20px;
  }

  .loader-header-right {
    top: 20px;
    right: 20px;
    gap: 8px;
  }

  .loader-scanning {
    font-size: 0.6rem;
    letter-spacing: 2px;
  }

  .loader-scan-bar-bg {
    width: 90px;
  }

  .loader-percent {
    font-size: 0.85rem;
    padding: 2px 8px;
  }

  .loader-globe-wrapper {
    width: 24px;
    height: 24px;
  }

  .loader-character {
    max-height: 36vh;
    max-width: 80vw;
  }

  .loader-brand {
    letter-spacing: 7px;
    margin-top: 20px;
  }

  @keyframes brandEntrance {
    0% { opacity: 0; transform: translateY(14px); letter-spacing: 12px; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 7px; }
  }

  .loader-orbit-1 { width: 260px; height: 260px; }
  .loader-orbit-2 { width: 290px; height: 290px; }
  .loader-ring { width: 320px; height: 320px; }
  .loader-ring-text { font-size: 8.5px; letter-spacing: 3px; }
  .loader-ring-text-inner { font-size: 7px; letter-spacing: 2px; }

  .loader-tech-serial {
    font-size: 0.45rem;
    letter-spacing: 1px;
    max-width: 85vw;
  }

  .loader::before {
    width: 240px;
    height: 240px;
  }
}
