/*
 * animations.css — Firmeza Design System
 *
 * Motion philosophy: animate with purpose.
 * – Micro-interactions: ≤120ms, feel instant
 * – State changes: 200–300ms, feel responsive
 * – Entrance animations: 500–700ms, feel deliberate
 * – Ambient/looping: slow and effortless
 */

/* ════════════════════════════════════════════════════════════════════
   KEYFRAMES
   ════════════════════════════════════════════════════════════════════ */

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

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

/* Fade + translate — primary scroll entrance */
/* Reveals combine opacity + translate + a whisper of blur/scale.
   Only compositor properties — no layout shift. */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(26px) scale(0.992); filter: blur(5px); }
  to   { opacity: 1; transform: translateY(0)    scale(1);     filter: blur(0);   }
}

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

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

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

/* Scale */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.955) translateY(12px); filter: blur(4px); }
  to   { opacity: 1; transform: scale(1)     translateY(0);    filter: blur(0);   }
}

@keyframes scaleOut {
  from { opacity: 1; transform: scale(1);    }
  to   { opacity: 0; transform: scale(0.92); }
}

/* Hero — large title staggered entrance */
@keyframes heroSlide {
  from { opacity: 0; transform: translateY(48px) skewY(1deg); }
  to   { opacity: 1; transform: translateY(0) skewY(0);       }
}

/* Reveal from bottom clip — word/line reveal */
@keyframes revealUp {
  from { transform: translateY(110%); }
  to   { transform: translateY(0);    }
}

/* Counter tick */
@keyframes countUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0);    }
}

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

@keyframes floatRotate {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%       { transform: translateY(-8px) rotate(4deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%       { opacity: 0.5; transform: scale(0.98); }
}

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

@keyframes ping {
  0%   { transform: scale(1);   opacity: 1;   }
  75%, 100% { transform: scale(1.8); opacity: 0; }
}

/* Shimmer — skeleton loading */
@keyframes shimmer {
  from { background-position: 200% center; }
  to   { background-position: -200% center; }
}

/* Gradient shift — ambient hero bg */
@keyframes gradientShift {
  0%   { background-position: 0% 50%;   }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%;   }
}

/* Marquee — horizontal logo strip */
@keyframes marqueeLTR {
  from { transform: translateX(0);    }
  to   { transform: translateX(-50%); }
}

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

/* Blink — cursor/caret */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Badge / status dot pulse */
@keyframes badgePulse {
  0%, 100% { transform: scale(1);    opacity: 1;   }
  50%       { transform: scale(1.18); opacity: 0.55; }
}

/* ════════════════════════════════════════════════════════════════════
   SCROLL ENTRANCE — base + triggered state
   ════════════════════════════════════════════════════════════════════ */

/*
 * Elements begin invisible. scroll.js's IntersectionObserver adds
 * the .entered class when they come into view.
 *
 * Usage:
 *   <div class="before-enter anim-fade-up">…</div>
 */

.before-enter {
  opacity:    0;
}

/* Default: fade up */
.before-enter.entered {
  animation: fadeUp var(--duration-slower) var(--ease-out) both;
}

/* Variant overrides */
.before-enter.anim-fade-up.entered    { animation: fadeUp    var(--duration-slower) var(--ease-out) both; }
.before-enter.anim-fade-down.entered  { animation: fadeDown  var(--duration-slower) var(--ease-out) both; }
.before-enter.anim-fade-left.entered  { animation: fadeLeft  var(--duration-slower) var(--ease-out) both; }
.before-enter.anim-fade-right.entered { animation: fadeRight var(--duration-slower) var(--ease-out) both; }
.before-enter.anim-scale-in.entered   { animation: scaleIn   var(--duration-slower) var(--ease-spring) both; }
.before-enter.anim-fade-only.entered  { animation: fadeIn    var(--duration-slower) var(--ease-out) both; }

/* Hero variant — more dramatic */
.before-enter.anim-hero.entered {
  animation: heroSlide var(--duration-slowest) var(--ease-out) both;
}

/* ════════════════════════════════════════════════════════════════════
   STAGGER DELAY HELPERS
   ════════════════════════════════════════════════════════════════════ */

.anim-delay-0   { animation-delay: 0ms;    }
.anim-delay-1   { animation-delay: 80ms;   }
.anim-delay-2   { animation-delay: 160ms;  }
.anim-delay-3   { animation-delay: 240ms;  }
.anim-delay-4   { animation-delay: 320ms;  }
.anim-delay-5   { animation-delay: 400ms;  }
.anim-delay-6   { animation-delay: 480ms;  }
.anim-delay-7   { animation-delay: 560ms;  }
.anim-delay-8   { animation-delay: 640ms;  }

/* ════════════════════════════════════════════════════════════════════
   LOOPING / AMBIENT ANIMATIONS
   ════════════════════════════════════════════════════════════════════ */

.anim-float {
  animation: float 4s var(--ease-in-out) infinite;
}

.anim-float-rotate {
  animation: floatRotate 6s var(--ease-in-out) infinite;
}

.anim-pulse {
  animation: pulse 2.5s var(--ease-in-out) infinite;
}

.anim-spin {
  animation: spin 1s linear infinite;
}

.anim-ping {
  animation: ping 1.5s var(--ease-out) infinite;
}

/* Skeleton loading state */
.anim-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-bg-muted) 25%,
    var(--color-zinc-100) 50%,
    var(--color-bg-muted) 75%
  );
  background-size: 400% auto;
  animation:      shimmer 1.8s linear infinite;
}

