/* ==========================================================================
   animations.css — keyframes, scroll-reveal states, micro-interactions
   ========================================================================== */

/* --------------------------------------------------------------
   1. Keyframes
   -------------------------------------------------------------- */
@keyframes fade-in      { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up     { from { opacity: 0; transform: translateY(38px); } to { opacity: 1; transform: none; } }
@keyframes slide-down   { from { opacity: 0; transform: translateY(-38px); } to { opacity: 1; transform: none; } }
@keyframes slide-left   { from { opacity: 0; transform: translateX(52px); }  to { opacity: 1; transform: none; } }
@keyframes slide-right  { from { opacity: 0; transform: translateX(-52px); } to { opacity: 1; transform: none; } }
@keyframes zoom-in      { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }

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

@keyframes pulse-ring {
  0%   { transform: scale(1);   opacity: .8; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes scroll-dot {
  0%   { transform: translate(-50%, 0);    opacity: 1; }
  70%  { transform: translate(-50%, 14px); opacity: 0; }
  100% { transform: translate(-50%, 0);    opacity: 0; }
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

@keyframes loader-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@keyframes ripple-out {
  to { transform: scale(2.6); opacity: 0; }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* --------------------------------------------------------------
   2. Page-load entrance (hero elements)
   -------------------------------------------------------------- */
.animate-in {
  opacity: 0;
  animation: slide-up .9s var(--ease-out) forwards;
}
.animate-in.d-1 { animation-delay: .12s; }
.animate-in.d-2 { animation-delay: .24s; }
.animate-in.d-3 { animation-delay: .36s; }
.animate-in.d-4 { animation-delay: .48s; }
.animate-in.d-5 { animation-delay: .60s; }

/* Fade the whole page in after preload (smooth page transition) */
body.is-loaded main,
body.is-loaded .header { animation: fade-in .5s var(--ease) both; }

/* --------------------------------------------------------------
   3. Scroll-reveal — driven by IntersectionObserver in animations.js
   -------------------------------------------------------------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(38px);
  transition:
    opacity .8s var(--ease-out),
    transform .8s var(--ease-out);
  will-change: opacity, transform;
}
[data-reveal="left"]  { transform: translateX(-52px); }
[data-reveal="right"] { transform: translateX(52px); }
[data-reveal="zoom"]  { transform: scale(.9); }
[data-reveal="down"]  { transform: translateY(-38px); }
[data-reveal="fade"]  { transform: none; }

[data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* Stagger children of a revealed container */
[data-stagger] > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .7s var(--ease-out), transform .7s var(--ease-out);
}
[data-stagger].is-revealed > * { opacity: 1; transform: none; }
[data-stagger].is-revealed > *:nth-child(1) { transition-delay: .05s; }
[data-stagger].is-revealed > *:nth-child(2) { transition-delay: .14s; }
[data-stagger].is-revealed > *:nth-child(3) { transition-delay: .23s; }
[data-stagger].is-revealed > *:nth-child(4) { transition-delay: .32s; }
[data-stagger].is-revealed > *:nth-child(5) { transition-delay: .41s; }
[data-stagger].is-revealed > *:nth-child(6) { transition-delay: .50s; }
[data-stagger].is-revealed > *:nth-child(7) { transition-delay: .59s; }
[data-stagger].is-revealed > *:nth-child(8) { transition-delay: .68s; }

/* Timeline items alternate direction before reveal */
.tl-item { opacity: 0; transform: translateX(-46px); transition: opacity .8s var(--ease-out), transform .8s var(--ease-out); }
.tl-item:nth-child(even) { transform: translateX(46px); }
.tl-item.is-revealed { opacity: 1; transform: none; }

/* --------------------------------------------------------------
   4. Hover / interaction utilities
   -------------------------------------------------------------- */
.hover-lift { transition: transform .4s var(--ease), box-shadow .4s var(--ease); }
.hover-lift:hover { transform: translateY(-8px); box-shadow: var(--shadow-lg); }

.hover-glow { transition: box-shadow .4s var(--ease), transform .4s var(--ease); }
.hover-glow:hover { box-shadow: var(--shadow-glow); transform: translateY(-4px); }

.floating { animation: float 5.5s ease-in-out infinite; }
.floating--slow { animation-duration: 8s; }
.floating--delay { animation-delay: -2.5s; }

.spin-slow { animation: spin 22s linear infinite; }

/* Submit button busy state */
.btn.is-busy { pointer-events: none; opacity: .8; }
.btn.is-busy::after {
  content: ""; width: 16px; height: 16px; margin-left: 4px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Invalid field nudge */
.field.has-error input,
.field.has-error select,
.field.has-error textarea { animation: shake .4s var(--ease); }

/* Section entry for counters that already ran */
.stat__num.is-counting { color: var(--blue-600); }

/* --------------------------------------------------------------
   5. Reduced motion — respect user preference
   -------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal],
  [data-stagger] > *,
  .tl-item,
  .animate-in { opacity: 1 !important; transform: none !important; }
}
