/* =============================================================================
   animations.css — UR Perfumes
   GSAP initial states, keyframes, and utility animation classes.
============================================================================= */

/* ── GSAP Initial States ────────────────────────────────────────────────────
   header.php inlines <script>document.documentElement.classList.add('urp-js')
   before first paint. These rules hide animated elements from frame 1 so
   GSAP can reveal them — preventing flash of visible content.
──────────────────────────────────────────────────────────────────────────── */
html.urp-js [data-animate="fade-up"],
html.urp-js [data-animate="fade-in"],
html.urp-js [data-animate="scale-in"] {
  opacity: 0;
}

html.urp-js [data-animate="clip-up"]  { clip-path: inset(100% 0 0 0); }
html.urp-js [data-animate="clip-left"] { clip-path: inset(0 100% 0 0); }

html.urp-js [data-split] { opacity: 0; }

html.urp-js [data-animate-group] > * { opacity: 0; }

/* ── No-JS / CDN-fail safety net ────────────────────────────────────────────
   If JS never loads, urp-js is never added → all elements stay visible.
──────────────────────────────────────────────────────────────────────────── */
html:not(.urp-js) [data-animate],
html:not(.urp-js) [data-split] {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
  visibility: visible !important;
}

/* ── Keyframes ──────────────────────────────────────────────────────────────── */

/* Spin — loading indicators */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Film grain texture */
@keyframes grain {
  0%,  100% { transform: translate(0, 0);     }
  10%        { transform: translate(-2%, -3%); }
  20%        { transform: translate(3%, 2%);   }
  30%        { transform: translate(-1%, 4%);  }
  40%        { transform: translate(4%, -1%);  }
  50%        { transform: translate(-3%, 3%);  }
  60%        { transform: translate(2%, -4%);  }
  70%        { transform: translate(-4%, 1%);  }
  80%        { transform: translate(1%, -2%);  }
  90%        { transform: translate(3%, -3%);  }
}

/* Marquee strip — CSS fallback when GSAP not loaded */
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

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

/* Scroll indicator line */
@keyframes scroll-line {
  0%  { transform: scaleY(0); transform-origin: top; }
  50% { transform: scaleY(1); transform-origin: top; }
  51% { transform: scaleY(1); transform-origin: bottom; }
  100%{ transform: scaleY(0); transform-origin: bottom; }
}

/* Shimmer — skeleton loaders */
@keyframes shimmer {
  0%   { transform: translateX(-100%) skewX(-15deg); }
  100% { transform: translateX(250%)  skewX(-15deg); }
}

/* Fade pulse */
@keyframes fade-pulse {
  0%,  100% { opacity: 1; }
  50%        { opacity: 0.5; }
}

/* Gold line grow */
@keyframes line-grow {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

/* ── Utility Classes ─────────────────────────────────────────────────────────── */
.is-floating      { animation: float 6s ease-in-out infinite; }
.is-floating-slow { animation: float 9s ease-in-out infinite; }
.is-pulsing       { animation: fade-pulse 2s ease-in-out infinite; }
.is-spinning      { animation: spin 1s linear infinite; }

/* Grain overlay */
.grain-overlay {
  pointer-events: none;
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  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)' opacity='0.08'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.35;
  mix-blend-mode: overlay;
  animation: grain 8s steps(10) infinite;
}

/* Skeleton loader */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--cream-2);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.5) 50%, transparent 100%);
  animation: shimmer 1.5s ease-in-out infinite;
}

/* ── Reduced Motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .is-floating, .is-floating-slow, .is-pulsing, .is-spinning, .grain-overlay {
    animation: none !important;
  }
  .skeleton::after { animation: none !important; }
}
