/* =========================================================================
   spiral.css — Componente firma .spiral (SISTEMA SOLAR)
   Animación orbital: 7 miembros del equipo en 3 anillos concéntricos
   alrededor del núcleo Inversión→Resultado.
   Autocontenido para reutilización en Fase 2 (WordPress).
   ========================================================================= */

.spiral {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 520px;
  margin-inline: auto;
  user-select: none;
  container-type: inline-size;
}

/* ---- Corona solar: glow ambiental pulsante ---- */
.spiral__corona {
  position: absolute;
  inset: -8%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(108, 99, 255, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 70% 70%, rgba(255, 51, 102, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(108, 99, 255, 0.08) 0%, transparent 60%);
  filter: blur(32px);
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease) 0.1s;
  animation: corona-pulse 4s ease-in-out infinite;
  animation-play-state: paused;
}
.spiral.is-in .spiral__corona {
  opacity: 1;
  animation-play-state: running;
}

@keyframes corona-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; filter: blur(32px); }
  50%      { transform: scale(1.08); opacity: 1; filter: blur(28px); }
}

/* ---- Partículas estelares de fondo ---- */
.spiral__stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.spiral__stars span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s, 1.5px);
  height: var(--s, 1.5px);
  border-radius: 50%;
  background: var(--violeta);
  opacity: 0;
  animation: star-twinkle 3s ease-in-out infinite;
  animation-delay: var(--d, 0s);
  animation-play-state: paused;
}
.spiral.is-in .spiral__stars span {
  animation-play-state: running;
}
@keyframes star-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.5); }
  50%      { opacity: 0.5; transform: scale(1); }
}

/* ---- Anillos concéntricos de guía (órbitas) ---- */
.spiral__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--ring-w);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease) 0.2s;
}
.spiral.is-in .spiral__ring--1 { opacity: 0.55; }
.spiral.is-in .spiral__ring--2 { opacity: 0.45; }
.spiral.is-in .spiral__ring--3 { opacity: 0.4; }

.spiral__ring--1 {
  --ring-w: 42%;
  border: 1.5px dashed var(--violeta);
  opacity: 0.55;
  box-shadow: 0 0 18px rgba(108, 99, 255, 0.08), inset 0 0 18px rgba(108, 99, 255, 0.04);
}
.spiral__ring--2 {
  --ring-w: 64%;
  border: 1.5px dashed var(--rosa);
  opacity: 0.45;
  box-shadow: 0 0 24px rgba(255, 51, 102, 0.06), inset 0 0 24px rgba(255, 51, 102, 0.03);
}
.spiral__ring--3 {
  --ring-w: 86%;
  border: 1.5px dashed var(--violeta);
  opacity: 0.4;
  box-shadow: 0 0 28px rgba(108, 99, 255, 0.05), inset 0 0 28px rgba(108, 99, 255, 0.02);
}

/* ---- Orbitadores: contenedores giratorios ---- */
.spiral__orbit {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  will-change: transform;
}

/* Animaciones de rotación por anillo (velocidades diferenciadas) */
.spiral__orbit--1 {
  animation: orbit-cw 30s linear infinite;
  animation-play-state: paused;
  animation-delay: 0.6s;
}
.spiral__orbit--1 .spiral-item { --radius: 21cqw; }

.spiral__orbit--2 {
  animation: orbit-ccw 44s linear infinite;
  animation-play-state: paused;
  animation-delay: 0.8s;
}
.spiral__orbit--2 .spiral-item { --radius: 32cqw; }

.spiral__orbit--3 {
  animation: orbit-cw 58s linear infinite;
  animation-play-state: paused;
  animation-delay: 1.2s;
}
.spiral__orbit--3 .spiral-item { --radius: 43cqw; }

.spiral.is-in .spiral__orbit {
  animation-play-state: running;
}

/* Pausar rotación en hover general */
.spiral:hover .spiral__orbit {
  animation-play-state: paused !important;
}
.spiral:hover .spiral-item__inner {
  animation-play-state: paused !important;
}

