/* ============================================================
   Zakaria mascot — reusable styles.
   Everything is scoped under #zakaria-loading so the very generic
   class names (.body, .eye, .scene, .star, .arm, .mouth …) can
   never clash with the host app.
   ============================================================ */

#zakaria-loading {
  --bg-top: #a2c9ff;
  --bg-mid: #cbdffd;
  --bg-bottom: #f3f8ff;
  --mascot-bright: #8ce0ff;
  --mascot-mid: #3b82f6;
  --mascot-deep: #1e40af;
  --mascot-shadow: #0f1d4a;
  --focus-glow: rgba(56, 189, 248, 0.8);
  --glasses-frame: #0f172a;

  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #cbdffd; /* fallback */
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 45%, var(--bg-bottom) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  z-index: 9999;
  transition: opacity 0.6s ease-out, visibility 0.6s;
}

#zakaria-loading .instruction {
  position: absolute;
  top: clamp(28px, 9vh, 96px);
  left: 0;
  right: 0;
  text-align: center;
  color: #1e3a8a;
  font-size: clamp(14px, 2.6vw, 18px);
  font-weight: 600;
  letter-spacing: 1.2px;
  opacity: 0.85;
  z-index: 20;
}

/* Scene Container — a transparent, centered stage that fills the screen.
   It keeps its intrinsic 360x380 coordinate system (so every mascot offset
   stays valid) and is just scaled up to fill the full-screen backdrop. */
#zakaria-loading .scene {
  position: relative;
  width: 360px;
  height: 380px;
  background: transparent;
  overflow: visible;
  transform: scale(1.2);
  transform-origin: center center;
}
@media (min-width: 640px) and (min-height: 640px) {
  #zakaria-loading .scene { transform: scale(1.5); }
}
@media (min-width: 1024px) and (min-height: 860px) {
  #zakaria-loading .scene { transform: scale(1.85); }
}

/* Loader Progress Control Panel — floating card near the bottom. */
#zakaria-loading .progress-container {
  position: absolute;
  bottom: clamp(28px, 7vh, 72px);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, 86vw);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-sizing: border-box;
  padding: 22px 28px;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(15, 29, 74, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 20;
}

#zakaria-loading .progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

#zakaria-loading .progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #0ea5e9);
  border-radius: 99px;
  transition: width 0.1s linear;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.4);
}

#zakaria-loading .progress-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #475569;
  font-size: 13px;
  font-weight: 600;
}

#zakaria-loading .status-text {
  transition: color 0.3s ease;
}

#zakaria-loading .status-text.complete {
  color: #10b981;
}

/* Background Ethereal Glows */
#zakaria-loading .ambient-glow {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  width: 150%;
  height: 120%;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0) 40%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0) 35%);
  mix-blend-mode: overlay;
  z-index: 1;
}

#zakaria-loading .mascot-aura {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(255,255,255,0.65) 0%, rgba(255,255,255,0) 70%);
  z-index: 2;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#zakaria-loading .scene.focus-active .mascot-aura {
  background: radial-gradient(circle, rgba(14, 165, 233, 0.45) 0%, rgba(14, 165, 233, 0) 70%);
  transform: translate3d(-50%, -50%, 0) scale(1.35);
}

/* Mascot Container Base Physics */
#zakaria-loading .mascot-container {
  position: absolute;
  bottom: 55px;
  left: 50%;
  transform: translate3d(-50%, 0, 0);
  width: 150px;
  height: 145px;
  z-index: 5;
  will-change: transform;
  animation: zakariaIdleFloat 5s ease-in-out infinite;
}

/* Unified Jump & Look loading execution engine */
#zakaria-loading .scene.animating .mascot-container {
  animation: zakariaJumpSequence 4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* 3D Volumetric Clay Body */
