/* ============================================================
   Ypsilon Kinetic Nebula — Animation System
   ============================================================ */

/* ============================================================
   1. SCROLL REVEAL
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal--left {
  transform: translateX(-40px);
}

.reveal--left.is-visible {
  transform: translateX(0);
}

.reveal--right {
  transform: translateX(40px);
}

.reveal--right.is-visible {
  transform: translateX(0);
}

.reveal--scale {
  transform: scale(0.9);
}

.reveal--scale.is-visible {
  transform: scale(1);
}

.reveal--fade {
  transform: none;
}

/* Stagger Delays */
.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }
.stagger-5 { transition-delay: 0.5s; }
.stagger-6 { transition-delay: 0.6s; }

/* ============================================================
   2. HERO ANIMATIONS
   ============================================================ */
@keyframes hero-fade-in {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero__label {
  animation: hero-fade-in 0.8s ease-out 0.2s both;
}

.hero__title {
  animation: hero-fade-in 0.8s ease-out 0.4s both;
}

.hero__subtitle {
  animation: hero-fade-in 0.8s ease-out 0.6s both;
}

.hero .btn-group {
  animation: hero-fade-in 0.8s ease-out 0.8s both;
}

/* Rotating Text */
@keyframes text-rotate-in {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(0);
  }
  40% {
    opacity: 0;
    transform: translateY(-100%);
  }
  100% {
    opacity: 0;
    transform: translateY(-100%);
  }
}

.hero__rotating-text {
  display: inline-block;
  position: relative;
  height: 1.2em;
  overflow: hidden;
  vertical-align: bottom;
}

/* Legacy rotating animation — overridden by text-morph.js when active */
.hero__rotating-text span {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  animation: text-rotate-in 9s ease-in-out infinite;
}

.hero__rotating-text span:nth-child(2) {
  animation-delay: 3s;
}

.hero__rotating-text span:nth-child(3) {
  animation-delay: 6s;
}

/* When text-morph.js takes over, it replaces children with .text-morph__display */
.hero__rotating-text:has(.text-morph__display) {
  height: auto;
  overflow: visible;
}

.hero__rotating-text .text-morph__display,
.hero__rotating-text .text-morph__display .text-morph__word,
.hero__rotating-text .text-morph__display .text-morph__char,
.hero__rotating-text .text-morph__display .text-morph__space {
  position: static;
  opacity: 1;
  animation: none;
}

/* ============================================================
   3. AMBIENT EFFECTS
   ============================================================ */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(234, 91, 27, 0.2);
  }
  50% {
    box-shadow: 0 0 40px rgba(234, 91, 27, 0.4);
  }
}

.pulse-glow {
  animation: pulse-glow 3s ease-in-out infinite;
}

/* Agentes IA: tick pulse (task completed) */
@keyframes pulse-tick-green {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(52, 210, 122, 0);
    border-color: var(--ia-green-soft, rgba(52, 210, 122, 0.25));
  }
  50% {
    box-shadow: 0 0 16px 2px rgba(52, 210, 122, 0.55);
    border-color: rgba(52, 210, 122, 0.75);
  }
}

.pulse-tick-green {
  animation: pulse-tick-green 2.4s ease-in-out infinite;
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.gradient-animated {
  background-size: 200% 200%;
  animation: gradient-shift 8s ease infinite;
}

/* ============================================================
   4. FLOAT & BOBBING
   ============================================================ */
@keyframes float-slow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes float-delayed {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-8px) rotate(1deg); }
  75% { transform: translateY(4px) rotate(-1deg); }
}

.float-slow {
  animation: float-slow 5s ease-in-out infinite;
}

.float-delayed {
  animation: float-delayed 7s ease-in-out infinite;
}

/* ============================================================
   5. COUNTER ANIMATION
   ============================================================ */
@keyframes count-pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.metric.is-visible .metric__number {
  animation: count-pop 0.6s ease-out both;
}

