/* ==========================================================================
   AgentSetup.agency — Animations & Motion
   Fade-in, glows, typing effect, floating, stagger, transitions
   ========================================================================== */

@import './variables.css';

/* --------------------------------------------------------------------------
   FADE-IN ON SCROLL
   JS sets .is-visible when element enters viewport via IntersectionObserver.
   Default state = hidden/translated; .is-visible triggers the reveal.
   -------------------------------------------------------------------------- */

/* Base state for all scroll-reveal elements */
[data-animate] {
  opacity: 0;
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
  will-change: opacity, transform;
}

/* Fade up (default — most common) */
[data-animate],
[data-animate="fade-up"] {
  transform: translateY(28px);
}

/* Fade in (no movement) */
[data-animate="fade"] {
  transform: none;
}

/* Fade from left */
[data-animate="fade-right"] {
  transform: translateX(-32px);
}

/* Fade from right */
[data-animate="fade-left"] {
  transform: translateX(32px);
}

/* Fade in + scale up */
[data-animate="scale"] {
  transform: scale(0.92);
}

/* Visible state — animation plays */
[data-animate].is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger delays — add data-stagger="1" through "6" on sibling elements */
[data-stagger="1"] { transition-delay: 0ms; }
[data-stagger="2"] { transition-delay: 80ms; }
[data-stagger="3"] { transition-delay: 160ms; }
[data-stagger="4"] { transition-delay: 240ms; }
[data-stagger="5"] { transition-delay: 320ms; }
[data-stagger="6"] { transition-delay: 400ms; }
[data-stagger="7"] { transition-delay: 480ms; }
[data-stagger="8"] { transition-delay: 560ms; }

/* --------------------------------------------------------------------------
   STAGGER ANIMATION CLASSES (for grids/lists)
   Parent gets .stagger-children; direct children get staggered delays.
   -------------------------------------------------------------------------- */

.stagger-children > *:nth-child(1)  { animation-delay: 0ms; transition-delay: 0ms; }
.stagger-children > *:nth-child(2)  { animation-delay: 60ms; transition-delay: 60ms; }
.stagger-children > *:nth-child(3)  { animation-delay: 120ms; transition-delay: 120ms; }
.stagger-children > *:nth-child(4)  { animation-delay: 180ms; transition-delay: 180ms; }
.stagger-children > *:nth-child(5)  { animation-delay: 240ms; transition-delay: 240ms; }
.stagger-children > *:nth-child(6)  { animation-delay: 300ms; transition-delay: 300ms; }
.stagger-children > *:nth-child(7)  { animation-delay: 360ms; transition-delay: 360ms; }
.stagger-children > *:nth-child(8)  { animation-delay: 420ms; transition-delay: 420ms; }
.stagger-children > *:nth-child(n+9) { animation-delay: 480ms; transition-delay: 480ms; }

/* --------------------------------------------------------------------------
   KEYFRAME DEFINITIONS
   -------------------------------------------------------------------------- */

/* Fade up — for programmatic use */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Fade in + scale */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.90);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Slide down from above (for dropdowns, toasts) */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Slide up from below */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   FLOATING ANIMATION — gentle vertical oscillation
   -------------------------------------------------------------------------- */

@keyframes float {
  0%   { transform: translateY(0px) rotate(0deg); }
  33%  { transform: translateY(-10px) rotate(0.5deg); }
  66%  { transform: translateY(-5px) rotate(-0.5deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes floatSlow {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-14px); }
  100% { transform: translateY(0px); }
}

@keyframes floatSubtle {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-6px); }
  100% { transform: translateY(0px); }
}

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

.float-slow {
  animation: floatSlow 7s var(--ease-in-out) infinite;
}

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

/* Stagger float offsets for multiple elements */
.float-delay-1 { animation-delay: 0s; }
.float-delay-2 { animation-delay: 0.8s; }
.float-delay-3 { animation-delay: 1.6s; }
.float-delay-4 { animation-delay: 2.4s; }

