/* ============================================
   CODEX landing — capa de movimiento (solo la portada, home/index)
   Solo transform/opacity en lo que corre en bucle. Todo lo que es bucle se
   pausa fuera de pantalla (.mx-paused) y con prefers-reduced-motion
   (motion.js no arranca nada y estas reglas lo apagan).
   ============================================ */

/* ---------- Barra de progreso de lectura ---------- */
.mx-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1100;
  background: linear-gradient(90deg, #00bcd4, #6b46c1);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

/* ---------- 1 · Hero: constelación + palabra que rota ---------- */
.mx-constellation {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mx-rotator {
  margin: -0.75rem 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  min-height: 1.3em;
}

.mx-rw {
  display: inline-block;
  background: linear-gradient(90deg, #67e8f9, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  transition: transform 0.32s cubic-bezier(0.5, 0, 0.2, 1), opacity 0.32s;
}

.mx-rw.mx-out { transform: translateY(-55%); opacity: 0; }
.mx-rw.mx-pre { transform: translateY(55%); opacity: 0; transition: none; }

/* ---------- 2 · Hero: tarjetas con profundidad ---------- */
/* `translate` se suma al `transform` de las animaciones flotantes originales. */
.mx-depth .floating-card {
  translate: calc(var(--px, 0) * var(--d, 20) * 1px) calc(var(--py, 0) * var(--d, 20) * 1px);
  transition: translate 0.25s ease-out;
}

.mx-depth .card-top-left { --d: 18; }
.mx-depth .card-top-right { --d: 26; }
.mx-depth .card-bottom-left { --d: 30; }
.mx-depth .card-bottom-right { --d: 22; }

.mx-depth > .position-relative {
  transform: perspective(900px) rotateX(calc(var(--py, 0) * -6deg)) rotateY(calc(var(--px, 0) * 8deg))
    translate(calc(var(--px, 0) * -10px), calc(var(--py, 0) * -10px));
  transition: transform 0.25s ease-out;
}

/* ---------- 3 · Cursos: cascada + foco que sigue al cursor ---------- */
.mx-cascade .course-card { opacity: 0; }

.mx-cascade .course-card.mx-in {
  opacity: 1;
  /* backwards, no both: al terminar suelta el transform y el :hover original vuelve a funcionar */
  animation: mx-rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 90ms);
}

@keyframes mx-rise {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.course-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px circle at var(--mx, -300px) var(--my, -300px), rgba(0, 188, 212, 0.2), transparent 65%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 0;
}

.course-card:hover::after { opacity: 1; }

/* ---------- 4 · Promociones: borde vivo + confeti ---------- */
.mx-live.promo-card { isolation: isolate; }

/* Un cuadrado grande con un destello cónico que gira (solo transform) y,
   encima, el fondo original de la tarjeta 3px hacia adentro: lo que asoma es
   el borde. */
.mx-live.promo-card::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160vmax;
  aspect-ratio: 1;
  margin: -80vmax 0 0 -80vmax;
  background: conic-gradient(transparent 0deg 210deg, rgba(255, 255, 255, 0.9) 270deg, #ffe08a 305deg, transparent 345deg);
  animation: mx-spin 6s linear infinite;
  animation-delay: var(--mx-delay, 0s);
  z-index: -1;
  pointer-events: none;
}

.mx-live.promo-card::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: calc(1.5rem - 3px);
  background: inherit;
  z-index: -1;
  pointer-events: none;
}

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

.mx-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

#promociones { position: relative; }

/* ---------- 5 · Beneficios: íconos animados ---------- */
.benefit-icon .mx-ico {
  width: 56px;
  height: 56px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.mx-ico .star { fill: #ffe08a; stroke: none; transform-box: fill-box; transform-origin: center; }
.mx-ico .play { fill: #fff; stroke: none; transform-box: fill-box; transform-origin: center; }
.mx-ico .ring,
.mx-ico .check { stroke-dasharray: 100; stroke-dashoffset: 0; }
.mx-ico .check { stroke: #ffe08a; }
.mx-ico .seal { transform-box: fill-box; transform-origin: center; }
.mx-ico .dt { fill: #fff; stroke: none; transform-box: fill-box; transform-origin: center; }

.mx-on .mx-ico .star { animation: mx-pop 1.1s ease-in-out infinite; }
.mx-on .mx-ico .ring { animation: mx-draw 1.8s ease-in-out infinite; }
.mx-on .mx-ico .play { animation: mx-beat 1.8s ease-in-out infinite; }
.mx-on .mx-ico .check { animation: mx-draw 1.8s ease-in-out infinite; }
.mx-on .mx-ico .seal { animation: mx-wobble 1.8s ease-in-out infinite; }
.mx-on .mx-ico .dt { animation: mx-hop 0.9s ease-in-out infinite; }
.mx-on .mx-ico .dt:nth-of-type(2) { animation-delay: 0.15s; }
.mx-on .mx-ico .dt:nth-of-type(3) { animation-delay: 0.3s; }

.benefit-icon-wrapper.mx-on { transform: scale(1.08); }

@keyframes mx-pop { 0%, 100% { transform: scale(0.75) rotate(0); } 50% { transform: scale(1.3) rotate(35deg); } }
/* stroke-dashoffset no es transform, pero son 4 íconos de 56px y solo el activo */
@keyframes mx-draw { 0% { stroke-dashoffset: 100; } 70%, 100% { stroke-dashoffset: 0; } }
@keyframes mx-beat { 50% { transform: scale(1.2); } }
@keyframes mx-wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes mx-hop { 50% { transform: translateY(-4px); } }

/* ---------- 6 · Títulos: descifrado + subrayado + subtítulo ---------- */
.mx-ul {
  display: block;
  height: 4px;
  width: min(200px, 50%);
  margin: -0.25rem auto 1.1rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #00bcd4, #6b46c1);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.mx-go .mx-ul { animation: mx-grow 0.9s 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
@keyframes mx-grow { to { transform: scaleX(1); } }

.mx-w { display: inline-block; white-space: pre; opacity: 0; }
.mx-go .mx-w { animation: mx-wordin 0.6s ease forwards; animation-delay: calc(var(--i) * 45ms + 350ms); }
@keyframes mx-wordin { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 7 · WhatsApp: doble pulso + burbuja ---------- */
.whatsapp-button::before,
.whatsapp-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #25d366;
  animation: mx-ring 2.4s ease-out infinite;
  pointer-events: none;
}

.whatsapp-button::after { animation-delay: 1.2s; }

@keyframes mx-ring { from { transform: scale(1); opacity: 0.7; } to { transform: scale(1.9); opacity: 0; } }

.whatsapp-message.fade-in .message-bubble {
  transform-origin: 100% 100%;
  animation: mx-bubble 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mx-bubble { from { opacity: 0; transform: scale(0.6) translateY(10px); } to { opacity: 1; transform: none; } }

.message-text.fade-in > * { animation: mx-wordin 0.4s ease backwards; }
.message-text.fade-in > *:nth-child(2) { animation-delay: 0.12s; }
.message-text.fade-in > *:nth-child(3) { animation-delay: 0.24s; }

/* El globo flota sobre el botón en vez de agrandar el widget: un widget fijo
   abajo que crece hacia arriba mueve su esquina y cuenta como desplazamiento
   de la página (CLS), y los anillos de arriba lo duplicaban. Mismos anchos que
   whatsapp_button.css. Solo en la portada; las demás páginas no cargan este archivo. */
.whatsapp-widget .whatsapp-message {
  position: absolute;
  right: 0;
  bottom: calc(100% + 1rem);
  width: 320px;
}

@media (max-width: 768px) {
  .whatsapp-widget .whatsapp-message { width: 280px; }
}

/* ---------- Pausa fuera de pantalla ---------- */
.mx-paused .promo-card::before,
.mx-paused .mx-ico *,
.mx-paused .floating-card,
.mx-paused .hero-bg-animated::before,
.mx-paused .hero-bg-animated::after,
.mx-paused .promo-icon {
  animation-play-state: paused !important;
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  .mx-rotator { display: none; }

  .mx-live.promo-card::before,
  .whatsapp-button::before,
  .whatsapp-button::after { animation: none; opacity: 0; }

  .mx-on .mx-ico *,
  .whatsapp-message.fade-in .message-bubble,
  .message-text.fade-in > * { animation: none !important; }

  .mx-cascade .course-card { opacity: 1; }
  .mx-ul { transform: none; }
  .mx-w { opacity: 1; }

  /* Lo que la landing ya animaba antes de esta capa (codex_landing.css y AOS). */
  .floating-card,
  .hero-bg-animated::before,
  .hero-bg-animated::after,
  .promo-icon { animation: none !important; }

  [data-aos] { opacity: 1 !important; transform: none !important; transition: none !important; }
}
