/* ============================================================
   Animaciones — César Villegas
   Scroll reveal con IntersectionObserver (ver js/script.js)
   ============================================================ */

/* Estado inicial: elementos ocultos */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

.reveal-left {
  opacity: 0;
  transform: translateX(-28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

.reveal-right {
  opacity: 0;
  transform: translateX(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

/* Estado activado por JS */
.reveal.visible,
.reveal-left.visible,
.reveal-right.visible {
  opacity: 1;
  transform: translate(0, 0);
}

/* ---------- Escalonado dentro de las grillas ---------- */
.stack-grid .reveal:nth-child(2),
.formacion-grid .reveal:nth-child(2),
.aptitudes-lista .reveal:nth-child(2) { transition-delay: 0.07s; }

.stack-grid .reveal:nth-child(3),
.formacion-grid .reveal:nth-child(3),
.aptitudes-lista .reveal:nth-child(3) { transition-delay: 0.14s; }

.stack-grid .reveal:nth-child(4),
.aptitudes-lista .reveal:nth-child(4) { transition-delay: 0.21s; }

.stack-grid .reveal:nth-child(5),
.aptitudes-lista .reveal:nth-child(5) { transition-delay: 0.28s; }

.stack-grid .reveal:nth-child(6),
.aptitudes-lista .reveal:nth-child(6) { transition-delay: 0.35s; }

.stack-grid .reveal:nth-child(7) { transition-delay: 0.42s; }

/* ---------- Entrada del hero ---------- */
.hero-text > * {
  opacity: 0;
  transform: translateY(20px);
  animation: heroIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero-text > *:nth-child(1) { animation-delay: 0.08s; }
.hero-text > *:nth-child(2) { animation-delay: 0.16s; }
.hero-text > *:nth-child(3) { animation-delay: 0.24s; }
.hero-text > *:nth-child(4) { animation-delay: 0.32s; }
.hero-text > *:nth-child(5) { animation-delay: 0.40s; }

@keyframes heroIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Esquema del hero: dibujado progresivo ---------- */
.schema-node {
  opacity: 0;
  animation: nodeIn 0.55s ease forwards;
}
.schema-node[data-node="1"] { animation-delay: 0.45s; }
.schema-node[data-node="2"] { animation-delay: 0.65s; }
.schema-node[data-node="3"] { animation-delay: 0.85s; }
.schema-node[data-node="4"] { animation-delay: 1.05s; }

@keyframes nodeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.schema-line {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawLine 0.4s ease forwards;
}
.schema-line:nth-of-type(1) { animation-delay: 0.58s; }
.schema-line:nth-of-type(2) { animation-delay: 0.78s; }
.schema-line:nth-of-type(3) { animation-delay: 0.98s; }

@keyframes drawLine {
  to { stroke-dashoffset: 0; }
}

/* ---------- Sin animación si el usuario lo pidió ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-left,
  .reveal-right {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero-text > *,
  .schema-node {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .schema-line {
    stroke-dashoffset: 0;
    animation: none;
  }
}
