/* ==========================================================================
   polarix-motion.css — Estados de movimiento, demo de flujo y microinteracciones
   GPU-composited (transform, opacity, clip-path) · 60fps · Reduced-motion safe
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Cabecera y bloqueo de scroll (menú móvil / modal)
   -------------------------------------------------------------------------- */
.px-header {
  transition:
    background-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    backdrop-filter 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.px-header.is-scrolled {
  background-color: rgba(8, 13, 24, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    inset 0 -1px 0 rgba(244, 247, 251, 0.08),
    0 12px 32px -16px rgba(0, 0, 0, 0.65);
}

html.px-menu-open,
html.px-modal-open {
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   2. Canvas de constelación estrella polar (#hero-constellation)
   -------------------------------------------------------------------------- */
#hero-constellation {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}

#hero-constellation.is-ready {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   3. Scrub de texto palabra por palabra ([data-fill] / .px-w)
   Sin GSAP (o con reduced-motion), el texto siempre permanece 100% legible.
   -------------------------------------------------------------------------- */
.px-w {
  display: inline;
  transition: none;
}

html.px-motion [data-fill] .px-w {
  color: rgba(244, 247, 251, 0.24);
}

/* --------------------------------------------------------------------------
   4. Marquee vivo ([data-marquee])
   -------------------------------------------------------------------------- */
[data-marquee] {
  overflow: hidden;
}

[data-marquee-track],
.px-marquee__track {
  will-change: transform;
}

/* --------------------------------------------------------------------------
   5. Demo interactiva de flujo (#flow-demo / #flow-stage / #flow-connectors)
   -------------------------------------------------------------------------- */
#flow-stage {
  position: relative;
}

#flow-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.px-conn-base {
  fill: none;
  stroke: rgba(244, 247, 251, 0.14);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.px-conn-active {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.96;
  transition: opacity 0.25s ease;
}

.px-pulse-halo {
  fill: rgba(34, 211, 238, 0.28);
  pointer-events: none;
  will-change: transform, opacity;
}

.px-pulse-dot {
  fill: #f4f7fb;
  stroke: #22d3ee;
  stroke-width: 2;
  pointer-events: none;
  will-change: transform, opacity;
}

/* Nodos del flujo */
.px-node {
  position: relative;
  z-index: 1;
  cursor: pointer;
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
  will-change: transform;
}

.px-node::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    120% 100% at 50% 0%,
    rgba(91, 124, 250, 0.22) 0%,
    rgba(34, 211, 238, 0.08) 45%,
    transparent 75%
  );
  transition: opacity 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}

.px-node:hover {
  transform: translate3d(0, -2px, 0);
  border-color: rgba(91, 124, 250, 0.5);
}

.px-node:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 3px;
}

.px-node.is-done {
  border-color: rgba(34, 211, 238, 0.38);
  box-shadow: 0 8px 24px -14px rgba(34, 211, 238, 0.28);
}

.px-node.is-active {
  transform: translate3d(0, -4px, 0);
  border-color: rgba(91, 124, 250, 0.88);
  box-shadow:
    0 0 0 1px rgba(34, 211, 238, 0.35),
    0 16px 36px -12px rgba(91, 124, 250, 0.45),
    0 0 28px -8px rgba(34, 211, 238, 0.3);
}

.px-node.is-active::before {
  opacity: 1;
}

.px-node.is-selected {
  border-color: rgba(34, 211, 238, 0.85);
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.48),
    0 16px 38px -12px rgba(91, 124, 250, 0.42);
}

.px-node.is-active.is-selected {
  box-shadow:
    0 0 0 2px rgba(34, 211, 238, 0.65),
    0 18px 42px -10px rgba(91, 124, 250, 0.55);
}

/* Indicador de pulso sutil en nodo activo */
.px-node.is-active .px-node__status,
.px-node.is-active [data-node-status] {
  animation: px-status-pulse 1.8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes px-status-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(1.18);
  }
}

