/* SGR Enterprises - Animation System */

/* Preloader Animation */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-primary);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity var(--transition-slow) ease, visibility var(--transition-slow);
}

.preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader {
  width: 60px;
  height: 60px;
  border: 4px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

.loader-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

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

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
  }
  50% {
    box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.6);
  }
}

/* Micro Interactions */
.pulse-hover:hover {
  animation: pulse-glow 1.5s infinite;
}

.animate-fade-in {
  animation: fadeIn 1s ease forwards;
}

.animate-slide-up {
  animation: slideUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Native CSS Scroll-Driven Animations */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    
    @keyframes reveal-up {
      from {
        opacity: 0;
        transform: translateY(50px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
    
    @keyframes fade-scroll {
      from { opacity: 0.3; }
      to { opacity: 1; }
    }
    
    /* Scroll entry animation reveal class */
    .scroll-reveal {
      animation: reveal-up linear both;
      animation-timeline: view();
      animation-range: entry 10% cover 30%;
    }
    
    .scroll-fade {
      animation: fade-scroll linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 20%;
    }
    
    /* Parallax Background effect */
    @keyframes parallax-bg {
      from { transform: translateY(-50px); }
      to { transform: translateY(50px); }
    }
    
    .parallax-subject {
      animation: parallax-bg linear both;
      animation-timeline: view();
      animation-range: exit -20% enter 120%;
    }
  }
}

/* CSS Fallback classes used by IntersectionObserver script */
.reveal-visible {
  opacity: 1 !important;
  transform: translateY(0) !important;
  transition: opacity var(--transition-slow), transform var(--transition-slow);
}

.reveal-hidden {
  opacity: 0;
  transform: translateY(40px);
}
