/* ==========================================================================
   Codehelix - Animations
   Apple-inspired scroll animations and micro-interactions
   ========================================================================== */

/* --------------------------------------------------------------------------
   Base Animation States
   Elements start hidden and are revealed via JavaScript
   -------------------------------------------------------------------------- */

/* Fade up animation - most common */
[data-animate="fade-up"] {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity var(--duration-slower) var(--ease-out),
    transform var(--duration-slower) var(--ease-out);
}

[data-animate="fade-up"].animated {
  opacity: 1;
  transform: translateY(0);
}

/* Fade in (no movement) */
[data-animate="fade"] {
  opacity: 0;
  transition: opacity var(--duration-slower) var(--ease-out);
}

[data-animate="fade"].animated {
  opacity: 1;
}

/* Scale up */
[data-animate="scale"] {
  opacity: 0;
  transform: scale(0.95);
  transition:
    opacity var(--duration-slower) var(--ease-out),
    transform var(--duration-slower) var(--ease-out);
}

[data-animate="scale"].animated {
  opacity: 1;
  transform: scale(1);
}

/* Slide from left */
[data-animate="slide-left"] {
  opacity: 0;
  transform: translateX(-40px);
  transition:
    opacity var(--duration-slower) var(--ease-out),
    transform var(--duration-slower) var(--ease-out);
}

[data-animate="slide-left"].animated {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right */
[data-animate="slide-right"] {
  opacity: 0;
  transform: translateX(40px);
  transition:
    opacity var(--duration-slower) var(--ease-out),
    transform var(--duration-slower) var(--ease-out);
}

[data-animate="slide-right"].animated {
  opacity: 1;
  transform: translateX(0);
}

/* --------------------------------------------------------------------------
   Stagger Delays
   Used for groups of items that animate sequentially
   -------------------------------------------------------------------------- */
[data-animate-delay="1"] { transition-delay: 0.1s; }
[data-animate-delay="2"] { transition-delay: 0.2s; }
[data-animate-delay="3"] { transition-delay: 0.3s; }
[data-animate-delay="4"] { transition-delay: 0.4s; }
[data-animate-delay="5"] { transition-delay: 0.5s; }
[data-animate-delay="6"] { transition-delay: 0.6s; }

/* Custom delays for fine control */
[data-animate-delay="50"] { transition-delay: 0.05s; }
[data-animate-delay="100"] { transition-delay: 0.1s; }
[data-animate-delay="150"] { transition-delay: 0.15s; }
[data-animate-delay="200"] { transition-delay: 0.2s; }
[data-animate-delay="250"] { transition-delay: 0.25s; }
[data-animate-delay="300"] { transition-delay: 0.3s; }

/* --------------------------------------------------------------------------
   Hero Specific Animations
   More dramatic entrance for hero content
   -------------------------------------------------------------------------- */
.hero [data-animate="fade-up"] {
  transform: translateY(50px);
}

.hero__headline[data-animate="fade-up"] {
  transition-duration: 1s;
}

.hero__subheadline[data-animate="fade-up"] {
  transition-delay: 0.2s;
}

.hero__cta[data-animate="fade-up"] {
  transition-delay: 0.4s;
}

/* --------------------------------------------------------------------------
   Line Reveal Animation
   Text or elements revealed with a line sweep
   -------------------------------------------------------------------------- */
[data-animate="line-reveal"] {
  position: relative;
  display: inline-block;
}

[data-animate="line-reveal"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-orange);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-slow) var(--ease-in-out);
}

[data-animate="line-reveal"].animated::after {
  animation: line-reveal 1s var(--ease-in-out) forwards;
}

@keyframes line-reveal {
  0% {
    transform: scaleX(0);
    transform-origin: left;
  }
  50% {
    transform: scaleX(1);
    transform-origin: left;
  }
  50.01% {
    transform-origin: right;
  }
  100% {
    transform: scaleX(0);
    transform-origin: right;
  }
}

/* --------------------------------------------------------------------------
   Count Up Animation
   For statistics/numbers
   -------------------------------------------------------------------------- */
[data-animate="count"] {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--duration-slow) var(--ease-out),
    transform var(--duration-slow) var(--ease-out);
}

[data-animate="count"].animated {
  opacity: 1;
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Image Reveal
   -------------------------------------------------------------------------- */
[data-animate="image-reveal"] {
  position: relative;
  overflow: hidden;
}

[data-animate="image-reveal"]::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-off-white);
  transform: translateX(0);
  z-index: 1;
  transition: transform var(--duration-slower) var(--ease-in-out);
}

[data-animate="image-reveal"].animated::before {
  transform: translateX(101%);
}

[data-animate="image-reveal"] img {
  transform: scale(1.1);
  transition: transform var(--duration-slower) var(--ease-out);
  transition-delay: 0.2s;
}

[data-animate="image-reveal"].animated img {
  transform: scale(1);
}

/* --------------------------------------------------------------------------
   Card Hover Enhancements
   -------------------------------------------------------------------------- */
