/* ==========================================================================
   QUICK ELITE — ANIMATIONS STYLESHEET
   Scroll reveals, hover effects, and ambient motion.
   ========================================================================== */

/* ---------- Scroll Reveal ----------
   Guarded behind html.js so content stays visible by default if
   JavaScript fails to load or run (progressive enhancement).
   Stagger delays for items inside a `.stagger` container are assigned
   inline by JS (see initScrollReveal) so any grid size stays covered
   without hand-written nth-child rules. */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.js .reveal--left { transform: translateX(-48px); }
.js .reveal--right { transform: translateX(48px); }
.js .reveal--scale { transform: translateY(16px) scale(0.94); }
.js .reveal--fade { transform: none; }

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Hero headline entrance ----------
   Self-contained CSS animation (not the IntersectionObserver-driven
   .reveal system) since the hero is always in the initial viewport on
   load — no scroll trigger needed, and it keeps working even if JS
   never runs. Each line clips its word and slides it up into place. */
@keyframes hero-word-in {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.hero__title-word {
  animation: hero-word-in 0.85s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero__title-line:nth-child(1) .hero__title-word { animation-delay: 0.1s; }
.hero__title-line:nth-child(2) .hero__title-word { animation-delay: 0.24s; }
.hero__title-line:nth-child(3) .hero__title-word { animation-delay: 0.38s; }

/* ---------- Ambient Motion ---------- */
@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes rotate-slow-reverse {
  from { transform: rotate(360deg); }
  to { transform: rotate(0deg); }
}

.globe-ring { transform-origin: 200px 200px; }
.hero__globe .globe-ring:nth-of-type(1) { animation: rotate-slow 22s linear infinite; }
.hero__globe .globe-outline--faint { animation: rotate-slow-reverse 40s linear infinite; transform-origin: 200px 200px; }

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.6); opacity: 0.5; }
}

.pulse-dot { animation: pulse-dot 2.6s ease-in-out infinite; }
.pulse-dot--2 { animation-delay: 0.6s; }
.pulse-dot--3 { animation-delay: 1.2s; }

@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.phone-mockup { animation: float-y 5s ease-in-out infinite; }

@keyframes line-flow {
  to { stroke-dashoffset: -24; }
}

.phone-line {
  stroke-dasharray: 4 4;
  animation: line-flow 1.6s linear infinite;
}

/* ---------- Page enter ---------- */
@keyframes page-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body { animation: page-fade-in 0.5s ease both; }

.contact-modal__success:not([hidden]) { animation: page-fade-in 0.4s ease both; }

/* ---------- Hero: grid pan ---------- */
@keyframes grid-pan {
  from { background-position: 0 0, 0 0; }
  to { background-position: 46px 46px, 46px 46px; }
}

.hero__grid { animation: grid-pan 14s linear infinite; }

/* ---------- Hero: GPS route lines + moving markers ---------- */
@keyframes route-flow {
  to { stroke-dashoffset: -240; }
}

.route-line--1 { animation: route-flow 9s linear infinite; }
.route-line--2 { animation: route-flow 11s linear infinite reverse; }

@keyframes route-travel-1 { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes route-travel-2 { from { offset-distance: 0%; } to { offset-distance: 100%; } }

.route-marker--1 {
  offset-path: path("M-40,380 C160,300 260,420 460,300 S 760,220 860,260");
  animation: route-travel-1 7s linear infinite;
}

.route-marker--2 {
  offset-path: path("M-40,120 C180,200 320,60 520,160 S 780,120 860,80");
  animation: route-travel-2 8.5s linear infinite 1.2s;
}

@keyframes route-marker-mini-travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }

.route-marker-mini {
  offset-path: path("M10 100 90 30 170 100");
  animation: route-marker-mini-travel 3.2s ease-in-out infinite alternate;
}

/* ---------- Hero: glowing pins + radar rings ---------- */
@keyframes radar-ping {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(3.2); opacity: 0; }
}

.geo-pin__ring { animation: radar-ping 3s ease-out infinite; }
.geo-pin__ring--2 { animation-delay: 1.5s; }

@keyframes geo-pin-glow {
  0%, 100% { box-shadow: 0 0 10px 3px rgba(91, 127, 255, 0.7); }
  50% { box-shadow: 0 0 16px 6px rgba(91, 127, 255, 0.9); }
}

.geo-pin__core { animation: geo-pin-glow 2.4s ease-in-out infinite; }

/* ---------- Hero: floating data particles ---------- */
@keyframes particle-float {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 0.8; }
  85% { opacity: 0.5; }
  100% { transform: translateY(-90px); opacity: 0; }
}

.particle { animation-name: particle-float; animation-timing-function: ease-in-out; animation-iteration-count: infinite; }

/* ---------- Hero: slow vertical scan sweep ---------- */
@keyframes scan-sweep {
  0% { top: -10%; }
  100% { top: 100%; }
}

.hero__scanline { animation: scan-sweep 10s linear infinite; }