/* --------------------------------------------------------------------------
   PULSE / GLOW CTA ANIMATION
   -------------------------------------------------------------------------- */

@keyframes glowPulse {
  0%, 100% {
    box-shadow:
      0 0 16px rgba(0, 212, 255, 0.30),
      0 4px 12px rgba(0, 0, 0, 0.40);
  }
  50% {
    box-shadow:
      0 0 32px rgba(0, 212, 255, 0.55),
      0 0 64px rgba(0, 212, 255, 0.18),
      0 4px 20px rgba(0, 0, 0, 0.50);
  }
}

@keyframes glowPulseSubtle {
  0%, 100% {
    box-shadow:
      0 0 12px rgba(0, 212, 255, 0.15),
      0 2px 8px rgba(0, 0, 0, 0.30);
  }
  50% {
    box-shadow:
      0 0 24px rgba(0, 212, 255, 0.30),
      0 2px 8px rgba(0, 0, 0, 0.30);
  }
}

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

.pulse-glow-subtle {
  animation: glowPulseSubtle 3s var(--ease-in-out) infinite;
}

/* Text version */
@keyframes textGlowPulse {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(0, 212, 255, 0.40),
      0 0 30px rgba(0, 212, 255, 0.15);
  }
  50% {
    text-shadow:
      0 0 20px rgba(0, 212, 255, 0.70),
      0 0 50px rgba(0, 212, 255, 0.25);
  }
}

.pulse-text-glow {
  animation: textGlowPulse 3s var(--ease-in-out) infinite;
}

/* --------------------------------------------------------------------------
   DOT / BEACON PING ANIMATION
   -------------------------------------------------------------------------- */

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

.ping {
  position: relative;
  display: inline-flex;
}

.ping::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
  animation: ping 1.5s var(--ease-out) infinite;
  opacity: 0.6;
}

/* --------------------------------------------------------------------------
   TYPING EFFECT
   Uses a CSS-only cursor blink + typed text relies on JS for character reveal,
   but the caret/cursor animation is pure CSS.
   -------------------------------------------------------------------------- */

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

.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--color-blue-glow);
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 1px;
  animation: caretBlink 1s step-end infinite;
  box-shadow: 0 0 6px var(--color-blue-glow);
}

/* Wrapper for typing container */
.typing-text {
  display: inline;
}

/* Underscore cursor variant */
.typing-cursor--underscore {
  width: 10px;
  height: 2px;
  vertical-align: baseline;
  margin-bottom: 2px;
}

/* --------------------------------------------------------------------------
   SHIMMER / SKELETON LOADING
   -------------------------------------------------------------------------- */

@keyframes shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.02) 0%,
    rgba(0, 212, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.02) 100%
  );
  background-size: 200% auto;
  animation: shimmer 2.5s linear infinite;
}

/* Skeleton loading blocks */
.skeleton {
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.00) 0%,
    rgba(255, 255, 255, 0.04) 50%,
    rgba(255, 255, 255, 0.00) 100%
  );
  background-size: 300% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   GRADIENT BORDER ANIMATION (rotating/moving gradient border)
   -------------------------------------------------------------------------- */

