/* ============================================================
   USALAMA HUB — ANIMATIONS & TRANSITIONS
   Scroll animations, micro-interactions, keyframes
   ============================================================ */

/* ══════════════════════════════════════════════════════════
   SCROLL-DRIVEN ANIMATIONS
   Classes applied by IntersectionObserver in main.js
   ══════════════════════════════════════════════════════════ */

/* Initial hidden state */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.fade-up {
  opacity: 0;
  transform: translateY(24px);
}

.animate-on-scroll.fade-left {
  opacity: 0;
  transform: translateX(-24px);
}

.animate-on-scroll.fade-right {
  opacity: 0;
  transform: translateX(24px);
}

.animate-on-scroll.scale-up {
  opacity: 0;
  transform: scale(0.96);
}

/* Visible state (added by JS) */
.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0) translateX(0) scale(1);
}

/* Stagger delays for child elements */
.stagger-children > *:nth-child(1) { transition-delay: 0ms; }
.stagger-children > *:nth-child(2) { transition-delay: 80ms; }
.stagger-children > *:nth-child(3) { transition-delay: 160ms; }
.stagger-children > *:nth-child(4) { transition-delay: 240ms; }
.stagger-children > *:nth-child(5) { transition-delay: 320ms; }
.stagger-children > *:nth-child(6) { transition-delay: 400ms; }

/* ── Reduced motion overrides ── */
@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll,
  .animate-on-scroll.fade-up,
  .animate-on-scroll.fade-left,
  .animate-on-scroll.fade-right,
  .animate-on-scroll.scale-up {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .stagger-children > * {
    transition-delay: 0ms;
  }

  .scroll-indicator {
    animation: none;
  }

  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ══════════════════════════════════════════════════════════
   HERO ENTRANCE ANIMATIONS
   ══════════════════════════════════════════════════════════ */
@keyframes heroFadeUp {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heroFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.hero-animate-1 {
  animation: heroFadeUp 0.7s ease forwards;
  animation-delay: 0.1s;
  opacity: 0;
}

.hero-animate-2 {
  animation: heroFadeUp 0.7s ease forwards;
  animation-delay: 0.25s;
  opacity: 0;
}

.hero-animate-3 {
  animation: heroFadeUp 0.7s ease forwards;
  animation-delay: 0.4s;
  opacity: 0;
}

.hero-animate-4 {
  animation: heroFadeUp 0.7s ease forwards;
  animation-delay: 0.55s;
  opacity: 0;
}

.hero-animate-5 {
  animation: heroFadeUp 0.7s ease forwards;
  animation-delay: 0.7s;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .hero-animate-1,
  .hero-animate-2,
  .hero-animate-3,
  .hero-animate-4,
  .hero-animate-5 {
    animation: none;
    opacity: 1;
  }
}

/* ══════════════════════════════════════════════════════════
   COUNTER ANIMATION (JS-driven)
   ══════════════════════════════════════════════════════════ */
.stat-counter {
  display: inline-block;
}

/* ══════════════════════════════════════════════════════════
   PULSE (for critical elements)
   ══════════════════════════════════════════════════════════ */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(192, 57, 43, 0);
  }
}

.quick-exit-btn {
  animation: pulse 3s ease infinite;
}

.quick-exit-btn:hover {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .quick-exit-btn {
    animation: none;
  }
}

/* ══════════════════════════════════════════════════════════
   CARD HOVER SHINE
   ══════════════════════════════════════════════════════════ */
.card-shine {
  position: relative;
  overflow: hidden;
}

.card-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    to right,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0) 100%
  );
  transform: skewX(-25deg);
  transition: left 0.6s ease;
  pointer-events: none;
}

.card-shine:hover::after {
  left: 150%;
}

/* ══════════════════════════════════════════════════════════
   LOADING / SKELETON
   ══════════════════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-2) 25%,
    var(--color-border) 50%,
    var(--color-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-md);
}

/* ══════════════════════════════════════════════════════════
   GRADIENT TEXT
   ══════════════════════════════════════════════════════════ */
.gradient-text {
  background: linear-gradient(135deg, var(--color-brand-primary-light), var(--color-brand-tertiary-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text--amber {
  background: linear-gradient(135deg, var(--color-brand-secondary-light), var(--color-brand-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text--violet {
  background: linear-gradient(135deg, var(--asha-primary-light), var(--asha-primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ══════════════════════════════════════════════════════════
   SVG DIAGRAM ANIMATIONS
   ══════════════════════════════════════════════════════════ */
@keyframes flowDown {
  0%   { stroke-dashoffset: 100; opacity: 0.4; }
  50%  { stroke-dashoffset: 0;   opacity: 1; }
  100% { stroke-dashoffset: 100; opacity: 0.4; }
}

.flow-path {
  stroke-dasharray: 8 4;
  stroke-dashoffset: 0;
  animation: flowDown 2.5s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
  .flow-path {
    animation: none;
    opacity: 0.6;
  }
}

/* ══════════════════════════════════════════════════════════
   SECTION FADE DIVIDERS
   ══════════════════════════════════════════════════════════ */
.wave-divider {
  display: block;
  overflow: hidden;
  line-height: 0;
}

.wave-divider svg {
  display: block;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════
   FOCUS RING ANIMATION
   ══════════════════════════════════════════════════════════ */
@keyframes focusRing {
  0%   { box-shadow: 0 0 0 0 rgba(45, 106, 79, 0.4); }
  100% { box-shadow: 0 0 0 6px rgba(45, 106, 79, 0); }
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  animation: focusRing 0.3s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  button:focus-visible,
  a:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    animation: none;
  }
}

/* ══════════════════════════════════════════════════════════
   NAV TRANSITION
   ══════════════════════════════════════════════════════════ */
.mobile-nav {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease;
}

/* ══════════════════════════════════════════════════════════
   FEATURE ALTERNATING LAYOUT TRANSITIONS
   ══════════════════════════════════════════════════════════ */
.feature-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  align-items: center;
  margin-bottom: var(--space-16);
}

.feature-row--reverse {
  direction: rtl;
}

.feature-row--reverse > * {
  direction: ltr;
}

@media (max-width: 767px) {
  .feature-row,
  .feature-row--reverse {
    grid-template-columns: 1fr;
    direction: ltr;
  }
}

/* ══════════════════════════════════════════════════════════
   TWO-COLUMN LAYOUT
   ══════════════════════════════════════════════════════════ */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  align-items: center;
}

.two-col--60-40 {
  grid-template-columns: 3fr 2fr;
}

.two-col--40-60 {
  grid-template-columns: 2fr 3fr;
}

@media (max-width: 767px) {
  .two-col,
  .two-col--60-40,
  .two-col--40-60 {
    grid-template-columns: 1fr;
  }
}