/* ---- Elementos orbitales (.spiral-item) ---- */
.spiral-item {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--radius))) rotate(calc(-1 * var(--angle))) scale(0.5);
  opacity: 0;
  pointer-events: auto;
  will-change: transform, opacity;
  z-index: 1;
  transition:
    opacity var(--dur-3) var(--ease),
    transform var(--dur-3) var(--ease),
    filter var(--dur-3) var(--ease),
    z-index 0s var(--dur-3); /* z-index cambia después de la transición */
  /* Trail glow sutil detrás del avatar en movimiento */
  filter: drop-shadow(0 0 6px rgba(108, 99, 255, 0));
}
/* Elevar z-index en hover para que tooltip quede por encima */
.spiral-item:hover {
  z-index: 10;
  transition-delay: 0s;
}

.spiral.is-in .spiral-item {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--radius))) rotate(calc(-1 * var(--angle))) scale(1);
  filter: drop-shadow(0 0 6px rgba(108, 99, 255, 0.08));
}

/* Escalonado de aparición por miembro (orden de órbita) */
.spiral.is-in .spiral__orbit--1 .spiral-item:nth-child(1) { transition-delay: 0.4s; }
.spiral.is-in .spiral__orbit--1 .spiral-item:nth-child(2) { transition-delay: 0.5s; }

.spiral.is-in .spiral__orbit--2 .spiral-item:nth-child(1) { transition-delay: 0.6s; }
.spiral.is-in .spiral__orbit--2 .spiral-item:nth-child(2) { transition-delay: 0.7s; }

.spiral.is-in .spiral__orbit--3 .spiral-item:nth-child(1) { transition-delay: 0.9s; }
.spiral.is-in .spiral__orbit--3 .spiral-item:nth-child(2) { transition-delay: 1.0s; }
.spiral.is-in .spiral__orbit--3 .spiral-item:nth-child(3) { transition-delay: 1.1s; }

/* Contenedor de contra-rotación: anula el giro del orbitador */
.spiral-item__inner {
  display: block;
  position: relative;
  animation-play-state: paused;
}

.spiral__orbit--1 .spiral-item__inner {
  animation: orbit-ccw 30s linear infinite;
}
.spiral__orbit--2 .spiral-item__inner {
  animation: orbit-cw 44s linear infinite;
}
.spiral__orbit--3 .spiral-item__inner {
  animation: orbit-ccw 58s linear infinite;
}

.spiral.is-in .spiral-item__inner {
  animation-play-state: running;
}

/* ---- Avatares con foto circular ---- */
.spiral-avatar__photo {
  width: clamp(48px, 11vw, 62px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--surface);
  box-shadow:
    var(--shadow-md),
    0 0 12px rgba(108, 99, 255, 0.12),
    inset 0 0 0 0 rgba(108, 99, 255, 0);
  object-fit: cover;
  display: block;
  transition:
    transform var(--dur-2) var(--ease),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
  backface-visibility: hidden;
}

/* Hover: el avatar se eleva y brilla */
.spiral-item:hover .spiral-avatar__photo {
  transform: scale(1.15);
  border-color: var(--violeta);
  box-shadow:
    var(--shadow-lg),
    0 0 24px rgba(108, 99, 255, 0.25);
  z-index: 10;
}