/* ============================================================
   6. CARD HOVER EFFECTS
   ============================================================ */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.glass-card--shimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.glass-card--shimmer:hover::before {
  opacity: 1;
  animation: shimmer 1.5s ease infinite;
}

/* ============================================================
   7. PAGE TRANSITIONS
   ============================================================ */
@keyframes page-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body {
  animation: page-enter 0.5s ease-out;
}

/* ============================================================
   8. MOBILE NAV TRANSITIONS
   ============================================================ */
.navbar__mobile-menu .navbar__link {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.navbar__mobile-menu.active .navbar__link {
  opacity: 1;
  transform: translateX(0);
}

.navbar__mobile-menu.active .navbar__link:nth-child(1) { transition-delay: 0.05s; }
.navbar__mobile-menu.active .navbar__link:nth-child(2) { transition-delay: 0.1s; }
.navbar__mobile-menu.active .navbar__link:nth-child(3) { transition-delay: 0.15s; }
.navbar__mobile-menu.active .navbar__link:nth-child(4) { transition-delay: 0.2s; }
.navbar__mobile-menu.active .navbar__link:nth-child(5) { transition-delay: 0.25s; }
.navbar__mobile-menu.active .navbar__link:nth-child(6) { transition-delay: 0.3s; }
.navbar__mobile-menu.active .navbar__link:nth-child(7) { transition-delay: 0.35s; }
.navbar__mobile-menu.active .navbar__link:nth-child(8) { transition-delay: 0.4s; }

/* ============================================================
   9. TYPING CURSOR (hero accent)
   ============================================================ */
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-cursor::after {
  content: '|';
  color: var(--primary);
  animation: blink-cursor 1s step-end infinite;
  margin-left: 2px;
}

/* ============================================================
   9.5 METRIC TELEMETRY (living counters)
   ============================================================ */
@keyframes metric-live-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 6px rgba(52, 210, 122, 0.6);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.35);
    box-shadow: 0 0 14px rgba(52, 210, 122, 1);
    opacity: 1;
  }
}

@keyframes metric-digit-glitch {
  0%   { transform: translate(0, 0);   opacity: 1;   }
  25%  { transform: translate(-1px, -1px); opacity: 0.7; }
  50%  { transform: translate(1px, 0);  opacity: 0.5; }
  75%  { transform: translate(-1px, 1px); opacity: 0.75; }
  100% { transform: translate(0, 0);   opacity: 1;   }
}

@keyframes metric-digit-lock {
  0%   { transform: translateY(-6px) scale(1.25); opacity: 0.2; filter: blur(1px); }
  55%  { transform: translateY(1px)  scale(1.1);  opacity: 1;   filter: blur(0); }
  100% { transform: translateY(0)    scale(1);    opacity: 1;   filter: blur(0); }
}

/* Cumulative growth tick — flash green on the changed digit */
@keyframes metric-digit-tick {
  0%   { transform: translateY(-3px); color: #34d27a; text-shadow: 0 0 10px rgba(52, 210, 122, 0.9); }
  60%  { transform: translateY(0);    color: #34d27a; text-shadow: 0 0 6px rgba(52, 210, 122, 0.4); }
  100% { transform: translateY(0);    color: inherit; text-shadow: none; }
}

@keyframes metric-scanline {
  0%   { top: 0; opacity: 0; }
  8%   { opacity: 0.9; }
  92%  { opacity: 0.9; }
  100% { top: 100%; opacity: 0; }
}

/* ============================================================
   10. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero__label,
  .hero__title,
  .hero__subtitle,
  .hero .btn-group {
    animation: none;
    opacity: 1;
  }

  .hero__rotating-text span {
    animation: none;
    position: static;
    opacity: 1;
  }

  .hero__rotating-text span:not(:first-child) {
    display: none;
  }

  .pulse-glow,
  .float-slow,
  .float-delayed,
  .gradient-animated {
    animation: none;
  }

  body {
    animation: none;
  }
}
