/* ═══════════════════════════════════════════════════════════════════════
   C.U.L.T. ANIMATION PRIMITIVES · v1
   Shared toolkit across all tiers (Sparks, Kids, Teens, Adult).
   Zero dependencies. Zero new libraries. Pure CSS keyframes.

   Usage:
     <div data-cult-anim="fade-up">        ← one-shot, triggers on scroll
     <div data-cult-anim="breathe">         ← loop, runs continuously
     <div data-cult-stagger="120">          ← children animate 120ms apart
     <div data-cult-anim-delay="200">       ← delay 200ms after trigger
     <div data-cult-anim-duration="800">    ← override default duration

   The companion cult-anim.js handles scroll-triggering via
   IntersectionObserver. For loop animations, no JS needed — CSS only.

   PRINCIPLE: prefers-reduced-motion always wins. Sensory-safe by default.
   ═══════════════════════════════════════════════════════════════════════ */

/* ─── REDUCED MOTION OVERRIDE ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  [data-cult-anim] {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}

/* ─── ENTRY ANIMATIONS (one-shot, triggered by .is-animated) ───────── */
/* Default initial state: invisible. .is-animated triggers reveal. */

[data-cult-anim="fade"],
[data-cult-anim="fade-up"],
[data-cult-anim="fade-down"],
[data-cult-anim="fade-left"],
[data-cult-anim="fade-right"],
[data-cult-anim="scale-pop"],
[data-cult-anim="bounce-in"],
[data-cult-anim="tilt-in"] {
  opacity: 0;
  transition-property: opacity, transform;
  transition-duration: var(--cult-anim-duration, 700ms);
  transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--cult-anim-delay, 0ms);
  will-change: opacity, transform;
}

[data-cult-anim="fade-up"]    { transform: translateY(20px); }
[data-cult-anim="fade-down"]  { transform: translateY(-20px); }
[data-cult-anim="fade-left"]  { transform: translateX(30px); }
[data-cult-anim="fade-right"] { transform: translateX(-30px); }
[data-cult-anim="scale-pop"]  { transform: scale(0.85); }
[data-cult-anim="bounce-in"]  { transform: scale(0.6); transition-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }
[data-cult-anim="tilt-in"]    { transform: rotate(-3deg) translateY(12px); }

/* Triggered state */
[data-cult-anim].is-animated {
  opacity: 1;
  transform: translate(0, 0) scale(1) rotate(0);
}

/* ─── BOUNCE-IN OVERSHOOT (uses keyframes for more pop) ───────────── */
[data-cult-anim="bounce-in"].is-animated {
  animation: cult-bounce-in var(--cult-anim-duration, 700ms) cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes cult-bounce-in {
  0%   { opacity: 0; transform: scale(0.6); }
  60%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* ─── LOOP ANIMATIONS (always running, no JS trigger needed) ──────── */

/* Breathe — subtle scale pulse, for planets, orbs, sun */
[data-cult-anim="breathe"] {
  animation: cult-breathe 4s ease-in-out infinite;
}
@keyframes cult-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

/* Float — gentle vertical bob, for icons, cards-on-hover */
[data-cult-anim="float"] {
  animation: cult-float 3.5s ease-in-out infinite;
}
@keyframes cult-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Slow drift — for background planets, decorative SVG */
[data-cult-anim="drift"] {
  animation: cult-drift 8s ease-in-out infinite;
}
@keyframes cult-drift {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  33%      { transform: translate(4px, -3px) rotate(0.5deg); }
  66%      { transform: translate(-3px, 2px) rotate(-0.5deg); }
}

/* Pulse-glow — for "tap me" prompts, attention hooks */
[data-cult-anim="pulse-glow"] {
  animation: cult-pulse-glow 2.2s ease-in-out infinite;
}
@keyframes cult-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 217, 106, 0.5); }
  50%      { box-shadow: 0 0 0 14px rgba(255, 217, 106, 0); }
}

