/* ==============================================
   AIZONIQ Preloader — "Neural Awakening"
   Premium full-screen loading experience
   ============================================== */

/* ── Base Overlay ────────────────────────────── */
.azq-preloader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0f;
  overflow: hidden;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Ambient Background ─────────────────────── */
.azq-pl-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Floating gradient orbs */
.azq-pl-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .35;
  will-change: transform;
}
.azq-pl-orb1 {
  width: 340px; height: 340px;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
  top: -100px; left: -80px;
  animation: azq-orb-float 6s ease-in-out infinite alternate;
}
.azq-pl-orb2 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #ec4899 0%, transparent 70%);
  bottom: -60px; right: -60px;
  animation: azq-orb-float 7s ease-in-out infinite alternate-reverse;
}
.azq-pl-orb3 {
  width: 200px; height: 200px;
  background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation: azq-orb-pulse 4s ease-in-out infinite;
}

/* Subtle grid pattern */
.azq-pl-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.04) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: azq-grid-drift 20s linear infinite;
}

/* ── Center Content ──────────────────────────── */
.azq-pl-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  z-index: 2;
}

/* ── Orbital Rings ───────────────────────────── */
.azq-pl-rings {
  position: absolute;
  width: 340px; height: 340px;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.azq-pl-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #6366f1;
  border-right-color: rgba(139, 92, 246, .5);
  animation: azq-spin 2.4s linear infinite;
  filter: drop-shadow(0 0 6px rgba(99,102,241,.4));
}

.azq-pl-ring2 {
  inset: 18px;
  border-top-color: #ec4899;
  border-right-color: rgba(236, 72, 153, .5);
  border-left-color: rgba(139, 92, 246, .3);
  animation: azq-spin-reverse 3s linear infinite;
  filter: drop-shadow(0 0 6px rgba(236,72,153,.3));
}

.azq-pl-ring3 {
  inset: 38px;
  border: 1.5px solid transparent;
  border-top-color: rgba(99,102,241,.4);
  border-bottom-color: rgba(139,92,246,.3);
  animation: azq-spin 4s linear infinite;
  filter: drop-shadow(0 0 4px rgba(99,102,241,.2));
}

/* ── Logo ────────────────────────────────────── */
.azq-pl-logo {
  position: relative;
  font-size: 3.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  z-index: 3;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  animation: azq-logo-breathe 3s ease-in-out infinite;
}

.azq-pl-ai {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(99,102,241,.6))
         drop-shadow(0 0 40px rgba(99,102,241,.3));
  animation: azq-ai-glow 2s ease-in-out infinite;
}

.azq-pl-zoniq {
  color: #ffffff;
  text-shadow: 0 0 30px rgba(255,255,255,.15);
  overflow: hidden;
  animation: azq-zoniq-reveal 1.2s cubic-bezier(.77,0,.175,1) .3s both;
}

/* Arabic logo mode */
html[dir="rtl"] .azq-pl-logo,
html[lang="ar"] .azq-pl-logo {
  font-family: 'Tajawal', 'Inter', sans-serif;
  letter-spacing: 0;
  direction: rtl;
}

/* ── Tagline ─────────────────────────────────── */
.azq-pl-tagline {
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  margin-top: -4px;
  animation: azq-tagline-in .8s ease-out .8s both;
}