/* Transición del payload y log del inspector */
#inspector-payload.is-updating {
  animation: px-payload-flash 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes px-payload-flash {
  0% {
    opacity: 0.45;
    transform: translate3d(0, 4px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.px-log-entry {
  animation: px-log-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes px-log-in {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Selector de escenario activo */
[data-scenario] {
  transition:
    background-color 0.24s ease,
    border-color 0.24s ease,
    color 0.24s ease,
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.24s ease;
}

[data-scenario].is-active,
[data-scenario][aria-selected="true"] {
  border-color: rgba(91, 124, 250, 0.8);
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.28), 0 8px 20px -10px rgba(91, 124, 250, 0.55);
}

/* --------------------------------------------------------------------------
   6. Mini toggles en Bento (.px-mini-toggle)
   -------------------------------------------------------------------------- */
.px-mini-toggle {
  cursor: pointer;
  transition:
    background-color 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.px-mini-toggle[aria-checked="true"] {
  background-color: rgba(91, 124, 250, 0.92);
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow: 0 0 14px -2px rgba(91, 124, 250, 0.55);
}

.px-mini-toggle::after,
.px-mini-toggle__thumb {
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.px-mini-toggle[aria-checked="true"] .px-mini-toggle__thumb {
  transform: translate3d(100%, 0, 0);
}

/* --------------------------------------------------------------------------
   7. Acordeón FAQ (.px-faq__item.is-open)
   -------------------------------------------------------------------------- */
.px-faq__item {
  transition:
    border-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.px-faq__item.is-open {
  border-color: rgba(91, 124, 250, 0.45);
  box-shadow: 0 12px 32px -18px rgba(91, 124, 250, 0.32);
}

.px-faq__trigger .px-faq__icon,
.px-faq__trigger svg {
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.px-faq__item.is-open .px-faq__trigger .px-faq__icon,
.px-faq__item.is-open .px-faq__trigger svg {
  transform: rotate(45deg);
}

.px-faq__item.is-open .px-faq__panel,
.px-faq__item.is-open [role="region"] {
  animation: px-faq-reveal 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes px-faq-reveal {
  from {
    opacity: 0;
    transform: translate3d(0, -6px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* --------------------------------------------------------------------------
   8. Menú móvil y modal (#mobile-menu / #demo-modal)
   -------------------------------------------------------------------------- */
#mobile-menu.is-open,
#demo-modal.is-open {
  animation: px-overlay-in 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#demo-modal.is-open .px-modal__dialog,
#demo-modal.is-open [role="dialog"] {
  animation: px-dialog-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes px-overlay-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes px-dialog-in {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* --------------------------------------------------------------------------
   9. Validación accesible y CTA de confirmación por WhatsApp
   -------------------------------------------------------------------------- */
[aria-invalid="true"] {
  border-color: rgba(248, 113, 113, 0.85) !important;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}

.px-status-ok {
  color: #6ee7b7;
}

.px-status-err {
  color: #fca5a5;
}

.px-wa-confirm {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #06281c;
  background: linear-gradient(135deg, #34d399 0%, #22d3ee 100%);
  text-decoration: none;
  box-shadow: 0 8px 22px -8px rgba(52, 211, 153, 0.55);
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.22s ease;
}

.px-wa-confirm:hover {
  transform: translate3d(0, -1px, 0);
  box-shadow: 0 12px 26px -8px rgba(34, 211, 238, 0.65);
}

.px-wa-confirm:focus-visible {
  outline: 2px solid #f4f7fb;
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   10. Preferencia estricta de movimiento reducido
   Desactiva transiciones y animaciones y garantiza 100% legibilidad y calma.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .px-w,
  html.px-motion [data-fill] .px-w {
    color: inherit !important;
  }

  #hero-constellation {
    opacity: 1 !important;
  }

  .px-node,
  .px-node:hover,
  .px-node.is-active,
  .px-wa-confirm:hover {
    transform: none !important;
  }

  [data-marquee-track],
  .px-marquee__track {
    will-change: auto;
  }
}