/* ════════════════════════════════════════════════════════════════════
   MARQUEE — Horizontal scrolling logo/tech strip
   ════════════════════════════════════════════════════════════════════ */

.marquee {
  overflow:   hidden;
  display:    flex;
  position:   relative;
  user-select: none;
}

/* Fade edges */
.marquee::before,
.marquee::after {
  content:    '';
  position:   absolute;
  top:        0;
  bottom:     0;
  width:      120px;
  z-index:    var(--z-raised);
  pointer-events: none;
}

.marquee::before {
  left:       0;
  background: linear-gradient(to right, var(--color-bg), transparent);
}

.marquee::after {
  right:      0;
  background: linear-gradient(to left, var(--color-bg), transparent);
}

.marquee__track {
  display:    flex;
  gap:        var(--space-12);
  animation:  marqueeLTR 30s linear infinite;
  white-space: nowrap;
  flex-shrink: 0;
}

.marquee--rtl .marquee__track {
  animation: marqueeRTL 30s linear infinite;
}

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

.marquee__item {
  display:     flex;
  align-items: center;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════════════
   TRANSITION UTILITIES
   ════════════════════════════════════════════════════════════════════ */

.transition-none     { transition: none; }
.transition-all      { transition: all             var(--duration-base) var(--ease-out); }
.transition-colors   { transition: color           var(--duration-fast) var(--ease-out),
                                   background-color var(--duration-fast) var(--ease-out),
                                   border-color     var(--duration-fast) var(--ease-out); }
.transition-opacity  { transition: opacity          var(--duration-base) var(--ease-out); }
.transition-transform{ transition: transform        var(--duration-base) var(--ease-out); }
.transition-shadow   { transition: box-shadow       var(--duration-base) var(--ease-out); }

/* ════════════════════════════════════════════════════════════════════
   HOVER INTERACTIONS
   ════════════════════════════════════════════════════════════════════ */

/* Lift on hover */
.hover-lift {
  transition: transform var(--duration-base) var(--ease-spring),
              box-shadow var(--duration-base) var(--ease-out);
}

.hover-lift:hover {
  transform:  var(--hover-lift);
  box-shadow: var(--shadow-lg);
}

/* Scale on hover */
.hover-scale {
  transition: transform var(--duration-base) var(--ease-spring);
}

.hover-scale:hover {
  transform: scale(1.03);
}

/* Text reveal underline */
.hover-underline {
  position:    relative;
  display:     inline-block;
}

.hover-underline::after {
  content:     '';
  position:    absolute;
  left:        0;
  bottom:      -1px;
  width:       0;
  height:      1px;
  background:  var(--color-brand-500);
  transition:  width var(--duration-base) var(--ease-out);
}

.hover-underline:hover::after {
  width: 100%;
}

/* Glow on hover */
.hover-glow {
  transition: box-shadow var(--duration-base) var(--ease-out);
}

.hover-glow:hover {
  box-shadow: var(--glow-brand-strong);
}

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

  /* Keep opacity transitions for screen-reader friendly show/hide */
  .overlay,
  .modal,
  .navbar__mobile-menu {
    transition: opacity 0.01ms !important;
  }

}


/* ════════════════════════════════════════════════════════════════════
   PREMIUM MOTION LAYER
   Additive only — no layout, colour, type, or spacing changes.
   Everything animates transform / opacity / filter (GPU-composited).
   ════════════════════════════════════════════════════════════════════ */

/* ── 1. Alternating reveal direction ──────────────────────────────────
   Sections alternate subtly so consecutive reveals never feel repetitive.
   Applied via a class, so no markup restructuring is needed.            */
.before-enter.anim-reveal-l.entered { animation: revealFromL var(--duration-slower) var(--ease-out) both; }
.before-enter.anim-reveal-r.entered { animation: revealFromR var(--duration-slower) var(--ease-out) both; }

