/* ============================================================
   GALLETAS PITUCA — Motion System Premium
   Cada contexto tiene su propio lenguaje de movimiento.
   El motion refuerza el contenido; nunca lo protagoniza.
============================================================ */

/* ============================================================
   1) HEADER — blur gradual (controlado por --header-blur en JS)
============================================================ */
.site-header,
.site-header.is-scrolled {
  backdrop-filter: saturate(180%) blur(var(--header-blur, 14px));
  -webkit-backdrop-filter: saturate(180%) blur(var(--header-blur, 14px));
}

/* ============================================================
   2) REVEAL GENÉRICO — base editorial (cards, textos, heads)
   Fill backwards para no bloquear hovers.
============================================================ */
.reveal {
  opacity: 0;
}

.reveal.is-visible {
  opacity: 1;
}

.reveal.is-visible:not(.hero-panel) {
  animation: revealIn 0.9s var(--ease-premium) backwards;
  animation-delay: var(--d, 0s);
}

@keyframes revealIn {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger refinado: +80ms por hijo (cubre grids con <li> o directos) */
.grid > .reveal:nth-child(2),
.grid > li:nth-child(2) > .reveal { --d: 0.08s; }
.grid > .reveal:nth-child(3),
.grid > li:nth-child(3) > .reveal { --d: 0.16s; }
.grid > .reveal:nth-child(4),
.grid > li:nth-child(4) > .reveal { --d: 0.24s; }
.grid > .reveal:nth-child(5),
.grid > li:nth-child(5) > .reveal { --d: 0.32s; }
.grid > .reveal:nth-child(6),
.grid > li:nth-child(6) > .reveal { --d: 0.40s; }
.grid > .reveal:nth-child(7),
.grid > li:nth-child(7) > .reveal { --d: 0.48s; }
.grid > .reveal:nth-child(8),
.grid > li:nth-child(8) > .reveal { --d: 0.56s; }
.grid > .reveal:nth-child(9),
.grid > li:nth-child(9) > .reveal { --d: 0.64s; }

/* ============================================================
   3) HERO — lenguaje cinematográfico
   • Blur → Focus extremadamente suave en la imagen
   • Ken Burns sutil (26s)
   • Panel con entrada escalonada
   • Acento con mask-reveal
============================================================ */
.hero::after {
  --hero-final-filter: blur(0.5px);
  animation:
    heroZoom 26s var(--ease-smooth) infinite alternate,
    heroFocus 1.8s var(--ease-premium) both;
}

.hero--home::after {
  --hero-final-filter: brightness(0.72) sepia(0.14) saturate(0.92) blur(0.5px);
}

@keyframes heroZoom {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* Blur → Focus: la fotografía "despierta" enfocándose */
@keyframes heroFocus {
  0% {
    filter: blur(16px);
    opacity: 0;
  }
  100% {
    filter: var(--hero-final-filter);
    opacity: 1;
  }
}

/* Panel de vidrio */
.hero--home .hero-panel.is-visible {
  animation: panelIn 1.1s var(--ease-premium) 0.1s backwards;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Contenido escalonado (delays .35 / .5 / .68 / .85) */
.hero--home .hero-eyebrow,
.hero--home .hero-title,
.hero--home .hero-lead,
.hero--home .hero-actions {
  opacity: 0;
  transform: translateY(22px);
  animation: heroUp 0.9s var(--ease-premium) both;
}

.hero--home .hero-eyebrow  { animation-delay: 0.35s; }
.hero--home .hero-title    { animation-delay: 0.50s; }
.hero--home .hero-lead     { animation-delay: 0.68s; }
.hero--home .hero-actions  { animation-delay: 0.85s; }

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

/* Acento del título con mask-reveal (derecha → izquierda) */
.hero--home .hero-title span {
  clip-path: inset(0 0 0 100%);
  animation: maskReveal 0.9s var(--ease-premium) 0.8s both;
}

@keyframes maskReveal {
  to { clip-path: inset(0 0 0 0); }
}

/* Héroes internos: entrada más contenida y editorial */
.hero:not(.hero--home) .hero-eyebrow,
.hero:not(.hero--home) .hero-title,
.hero:not(.hero--home) .hero-lead {
  opacity: 0;
  transform: translateY(22px);
  animation: heroUp 0.9s var(--ease-premium) both;
}

.hero:not(.hero--home) .hero-eyebrow { animation-delay: 0.20s; }
.hero:not(.hero--home) .hero-title   { animation-delay: 0.35s; }
.hero:not(.hero--home) .hero-lead    { animation-delay: 0.55s; }

/* Indicador de scroll: aparece tarde, con delicadeza */
.hero-scroll {
  opacity: 0;
  animation: fadeIn 1s var(--ease-smooth) 1.6s backwards;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   4) PRODUCTOS — zoom cinematográfico de imagen al revelar
============================================================ */
.product-card .product-media img,
.card-mini .card-media img {
  opacity: 0;
  transform: scale(1.14);
}

.product-card.is-visible .product-media img,
.card-mini.is-visible .card-media img {
  opacity: 1;
  transform: scale(1);
  animation: imgZoom 1.2s var(--ease-premium) backwards;
}

@keyframes imgZoom {
  from {
    opacity: 0;
    transform: scale(1.14);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ============================================================
   5) TIMELINE — entrada lateral cruzada (año ↔ cuerpo)
============================================================ */
.timeline-item .timeline-year,
.timeline-item .timeline-body {
  opacity: 0;
}

.timeline-item.is-visible .timeline-year {
  opacity: 1;
  animation: slideFromLeft 0.8s var(--ease-premium) backwards;
}

.timeline-item.is-visible .timeline-body {
  opacity: 1;
  animation: slideFromRight 0.8s var(--ease-premium) 0.12s backwards;
}

@keyframes slideFromLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideFromRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   6) FOTO HISTORIA — scale-in con asentamiento
============================================================ */
.historia-photo {
  opacity: 0;
}

.historia-photo.is-visible {
  opacity: 1;
  animation: photoIn 0.9s var(--ease-lift) backwards;
}

@keyframes photoIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Badge 1969: flotación perpetua sutil */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

/* ============================================================
   7) CTA — asentamiento suave (scale + fade)
============================================================ */
.cta-card {
  opacity: 0;
}

.cta-card.is-visible {
  opacity: 1;
  animation: ctaIn 1s var(--ease-premium) backwards;
}

@keyframes ctaIn {
  from {
    opacity: 0;
    transform: scale(0.965) translateY(16px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================================
   8) FOOTER — aparición contenida (sin ocultar si falla JS)
============================================================ */
.site-footer.is-visible {
  animation: footerIn 0.9s var(--ease-smooth) backwards;
}

@keyframes footerIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   9) STATS — fade de contadores
============================================================ */
.stats strong[data-count] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.6s var(--ease-smooth),
              transform 0.6s var(--ease-smooth);
}

.stats.is-visible strong[data-count] {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   10) INDICADOR DE SCROLL — pulso
============================================================ */
@keyframes scrollPulse {
  0%, 100% {
    opacity: 0.35;
    transform: scaleY(0.7);
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
  }
}

/* ============================================================
   11) FORMULARIO — estados
============================================================ */
.btn-submit.is-loading::before {
  content: '';
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--c-white);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-submit.is-success {
  background: linear-gradient(180deg, #43a047, #2e7d32);
  box-shadow: 0 8px 20px rgba(46, 125, 50, 0.35);
}

/* ============================================================
   12) REDUCED MOTION — todo visible, nada animado
============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .reveal,
  .hero--home .hero-panel,
  .hero--home .hero-eyebrow,
  .hero--home .hero-title,
  .hero--home .hero-lead,
  .hero--home .hero-actions,
  .hero:not(.hero--home) .hero-eyebrow,
  .hero:not(.hero--home) .hero-title,
  .hero:not(.hero--home) .hero-lead,
  .hero-scroll,
  .product-card .product-media img,
  .card-mini .card-media img,
  .timeline-item .timeline-year,
  .timeline-item .timeline-body,
  .historia-photo,
  .cta-card,
  .stats strong[data-count] {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    filter: none !important;
  }
}