/* ============================================
   ESPELUNCA DIGITAL - Animaciones Avanzadas
   ============================================ */

/* ========== ANIMACIONES BASE ========== */

/* Fade In desde abajo */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In desde la izquierda */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In desde la derecha */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Escalar desde pequeño */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Revelar con blur */
@keyframes revealBlur {
  from {
    opacity: 0;
    filter: blur(20px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* Texto letra por letra (para usar con JS) */
@keyframes revealLetter {
  from {
    opacity: 0;
    transform: translateY(20px) rotateX(-90deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* ========== OBRAS QUE RESPIRAN ========== */
@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    filter: brightness(0.95);
  }
  50% {
    transform: scale(1.02);
    filter: brightness(1);
  }
}

.obra-respira img {
  animation: breathe 4s ease-in-out infinite;
}

/* ========== EFECTO FLOTANTE ========== */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.flotar {
  animation: float 3s ease-in-out infinite;
}

/* ========== PARALLAX CSS ========== */
.parallax-container {
  perspective: 1px;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

.parallax-layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.parallax-layer--back {
  transform: translateZ(-1px) scale(2);
}

.parallax-layer--front {
  transform: translateZ(0);
}

/* ========== SCROLL-DRIVEN ANIMATIONS (CSS Nativo 2024+) ========== */
@supports (animation-timeline: scroll()) {
  .scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    animation: scrollReveal linear forwards;
    animation-timeline: view();
    animation-range: entry 0% cover 40%;
  }

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

  .scroll-scale {
    transform: scale(0.8);
    opacity: 0;
    animation: scrollScale linear forwards;
    animation-timeline: view();
    animation-range: entry 0% cover 50%;
  }

  @keyframes scrollScale {
    to {
      transform: scale(1);
      opacity: 1;
    }
  }

  /* Parallax nativo con scroll */
  .scroll-parallax {
    animation: parallaxMove linear;
    animation-timeline: scroll();
  }

  @keyframes parallaxMove {
    from {
      transform: translateY(-50px);
    }
    to {
      transform: translateY(50px);
    }
  }
}

/* ========== VIEW TRANSITIONS API ========== */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
}

::view-transition-old(root) {
  animation: fade-out 0.5s ease-out;
}

::view-transition-new(root) {
  animation: fade-in 0.5s ease-in;
}

@keyframes fade-out {
  from { opacity: 1; filter: blur(0); }
  to { opacity: 0; filter: blur(10px); }
}

@keyframes fade-in {
  from { opacity: 0; filter: blur(10px); }
  to { opacity: 1; filter: blur(0); }
}

/* View transition para imagenes */
.obra img {
  view-transition-name: obra-image;
}

::view-transition-old(obra-image),
::view-transition-new(obra-image) {
  animation-duration: 0.4s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== EFECTOS DE TEXTO ========== */
.text-gradient {
  background: linear-gradient(
    135deg,
    var(--luz-calida) 0%,
    var(--ambar-luz) 50%,
    var(--luz-calida) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: 200% center;
  }
}

/* Texto que aparece palabra por palabra */
.word-reveal {
  overflow: hidden;
}

.word-reveal .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.5s var(--ease-dramatic);
}

.word-reveal.animate .word {
  opacity: 1;
  transform: translateY(0);
}

/* ========== EFECTO GLOW ========== */
@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px var(--luz-calida),
                0 0 10px var(--luz-calida),
                0 0 15px var(--luz-calida);
  }
  50% {
    box-shadow: 0 0 10px var(--luz-calida),
                0 0 20px var(--luz-calida),
                0 0 30px var(--luz-calida);
  }
}

.glow {
  animation: glow 2s ease-in-out infinite;
}

/* ========== LINEAS QUE SE DIBUJAN ========== */
.draw-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: drawLine 2s ease forwards;
}

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

/* ========== EFECTO DE ONDA ========== */
@keyframes wave {
  0% {
    transform: translateX(0) translateZ(0) scaleY(1);
  }
  50% {
    transform: translateX(-25%) translateZ(0) scaleY(0.55);
  }
  100% {
    transform: translateX(-50%) translateZ(0) scaleY(1);
  }
}

.wave {
  animation: wave 3s ease-in-out infinite;
}

/* ========== TRANSICIONES DE PÁGINA ========== */
.page-transition-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-transition-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-transition-exit {
  opacity: 1;
}

.page-transition-exit-active {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ========== EFECTO MORPH (para transiciones entre secciones) ========== */
.morph-container {
  position: relative;
  overflow: hidden;
}

.morph-shape {
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--serie-color, var(--gris-cueva));
  border-radius: 50%;
  transform: scale(0);
  opacity: 0;
  transition: all 0.8s var(--ease-dramatic);
}

.morph-container.active .morph-shape {
  transform: scale(2);
  opacity: 1;
  border-radius: 0;
}

/* ========== STAGGER ANIMATIONS (para listas) ========== */
.stagger-item {
  opacity: 0;
  transform: translateY(30px);
}

.stagger-item.animate {
  animation: fadeInUp 0.6s var(--ease-smooth) forwards;
}

/* Delays escalonados */
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 100ms; }
.stagger-item:nth-child(3) { animation-delay: 200ms; }
.stagger-item:nth-child(4) { animation-delay: 300ms; }
.stagger-item:nth-child(5) { animation-delay: 400ms; }
.stagger-item:nth-child(6) { animation-delay: 500ms; }
.stagger-item:nth-child(7) { animation-delay: 600ms; }
.stagger-item:nth-child(8) { animation-delay: 700ms; }
.stagger-item:nth-child(9) { animation-delay: 800ms; }
.stagger-item:nth-child(10) { animation-delay: 900ms; }

/* ========== EFECTO DE MASCARA CIRCULAR (para revelar) ========== */
@keyframes circularReveal {
  from {
    clip-path: circle(0% at 50% 50%);
  }
  to {
    clip-path: circle(100% at 50% 50%);
  }
}

.circular-reveal {
  animation: circularReveal 1s var(--ease-dramatic) forwards;
}

/* ========== RUIDO / GRAIN EFFECT ========== */
.grain::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ========== EFECTO DE DESENFOQUE PROGRESIVO ========== */
.progressive-blur {
  mask-image: linear-gradient(to bottom,
    black 0%,
    black 60%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(to bottom,
    black 0%,
    black 60%,
    transparent 100%
  );
}

/* ========== CURSOR TRAIL (rastro del cursor) ========== */
.cursor-trail {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--luz-calida);
  opacity: 0;
  pointer-events: none;
  z-index: calc(var(--z-cursor) - 1);
  animation: trailFade 0.5s ease forwards;
}

@keyframes trailFade {
  from {
    opacity: 0.3;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0);
  }
}
