/* ═══════════════════════════════════════════════════════════════
   STOKHOS LABS — Animations
   Scroll-reveal classes (IntersectionObserver-driven) +
   hover micro-interactions + entrance effects.

   HOW TO USE:
   1. Add a reveal class to your element: class="fade-up"
   2. The IntersectionObserver in scripts/main.js adds .revealed
      when the element scrolls into view.
   3. For staggered children, add .stagger to the parent.
   4. Use .delay-N to offset an individual element's reveal.
   ═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   SCROLL-REVEAL BASE STATES
   Hidden by default; .revealed class applied by main.js JS
   ══════════════════════════════════════════════════════════════ */

/* Slides up 28px and fades in — most common reveal */
.fade-up {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity  0.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-up.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Pure opacity fade — no movement */
.fade-in {
  opacity: 0;
  transition: opacity 0.7s ease;
}
.fade-in.revealed { opacity: 1; }

/* Slides in from right side */
.fade-left {
  opacity: 0;
  transform: translateX(28px);
  transition:
    opacity  0.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-left.revealed { opacity: 1; transform: translateX(0); }

/* Slides in from left side */
.fade-right {
  opacity: 0;
  transform: translateX(-28px);
  transition:
    opacity  0.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}
.fade-right.revealed { opacity: 1; transform: translateX(0); }

/* Scales up from 94% and fades */
.scale-in {
  opacity: 0;
  transform: scale(0.94);
  transition:
    opacity  0.55s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.scale-in.revealed { opacity: 1; transform: scale(1); }

/* ══════════════════════════════════════════════════════════════
   STAGGER PARENT
   Apply .stagger to the parent container. Each direct child
   gets a sequentially longer transition-delay. The Observer
   watches the parent; when it fires, .revealed is added and
   all children animate in sequence.
   ══════════════════════════════════════════════════════════════ */
.stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity  0.55s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
.stagger > *:nth-child(1)  { transition-delay: 0.04s; }
.stagger > *:nth-child(2)  { transition-delay: 0.11s; }
.stagger > *:nth-child(3)  { transition-delay: 0.18s; }
.stagger > *:nth-child(4)  { transition-delay: 0.25s; }
.stagger > *:nth-child(5)  { transition-delay: 0.32s; }
.stagger > *:nth-child(6)  { transition-delay: 0.39s; }
.stagger > *:nth-child(7)  { transition-delay: 0.46s; }
.stagger > *:nth-child(8)  { transition-delay: 0.53s; }
.stagger > *:nth-child(9)  { transition-delay: 0.60s; }
.stagger > *:nth-child(10) { transition-delay: 0.67s; }

.stagger.revealed > * {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════════════════════════════
   DELAY MODIFIERS
   Override a single element's transition-delay.
   Example: <p class="fade-up delay-3">Delayed text</p>
   ══════════════════════════════════════════════════════════════ */
.delay-1 { transition-delay: 0.08s !important; }
.delay-2 { transition-delay: 0.16s !important; }
.delay-3 { transition-delay: 0.24s !important; }
.delay-4 { transition-delay: 0.32s !important; }
.delay-5 { transition-delay: 0.44s !important; }
.delay-6 { transition-delay: 0.56s !important; }

/* ══════════════════════════════════════════════════════════════
   PAGE ENTRANCE
   The .page-main wrapper fades in on load automatically.
   ══════════════════════════════════════════════════════════════ */
.page-main {
  animation: page-enter 0.45s ease both;
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   HOVER UTILITY CLASSES (no JS needed)
   ══════════════════════════════════════════════════════════════ */

/* Lifts element up on hover */
.hover-lift {
  transition:
    transform  var(--t-base, 220ms) var(--ease, cubic-bezier(0.16,1,0.3,1)),
    box-shadow var(--t-base, 220ms) var(--ease, cubic-bezier(0.16,1,0.3,1));
}
.hover-lift:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(21,37,62,0.10);
}

/* Green glow on hover */
.hover-glow {
  transition: box-shadow var(--t-slow, 380ms) var(--ease, cubic-bezier(0.16,1,0.3,1));
}
.hover-glow:hover {
  box-shadow: 0 0 36px rgba(63,184,115,0.20);
}

/* Sliding underline on hover */
.hover-underline {
  position: relative;
  display: inline-block;
}
.hover-underline::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 1.5px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base, 220ms) var(--ease, cubic-bezier(0.16,1,0.3,1));
}
.hover-underline:hover::after { transform: scaleX(1); }

/* ══════════════════════════════════════════════════════════════
   ANIMATED NUMBER COUNTER
   Apply data-counter="N" data-suffix="%" data-decimals="1"
   to any element. main.js will animate it from 0 → N when
   it enters the viewport.
   ══════════════════════════════════════════════════════════════ */
[data-counter] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ══════════════════════════════════════════════════════════════
   LIVE / PULSE INDICATOR
   Use .pulse-dot for blinking live-data indicators.
   ══════════════════════════════════════════════════════════════ */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green, #3FB873);
  flex-shrink: 0;
  animation: pulse-ring 2.5s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0   rgba(63,184,115,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(63,184,115,0); }
  100% { box-shadow: 0 0 0 0   rgba(63,184,115,0); }
}

/* ══════════════════════════════════════════════════════════════
   SKELETON LOADER
   For dashboard placeholder states.
   ══════════════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-panel, #EEF2F8) 25%,
    var(--border,   #E3E8EE) 50%,
    var(--bg-panel, #EEF2F8) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm, 4px);
  animation: shimmer 1.6s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════════
   PREFERS-REDUCED-MOTION
   Respect the user's OS accessibility setting.
   All animations become instant; no motion.
   ══════════════════════════════════════════════════════════════ */
/* ══════════════════════════════════════════════════════════════
   HERO SVG CHART — entrance animations
   ══════════════════════════════════════════════════════════════ */

/* Confidence band fades in first */
#hero-band {
  opacity: 0;
  animation: hero-fade 0.9s ease 0.15s both;
}

