/* =====================================================================
   animations.css — keyframes, reveal states, decorative motion
   Heavy scroll animations are driven by GSAP in assets/js/animations.js.
   Everything here uses transform / opacity only (GPU friendly).
   ===================================================================== */

/* ---------- Reveal initial states ----------
   Only hidden when JS + motion are available (html.has-motion), so the
   page is still fully readable without JavaScript. */
.has-motion [data-reveal] {
  opacity: 0;
  will-change: transform, opacity;
}

.has-motion [data-reveal="fade-up"]    { transform: translateY(40px); }
.has-motion [data-reveal="fade-down"]  { transform: translateY(-40px); }
.has-motion [data-reveal="fade-left"]  { transform: translateX(48px); }
.has-motion [data-reveal="fade-right"] { transform: translateX(-48px); }
.has-motion [data-reveal="zoom"]       { transform: scale(0.88); }

.has-motion [data-split] .split-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.has-motion [data-split] .split-word > span {
  display: inline-block;
  transform: translateY(110%);
  will-change: transform;
}

/* Keep gradient text working on split (transformed) words */
.text-gradient .split-word > span {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Keyframes ---------- */
@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

@keyframes bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}

@keyframes tube-fill {
  from { transform: scaleY(0.25); }
  to   { transform: scaleY(1); }
}

@keyframes curtain-in {
  from { transform: scaleY(0); transform-origin: bottom; }
  to   { transform: scaleY(1); transform-origin: bottom; }
}

@keyframes curtain-out {
  from { transform: scaleY(1); transform-origin: top; }
  to   { transform: scaleY(0); transform-origin: top; }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(46, 224, 198, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(46, 224, 198, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 224, 198, 0); }
}

@keyframes ping {
  0%   { transform: scale(1); opacity: 0.8; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-16px) rotate(3deg); }
}

@keyframes float-x {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(12px); }
}

@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -40px) scale(1.08); }
  66%      { transform: translate(-25px, 25px) scale(0.95); }
}

@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

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

@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}

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

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* ---------- Decorative helpers ---------- */
.float      { animation: float 6s var(--ease-in-out) infinite; }
.float-slow { animation: float 9s var(--ease-in-out) infinite; }
.float-x    { animation: float-x 5s var(--ease-in-out) infinite; }

.blob {
  position: absolute;
  z-index: 0;
  width: 420px;
  height: 420px;
  border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%;
  filter: blur(60px);
  opacity: 0.5;
  animation: blob 18s var(--ease-in-out) infinite;
  pointer-events: none;
}

.blob--blue   { background: rgba(10, 108, 255, 0.45); }
.blob--teal   { background: rgba(0, 194, 168, 0.4); animation-delay: -6s; }
.blob--orange { background: rgba(255, 107, 53, 0.28); animation-delay: -12s; }

.animated-gradient {
  background: linear-gradient(120deg, var(--primary), var(--accent), #6c5ce7, var(--primary));
  background-size: 300% 300%;
  animation: gradient-shift 10s ease infinite;
}

/* ECG / heartbeat line: draws itself, then wipes away, on a loop.
   The <path> needs pathLength="100". */
.ecg-line path {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: ecg 3.2s linear 0.3s infinite;
}

@keyframes ecg {
  0%   { stroke-dashoffset: 100; }
  55%  { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: -100; }
}

/* Infinite marquee */
.marquee {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.marquee__track {
  display: flex;
  width: max-content;
  gap: var(--sp-6);
  animation: marquee 30s linear infinite;
}

.marquee:hover .marquee__track {
  animation-play-state: paused;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* Typing caret for animated placeholders */
.typing-caret::after {
  content: "|";
  margin-left: 2px;
  animation: caret-blink 1s step-end infinite;
}

/* 3D tilt (transform applied by JS) */
[data-tilt] {
  transform-style: preserve-3d;
  will-change: transform;
}

[data-tilt] .tilt-pop {
  transform: translateZ(30px);
}

/* Magnetic elements (transform applied by JS) */
[data-magnetic] {
  will-change: transform;
}

/* Flying cart dot */
.fly-dot {
  position: fixed;
  z-index: 500;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cta);
  box-shadow: var(--sh-glow-cta);
  pointer-events: none;
}

/* ---------- 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;
  }

  .ecg-line path {
    animation: none !important;
    stroke-dashoffset: 0;
  }

  .marquee__track {
    animation: none;
  }
}