/* ── Loading Dots ────────────────────────────── */
.azq-pl-dots {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.azq-pl-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #6366f1;
  opacity: .3;
  animation: azq-dot-pulse 1.4s ease-in-out infinite;
}
.azq-pl-dots span:nth-child(2) { animation-delay: .15s; background: #7c3aed; }
.azq-pl-dots span:nth-child(3) { animation-delay: .30s; background: #8b5cf6; }
.azq-pl-dots span:nth-child(4) { animation-delay: .45s; background: #a855f7; }
.azq-pl-dots span:nth-child(5) { animation-delay: .60s; background: #ec4899; }

/* ── Floating Particles ──────────────────────── */
.azq-pl-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.azq-pl-particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: #6366f1;
  opacity: 0;
  animation: azq-particle-float 4s ease-in-out infinite;
}
.azq-pl-particle:nth-child(1)  { left:18%; top:25%; animation-delay:0s;    background:#6366f1; }
.azq-pl-particle:nth-child(2)  { left:82%; top:20%; animation-delay:.6s;   background:#8b5cf6; }
.azq-pl-particle:nth-child(3)  { left:12%; top:70%; animation-delay:1.2s;  background:#ec4899; }
.azq-pl-particle:nth-child(4)  { left:85%; top:75%; animation-delay:.3s;   background:#a78bfa; }
.azq-pl-particle:nth-child(5)  { left:50%; top:15%; animation-delay:.9s;   background:#6366f1; }
.azq-pl-particle:nth-child(6)  { left:30%; top:85%; animation-delay:1.5s;  background:#8b5cf6; }
.azq-pl-particle:nth-child(7)  { left:70%; top:50%; animation-delay:.4s;   background:#ec4899; }
.azq-pl-particle:nth-child(8)  { left:40%; top:40%; animation-delay:1.1s;  background:#a78bfa; }
.azq-pl-particle:nth-child(9)  { left:60%; top:80%; animation-delay:.7s;   background:#6366f1; }
.azq-pl-particle:nth-child(10) { left:25%; top:55%; animation-delay:1.8s;  background:#8b5cf6; }
.azq-pl-particle:nth-child(11) { left:75%; top:35%; animation-delay:.2s;   background:#ec4899; }
.azq-pl-particle:nth-child(12) { left:55%; top:60%; animation-delay:1.4s;  background:#a78bfa; }

/* ── Progress Bar ────────────────────────────── */
.azq-pl-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,.05);
  overflow: hidden;
  z-index: 5;
}

.azq-pl-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899, #f43f5e);
  background-size: 300% 100%;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 15px rgba(99,102,241,.5), 0 0 30px rgba(236,72,153,.3);
  animation: azq-progress 2s cubic-bezier(.4,0,.2,1) forwards,
             azq-bar-shimmer 2s linear infinite;
}

/* ── Connector Lines (neural network feel) ──── */
.azq-pl-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.azq-pl-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,.15), transparent);
  animation: azq-line-scan 3s ease-in-out infinite;
}
.azq-pl-line:nth-child(1) { top: 30%; width: 100%; animation-delay: 0s; }
.azq-pl-line:nth-child(2) { top: 50%; width: 100%; animation-delay: 1s; }
.azq-pl-line:nth-child(3) { top: 70%; width: 100%; animation-delay: 2s; }

.azq-pl-line-v {
  position: absolute;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, rgba(139,92,246,.1), transparent);
  animation: azq-line-scan-v 4s ease-in-out infinite;
}
.azq-pl-line-v:nth-child(4) { left: 25%; animation-delay: .5s; }
.azq-pl-line-v:nth-child(5) { left: 50%; animation-delay: 1.5s; }
.azq-pl-line-v:nth-child(6) { left: 75%; animation-delay: 2.5s; }

/* ══════════════════════════════════════════════
   EXIT ANIMATION
   ══════════════════════════════════════════════ */
.azq-preloader.azq-pl-exit {
  animation: azq-exit .65s cubic-bezier(.4,0,.2,1) forwards;
}

.azq-preloader.azq-pl-exit .azq-pl-logo {
  animation: azq-logo-exit .5s cubic-bezier(.4,0,.2,1) forwards;
}

.azq-preloader.azq-pl-exit .azq-pl-ring,
.azq-preloader.azq-pl-exit .azq-pl-ring2,
.azq-preloader.azq-pl-exit .azq-pl-ring3 {
  animation: azq-ring-exit .5s ease-out forwards;
}

.azq-preloader.azq-pl-exit .azq-pl-dots,
.azq-preloader.azq-pl-exit .azq-pl-tagline {
  animation: azq-fade-down .3s ease-out forwards;
}

.azq-preloader.azq-pl-exit .azq-pl-bar {
  width: 100% !important;
  transition: width .3s ease-out;
}

/* ══════════════════════════════════════════════
   MINI MODE (Language switch & nav transition)
   ══════════════════════════════════════════════ */
.azq-preloader.azq-pl-mini {
  animation: azq-mini-in .25s ease-out both;
}

.azq-preloader.azq-pl-mini .azq-pl-rings,
.azq-preloader.azq-pl-mini .azq-pl-particles,
.azq-preloader.azq-pl-mini .azq-pl-lines,
.azq-preloader.azq-pl-mini .azq-pl-tagline {
  display: none;
}

.azq-preloader.azq-pl-mini .azq-pl-logo {
  font-size: 2.8rem;
  animation: azq-mini-pulse .6s ease-in-out;
}

.azq-preloader.azq-pl-mini .azq-pl-progress {
  height: 2px;
}

.azq-preloader.azq-pl-mini .azq-pl-bar {
  animation-duration: .7s;
}

.azq-preloader.azq-pl-mini.azq-pl-exit {
  animation: azq-exit .35s cubic-bezier(.4,0,.2,1) forwards;
}

/* ══════════════════════════════════════════════
   KEYFRAME ANIMATIONS
   ══════════════════════════════════════════════ */

/* Ring rotation */
@keyframes azq-spin {
  to { transform: rotate(360deg); }
}
@keyframes azq-spin-reverse {
  to { transform: rotate(-360deg); }
}

/* Orb floating */
@keyframes azq-orb-float {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, -30px) scale(1.15); }
}
@keyframes azq-orb-pulse {
  0%, 100% { opacity: .2; transform: translate(-50%,-50%) scale(.8); }
  50%      { opacity: .4; transform: translate(-50%,-50%) scale(1.2); }
}

/* Grid drift */
@keyframes azq-grid-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(60px, 60px); }
}

/* Logo breathing */
@keyframes azq-logo-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

/* AI glow pulse */
@keyframes azq-ai-glow {
  0%, 100% {
    filter: drop-shadow(0 0 20px rgba(99,102,241,.6))
            drop-shadow(0 0 40px rgba(99,102,241,.3));
  }
  50% {
    filter: drop-shadow(0 0 30px rgba(99,102,241,.8))
            drop-shadow(0 0 60px rgba(139,92,246,.5))
            drop-shadow(0 0 80px rgba(236,72,153,.2));
  }
}

/* ZONIQ text reveal */
@keyframes azq-zoniq-reveal {
  from { max-width: 0; opacity: 0; }
  to   { max-width: 300px; opacity: 1; }
}

/* Tagline entrance */
@keyframes azq-tagline-in {
  from { opacity: 0; transform: translateY(10px); letter-spacing: 8px; }
  to   { opacity: 1; transform: translateY(0); letter-spacing: 4px; }
}

/* Loading dots */
@keyframes azq-dot-pulse {
  0%, 80%, 100% { opacity: .25; transform: scale(.8); }
  40%           { opacity: 1; transform: scale(1.3); }
}

/* Particle float */
@keyframes azq-particle-float {
  0%   { opacity: 0; transform: translateY(0) scale(0); }
  20%  { opacity: .7; transform: translateY(-10px) scale(1); }
  80%  { opacity: .5; transform: translateY(-40px) scale(.8); }
  100% { opacity: 0; transform: translateY(-60px) scale(0); }
}

/* Progress bar */
@keyframes azq-progress {
  0%   { width: 0%; }
  20%  { width: 25%; }
  50%  { width: 55%; }
  70%  { width: 75%; }
  90%  { width: 88%; }
  100% { width: 95%; }
}

@keyframes azq-bar-shimmer {
  from { background-position: 0% 0%; }
  to   { background-position: 300% 0%; }
}

/* Neural lines scan */
@keyframes azq-line-scan {
  0%   { opacity: 0; transform: translateX(-100%); }
  50%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(100%); }
}
@keyframes azq-line-scan-v {
  0%   { opacity: 0; transform: translateY(-100%); }
  50%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(100%); }
}

/* Exit animations */
@keyframes azq-exit {
  0%   { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

@keyframes azq-logo-exit {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0; }
}

@keyframes azq-ring-exit {
  to { transform: scale(2); opacity: 0; }
}

@keyframes azq-fade-down {
  to { opacity: 0; transform: translateY(15px); }
}

/* Mini mode */
@keyframes azq-mini-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes azq-mini-pulse {
  0%   { transform: scale(.9); opacity: .7; }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .azq-pl-logo { font-size: 2.6rem; }
  .azq-pl-rings { width: 270px; height: 270px; }
  .azq-pl-tagline { font-size: .8rem; letter-spacing: 3px; }
  .azq-pl-orb1 { width: 200px; height: 200px; }
  .azq-pl-orb2 { width: 160px; height: 160px; }
  .azq-pl-orb3 { width: 120px; height: 120px; }
}

@media (max-width: 480px) {
  .azq-pl-logo { font-size: 2rem; }
  .azq-pl-rings { width: 230px; height: 230px; }
  .azq-pl-dots span { width: 5px; height: 5px; }
  .azq-pl-tagline { font-size: .7rem; }
}

/* ── Accessibility: Reduced Motion ───────────── */
@media (prefers-reduced-motion: reduce) {
  .azq-preloader *,
  .azq-preloader *::before,
  .azq-preloader *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .azq-pl-bar {
    animation: none !important;
    width: 95% !important;
  }
}