.card {
  transition:
    transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

/* Card icon animation */
.card__icon {
  transition: transform var(--duration-normal) var(--ease-bounce);
}

.card:hover .card__icon {
  transform: scale(1.1);
}

/* --------------------------------------------------------------------------
   Button Hover Effects
   -------------------------------------------------------------------------- */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

/* --------------------------------------------------------------------------
   Link Underline Animation
   -------------------------------------------------------------------------- */
.link-underline::after {
  transition: width var(--duration-normal) var(--ease-out);
}

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

/* Underline from center */
.link-underline--center::after {
  left: 50%;
  transform: translateX(-50%);
}

/* --------------------------------------------------------------------------
   Image Hover Zoom
   -------------------------------------------------------------------------- */
.image-zoom {
  overflow: hidden;
  border-radius: var(--radius-md);
}

.image-zoom img {
  transition: transform var(--duration-slow) var(--ease-out);
}

.image-zoom:hover img {
  transform: scale(1.05);
}

/* --------------------------------------------------------------------------
   Pulse Animation (for scroll indicator, etc.)
   -------------------------------------------------------------------------- */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* --------------------------------------------------------------------------
   Float Animation (subtle up/down movement)
   -------------------------------------------------------------------------- */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.animate-float {
  animation: float 4s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Spin Animation
   -------------------------------------------------------------------------- */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

/* --------------------------------------------------------------------------
   Loading Spinner
   -------------------------------------------------------------------------- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --------------------------------------------------------------------------
   Page Transition (optional)
   -------------------------------------------------------------------------- */
.page-transition {
  opacity: 0;
  animation: page-fade-in 0.5s var(--ease-out) forwards;
}

@keyframes page-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   Parallax Elements
   Elements that move at different rates on scroll
   -------------------------------------------------------------------------- */
[data-parallax] {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* Parallax speed variations */
[data-parallax="slow"] {
  --parallax-speed: 0.03;
}

[data-parallax="medium"] {
  --parallax-speed: 0.06;
}

[data-parallax="fast"] {
  --parallax-speed: 0.1;
}

/* Parallax direction */
[data-parallax-direction="up"] {
  --parallax-direction: -1;
}

[data-parallax-direction="down"] {
  --parallax-direction: 1;
}

/* --------------------------------------------------------------------------
   More Dramatic Entrance Animations
   -------------------------------------------------------------------------- */

/* Slide up with more distance */
[data-animate="slide-up-lg"] {
  opacity: 0;
  transform: translateY(80px);
  transition:
    opacity 0.8s var(--ease-out),
    transform 0.8s var(--ease-out);
}

[data-animate="slide-up-lg"].animated {
  opacity: 1;
  transform: translateY(0);
}

/* Slide from left - larger */
[data-animate="slide-left-lg"] {
  opacity: 0;
  transform: translateX(-80px);
  transition:
    opacity 0.8s var(--ease-out),
    transform 0.8s var(--ease-out);
}

[data-animate="slide-left-lg"].animated {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right - larger */
[data-animate="slide-right-lg"] {
  opacity: 0;
  transform: translateX(80px);
  transition:
    opacity 0.8s var(--ease-out),
    transform 0.8s var(--ease-out);
}

[data-animate="slide-right-lg"].animated {
  opacity: 1;
  transform: translateX(0);
}

/* Scale up from smaller */
[data-animate="scale-up"] {
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

[data-animate="scale-up"].animated {
  opacity: 1;
  transform: scale(1);
}

/* Rotate and fade */
[data-animate="rotate-in"] {
  opacity: 0;
  transform: rotate(-5deg) translateY(30px);
  transition:
    opacity 0.7s var(--ease-out),
    transform 0.7s var(--ease-out);
}

[data-animate="rotate-in"].animated {
  opacity: 1;
  transform: rotate(0) translateY(0);
}

/* Clip reveal from bottom */
[data-animate="clip-up"] {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.8s var(--ease-out);
}

[data-animate="clip-up"].animated {
  clip-path: inset(0 0 0 0);
}

/* Blur in */
[data-animate="blur-in"] {
  opacity: 0;
  filter: blur(10px);
  transform: translateY(20px);
  transition:
    opacity 0.6s var(--ease-out),
    filter 0.6s var(--ease-out),
    transform 0.6s var(--ease-out);
}

[data-animate="blur-in"].animated {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Image Parallax Container
   -------------------------------------------------------------------------- */
.parallax-image-container {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg, 16px);
}

.parallax-image-container img,
.parallax-image-container .image-placeholder {
  transition: transform 0.1s linear;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   Floating Elements (decorative)
   -------------------------------------------------------------------------- */
.float-element {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}

@keyframes float-gentle {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-15px) rotate(2deg);
  }
  75% {
    transform: translateY(10px) rotate(-2deg);
  }
}

.float-element--slow {
  animation: float-gentle 8s ease-in-out infinite;
}

.float-element--medium {
  animation: float-gentle 6s ease-in-out infinite;
}

.float-element--fast {
  animation: float-gentle 4s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   Scroll Progress Indicator
   -------------------------------------------------------------------------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--color-orange, #f15534);
  width: 0%;
  z-index: 9999;
  transition: width 0.1s linear;
}

/* --------------------------------------------------------------------------
   Content Reveal on Scroll
   -------------------------------------------------------------------------- */
.reveal-content {
  position: relative;
}

.reveal-content::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--color-off-white, #f8f6f3);
  transform-origin: right;
  transition: transform 0.8s var(--ease-out);
}

.reveal-content.animated::after {
  transform: scaleX(0);
}

/* --------------------------------------------------------------------------
   Stagger Animations - More Options
   -------------------------------------------------------------------------- */
[data-animate-delay="7"] { transition-delay: 0.7s; }
[data-animate-delay="8"] { transition-delay: 0.8s; }
[data-animate-delay="9"] { transition-delay: 0.9s; }
[data-animate-delay="10"] { transition-delay: 1s; }

/* --------------------------------------------------------------------------
   Reduced Motion
   Respect user preferences for 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;
  }

  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
  }

  [data-animate="image-reveal"]::before {
    display: none;
  }

  [data-parallax] {
    transform: none !important;
  }

  .float-element {
    animation: none !important;
  }
}