#zakaria-loading .body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 35% 25%, var(--mascot-bright) 0%, var(--mascot-mid) 45%, var(--mascot-deep) 80%, var(--mascot-shadow) 100%);
  border-radius: 44% 44% 48% 48% / 52% 52% 45% 45%;
  box-shadow:
    inset 8px 10px 16px rgba(255, 255, 255, 0.65),
    inset -12px -15px 24px rgba(15, 29, 74, 0.7),
    inset -4px -4px 40px rgba(0, 0, 0, 0.4),
    0 16px 32px rgba(15, 29, 74, 0.2);
  z-index: 10;
  transition: box-shadow 0.6s ease;
}

#zakaria-loading .scene.focus-active .body {
  box-shadow:
    inset 8px 10px 16px rgba(255, 255, 255, 0.75),
    inset -12px -15px 24px rgba(15, 29, 74, 0.7),
    inset -4px -4px 40px rgba(0, 0, 0, 0.4),
    0 0 35px var(--focus-glow),
    0 16px 32px rgba(15, 29, 74, 0.3);
}

/* 3D Ears */
#zakaria-loading .ear {
  position: absolute;
  top: -8px;
  width: 38px;
  height: 38px;
  background: radial-gradient(circle at 40% 40%, var(--mascot-bright) 0%, var(--mascot-mid) 50%, var(--mascot-deep) 100%);
  border-radius: 50% 50% 40% 40%;
  box-shadow: inset 3px 4px 6px rgba(255,255,255,0.6), inset -4px -4px 8px rgba(15, 29, 74, 0.6), 0 6px 10px rgba(15, 29, 74, 0.25);
  z-index: 9;
}
#zakaria-loading .ear.left { left: 20px; transform: rotate(-8deg); }
#zakaria-loading .ear.right { right: 20px; transform: rotate(8deg); }

/* 3D Arms */
#zakaria-loading .arm {
  position: absolute;
  top: 62px;
  width: 28px;
  height: 46px;
  background: linear-gradient(165deg, var(--mascot-bright) 0%, var(--mascot-mid) 40%, var(--mascot-deep) 100%);
  border-radius: 20px;
  box-shadow: inset 3px 3px 5px rgba(255,255,255,0.5), inset -3px -4px 8px rgba(15, 29, 74, 0.6);
  filter: drop-shadow(5px 8px 6px rgba(15, 29, 74, 0.35));
  z-index: 11;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#zakaria-loading .arm.left { left: -12px; transform: rotate(22deg); }
#zakaria-loading .arm.right { right: -12px; transform: rotate(-22deg); filter: drop-shadow(-2px 8px 6px rgba(15, 29, 74, 0.3)); }

#zakaria-loading .scene.focus-active .arm.left { transform: rotate(12deg) translateY(-3px); }
#zakaria-loading .scene.focus-active .arm.right { transform: rotate(-12deg) translateY(-3px); }

/* 3D Feet */
#zakaria-loading .leg {
  position: absolute;
  bottom: -12px;
  width: 26px;
  height: 30px;
  background: radial-gradient(circle at 40% 30%, var(--mascot-deep) 0%, var(--mascot-shadow) 100%);
  border-radius: 50% 50% 42% 42%;
  box-shadow: inset 2px 2px 4px rgba(255,255,255,0.2), 0 -4px 6px rgba(15, 29, 74, 0.5);
  z-index: 8;
}
#zakaria-loading .leg.left { left: 36px; transform: rotate(4deg); }
#zakaria-loading .leg.right { right: 36px; transform: rotate(-4deg); }

/* Eyes */
#zakaria-loading .eye {
  position: absolute;
  top: 36px;
  width: 34px;
  height: 44px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: inset -2px -3px 6px rgba(0, 0, 0, 0.1), inset 2px 2px 4px rgba(0, 0, 0, 0.05), 2px 4px 8px rgba(15, 29, 74, 0.2);
  z-index: 12;
  overflow: hidden;
}
#zakaria-loading .eye.left { left: 30px; }
#zakaria-loading .eye.right { right: 30px; }

