/* ============================================================
   PROJERA — SHARED ANIMATIONS CSS
   animations.css v1.0
   Works alongside design-tokens.css + components.css
   ============================================================ */

/* ── AOS (Animate On Scroll) — Safe Overrides ──
   IMPORTANT: Never hide elements before AOS initializes.
   The AOS library itself handles initial hidden state via its own CSS.
   We only override timing here. ── */

/* AOS-animate pointer-events fix */
[data-aos]:not(.aos-animate) {
  pointer-events: auto !important; /* Never block interaction */
}

/* Faster, snappier AOS timing */
[data-aos][data-aos][data-aos-duration='400'] {
  transition-duration: 400ms;
}
[data-aos][data-aos][data-aos-duration='600'] {
  transition-duration: 600ms;
}
[data-aos][data-aos][data-aos-duration='800'] {
  transition-duration: 800ms;
}

/* Custom fade-up-sm (shorter travel distance) */
[data-aos="fade-up-sm"] {
  transform: translateY(24px);
  transition-property: transform, opacity;
  /* opacity handled by AOS library itself */
}
[data-aos="fade-up-sm"].aos-animate {
  transform: translateY(0);
  opacity: 1;
}
/* Ensure sections are NOT invisible before AOS inits */
section[data-aos]:not([data-aos-init]) {
  opacity: 1 !important;
  transform: none !important;
}

/* Stagger children */
[data-aos-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
[data-aos-stagger].aos-animate > * {
  opacity: 1;
  transform: translateY(0);
}

/* ── Cursor Glow ── */
.cursor-glow {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease;
  opacity: 0;
  mix-blend-mode: screen;
  /* Color set via JS per site */
  background: radial-gradient(circle, rgba(32, 214, 255, 0.12) 0%, transparent 70%);
  will-change: transform;
}
.cursor-glow.is-visible {
  opacity: 1;
}
@media (hover: none) {
  .cursor-glow { display: none !important; }
}

/* ── Magnetic Button ── */
.btn-magnetic {
  display: inline-flex;
  transition: transform 0.15s cubic-bezier(0.23, 1, 0.32, 1);
  will-change: transform;
}

/* ── Number Counter ── */
.counter-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

/* ── SVG Draw Animation ── */
.svg-draw path,
.svg-draw line,
.svg-draw circle,
.svg-draw polyline {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.svg-draw.is-drawn path,
.svg-draw.is-drawn line,
.svg-draw.is-drawn polyline {
  stroke-dashoffset: 0;
}
.svg-draw.is-drawn circle {
  stroke-dashoffset: 0;
  transition-delay: 0.3s;
}

/* ── Section Reveal Defaults ── */
.reveal-section {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal-section.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Card Tilt Wrapper ── */
.tilt-card {
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ── Gradient Text Shimmer ── */
@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.text-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-cyan) 0%,
    var(--color-magenta) 25%,
    var(--color-violet) 50%,
    var(--color-cyan) 75%,
    var(--color-magenta) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
}

/* ── Floating Animation ── */
@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}
.float-element {
  animation: float 4s ease-in-out infinite;
}

/* ── Network Pulse Dash ── */
@keyframes dash-flow {
  to { stroke-dashoffset: -40; }
}
.network-line-animated {
  stroke-dasharray: 8 6;
  animation: dash-flow 1.5s linear infinite;
}

/* ── Scroll Progress Bar ── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-cyan), var(--color-magenta));
  z-index: 10000;
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

/* ── Hero Text Reveal ── */
.hero-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}
.hero-word__inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.hero-revealed .hero-word__inner {
  transform: translateY(0);
}

/* ── Noise Texture Overlay (CSS only) ── */
.noise-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
  border-radius: inherit;
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  [data-aos] {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
  .cursor-glow,
  .scroll-progress,
  .network-line-animated,
  .float-element,
  .text-shimmer {
    display: none !important;
    animation: none !important;
  }
  .reveal-section {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .svg-draw path,
  .svg-draw line,
  .svg-draw circle {
    stroke-dashoffset: 0 !important;
    transition: none !important;
  }
}

/* ============================================================
   HERO CANVAS BACKGROUNDS — Abstract Continuous Animations
   Canvas is always BEHIND content (z-index: 0)
   ============================================================ */

/* Canvas element — always behind hero content */
.hero-canvas {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
  z-index: 0 !important;
  opacity: 1;
}

/* All direct hero children sit above canvas */
.hero-projera > *:not(.hero-canvas),
.hero-consulting > *:not(.hero-canvas),
.hero-institute > *:not(.hero-canvas),
.hero-partners > *:not(.hero-canvas),
.inst-hero > *:not(.hero-canvas),
[class*="page-hero"] > *:not(.hero-canvas) {
  position: relative;
  z-index: 1;
}

/* ── Gradient orb animations ── */
@keyframes orb-float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, -30px) scale(1.08); }
  66%       { transform: translate(-20px, 20px) scale(0.95); }
}
@keyframes orb-float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%       { transform: translate(-50px, 30px) scale(1.1); }
  70%       { transform: translate(30px, -20px) scale(0.92); }
}
@keyframes orb-float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(20px, 40px) scale(1.05); }
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  will-change: transform;
}
.hero-orb--1 { animation: orb-float-1 12s ease-in-out infinite; }
.hero-orb--2 { animation: orb-float-2 16s ease-in-out infinite; animation-delay: -4s; }
.hero-orb--3 { animation: orb-float-3 10s ease-in-out infinite; animation-delay: -7s; }

@media (prefers-reduced-motion: reduce) {
  .hero-orb { animation: none !important; }
  .hero-canvas { display: none; }
}