@keyframes gradientBorderRotate {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animated-border {
  position: relative;
  border-radius: var(--radius-xl);
}

.animated-border::before {
  content: '';
  position: absolute;
  inset: -1.5px;
  background: linear-gradient(
    270deg,
    var(--color-blue-glow),
    var(--color-cyan-400),
    var(--color-emerald-400),
    var(--color-blue-glow)
  );
  background-size: 400% 400%;
  border-radius: calc(var(--radius-xl) + 2px);
  animation: gradientBorderRotate 4s ease infinite;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.animated-border:hover::before,
.animated-border--active::before {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   MARQUEE / SCROLL TRACK (logo strips, tech stacks)
   -------------------------------------------------------------------------- */

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

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

.marquee-track {
  display: flex;
  animation: marquee 30s linear infinite;
  width: max-content;
}

.marquee-track--reverse {
  animation: marqueeReverse 30s linear infinite;
}

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

/* --------------------------------------------------------------------------
   PAGE TRANSITION (for SPA-style navigation or initial load)
   -------------------------------------------------------------------------- */

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-enter {
  animation: pageEnter var(--duration-slow) var(--ease-out) both;
}

/* --------------------------------------------------------------------------
   UTILITY ANIMATION CLASSES
   -------------------------------------------------------------------------- */

/* One-shot entrance animations (used on initial render, not scroll) */
.animate-fade-in {
  animation: fadeIn var(--duration-slow) var(--ease-out) both;
}

.animate-fade-up {
  animation: fadeUp var(--duration-slow) var(--ease-out) both;
}

.animate-scale-in {
  animation: scaleIn var(--duration-slow) var(--ease-spring) both;
}

.animate-slide-down {
  animation: slideDown var(--duration-normal) var(--ease-out) both;
}

.animate-slide-up {
  animation: slideUp var(--duration-normal) var(--ease-out) both;
}

/* Animation delay utilities */
.delay-0,   .animate-delay-0   { animation-delay: 0ms; }
.delay-100, .animate-delay-100 { animation-delay: 100ms; }
.delay-200, .animate-delay-200 { animation-delay: 200ms; }
.delay-300, .animate-delay-300 { animation-delay: 300ms; }
.delay-400, .animate-delay-400 { animation-delay: 400ms; }
.delay-500, .animate-delay-500 { animation-delay: 500ms; }
.delay-600, .animate-delay-600 { animation-delay: 600ms; }
.delay-700, .animate-delay-700 { animation-delay: 700ms; }
.delay-800, .animate-delay-800 { animation-delay: 800ms; }

/* Speed modifiers */
.duration-fast   { animation-duration: var(--duration-fast); }
.duration-normal { animation-duration: var(--duration-normal); }
.duration-slow   { animation-duration: var(--duration-slow); }
.duration-slower { animation-duration: var(--duration-slower); }

/* --------------------------------------------------------------------------
   HOVER TRANSITIONS — applied to any element
   -------------------------------------------------------------------------- */

.hover-lift {
  transition: transform var(--duration-normal) var(--ease-spring),
              box-shadow var(--duration-normal) var(--ease-out);
}

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

.hover-scale {
  transition: transform var(--duration-fast) var(--ease-spring);
}

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

.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

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

.hover-bright {
  transition: filter var(--duration-fast) var(--ease-out);
}

.hover-bright:hover {
  filter: brightness(1.15);
}

/* --------------------------------------------------------------------------
   SPIN — for loading icons
   -------------------------------------------------------------------------- */

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

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

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

/* --------------------------------------------------------------------------
   REDUCED MOTION — disable all animations
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  /* All keyframe animations */
  .float,
  .float-slow,
  .float-subtle,
  .pulse-glow,
  .pulse-glow-subtle,
  .pulse-text-glow,
  .shimmer,
  .spin,
  .spin-slow,
  .ping::before,
  .marquee-track,
  .marquee-track--reverse,
  .animate-fade-in,
  .animate-fade-up,
  .animate-scale-in,
  .animate-slide-down,
  .animate-slide-up,
  .page-enter {
    animation: none !important;
  }

  /* Scroll reveal — show immediately without motion */
  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  /* Typing cursor — keep blinking but no other motion */
  .typing-cursor {
    animation: caretBlink 1s step-end infinite;
  }

  /* Animated border — no animation but keep visible on hover */
  .animated-border::before {
    animation: none;
    background: var(--color-border-strong);
    background-size: auto;
  }

  /* Hover lifts — remove transform, keep shadow */
  .hover-lift:hover {
    transform: none;
  }

  .hover-scale:hover {
    transform: none;
  }
}
