/* ============================================================
   TitanCraft — Cinematic Galaxy Sky System
   Layered nebula + twinkling stars (3 depths) + meteor shower
   Server-driven via window.siteSettings (galaxy_* keys).
   All layers are pointer-events:none and respect
   prefers-reduced-motion.
   ============================================================ */

#galaxySky {
  position: fixed;
  inset: 0;
  z-index: -10;
  pointer-events: none;
  overflow: hidden;
  /* Base deep-space gradient — tinted at runtime by JS */
  background:
    radial-gradient(1100px 700px at 78% -8%, var(--nebula-a, rgba(124,92,224,.16)), transparent 62%),
    radial-gradient(900px 620px at 12% 112%, var(--nebula-b, rgba(245,197,66,.07)), transparent 60%),
    radial-gradient(700px 500px at 50% 45%, var(--nebula-core, rgba(76,60,160,.10)), transparent 65%),
    linear-gradient(180deg, #05060f 0%, #0b0e1d 45%, #10142b 100%);
}

/* --- nebula clouds: two large blurred blobs drifting very slowly --- */
.gx-nebula {
  position: absolute;
  width: 130vmax;
  height: 130vmax;
  left: 50%;
  top: 50%;
  margin: -65vmax 0 0 -65vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: var(--nebula-opacity, .55);
  will-change: transform, opacity;
}
.gx-nebula.n1 {
  background:
    radial-gradient(circle at 32% 38%, var(--nebula-a, rgba(124,92,224,.20)), transparent 55%),
    radial-gradient(circle at 68% 62%, var(--nebula-b, rgba(245,197,66,.10)), transparent 50%);
  animation: gxNebulaDrift 90s ease-in-out infinite alternate;
}
.gx-nebula.n2 {
  background:
    radial-gradient(circle at 60% 30%, rgba(56,189,248,.10), transparent 50%),
    radial-gradient(circle at 35% 70%, var(--nebula-core, rgba(76,60,160,.14)), transparent 55%);
  animation: gxNebulaDrift2 120s ease-in-out infinite alternate;
  opacity: calc(var(--nebula-opacity, .55) * .8);
}
@keyframes gxNebulaDrift {
  from { transform: translate(-4%, -2%) scale(1) rotate(0deg); }
  to   { transform: translate(4%, 3%) scale(1.08) rotate(8deg); }
}
@keyframes gxNebulaDrift2 {
  from { transform: translate(3%, 2%) scale(1.05) rotate(5deg); }
  to   { transform: translate(-4%, -3%) scale(.97) rotate(-6deg); }
}

/* --- star fields: 3 depth layers, JS fills them with .gx-star --- */
.gx-stars {
  position: absolute;
  inset: 0;
}
.gx-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: gxTwinkle var(--tw, 4s) ease-in-out var(--td, 0s) infinite;
  will-change: opacity, transform;
}
.gx-stars.far .gx-star  { animation-duration: 6s; }
.gx-stars.mid .gx-star  { animation-duration: 4s; }
.gx-stars.near .gx-star { animation-duration: 2.8s; }
@keyframes gxTwinkle {
  0%, 100% { opacity: var(--o0, .25); transform: scale(1); }
  50%      { opacity: var(--o1, .95); transform: scale(1.35); }
}

/* A few stars get a cross sparkle */
.gx-star.sparkle::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 200%; height: 1px;
  background: inherit;
  transform: translate(-50%, -50%);
  opacity: .7;
}
.gx-star.sparkle::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 200%;
  background: inherit;
  transform: translate(-50%, -50%);
  opacity: .7;
}

/* --- shooting stars (DOM-based, spawned by JS) --- */
.gx-shoot {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  will-change: transform, opacity;
}
.gx-shoot .gx-tail {
  position: absolute;
  top: 0; right: 0;
  height: 2px;
  width: var(--len, 120px);
  border-radius: 2px;
  background: linear-gradient(to left, var(--shoot-color, #ffd97a), transparent);
  transform-origin: right center;
  filter: blur(.6px);
}

/* --- vignette for cinematic depth --- */
#galaxySky::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0,0,0,.45) 100%);
}

/* --- حالت گرادیان متحرک (بدون ستاره): همان سحابی روی بادی --- */
#galaxySky.gx-gradient-only {
  background: transparent;
  z-index: -10;
}
#galaxySky.gx-gradient-only::after { display: none; }
#galaxySky.gx-gradient-only .gx-nebula { width: 110vmax; height: 110vmax; margin: -55vmax 0 0 -55vmax; }

/* --- cinematic hero entrance: one orchestrated sequence --- */
@keyframes gxRise {
  from { opacity: 0; transform: translateY(26px); filter: blur(6px); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.gx-enter { opacity: 0; }
body.gx-ready .gx-enter { animation: gxRise .9s cubic-bezier(.22,1,.36,1) forwards; }
body.gx-ready .gx-d1 { animation-delay: .05s; }
body.gx-ready .gx-d2 { animation-delay: .18s; }
body.gx-ready .gx-d3 { animation-delay: .32s; }
body.gx-ready .gx-d4 { animation-delay: .46s; }
body.gx-ready .gx-d5 { animation-delay: .60s; }

/* --- scroll reveal: quiet single fade (no slide spam) --- */
.gx-reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.22,1,.36,1); }
.gx-reveal.gx-in { opacity: 1; transform: none; }

/* --- server status dot: slow calm blink (asked) --- */
@keyframes gxStatusBreathe {
  0%, 100% { box-shadow: 0 0 0 3px rgba(74,222,128,.18), 0 0 12px var(--ok); }
  50%      { box-shadow: 0 0 0 5px rgba(74,222,128,.32), 0 0 28px var(--ok); }
}
.status-dot-large.online { animation: gxStatusBreathe 3.2s ease-in-out infinite; }

/* --- hero planet accent: one bold memorable object --- */
.gx-planet {
  position: absolute;
  width: 340px; height: 340px;
  left: -110px; top: -70px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 30%, rgba(255,255,255,.20), transparent 42%),
    radial-gradient(circle at 60% 65%, var(--nebula-a, rgba(124,92,224,.5)), transparent 70%),
    radial-gradient(circle at 50% 50%, #2a2358 0%, #171438 55%, #0b0a22 100%);
  box-shadow:
    0 0 60px 10px rgba(124,92,224,.28),
    0 0 140px 40px rgba(124,92,224,.12),
    inset -30px -24px 60px rgba(0,0,0,.6);
  opacity: .9;
  animation: gxPlanetFloat 14s ease-in-out infinite;
  pointer-events: none;
}
.gx-planet::after { /* ring */
  content: '';
  position: absolute;
  left: -22%; top: 46%;
  width: 144%; height: 26%;
  border-radius: 50%;
  border: 2px solid rgba(245,197,66,.35);
  border-top-color: transparent;
  border-bottom-color: rgba(245,197,66,.55);
  transform: rotate(-14deg);
  box-shadow: 0 0 24px rgba(245,197,66,.25);
}
@keyframes gxPlanetFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-16px) rotate(2deg); }
}
@media (max-width: 900px) {
  .gx-planet { width: 200px; height: 200px; left: -70px; top: -50px; opacity: .7; }
}

/* --- reduced motion: static sky --- */
@media (prefers-reduced-motion: reduce) {
  #galaxySky *, #galaxySky { animation: none !important; }
  .gx-enter, .gx-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  #meteorsCanvas, #particlesCanvas { display: none !important; }
}
