/**
 * Theme Animations
 *
 * Scroll-triggered reveals, hover micro-interactions, and transitions.
 * All animations respect prefers-reduced-motion.
 *
 * @package EthicalInfrastructure
 */

/* ─────────────────────────────────────────────────────────────────────────────
   SCROLL REVEAL
   IntersectionObserver in theme-scroll-reveal.js adds .is-visible class
   to elements with .ei-scroll-reveal when they enter the viewport.
   ───────────────────────────────────────────────────────────────────────────── */

.ei-scroll-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.ei-scroll-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delay variants — use on child elements within a reveal group */
.ei-scroll-reveal--delay-1 { transition-delay: 0.1s; }
.ei-scroll-reveal--delay-2 { transition-delay: 0.2s; }
.ei-scroll-reveal--delay-3 { transition-delay: 0.3s; }
.ei-scroll-reveal--delay-4 { transition-delay: 0.4s; }
.ei-scroll-reveal--delay-5 { transition-delay: 0.5s; }

/* Horizontal reveal variant — slides in from left */
.ei-scroll-reveal--from-left {
  opacity: 0;
  transform: translateX(-20px);
}

.ei-scroll-reveal--from-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Horizontal reveal — slides in from right */
.ei-scroll-reveal--from-right {
  opacity: 0;
  transform: translateX(20px);
}

.ei-scroll-reveal--from-right.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Fade only — no movement (for large sections) */
.ei-scroll-reveal--fade {
  opacity: 0;
  transform: none;
}

.ei-scroll-reveal--fade.is-visible {
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────────
   HERO SECTION ENTRANCE
   Elements inside the hero fade in on page load (no scroll needed).
   ───────────────────────────────────────────────────────────────────────────── */

@keyframes ei-fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ei-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ei-hero-animate-1 {
  animation: ei-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.ei-hero-animate-2 {
  animation: ei-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.25s both;
}

.ei-hero-animate-3 {
  animation: ei-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.4s both;
}

.ei-hero-animate-4 {
  animation: ei-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.55s both;
}

.ei-hero-stat-bar-animate {
  animation: ei-fade-in 0.6s ease 0.7s both;
}

/* ─────────────────────────────────────────────────────────────────────────────
   CARD HOVER TRANSITIONS
   ───────────────────────────────────────────────────────────────────────────── */

/* Card border glow — border-color transitions to primary on hover */
.ei-card-hover {
  transition: border-color 0.5s ease, background-color 0.3s ease;
}

/* Button text gap expansion on hover — group-based */
.ei-group:hover .ei-btn--text,
.ei-group:hover .ei-group-text-link {
  gap: var(--space-3);
}

/* ─────────────────────────────────────────────────────────────────────────────
   NAV LINK UNDERLINE ANIMATION
   The 2px border-bottom slides in from left to right.
   ───────────────────────────────────────────────────────────────────────────── */

.ei-nav-link {
  position: relative;
}

/* TOC line expansion is handled by CSS in theme-components.css */

/* ─────────────────────────────────────────────────────────────────────────────
   GRAYSCALE IMAGE TRANSITION
   ───────────────────────────────────────────────────────────────────────────── */

/* Already defined in theme-components.css — no duplication here */

/* ─────────────────────────────────────────────────────────────────────────────
   DROPDOWN TRANSITION
   ───────────────────────────────────────────────────────────────────────────── */

/* Already handled in theme-components.css .ei-nav-dropdown */

/* ─────────────────────────────────────────────────────────────────────────────
   FORM FIELD FOCUS EFFECTS
   ───────────────────────────────────────────────────────────────────────────── */

/* Underline expand on focus — the border-bottom glows to navy */
.ei-form-underline__input:focus,
.ei-form-underline__textarea:focus {
  border-bottom-color: var(--color-primary);
  outline: none;
  box-shadow: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
   REDUCED MOTION
   All animations and transitions are disabled for users who prefer it.
   ───────────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ei-scroll-reveal,
  .ei-scroll-reveal--from-left,
  .ei-scroll-reveal--from-right,
  .ei-scroll-reveal--fade {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .ei-hero-animate-1,
  .ei-hero-animate-2,
  .ei-hero-animate-3,
  .ei-hero-animate-4,
  .ei-hero-stat-bar-animate {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .ei-img-grayscale,
  .ei-policy-row__image,
  .ei-card,
  .ei-nav-dropdown,
  .ei-toc-link__line {
    transition: none;
  }
}
