/* ==========================================================================
   TRITECH COMPUTERS & ENGINEERS — ANIMATIONS
   All motion is GPU-friendly (transform / opacity only) to hold 60 FPS.
   --------------------------------------------------------------------------
   01. Keyframes
   02. Scroll Reveal
   03. Stagger Helpers
   04. Page Transition
   05. Floating Shapes & Ambient Motion
   06. Ripple Effect
   07. Marquee
   08. Micro-interactions
   09. Reduced Motion
   ========================================================================== */

/* ==========================================================================
   01. KEYFRAMES
   ========================================================================== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translate3d(0, 34px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translate3d(0, -28px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeLeft {
  from {
    opacity: 0;
    transform: translate3d(-42px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeRight {
  from {
    opacity: 0;
    transform: translate3d(42px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes zoomIn {
  from {
    opacity: 0;
    transform: scale3d(0.92, 0.92, 1);
  }
  to {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

@keyframes floatY {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -18px, 0);
  }
}

@keyframes floatSoft {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  33% {
    transform: translate3d(14px, -20px, 0) rotate(1.5deg);
  }
  66% {
    transform: translate3d(-12px, 12px, 0) rotate(-1.5deg);
  }
}

@keyframes blobDrift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  33% {
    transform: translate3d(60px, -40px, 0) scale(1.08);
  }
  66% {
    transform: translate3d(-40px, 40px, 0) scale(0.95);
  }
}

@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55);
  }
  70% {
    box-shadow: 0 0 0 9px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

@keyframes loaderPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.9);
    opacity: 0.65;
  }
}

@keyframes scrollLine {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes marqueeScroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes rippleOut {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes shimmer {
  0% {
    background-position: -420px 0;
  }
  100% {
    background-position: 420px 0;
  }
}

@keyframes spinSlow {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   02. SCROLL REVEAL
   Elements start hidden; IntersectionObserver adds .is-revealed.
   ========================================================================== */
[data-reveal] {
  opacity: 0;
  will-change: opacity, transform;
}

[data-reveal].is-revealed {
  animation-duration: 0.85s;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  animation-fill-mode: both;
}

[data-reveal="up"].is-revealed {
  animation-name: fadeUp;
}
[data-reveal="down"].is-revealed {
  animation-name: fadeDown;
}
[data-reveal="left"].is-revealed {
  animation-name: fadeLeft;
}
[data-reveal="right"].is-revealed {
  animation-name: fadeRight;
}
[data-reveal="zoom"].is-revealed {
  animation-name: zoomIn;
}
[data-reveal="fade"].is-revealed {
  animation-name: zoomIn;
  animation-duration: 1s;
}

/* Once revealed, drop the will-change hint so the compositor can free memory */
[data-reveal].is-revealed {
  will-change: auto;
}

/* ==========================================================================
   03. STAGGER HELPERS
   Applied by JS on children of [data-stagger] as inline delays; these
   classes cover static markup that needs a fixed cascade.
   ========================================================================== */
.d-1 {
  animation-delay: 0.08s;
}
.d-2 {
  animation-delay: 0.16s;
}
.d-3 {
  animation-delay: 0.24s;
}
.d-4 {
  animation-delay: 0.32s;
}
.d-5 {
  animation-delay: 0.4s;
}
.d-6 {
  animation-delay: 0.48s;
}

/* ==========================================================================
   04. PAGE TRANSITION
   A wipe panel that covers the viewport during navigation.
   ========================================================================== */
.page-fx {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: none;
  background: var(--primary);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.5s cubic-bezier(0.76, 0, 0.24, 1);
}

/* Leaving the page: panel grows up from the bottom */
.page-fx.is-leaving {
  transform: scaleY(1);
  transform-origin: bottom;
}

/* Arriving: panel starts full and retracts upward */
.page-fx.is-entering {
  transform: scaleY(1);
  transform-origin: top;
}

.page-fx.is-entering.is-done {
  transform: scaleY(0);
  transform-origin: top;
}