/* ---------- ETS ecosystem flow: traveling connector pulse ---------- */
@keyframes flow-travel {
  0% { left: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

@keyframes flow-travel-vertical {
  0% { top: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.flow-connector__pulse { animation: flow-travel 2.2s linear infinite; }
.flow-connector:nth-of-type(3) .flow-connector__pulse { animation-delay: 0.6s; }
.flow-connector:nth-of-type(5) .flow-connector__pulse { animation-delay: 1.2s; }

.ets-flow:hover .flow-node__icon,
.flow-node:hover .flow-node__icon {
  transform: translateY(-3px);
  border-color: rgba(91, 127, 255, 0.4);
}

/* ---------- Software dashboard mock: bars + sparkline ---------- */
@keyframes bar-grow {
  0%, 100% { transform: scaleY(0.35); opacity: 0.7; }
  50% { transform: scaleY(1); opacity: 1; }
}

.dashboard-bars span { animation: bar-grow 2.4s ease-in-out infinite; }
.dashboard-bars span:nth-child(1) { animation-delay: 0s; }
.dashboard-bars span:nth-child(2) { animation-delay: 0.15s; }
.dashboard-bars span:nth-child(3) { animation-delay: 0.3s; }
.dashboard-bars span:nth-child(4) { animation-delay: 0.45s; }
.dashboard-bars span:nth-child(5) { animation-delay: 0.6s; }
.dashboard-bars span:nth-child(6) { animation-delay: 0.75s; }
.dashboard-bars span:nth-child(7) { animation-delay: 0.9s; }
.dashboard-bars span:nth-child(8) { animation-delay: 1.05s; }

@keyframes spark-draw {
  from { stroke-dashoffset: 900; }
  to { stroke-dashoffset: 0; }
}

.dashboard-spark__line {
  /* A dash longer than the path's own length keeps it one continuous
     stroke while the offset animates — no broken mid-line segments. */
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: spark-draw 3.5s ease-in-out infinite alternate;
}

.status-chip__dot { animation: pulse-dot 2.2s ease-in-out infinite; }
.status-chip--alert .status-chip__dot { animation-duration: 1.5s; animation-delay: 0.4s; }

/* ---------- Partner badge: slow-rotating dashed ring ---------- */
.partner__badge-ring { animation: rotate-slow 30s linear infinite; }

/* ---------- Solutions: live map data points appearing/disappearing ---------- */
@keyframes data-point-blink {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

.map-dot { animation: data-point-blink 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.map-dot:nth-of-type(1) { animation-delay: 0s; }
.map-dot:nth-of-type(2) { animation-delay: 0.5s; }
.map-dot:nth-of-type(3) { animation-delay: 1s; }
.map-dot:nth-of-type(4) { animation-delay: 1.5s; }

.line-dot { animation: pulse-dot 2.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

/* ---------- Solutions: waste collection route + tracked bin ---------- */
.waste-marker {
  offset-path: path("M35 80 Q70 40 95 65 T145 35");
  animation: route-marker-mini-travel 3.4s ease-in-out infinite alternate;
}

.waste-dot { animation: data-point-blink 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

.tracker-ping { transform-box: fill-box; transform-origin: center; animation: radar-ping 2.6s ease-out infinite; }

/* ---------- Solutions: employee workforce network + live location ---------- */
.emp-status { animation: data-point-blink 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

.emp-pin-ring { transform-box: fill-box; transform-origin: center; animation: radar-ping 3s ease-out infinite; }

/* ---------- Card Hover Effects ---------- */
.tech-card, .hardware-mini, .solution-card, .software-card,
.quality-card, .why-card, .client-chip, .service-pill, .hardware-card {
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base), border-color var(--transition-base), background var(--transition-base), box-shadow var(--transition-base);
}

/* Diagonal light sweep on hover */
.tech-card::after, .hardware-mini::after, .solution-card::after, .software-card::after,
.quality-card::after, .why-card::after, .client-chip::after, .service-pill::after, .hardware-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(91, 127, 255, 0.14), transparent);
  transform: skewX(-20deg);
  transition: left 0.7s ease;
  pointer-events: none;
}

.tech-card:hover::after, .hardware-mini:hover::after, .solution-card:hover::after, .software-card:hover::after,
.quality-card:hover::after, .why-card:hover::after, .client-chip:hover::after, .service-pill:hover::after,
.hardware-card:hover::after {
  left: 120%;
}

.tech-card:hover, .hardware-mini:hover, .solution-card:hover,
.software-card:hover, .quality-card:hover, .why-card:hover,
.client-chip:hover, .service-pill:hover {
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(91, 127, 255, 0.22), 0 0 26px -6px rgba(47, 91, 255, 0.45);
}

/* Icon micro-interaction on card hover */
.tech-card__icon, .hardware-mini__icon, .software-card__icon, .why-feature__icon, .flow-node__icon {
  transition: transform var(--transition-base);
}

.tech-card:hover .tech-card__icon,
.hardware-mini:hover .hardware-mini__icon,
.software-card:hover .software-card__icon,
.why-feature:hover .why-feature__icon {
  transform: scale(1.12) rotate(-4deg);
}

/* Visual/illustration zoom on hover */
.device-svg, .mini-illustration { transition: transform 0.5s ease; }
.hardware-card:hover .device-svg { transform: scale(1.04); }
.solution-card:hover .mini-illustration { transform: scale(1.05); }

.btn { will-change: transform; }

/* Nav scroll shadow transition already covered in style.css; add smoothing */
.navbar { will-change: background; }

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * , *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .reveal, .reveal--left, .reveal--right, .reveal--scale, .reveal--fade {
    opacity: 1;
    transform: none;
  }

  .hero__title-word { opacity: 1; transform: none; }

  /* Purely decorative live-motion layers are hidden outright rather than
     left to freeze mid-frame. */
  .hero__scanline,
  .particle,
  .route-marker,
  .route-marker--1,
  .route-marker--2,
  .route-marker-mini,
  .geo-pin__ring,
  .flow-connector__pulse {
    display: none;
  }

  .hero__grid,
  .route-line--1,
  .route-line--2,
  .globe-ring,
  .globe-outline--faint,
  .partner__badge-ring {
    animation: none;
  }
}
