/* ============================================================
   Star One Roofing — Animations
   All keyframes, animation classes, and GSAP-compatible utilities
   ============================================================ */

/* ==========================================================
   KEYFRAMES
   ========================================================== */

/* Float (Hero scroll indicator, decorative elements) */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

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

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Down */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Subtle Zoom (Hero background) */
@keyframes subtleZoom {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* Gradient Shift */
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Shine Sweep (Button reflection) */
@keyframes shineSweep {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Checkmark Draw (Form success) */
@keyframes checkmarkDraw {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Circle Scale (Form success) */
@keyframes circleScale {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Counter Tick */
@keyframes counterTick {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Slide In from Bottom (mobile menu links) */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Border Glow Pulse */
@keyframes borderGlow {
  0%, 100% { border-color: var(--clr-border); }
  50% { border-color: rgba(14, 165, 255, 0.5); }
}

/* Dot Pulse (loading states) */
@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Morph Circle to Rounded Square (back-to-top) */
@keyframes morphShape {
  0% { border-radius: 50%; }
  50% { border-radius: var(--radius-md); }
  100% { border-radius: 50%; }
}

/* Progress Bar Animation */
@keyframes progressFill {
  from { width: 0%; }
  to { width: var(--progress-width, 100%); }
}

/* Text Reveal (clip) */
@keyframes textReveal {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

/* Particle Float */
@keyframes particleFloat1 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translate(100px, -400px) scale(0.3); opacity: 0; }
}

@keyframes particleFloat2 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translate(-80px, -350px) scale(0.5); opacity: 0; }
}

@keyframes particleFloat3 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 0.5; }
  90% { opacity: 0.5; }
  100% { transform: translate(60px, -300px) scale(0.2); opacity: 0; }
}

/* ==========================================================
   GSAP-COMPATIBLE ANIMATION CLASSES
   Initial states for elements that GSAP will animate.
   These define the "from" state; GSAP animates to the natural state.
   ========================================================== */

/* Reveal: Visible by default so pages are never blank and elements never disappear */
[data-animate],
[data-animate-stagger] > * {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Initial hidden state only when JS animation controller is active */
html.js-animate [data-animate]:not(.is-animated) {
  opacity: 0;
}

html.js-animate [data-animate="fade-up"]:not(.is-animated) {
  transform: translateY(30px);
}

html.js-animate [data-animate="fade-down"]:not(.is-animated) {
  transform: translateY(-30px);
}

html.js-animate [data-animate="fade-left"]:not(.is-animated) {
  transform: translateX(-30px);
}

html.js-animate [data-animate="fade-right"]:not(.is-animated) {
  transform: translateX(30px);
}

html.js-animate [data-animate="scale-in"]:not(.is-animated) {
  transform: scale(0.94);
}

html.js-animate [data-animate="zoom-in"]:not(.is-animated) {
  transform: scale(0.88);
}

html.js-animate [data-animate-stagger]:not(.is-animated) > * {
  opacity: 0;
  transform: translateY(25px);
}

/* Once animated, permanently force visible */
.is-animated,
[data-animate].is-animated,
[data-animate-stagger].is-animated > * {
  opacity: 1 !important;
  transform: none !important;
}

/* Split text characters/words (initial state for GSAP SplitText) */
.split-text .char,
.split-text .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%);
}

/* ==========================================================
   CSS-ONLY ANIMATION CLASSES (Non-GSAP fallbacks)
   ========================================================== */

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

.animate-fade-in {
  animation: fadeIn 0.6s var(--ease-out-expo) forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 0.6s var(--ease-out-expo) forwards;
}

.animate-fade-in-down {
  animation: fadeInDown 0.6s var(--ease-out-expo) forwards;
}

.animate-fade-in-left {
  animation: fadeInLeft 0.6s var(--ease-out-expo) forwards;
}

.animate-fade-in-right {
  animation: fadeInRight 0.6s var(--ease-out-expo) forwards;
}

.animate-scale-in {
  animation: scaleIn 0.6s var(--ease-out-expo) forwards;
}

.animate-subtle-zoom {
  animation: subtleZoom 20s ease-in-out infinite alternate;
}

.animate-gradient {
  background-size: 200% auto;
  animation: gradientShift 6s ease-in-out infinite;
}

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

/* Stagger Delays (for CSS-only staggered animations) */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }
.animate-delay-6 { animation-delay: 0.6s; }
.animate-delay-7 { animation-delay: 0.7s; }
.animate-delay-8 { animation-delay: 0.8s; }

/* ==========================================================
   HERO PARTICLES (CSS-based)
   Lightweight floating particles for hero section
   ========================================================== */

.hero-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(245, 247, 250, 0.4);
  border-radius: 50%;
  pointer-events: none;
}

.hero-particle:nth-child(1) {
  left: 10%;
  bottom: 20%;
  animation: particleFloat1 8s linear infinite;
}

.hero-particle:nth-child(2) {
  left: 25%;
  bottom: 10%;
  animation: particleFloat2 10s linear infinite 1s;
}