/* Actual (dashed) line fades in after forecast draws */
#hero-actual {
  opacity: 0;
  animation: hero-fade 0.6s ease 1.2s both;
}

/* Forecast draws itself via stroke-dashoffset (~500 SVG units) */
#hero-forecast {
  stroke-dasharray: 520;
  stroke-dashoffset: 520;
  animation: hero-draw 1.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}
@keyframes hero-draw  { to { stroke-dashoffset: 0; } }
@keyframes hero-fade  { to { opacity: 1; } }

/* Dots pop in sequentially after the line finishes */
#hero-dots circle {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: hero-dot-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
#hero-dots circle:nth-child(1)  { animation-delay: 1.45s; }
#hero-dots circle:nth-child(2)  { animation-delay: 1.52s; }
#hero-dots circle:nth-child(3)  { animation-delay: 1.59s; }
#hero-dots circle:nth-child(4)  { animation-delay: 1.66s; }
#hero-dots circle:nth-child(5)  { animation-delay: 1.73s; }
#hero-dots circle:nth-child(6)  { animation-delay: 1.80s; }
#hero-dots circle:nth-child(7)  { animation-delay: 1.87s; }
#hero-dots circle:nth-child(8)  { animation-delay: 1.94s; }
#hero-dots circle:nth-child(9)  { animation-delay: 2.01s; }
#hero-dots circle:nth-child(10) { animation-delay: 2.08s; }
@keyframes hero-dot-pop {
  from { opacity: 0; transform: scale(0); }
  to   { opacity: 1; transform: scale(1); }
}

/* Callout badge fades in last, then pulses */
#hero-callout {
  opacity: 0;
  animation: hero-fade 0.5s ease 2.25s both;
}
#hero-callout rect {
  animation: callout-glow 3s ease-in-out 2.9s infinite alternate;
}
@keyframes callout-glow {
  from { filter: drop-shadow(0 0 0px  rgba(63,207,142,0.0)); }
  to   { filter: drop-shadow(0 0 10px rgba(63,207,142,0.5)); }
}

/* ══════════════════════════════════════════════════════════════
   EQUATION BLOCK — wipe-reveal on scroll
   The ::after overlay starts fully visible and wipes right→off,
   revealing the green equation text underneath.
   ══════════════════════════════════════════════════════════════ */
.equation-block {
  position: relative;
  overflow: hidden;
}
.equation-block::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--navy-bg);
  border-radius: var(--radius-xl);
  transform-origin: right;
  transform: scaleX(1);
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.55s;
  pointer-events: none;
}
.equation-block.revealed::after {
  transform: scaleX(0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-up,
  .fade-in,
  .fade-left,
  .fade-right,
  .scale-in {
    opacity: 1 !important;
    transform: none !important;
  }

  .stagger > * {
    opacity: 1 !important;
    transform: none !important;
  }

  .page-main { animation: none; }
  .pulse-dot { animation: none; }
  .skeleton  { animation: none; }

  #hero-band, #hero-actual, #hero-forecast, #hero-callout,
  #hero-dots circle {
    animation: none !important;
    opacity: 1 !important;
    stroke-dashoffset: 0 !important;
    transform: none !important;
  }
  .equation-block::after { display: none; }
}
