@keyframes orbit {
  to { transform: rotate(1turn); }
}

@keyframes pulse {
  0%, 100% { opacity: .72; transform: scale(.92); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes sphere-tilt {
  0%, 100% { transform: rotate(-16deg) scaleY(.28); }
  50% { transform: rotate(16deg) scaleY(1.28); }
}

@keyframes sphere-bank {
  0%, 100% { transform: rotate(12deg) scaleX(.32); }
  50% { transform: rotate(-18deg) scaleX(1.42); }
}

@keyframes sphere-glint {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -100; }
}

@keyframes shimmer {
  0%, 100% { opacity: .45; }
  50% { opacity: .9; }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(.28rem); }
  to { opacity: 1; transform: translateY(0); }
}

.sphere-glint { visibility: hidden; }
.sphere-response { display: none; opacity: 0; }

@keyframes ambient-light {
  from { opacity: .74; transform: translate(-5px, 2px); }
  to { opacity: 1; transform: translate(7px, -6px); }
}

@keyframes ambient-drift {
  from { opacity: .64; transform: translate(2px, 5px); }
  to { opacity: .9; transform: translate(-6px, -7px); }
}

@keyframes binary-fall {
  0% { opacity: 0; transform: translateY(-20%); }
  20%, 70% { opacity: var(--binary-opacity); }
  100% { opacity: 0; transform: translateY(55%); }
}

@keyframes circuit-travel {
  from { stroke-dashoffset: 6; opacity: 0; }
  15%, 80% { opacity: .88; }
  to { stroke-dashoffset: -94; opacity: 0; }
}

@keyframes projector-pulse {
  from { opacity: .67; }
  to { opacity: 1; }
}