/* Pupils dynamic tracking */
#zakaria-loading .pupil {
  position: absolute;
  bottom: 4px;
  right: 2px;
  width: 24px;
  height: 28px;
  background: radial-gradient(circle at 40% 40%, #1e293b 0%, #0f172a 100%);
  border-radius: 50%;
  box-shadow: inset 1px 1px 3px rgba(255,255,255,0.2);
  will-change: transform;
}

#zakaria-loading .sparkle-main {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 10px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
}

#zakaria-loading .sparkle-sub {
  position: absolute;
  bottom: 4px;
  left: 3px;
  width: 5px;
  height: 5px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.6;
}

/* Glasses */
#zakaria-loading .glasses {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, -35px, 0) scale(0.7);
  transition: transform 0.6s cubic-bezier(0.34, 1.6, 0.64, 1), opacity 0.4s ease;
  filter: drop-shadow(0 6px 8px rgba(15, 29, 74, 0.35));
}

#zakaria-loading .scene.focus-active .glasses {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

#zakaria-loading .lens {
  position: absolute;
  top: 32px;
  width: 44px;
  height: 44px;
  border: 4.5px solid var(--glasses-frame);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.05) 60%);
  border-radius: 42% 42% 45% 45%;
  box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.3);
  box-sizing: border-box;
}
#zakaria-loading .lens.left { left: 23px; }
#zakaria-loading .lens.right { right: 23px; }

#zakaria-loading .lens::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 7px;
  width: 24px;
  height: 3px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0));
  transform: rotate(-35deg);
  border-radius: 2px;
}

#zakaria-loading .glasses-bridge {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 6px;
  background: var(--glasses-frame);
  border-radius: 3px 3px 0 0;
}

/* Smile Line */
#zakaria-loading .mouth {
  position: absolute;
  top: 81px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 6px;
  border-bottom: 4px solid #0f172a;
  border-radius: 0 0 14px 14px;
  z-index: 12;
}

/* Animation Timelines Linked to Automatic Start */
#zakaria-loading .scene.animating .pupil {
  animation: zakariaPupilLook 4s cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

#zakaria-loading .scene.animating .mouth {
  animation: zakariaMouthSmile 4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#zakaria-loading .scene.animating .shadow-wrapper {
  animation: zakariaShadowAction 4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes zakariaJumpSequence {
  0% { transform: translate3d(-50%, 0, 0) scale(1, 1); }
  8% { transform: translate3d(-50%, 6px, 0) scale(1.12, 0.85); }
  20% { transform: translate3d(-50%, -65px, 0) scale(0.88, 1.18); }
  30% { transform: translate3d(-50%, -75px, 0) scale(1, 1); }
  40% { transform: translate3d(-50%, -20px, 0) scale(0.95, 1.05); }
  46% { transform: translate3d(-50%, 4px, 0) scale(1.1, 0.9); }
  54% { transform: translate3d(-50%, -4px, 0) scale(0.97, 1.03); }
  62%, 100% { transform: translate3d(-50%, 0, 0) scale(1, 1); }
}

@keyframes zakariaPupilLook {
  0% { transform: translate3d(0, 0, 0); }
  24%, 44% { transform: translate3d(-6px, -1px, 0); }
  56%, 76% { transform: translate3d(6px, -1px, 0); }
  88%, 100% { transform: translate3d(0, -2px, 0); }
}

@keyframes zakariaMouthSmile {
  0%, 78% {
    width: 14px;
    height: 6px;
    border-bottom: 4px solid #0f172a;
    border-radius: 0 0 14px 14px;
  }
  90%, 100% {
    width: 24px;
    height: 11px;
    border-bottom: 5.5px solid #0f172a;
    border-radius: 0 0 20px 20px;
  }
}

/* Shadow Tracking System */
#zakaria-loading .shadow-wrapper {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translate3d(-50%, 0, 0);
  width: 110px;
  height: 16px;
  z-index: 4;
  will-change: transform, opacity;
  animation: zakariaShadowIdlePulse 5s ease-in-out infinite;
}