/* ---- Tooltips (nombres sobre el avatar) ---- */
.spiral-avatar__name {
  position: absolute;
  bottom: -2.8em;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap;
  text-align: center;
  font-family: var(--font-body);
  font-size: clamp(9.5px, 1.2vw, 11px);
  line-height: 1.2;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px var(--sp-3);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--dur-2) var(--ease),
    transform var(--dur-2) var(--ease);
}
.spiral-avatar__name b {
  font-weight: 600;
  color: var(--violeta);
  letter-spacing: 0.04em;
}
.spiral-item:hover .spiral-avatar__name {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Núcleo solar (estilo Sol premium) ---- */
.spiral__core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: 28%;
  min-width: 120px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 2px;
  background: radial-gradient(circle at 40% 35%, #2A1F5E, #0C0A14 80%);
  border-radius: 50%;
  z-index: 5;
  color: #fff;
  opacity: 0;
  /* Sombra base estática — no la animamos (trigger de repaint) */
  box-shadow:
    0 0 0 1px rgba(108, 99, 255, 0.25),
    0 0 28px rgba(108, 99, 255, 0.20),
    0 0 60px rgba(108, 99, 255, 0.08),
    inset 0 0 40px rgba(108, 99, 255, 0.06);
  /* Transición maneja entrada suave (opacity + transform) */
  transition:
    opacity var(--dur-3) var(--ease) 0.3s,
    transform var(--dur-3) var(--ease) 0.3s;
  will-change: transform, opacity;
}
.spiral.is-in .spiral__core {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  /* La animación empieza DESPUÉS de que la transición de entrada termina (0.3s delay + 0.6s duration = 0.9s) */
  animation: sun-pulse 3.2s ease-in-out 0.9s infinite;
}

/* Pulsación suave del núcleo (solo transform — GPU acelerado) */
@keyframes sun-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.04); }
}

/* Anillo exterior del núcleo (corona solar animada con opacidad/transform) */
.spiral__core-ring {
  position: absolute;
  inset: -12%;
  border-radius: 50%;
  border: 1px solid rgba(108, 99, 255, 0.12);
  pointer-events: none;
  will-change: transform, opacity;
  /* Efecto glow pulsante manejado por opacidad + transform del anillo */
  animation: core-ring-pulse 3.2s ease-in-out infinite;
}
@keyframes core-ring-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.4;
    border-color: rgba(108, 99, 255, 0.10);
  }
  50% {
    transform: scale(1.08);
    opacity: 0.7;
    border-color: rgba(108, 99, 255, 0.20);
  }
}

.spiral__core-label {
  font-family: var(--font-mono);
  font-size: clamp(8px, 1vw, 10px);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.3;
  padding-inline: 6px;
}

.spiral__core-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 1;
  letter-spacing: var(--ls-display);
  color: #ffffff;
  text-shadow: 0 0 20px rgba(108, 99, 255, 0.4);
}

.spiral__core-sub {
  font-family: var(--font-mono);
  font-size: clamp(7px, 0.85vw, 9px);
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.45);
  padding-inline: 8px;
  line-height: 1.2;
}

/* ---- Animaciones de Rotación (Keyframes) ---- */
@keyframes orbit-cw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes orbit-ccw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* ---- Reduced Motion: estático en estado ideal ---- */
@media (prefers-reduced-motion: reduce) {
  .spiral__corona,
  .spiral__ring,
  .spiral-item,
  .spiral__core {
    transition: none !important;
    opacity: 1 !important;
  }
  .spiral-item {
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(-1 * var(--radius))) rotate(calc(-1 * var(--angle))) scale(1) !important;
  }
  .spiral__orbit,
  .spiral-item__inner {
    animation: none !important;
  }
  .spiral__stars span { animation: none !important; opacity: 0.4 !important; }
  .spiral__corona {
    animation: none !important;
    opacity: 0.5 !important;
    filter: blur(40px) !important;
    transform: scale(1) !important;
  }
  .spiral__core {
    animation: none !important;
    transform: translate(-50%, -50%) scale(1) !important;
  }
  .spiral__core-ring { animation: none !important; }
}

/* ---- Adaptabilidad Responsive ---- */
@media (max-width: 860px) {
  .spiral {
    max-width: 440px;
  }
}

@media (max-width: 420px) {
  .spiral {
    max-width: 330px;
  }
  .spiral__core { min-width: 100px; }
  .spiral-avatar__photo {
    width: clamp(40px, 10vw, 50px);
    border-width: 2px;
  }
  .spiral-avatar__name {
    font-size: clamp(8px, 1.8vw, 10px);
    bottom: -2.4em;
    padding: 2px var(--sp-2);
  }
}
