/* ============================================================
   animations.css — Handwerker Mockup Webseite
   Animationen: Funken-Canvas, Sägespäne, Hover-Effekte,
   Scroll-Transitions, Loading-Animationen
   ============================================================ */

/* ==================== Sägespäne (Sägeholzpartikel) ==================== */
.sawdust-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.sawdust-particle {
  position: absolute;
  width: 8px;
  height: 2px;
  background: var(--color-accent-light, #E8B96D);
  border-radius: 1px;
  opacity: 0;
  animation: sawdust-fall linear forwards;
}

@keyframes sawdust-fall {
  0% {
    opacity: 0;
    transform: translateY(-10px) rotate(0deg) scale(0.5);
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.3);
  }
}

/* ==================== Funken-Canvas Styles ==================== */
#sparks-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* ==================== Scroll-Triggered Section Animations ==================== */
.section {
  opacity: 1;
}

.section.animate-on-scroll {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.section.animate-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger-Animation für Service-Karten */
.services-grid .service-card {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.services-grid.in-view .service-card {
  opacity: 1;
  transform: translateY(0);
}

.services-grid.in-view .service-card:nth-child(1) { transition-delay: 0ms; }
.services-grid.in-view .service-card:nth-child(2) { transition-delay: 100ms; }
.services-grid.in-view .service-card:nth-child(3) { transition-delay: 200ms; }
.services-grid.in-view .service-card:nth-child(4) { transition-delay: 300ms; }
.services-grid.in-view .service-card:nth-child(5) { transition-delay: 400ms; }
.services-grid.in-view .service-card:nth-child(6) { transition-delay: 500ms; }

/* Stagger-Animation für Galerie-Items */
.gallery-grid .gallery-item {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.gallery-grid.in-view .gallery-item {
  opacity: 1;
  transform: scale(1);
}

.gallery-grid.in-view .gallery-item:nth-child(1) { transition-delay: 0ms; }
.gallery-grid.in-view .gallery-item:nth-child(2) { transition-delay: 150ms; }
.gallery-grid.in-view .gallery-item:nth-child(3) { transition-delay: 300ms; }

/* Stagger für Testimonials */
.testimonials-slider .testimonial-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.testimonials-slider.in-view .testimonial-card {
  opacity: 1;
  transform: translateY(0);
}

.testimonials-slider.in-view .testimonial-card:nth-child(1) { transition-delay: 0ms; }
.testimonials-slider.in-view .testimonial-card:nth-child(2) { transition-delay: 150ms; }
.testimonials-slider.in-view .testimonial-card:nth-child(3) { transition-delay: 300ms; }

/* ==================== Hover-Effekte Service-Karten ==================== */
.service-card {
  position: relative;
  overflow: hidden;
}

.service-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-normal);
}

.service-card:hover::after {
  transform: scaleX(1);
}

.service-card:hover .service-icon {
  animation: icon-pulse 0.6s ease;
}

@keyframes icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ==================== Gallery Hover-Effekte ==================== */
.gallery-item {
  transition: transform var(--transition-normal);
}

.gallery-item:hover {
  transform: scale(1.02);
}

.gallery-overlay {
  transition: opacity var(--transition-normal);
}

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

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

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

/* ==================== Navigation Hover-Unterstrich ==================== */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-accent);
  transition: width var(--transition-normal), left var(--transition-normal);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 60%;
  left: 20%;
}

.nav-link--cta::after {
  display: none;
}

/* ==================== Link Hover-Effekte ==================== */
a[href^="#"] {
  position: relative;
}

/* ==================== Hero-Text Animation ==================== */
.hero-title,
.hero-subtitle,
.btn--hero {
  opacity: 0;
  transform: translateY(30px);
  animation: hero-fade-up 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero-title { animation-delay: 0.2s; }
.hero-subtitle { animation-delay: 0.4s; }
.btn--hero { animation-delay: 0.6s; }

@keyframes hero-fade-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== Messwerkzeug Loading-Animation ==================== */
.tape-measure-loader {
  width: 200px;
  height: 60px;
  position: relative;
}

.tape-measure-loader .tape-body {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 30px;
  background: var(--color-accent);
  border-radius: 6px;
}

.tape-measure-loader .tape-body::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--color-white);
  border-radius: 50%;
}

.tape-measure-loader .tape-ribbon {
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  width: 0;
  background: repeating-linear-gradient(
    90deg,
    var(--color-accent) 0px,
    var(--color-accent) 4px,
    var(--color-bg-light) 4px,
    var(--color-bg-light) 8px
  );
  animation: tape-extend 2s ease-in-out infinite;
  border-radius: 0 2px 2px 0;
}

@keyframes tape-extend {
  0%, 100% { width: 0; }
  50% { width: 140px; }
}

/* ==================== Stat-Counter Animation ==================== */
.stat-number {
  display: inline-block;
  transition: transform var(--transition-normal);
}

.stat-number.animate {
  animation: count-pop 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes count-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ==================== Focus-Effekte (Accessibility) ==================== */
*:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

  .sawdust-particle {
    display: none;
  }
}