.hero-particle:nth-child(3) {
  left: 40%;
  bottom: 15%;
  animation: particleFloat3 9s linear infinite 2s;
}

.hero-particle:nth-child(4) {
  left: 55%;
  bottom: 25%;
  animation: particleFloat1 11s linear infinite 3s;
}

.hero-particle:nth-child(5) {
  left: 70%;
  bottom: 10%;
  animation: particleFloat2 8.5s linear infinite 1.5s;
}

.hero-particle:nth-child(6) {
  left: 85%;
  bottom: 20%;
  animation: particleFloat3 10.5s linear infinite 0.5s;
}

.hero-particle:nth-child(7) {
  left: 15%;
  bottom: 30%;
  animation: particleFloat1 9.5s linear infinite 2.5s;
}

.hero-particle:nth-child(8) {
  left: 60%;
  bottom: 5%;
  animation: particleFloat2 12s linear infinite 4s;
}

.hero-particle:nth-child(9) {
  left: 35%;
  bottom: 35%;
  animation: particleFloat3 7.5s linear infinite 0.8s;
}

.hero-particle:nth-child(10) {
  left: 78%;
  bottom: 30%;
  animation: particleFloat1 10s linear infinite 3.5s;
}

/* Particle size variations */
.hero-particle:nth-child(odd) {
  width: 2px;
  height: 2px;
  opacity: 0.5;
}

.hero-particle:nth-child(3n) {
  width: 4px;
  height: 4px;
  opacity: 0.3;
  background: rgba(25, 200, 255, 0.4);
}

/* ==========================================================
   SCROLL PROGRESS ANIMATION
   ========================================================== */

.scroll-progress {
  transform-origin: left;
  will-change: width;
}

/* ==========================================================
   CARD HOVER EFFECTS
   ========================================================== */

/* Cursor-follow glow (positioned by JS) */
.card-glow {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 165, 255, 0.18) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 0;
  transform: translate(-50%, -50%);
}

.service-card:hover .card-glow,
.why-card:hover .card-glow {
  opacity: 1;
}

/* ==========================================================
   BUTTON MAGNETIC EFFECT (Positioned by JS)
   ========================================================== */

.btn-magnetic {
  transition: transform 0.3s var(--ease-out-expo);
  will-change: transform;
}

/* ==========================================================
   IMAGE TILT EFFECT
   ========================================================== */

.tilt-effect {
  transition: transform 0.4s var(--ease-out-expo);
  will-change: transform;
  transform-style: preserve-3d;
  perspective: 1000px;
}

/* ==========================================================
   PAGE TRANSITION OVERLAY
   ========================================================== */

.page-transition {
  position: fixed;
  inset: 0;
  background: var(--clr-bg-primary);
  z-index: var(--z-max);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.page-transition.is-active {
  opacity: 1;
  pointer-events: all;
}

/* ==========================================================
   LOADING DOTS
   ========================================================== */

.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--clr-accent);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* ==========================================================
   SUCCESS CHECKMARK ANIMATION
   ========================================================== */

.success-checkmark {
  animation: circleScale 0.6s var(--ease-out-expo) forwards;
}

.success-checkmark svg circle {
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  animation: checkmarkDraw 0.6s ease 0.3s forwards;
}

.success-checkmark svg polyline {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmarkDraw 0.4s ease 0.7s forwards;
}

/* ==========================================================
   LINE REVEAL (Decorative)
   ========================================================== */

.line-reveal {
  position: relative;
  overflow: hidden;
}

.line-reveal::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--clr-accent);
  transform: translateX(-100%);
  transition: transform 0.6s var(--ease-out-expo);
}

.line-reveal:hover::after,
.line-reveal.is-revealed::after {
  transform: translateX(0);
}

/* ==========================================================
   COUNTER ANIMATION CLASS
   ========================================================== */

.count-up {
  display: inline-block;
  transition: transform 0.3s ease;
}

.count-up.is-counting {
  animation: counterTick 0.3s ease forwards;
}

/* ==========================================================
   REDUCED MOTION SUPPORT
   Disable all animations for users who prefer 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],
  [data-animate-stagger] > * {
    opacity: 1 !important;
    transform: none !important;
  }

  .split-text .char,
  .split-text .word {
    opacity: 1;
    transform: none;
  }

  .hero-particle {
    display: none;
  }

  .hero__background img,
  .hero__background video {
    animation: none !important;
  }

  .animate-subtle-zoom {
    animation: none !important;
  }

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

  .emergency__phone {
    animation: none !important;
  }

  .emergency__badge .pulse-dot::before {
    animation: none !important;
  }

  .scroll-progress {
    display: none;
  }

  .btn--primary::before {
    display: none;
  }

  .gallery-item img {
    transition: none !important;
  }

  .gallery-item:hover img {
    transform: none;
  }

  .service-card:hover,
  .why-card:hover {
    transform: none;
  }

  .back-to-top:hover {
    transform: none;
  }

  .page-transition {
    display: none;
  }
}