@keyframes conversation-arrival {
  from { opacity: .82; transform: translateY(.3rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes envelope-open {
  from { transform: rotateX(0); }
  to { transform: rotateX(155deg); }
}

@keyframes seal-release {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes letter-unfold {
  from { opacity: 0; transform: translateY(2rem) scale(.88); }
  to { opacity: 1; transform: none; }
}

@keyframes date-selection {
  from { opacity: .72; transform: translateY(.25rem); }
  to { opacity: 1; transform: none; }
}

@keyframes activation-power {
  0% { opacity: .46; }
  24% { opacity: .57; }
  67% { opacity: 1; }
  100% { opacity: 1; }
}

@keyframes activation-wave {
  0% { opacity: .15; transform: scale(.45); }
  40% { opacity: 1; }
  78% { opacity: 0; transform: scale(1.38); }
  100% { opacity: 1; transform: none; }
}

@property --farewell-glow {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

@keyframes farewell-glow {
  0%, 100% { --farewell-glow: 0; }
  24% { --farewell-glow: .94; }
}

@keyframes farewell-wave {
  0% { opacity: 0; transform: scale(.25); }
  24% { opacity: .86; }
  100% { opacity: 0; transform: scale(1); }
}

.projection.farewell-pulse { animation: farewell-glow 1.5s ease-in-out; }

@media (prefers-reduced-motion: reduce) {
  .projection.farewell-pulse { animation-duration: .45s; }
  body[data-activation="activating"] .projection svg,
  body[data-activation="activating"] .scenery { transition: opacity 180ms ease-out; }
}

@media (prefers-reduced-motion: no-preference) {
  .projection.farewell-pulse::after {
    inset: 0 auto auto 50%;
    width: 96%;
    height: auto;
    aspect-ratio: 1;
    translate: -50% 2%;
    z-index: 0;
    border-color: #ffcf85;
    box-shadow: 0 0 .75rem #ffc36a85, inset 0 0 .65rem #ffc36a50;
    animation: farewell-wave 1.5s ease-out both;
  }

  .scenery::before, .scenery::after { transition: opacity 900ms ease; }
  body[data-conversation-module="about-luis"] .conversation,
  body[data-conversation-module="letter-intro"] .conversation,
  body[data-conversation-module="decision-intro"] .conversation,
  body[data-conversation-module="date-intro"] .conversation,
  body[data-conversation-module="mission"] .conversation {
    animation: conversation-arrival .52s ease-out;
  }

  .date-summary, .date-card[aria-pressed="true"] {
    animation: date-selection .35s ease-out;
  }

  .scenery, .projection { transition: opacity 1.6s ease; }

  body[data-activation="standby"] :is(.orbit, .core, .sphere-grid, .sphere-glint, .particles, .projector-energy) {
    animation-play-state: paused;
  }

  body[data-activation="standby"] .projection::before { animation: none; }

  body[data-activation="activating"] .activation-copy { transition: opacity .6s ease; }
  body[data-activation="activating"] .projection svg { animation: activation-power 2.5s ease-in-out both; }
  body[data-activation="activating"] .projection::after { animation: activation-wave 2s .75s ease-out both; }
  body[data-activation="activating"] .orbit-cyan {
    transition: opacity 1.2s .45s ease-out;
  }

  body[data-activation="activating"] .orbit-gold {
    transition: opacity 1.1s .8s ease-out;
  }

  body[data-activation="activating"] .pulse-left,
  body[data-activation="activating"] .pulse-right {
    animation: circuit-travel 2s .8s ease-out both;
  }

  body[data-activation="active"][data-conversation-module="welcome"] #conversation {
    animation: conversation-arrival .52s ease-out;
  }

  body[data-conversation-module="finished"] :is(
    .binary-rain span, .circuit-pulse, .projector-energy, .orbit, .core, .sphere-grid, .sphere-glint, .particles
  ) { animation-play-state: paused; }

  body[data-conversation-module="finished"] .projection::before {
    animation-play-state: paused;
  }

  body[data-conversation-module="finished"]::before,
  body[data-conversation-module="finished"]::after {
    animation: none;
    opacity: .2;
  }

  .letter-stage .letter-flap { animation: envelope-open .52s ease-in-out both; }
  .letter-stage .letter-seal { animation: seal-release .2s ease-out both; }
  .letter-stage .letter-paper {
    transform-origin: center top;
    animation: letter-unfold .72s .32s ease-out both;
  }

  body::before { animation: ambient-light 32s ease-in-out infinite alternate; }
  body::after { animation: ambient-drift 46s ease-in-out infinite alternate; }
  .binary-rain span { animation: binary-fall var(--binary-duration) var(--binary-delay) linear infinite; }
  .circuit-pulse { visibility: visible; }
  .pulse-left { animation: circuit-travel 9s -2s linear infinite; }
  .pulse-center { animation: circuit-travel 13s -9s linear infinite reverse; }
  .pulse-right { animation: circuit-travel 11s -6s linear infinite; }
  .projection::before { animation: projector-pulse 5.6s ease-in-out infinite alternate; }
  .projector-energy { animation: projector-pulse 3.8s ease-in-out infinite alternate; }
  button, .whatsapp-contact { transition: background-color .2s ease, box-shadow .2s ease; }

  .orbit, .core, .sphere-grid {
    transform-box: view-box;
    transform-origin: 200px 200px;
  }

  .orbit-outer { animation: orbit 65s linear infinite; }
  .orbit-cyan { animation: orbit 34s linear infinite reverse; }
  .orbit-gold { animation: orbit 46s linear infinite; }
  .orbit-inner { animation: orbit 84s linear infinite reverse; }
  .core { animation: pulse 5s ease-in-out infinite; }
  .sphere-response { display: inline; }
  /* Cambiar la apertura de las elipses simula la inclinación de cada plano. */
  .sphere-grid-cyan { animation: sphere-tilt 11s ease-in-out infinite; }
  .sphere-grid-blue { animation: sphere-bank 14s ease-in-out -4s infinite; }
  .sphere-grid-gold { animation: sphere-tilt 17s ease-in-out -8s infinite; }

  .sphere-glint {
    visibility: visible;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 2 98;
    opacity: .66;
  }

  .sphere-glint-cyan { animation: sphere-glint 7s linear infinite; }
  .sphere-glint-blue { animation: sphere-glint 9s linear -3s infinite; }
  .sphere-glint-gold { animation: sphere-glint 12s linear -4s infinite reverse; }
  .particles { animation: shimmer 6s ease-in-out infinite; }
  .message p { animation: reveal .42s ease-out both; }
  .message p:nth-child(2) { animation-delay: .10s; }
  .message p:nth-child(3) { animation-delay: .20s; }
}