/* Content fade-in on first paint */
.page-enter {
  animation: fadeUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ==========================================================================
   05. FLOATING SHAPES & AMBIENT MOTION
   ========================================================================== */
.blob--1 {
  animation: blobDrift 22s ease-in-out infinite;
}

.blob--2 {
  animation: blobDrift 26s ease-in-out infinite reverse;
}

.blob--3 {
  animation: blobDrift 30s ease-in-out infinite;
  animation-delay: -8s;
}

/* Hero glass panels drift gently and respond to parallax via JS */
.hero-panel--stat {
  animation: floatY 6s ease-in-out infinite;
}

.hero-panel--alert {
  animation: floatY 7.5s ease-in-out infinite;
  animation-delay: -2s;
}

.float-card {
  animation: floatY 8s ease-in-out infinite;
}

/* Decorative shapes scattered in sections */
.shape {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
  animation: floatSoft 18s ease-in-out infinite;
}

.shape--ring {
  border: 1.5px solid var(--border);
  border-radius: 50%;
}

.shape--dot-grid {
  background-image: radial-gradient(
    circle at 1px 1px,
    var(--border-strong) 1px,
    transparent 0
  );
  background-size: 18px 18px;
}

.shape--square {
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  transform: rotate(18deg);
}

.shape-2 {
  animation-duration: 24s;
  animation-delay: -6s;
}

.shape-3 {
  animation-duration: 30s;
  animation-delay: -12s;
}

/* Live status dot */
.status-dot {
  animation: pulseRing 2.4s ease-out infinite;
}

/* Scroll cue travelling line */
.scroll-cue__line::after {
  content: "";
  display: block;
  width: 100%;
  height: 60%;
  background: #fff;
  animation: scrollLine 2s ease-in-out infinite;
}

/* Green band decorative rings rotate imperceptibly */
.green-ring {
  animation: spinSlow 60s linear infinite;
}

/* ==========================================================================
   06. RIPPLE EFFECT
   JS injects a <span class="ripple"> at the click point.
   ========================================================================== */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
  animation: rippleOut 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Darker ripple on light-background buttons */
.btn-outline .ripple,
.btn-glass .ripple,
.chip .ripple {
  background: rgba(37, 99, 235, 0.22);
}

/* ==========================================================================
   07. MARQUEE
   Track is duplicated in markup, so -50% is a seamless loop.
   ========================================================================== */
.marquee__track {
  animation: marqueeScroll 40s linear infinite;
}

.marquee__track--reverse {
  animation-direction: reverse;
  animation-duration: 46s;
}

/* ==========================================================================
   08. MICRO-INTERACTIONS
   ========================================================================== */

/* Counter values snap in when they finish counting */
.stat__value.is-counted {
  animation: zoomIn 0.4s var(--ease-spring) both;
}

/* Product grid items fade in when a filter is applied */
.product-card.is-filtered-in {
  animation: fadeUp 0.5s var(--ease-out) both;
}

.product-card.is-hidden {
  display: none;
}

/* Skeleton shimmer, used while lazy media resolves */
.shimmer {
  background: linear-gradient(
    90deg,
    var(--bg-alt) 0%,
    #ffffff 50%,
    var(--bg-alt) 100%
  );
  background-size: 420px 100%;
  animation: shimmer 1.4s linear infinite;
}

/* Images fade in once loaded (paired with loading="lazy") */
img[data-lazy] {
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}

img[data-lazy].is-loaded {
  opacity: 1;
}

/* Nav drawer items cascade in on mobile */
.nav.is-open .nav__item {
  animation: fadeRight 0.45s var(--ease-out) both;
}

.nav.is-open .nav__item:nth-child(1) {
  animation-delay: 0.05s;
}
.nav.is-open .nav__item:nth-child(2) {
  animation-delay: 0.1s;
}
.nav.is-open .nav__item:nth-child(3) {
  animation-delay: 0.15s;
}
.nav.is-open .nav__item:nth-child(4) {
  animation-delay: 0.2s;
}
.nav.is-open .nav__item:nth-child(5) {
  animation-delay: 0.25s;
}
.nav.is-open .nav__item:nth-child(6) {
  animation-delay: 0.3s;
}
.nav.is-open .nav__item:nth-child(7) {
  animation-delay: 0.35s;
}

/* Parallax targets — JS writes --py, CSS applies it */
[data-parallax] {
  transform: translate3d(0, var(--py, 0px), 0);
  will-change: transform;
}

/* Tilt targets — JS writes --rx / --ry */
[data-tilt] {
  transition: transform 0.4s var(--ease-out);
  transform-style: preserve-3d;
}

[data-tilt].is-tilting {
  transition: transform 0.1s linear;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}

/* ==========================================================================
   09. REDUCED MOTION
   Respect the user's OS preference — kill all non-essential 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;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }

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

  .cursor-dot,
  .cursor-ring,
  .mouse-glow {
    display: none !important;
  }

  .marquee__track {
    animation: none !important;
  }
}