/* Splash de arranque, portado de SplashScreen.vue + SplashOrbit.vue de la PWA
   Connectyx. Va como CSS estático y no dentro del bundle porque tiene que
   pintar antes de que Vue monte. Los iconos de los satélites entran por
   máscara para que el markup del index quede corto. */

#cx-splash {
  --splash-primary: #8b78ff;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: calc(1.25rem + env(safe-area-inset-top)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  color: #fff;
  background: #000;
  font-family: 'Sora', 'Montserrat', 'Segoe UI', sans-serif;
  opacity: 1;
  transition: opacity 0.28s ease;
}

#cx-splash.is-out {
  opacity: 0;
  pointer-events: none;
}

/* Terminado el fundido el splash se saca del flujo, así el orbit deja de
   animarse. Queda en el DOM para poder reproducirlo desde el login. */
#cx-splash.is-hidden {
  display: none;
}

#cx-splash.is-instant {
  transition: none;
}

/* El escritorio admin arranca sin splash. */
@media (min-width: 1024px) {
  #cx-splash { display: none; }
}

.splash-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.75rem;
  animation: splash-in 0.55s ease both;
}

.splash-logo-wrap {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  width: min(82vw, 320px);
  animation: logo-float 4s ease-in-out infinite;
  filter: drop-shadow(0 0 24px rgba(139, 120, 255, 0.35));
}

.splash-logo {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.splash-powered {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  animation: splash-in 0.55s ease 0.18s both;
}

.splash-powered > span {
  color: rgba(255, 255, 255, 0.32);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.splash-powered-logo {
  display: block;
  width: min(180px, 55vw);
  height: auto;
  object-fit: contain;
}

.orbit-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.orbit-ambient {
  position: absolute;
  width: 90%;
  height: 90%;
  background: radial-gradient(circle, rgba(139, 120, 255, 0.32), rgba(139, 120, 255, 0.06) 45%, transparent 70%);
  filter: blur(8px);
  pointer-events: none;
  animation: glow-breathe 3.2s ease-in-out infinite;
}

.orbit {
  position: relative;
  z-index: 1;
  width: min(72vw, 280px);
  height: min(72vw, 280px);
}

.ring,
.rays {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.ring-a {
  inset: 6%;
  border: 1.5px dashed rgba(139, 120, 255, 0.4);
  animation: spin 18s linear infinite;
}

.ring-b {
  inset: 24%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  animation: spin-rev 24s linear infinite;
}

.rays {
  inset: 10%;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.05) 0deg 2deg,
    transparent 2deg 30deg
  );
  mask: radial-gradient(circle, transparent 42%, #000 43%, #000 70%, transparent 71%);
  -webkit-mask: radial-gradient(circle, transparent 42%, #000 43%, #000 70%, transparent 71%);
  animation: spin 28s linear infinite;
  opacity: 0.7;
}

.core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2a2a2e, #0a0a0a 72%);
  display: grid;
  place-items: center;
  animation: core-pulse 2.6s ease-in-out infinite;
}

.core-mark {
  position: relative;
  width: 28px;
  height: 14px;
  border: 2.5px solid #fff;
  border-radius: 999px;
}

.core-mark::before,
.core-mark::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--splash-primary);
  transform: translateY(-50%);
}

.core-mark::before { left: 2px; }
.core-mark::after { right: 2px; }

.satellites {
  position: absolute;
  inset: 0;
}

.sat-spin { animation: spin 11s linear infinite; }
.sat-spin-rev { animation: spin-rev 15s linear infinite; }

.sat {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
}

.node,
.spark {
  display: block;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.node {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(145deg, #3a3a3e, #161618);
  box-shadow: 0 0 18px rgba(139, 120, 255, 0.22);
  display: grid;
  place-items: center;
}

.node.accent {
  border-color: rgba(139, 120, 255, 0.85);
  box-shadow: 0 0 18px rgba(139, 120, 255, 0.55);
}

.node.bright {
  border-color: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.25);
}

/* Contrarresta el giro del anillo para que las siluetas no queden invertidas. */
.node-face {
  display: grid;
  place-items: center;
  animation: spin-rev 11s linear infinite;
}

.node-face::before {
  content: '';
  display: block;
  width: 17px;
  height: 17px;
  background: rgba(255, 255, 255, 0.8);
  mask: var(--node-icon) center / contain no-repeat;
  -webkit-mask: var(--node-icon) center / contain no-repeat;
  --node-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4.7a3.7 3.7 0 1 1 0 7.4 3.7 3.7 0 0 1 0-7.4z'/%3E%3Cpath d='M12 13.6c-3.8 0-6.9 2.3-6.9 5.3 0 .7.6 1.2 1.2 1.2h11.4c.7 0 1.2-.5 1.2-1.2 0-3-3.1-5.3-6.9-5.3z'/%3E%3C/svg%3E");
}

.node.accent .node-face::before { background: #b9aeff; }
.node.bright .node-face::before { background: rgba(255, 255, 255, 0.95); }

/* Compensa la rotación fija con la que cada satélite se coloca en el anillo. */
.s1 .node-face::before { transform: rotate(0deg); }
.s2 .node-face::before { transform: rotate(-60deg); }
.s3 .node-face::before { transform: rotate(-120deg); }
.s4 .node-face::before { transform: rotate(-180deg); }
.s5 .node-face::before { transform: rotate(-240deg); }
.s6 .node-face::before { transform: rotate(-300deg); }

.spark {
  width: 10px;
  height: 10px;
  background: var(--splash-primary);
  box-shadow: 0 0 14px rgba(139, 120, 255, 0.8);
  animation: blip 1.7s ease-in-out infinite;
}

.s1 { transform: rotate(0deg) translateY(-118px); }
.s2 { transform: rotate(60deg) translateY(-118px); }
.s3 { transform: rotate(120deg) translateY(-118px); }
.s4 { transform: rotate(180deg) translateY(-118px); }
.s5 { transform: rotate(240deg) translateY(-118px); }
.s6 { transform: rotate(300deg) translateY(-118px); }
.s7 { transform: rotate(30deg) translateY(-86px); }
.s8 { transform: rotate(150deg) translateY(-86px); }
.s9 { transform: rotate(270deg) translateY(-86px); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }

@keyframes splash-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes core-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 10px rgba(139, 120, 255, 0.08),
      0 0 40px rgba(139, 120, 255, 0.32),
      0 0 70px rgba(139, 120, 255, 0.1);
  }
  50% {
    box-shadow:
      0 0 0 14px rgba(139, 120, 255, 0.14),
      0 0 58px rgba(139, 120, 255, 0.5),
      0 0 90px rgba(139, 120, 255, 0.18);
  }
}

@keyframes glow-breathe {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

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

@media (prefers-reduced-motion: reduce) {
  .splash-stage,
  .splash-logo-wrap,
  .splash-powered,
  .orbit-ambient,
  .ring,
  .rays,
  .core,
  .satellites,
  .node-face,
  .spark {
    animation: none;
  }
}