@keyframes revealFromL {
  from { opacity: 0; transform: translate3d(-22px, 14px, 0) scale(0.994); filter: blur(5px); }
  to   { opacity: 1; transform: translate3d(0, 0, 0) scale(1);            filter: blur(0);   }
}
@keyframes revealFromR {
  from { opacity: 0; transform: translate3d(22px, 14px, 0) scale(0.994); filter: blur(5px); }
  to   { opacity: 1; transform: translate3d(0, 0, 0) scale(1);           filter: blur(0);   }
}

/* ── 2. Button micro-interactions: glow + click ripple ───────────────── */
.btn { position: relative; overflow: hidden; }

.btn--primary { transition: transform 260ms var(--ease-out), box-shadow 320ms ease, background-color 220ms ease; }
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(21, 67, 120, 0.32), 0 0 0 1px rgba(21, 67, 120, 0.10);
}
.btn--primary:active { transform: translateY(0) scale(0.985); }

.btn--secondary:hover,
.btn--outline:hover,
.btn--ghost:hover { transform: translateY(-1px); }
.btn--secondary:active,
.btn--outline:active,
.btn--ghost:active { transform: translateY(0) scale(0.985); }

/* Ripple element injected by js/motion.js */
.btn__ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: currentColor;
  opacity: 0.28;
  pointer-events: none;
  animation: btnRipple 620ms var(--ease-out) forwards;
}
@keyframes btnRipple {
  to { transform: scale(2.6); opacity: 0; }
}

/* ── 3. Hero mouse-following spotlight ───────────────────────────────── */
.hero__spotlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 500ms ease;
  background: radial-gradient(520px circle at var(--hx, 50%) var(--hy, 40%),
              rgba(61, 107, 160, 0.16), transparent 62%);
}
.hero.is-pointer .hero__spotlight { opacity: 1; }

/* ── 4. Image reveal — fade + micro-zoom as images enter view ─────────── */
img[data-reveal] {
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 800ms var(--ease-out), transform 900ms var(--ease-out);
  will-change: opacity, transform;
}
img[data-reveal].is-revealed {
  opacity: 1;
  transform: scale(1);
}

/* ── 5. Ambient noise texture (≈2.5%) ────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── 6. Process: staggered card entrance + settle glow ───────────────── */
.process__grid .process__stage-card.entered { animation-delay: calc(var(--i, 0) * 90ms); }
.process__stage-card {
  transition: box-shadow 500ms ease, border-color 500ms ease;
}
.process__stage-card.is-lit {
  box-shadow: 0 0 0 1px rgba(21, 67, 120, 0.16), 0 18px 44px rgba(21, 67, 120, 0.12);
}

/* ── 7. Footer / final CTA — one-time attention pulse ────────────────── */
.js-cta-pulse.is-pulsing { animation: ctaPulse 1400ms var(--ease-out) 1; }
@keyframes ctaPulse {
  0%   { box-shadow: 0 0 0 0 rgba(21, 67, 120, 0.45); }
  70%  { box-shadow: 0 0 0 16px rgba(21, 67, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(21, 67, 120, 0); }
}

/* ── 8. Page transitions — soft fade in & out ────────────────────────────
   NOTE: this class lives on <body>. It must NOT animate transform or filter:
   either one turns <body> into the containing block for position:fixed
   descendants, which breaks the fixed navbar (it would scroll away) and
   spawns a nested scroll container. Opacity only — safe for fixed children. */
.page-fade {
  animation: pageIn 460ms var(--ease-out) both;
}
@keyframes pageIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
body.is-leaving {
  opacity: 0;
  transition: opacity 320ms ease;
}

/* ── Interaction polish: trailing icon nudges on button hover ─────────────
   Subtle 3px slide of a button's icon on hover — the Linear/Vercel/Stripe
   "the arrow leans toward where it takes you" cue. GPU transform only, and
   only on hover-capable pointers so it never fires on touch taps. */
@media (hover: hover) {
  .btn > svg { transition: transform 220ms var(--ease-out); }
  .btn:not(.btn--icon):hover > svg { transform: translateX(3px); }
}

/* ── Reduced motion: disable the whole premium layer ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  .btn__ripple,
  .js-cta-pulse.is-pulsing,
  .page-fade { animation: none !important; }

  .hero__spotlight { display: none; }

  img[data-reveal] { opacity: 1; transform: none; transition: none; }

  .btn--primary:hover,
  .btn--secondary:hover,
  .btn--outline:hover,
  .btn--ghost:hover { transform: none; }

  .btn:not(.btn--icon):hover > svg { transform: none; }

  body.is-leaving { opacity: 1; filter: none; }
  body::after { display: none; }
}