#zakaria-loading .shadow-core {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse, rgba(12, 22, 54, 0.4) 0%, rgba(12, 22, 54, 0.15) 50%, rgba(0,0,0,0) 100%);
  border-radius: 50%;
  filter: blur(7px);
}

#zakaria-loading .shadow-blur {
  position: absolute;
  width: 150%;
  height: 200%;
  top: -50%;
  left: -25%;
  background: radial-gradient(ellipse, rgba(15, 29, 74, 0.25) 0%, rgba(15, 29, 74, 0) 70%);
  border-radius: 50%;
  filter: blur(14px);
}

@keyframes zakariaShadowAction {
  0% { transform: translate3d(-50%, 0, 0) scale(1); opacity: 1; filter: blur(0px); }
  8% { transform: translate3d(-50%, 0, 0) scale(1.15); opacity: 1.2; }
  24%, 32% { transform: translate3d(-50%, 0, 0) scale(0.45); opacity: 0.15; filter: blur(6px); }
  46% { transform: translate3d(-50%, 0, 0) scale(1.1); opacity: 1.1; filter: blur(0px); }
  54% { transform: translate3d(-50%, 0, 0) scale(0.95); opacity: 0.9; }
  62%, 100% { transform: translate3d(-50%, 0, 0) scale(1); opacity: 1; }
}

/* Environmental Ambiance Elements */
#zakaria-loading .star {
  position: absolute;
  background: #ffffff;
  clip-path: polygon(50% 0%, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0% 50%, 37% 37%);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)) drop-shadow(0 0 8px rgba(255,255,255,0.8));
  z-index: 3;
  animation: zakariaDreamyTwinkle 4s infinite ease-in-out alternate;
}
#zakaria-loading .star-1 { width: 44px; height: 44px; top: 135px; right: 25px; animation-delay: 0s; }
#zakaria-loading .star-2 { width: 22px; height: 22px; top: 90px; right: 85px; animation-delay: 1.2s; opacity: 0.7; }
#zakaria-loading .star-3 { width: 26px; height: 26px; top: 165px; left: 35px; animation-delay: 0.6s; }
#zakaria-loading .star-4 { width: 16px; height: 16px; top: 215px; left: 75px; animation-delay: 1.8s; opacity: 0.5; }

#zakaria-loading .mist-floor {
  position: absolute;
  bottom: -65px;
  left: -10%;
  width: 120%;
  height: 115px;
  background: #ffffff;
  filter: blur(14px);
  border-radius: 50% 50% 0 0;
  z-index: 3;
}

@keyframes zakariaIdleFloat {
  0%, 100% { transform: translate3d(-50%, 0, 0); }
  50% { transform: translate3d(-50%, -14px, 0) rotate(1deg); }
}
@keyframes zakariaShadowIdlePulse {
  0%, 100% { transform: translate3d(-50%, 0, 0) scale(1); opacity: 1; }
  50% { transform: translate3d(-50%, 0, 0) scale(0.82); opacity: 0.6; }
}
@keyframes zakariaDreamyTwinkle {
  0% { transform: scale(0.85) rotate(0deg); }
  100% { transform: scale(1.15) rotate(12deg); }
}

/* Hidden state used during fade-out */
#zakaria-loading.zakaria-hide {
  opacity: 0;
  visibility: hidden;
}

/* Respect users who prefer reduced motion: keep the mascot, drop the motion. */
@media (prefers-reduced-motion: reduce) {
  #zakaria-loading .mascot-container,
  #zakaria-loading .scene.animating .mascot-container,
  #zakaria-loading .shadow-wrapper,
  #zakaria-loading .scene.animating .shadow-wrapper,
  #zakaria-loading .scene.animating .pupil,
  #zakaria-loading .scene.animating .mouth,
  #zakaria-loading .star {
    animation: none !important;
  }
}
