/* ============================================================
   ANIMATIONS
   Keyframe definitions and scroll-triggered animation utilities.
   Elements receive .is-visible via IntersectionObserver in main.js
   ============================================================ */

/* ── Keyframes ─────────────────────────────────────────────── */

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-32px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(32px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* ── Scroll-triggered base states ───────────────────────────── */
/* Elements start invisible; .is-visible triggers animation     */

.animate-fade-up {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.animate-fade-up.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-fade-in {
  opacity: 0;
  transition: opacity 0.7s ease;
}

.animate-fade-in.is-visible {
  opacity: 1;
}

.animate-scale {
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-scale.is-visible {
  opacity: 1;
  transform: scale(1);
}

.animate-slide-left {
  opacity: 0;
  transform: translateX(-32px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.animate-slide-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.animate-slide-right {
  opacity: 0;
  transform: translateX(32px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.animate-slide-right.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* ── Staggered children ─────────────────────────────────────── */
/* Apply .stagger-children to a parent; children get delays      */

.stagger-children .animate-fade-up:nth-child(1)  { transition-delay: 0ms; }
.stagger-children .animate-fade-up:nth-child(2)  { transition-delay: 80ms; }
.stagger-children .animate-fade-up:nth-child(3)  { transition-delay: 160ms; }
.stagger-children .animate-fade-up:nth-child(4)  { transition-delay: 240ms; }
.stagger-children .animate-fade-up:nth-child(5)  { transition-delay: 320ms; }
.stagger-children .animate-fade-up:nth-child(6)  { transition-delay: 400ms; }
.stagger-children .animate-fade-up:nth-child(7)  { transition-delay: 480ms; }
.stagger-children .animate-fade-up:nth-child(8)  { transition-delay: 560ms; }
.stagger-children .animate-fade-up:nth-child(9)  { transition-delay: 640ms; }
.stagger-children .animate-fade-up:nth-child(10) { transition-delay: 720ms; }
.stagger-children .animate-fade-up:nth-child(n+11) { transition-delay: 720ms; }

/* ── Hero entrance ───────────────────────────────────────────── */

.hero__content {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s ease 0.4s, transform 0.9s ease 0.4s;
}

.hero--loaded .hero__content {
  opacity: 1;
  transform: translateY(0);
}

/* ── Loading spinner ─────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ── Lightbox image transition ───────────────────────────────── */

.lightbox__image {
  transition: opacity 0.2s ease;
}

.lightbox__image.is-loading {
  opacity: 0;
}

/* ── FAQ details animation ───────────────────────────────────── */

.faq-answer {
  overflow: hidden;
  animation: fadeInDown 0.3s ease;
}

/* ── Portfolio grid filter transition ────────────────────────── */

.portfolio-grid--fading {
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* ── Testimonials carousel ───────────────────────────────────── */

.testimonial-item {
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* ── Reduced motion ──────────────────────────────────────────── */
/* Respects the user's system preference                          */

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

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

  .hero__content {
    opacity: 1;
    transform: none;
  }
}


/* ============================================================
   ARTISTIC / EDITORIAL ANIMATION ADDITIONS
   ============================================================ */

/* ── Marquee ─────────────────────────────────────────────────── */

@keyframes marquee-left {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes marquee-right {
  0%   { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

/* ── Floating orbs (hero decoration) ────────────────────────── */

@keyframes orb-float-a {
  0%, 100% { transform: translate(0,    0)    scale(1);    }
  33%       { transform: translate(18px, -22px) scale(1.05); }
  66%       { transform: translate(-12px, -10px) scale(0.97); }
}

@keyframes orb-float-b {
  0%, 100% { transform: translate(0,   0)    scale(1);    }
  40%       { transform: translate(-20px, 14px) scale(1.04); }
  75%       { transform: translate(10px, -18px) scale(0.96); }
}

@keyframes orb-float-c {
  0%, 100% { transform: translate(0, 0)   rotate(0deg); }
  50%       { transform: translate(14px, 20px) rotate(15deg); }
}

/* ── Clip-path line reveal ───────────────────────────────────── */
/* Applied to .reveal-wrap / .reveal-inner pairs by JS           */

.reveal-wrap {
  display: block;
  overflow: hidden;
  line-height: 1.15;
}

.reveal-inner {
  display: block;
  transform: translateY(108%);
  transition: transform 0.95s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-wrap.is-revealed .reveal-inner {
  transform: translateY(0);
}

/* Stagger successive lines */
.reveal-wrap:nth-child(2) .reveal-inner { transition-delay: 90ms;  }
.reveal-wrap:nth-child(3) .reveal-inner { transition-delay: 180ms; }
.reveal-wrap:nth-child(4) .reveal-inner { transition-delay: 270ms; }

/* ── Split-word hero heading ─────────────────────────────────── */

.split-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}

.split-word__inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger via CSS custom property --i set by JS */
.hero--loaded .split-word__inner {
  transform: translateY(0);
}

.split-word:nth-child(1)  .split-word__inner { transition-delay: calc(0   * 55ms + 400ms); }
.split-word:nth-child(2)  .split-word__inner { transition-delay: calc(1   * 55ms + 400ms); }
.split-word:nth-child(3)  .split-word__inner { transition-delay: calc(2   * 55ms + 400ms); }
.split-word:nth-child(4)  .split-word__inner { transition-delay: calc(3   * 55ms + 400ms); }
.split-word:nth-child(5)  .split-word__inner { transition-delay: calc(4   * 55ms + 400ms); }
.split-word:nth-child(6)  .split-word__inner { transition-delay: calc(5   * 55ms + 400ms); }
.split-word:nth-child(7)  .split-word__inner { transition-delay: calc(6   * 55ms + 400ms); }
.split-word:nth-child(8)  .split-word__inner { transition-delay: calc(7   * 55ms + 400ms); }
.split-word:nth-child(n+9).split-word__inner { transition-delay: calc(8   * 55ms + 400ms); }

/* ── Image scroll skew ───────────────────────────────────────── */

.scroll-skewable {
  will-change: transform;
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Philosophy quote big text ───────────────────────────────── */

@keyframes char-in {
  from { opacity: 0; filter: blur(8px); transform: translateY(12px); }
  to   { opacity: 1; filter: blur(0);   transform: translateY(0); }
}

/* ── Cursor ──────────────────────────────────────────────────── */

@keyframes cursor-appear {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ── Parallax background text ────────────────────────────────── */

@keyframes drift-slow {
  0%, 100% { letter-spacing: 0.3em; }
  50%       { letter-spacing: 0.28em; }
}