/* Glow-text — gold accent words pulse softly */
[data-cult-anim="glow-text"] {
  animation: cult-glow-text 3s ease-in-out infinite;
}
@keyframes cult-glow-text {
  0%, 100% { text-shadow: 0 0 8px rgba(255, 217, 106, 0.35); }
  50%      { text-shadow: 0 0 18px rgba(255, 217, 106, 0.65); }
}

/* Shimmer — light sweep across surface (premium feel on CTAs/cards) */
[data-cult-anim="shimmer"] {
  position: relative;
  overflow: hidden;
}
[data-cult-anim="shimmer"]::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    100deg,
    transparent 0%,
    transparent 40%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 60%,
    transparent 100%
  );
  transform: translateX(-100%);
  animation: cult-shimmer 3.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cult-shimmer {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

/* Spin — for loaders, decorative rings */
[data-cult-anim="spin"] {
  animation: cult-spin 6s linear infinite;
}
@keyframes cult-spin {
  to { transform: rotate(360deg); }
}

/* Orbit — element traces a small circular path (for moons, decorative particles) */
[data-cult-anim="orbit"] {
  animation: cult-orbit 8s linear infinite;
  transform-origin: center;
}
@keyframes cult-orbit {
  0%   { transform: rotate(0deg)   translateX(8px) rotate(0deg);   }
  100% { transform: rotate(360deg) translateX(8px) rotate(-360deg); }
}

/* ─── ONE-SHOT INTERACTION ANIMATIONS (added via JS class) ────────── */

/* Shake — for errors */
.cult-anim-shake {
  animation: cult-shake 0.45s ease-in-out;
}
@keyframes cult-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

/* Flash — for newly-arrived content, success states */
.cult-anim-flash {
  animation: cult-flash 0.6s ease-out;
}
@keyframes cult-flash {
  0%   { background-color: rgba(255, 217, 106, 0.4); }
  100% { background-color: transparent; }
}

/* Pop — for tap responses, badge earned moments */
.cult-anim-pop {
  animation: cult-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cult-pop {
  0%   { transform: scale(1);    }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1);    }
}

/* Wiggle — for character beats, attention nudges */
.cult-anim-wiggle {
  animation: cult-wiggle 0.6s ease-in-out;
}
@keyframes cult-wiggle {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-4deg); }
  75%      { transform: rotate(4deg); }
}

/* ─── HOVER ELEVATIONS (apply via CSS class on hoverable surfaces) ── */

.cult-anim-hover-lift {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.cult-anim-hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.cult-anim-hover-glow {
  transition: box-shadow 0.25s ease-out, border-color 0.25s ease-out;
}
.cult-anim-hover-glow:hover {
  box-shadow: 0 0 24px rgba(255, 217, 106, 0.35);
}

/* ─── BUTTON PRESS RESPONSE (apply to any button to feel "alive") ─── */
.cult-anim-press {
  transition: transform 0.08s ease-out;
}
.cult-anim-press:active {
  transform: scale(0.96);
}

/* ─── STAGGERED CHILDREN (set via data-cult-stagger on parent) ─────
   Companion JS applies inline transition-delay to each direct child. */

/* ─── CONFETTI (reused from sparks-points.js, now globally available) ── */
.cult-anim-confetti {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  overflow: hidden;
}
.cult-anim-confetti__piece {
  position: absolute; top: -20px;
  width: 10px; height: 14px;
  border-radius: 2px;
  animation: cult-confetti-fall 2s linear forwards;
}
@keyframes cult-confetti-fall {
  0%   { transform: translateY(-20vh) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.4; }
}

/* ─── BACKGROUND TWINKLE (subtle starfield enhancement) ──────────── */
[data-cult-anim="twinkle"] {
  animation: cult-twinkle 3s ease-in-out infinite;
}
@keyframes cult-twinkle {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}
