/**
 * assets/css/animations.css
 * Keyframe definitions and scroll-reveal utility classes.
 * JavaScript in animations.js adds .is-visible to trigger these.
 */

/* ── Accessibility: respect reduced motion ──────────────────────────────────── */
@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;
  }

  .reveal,
  .reveal-up,
  .reveal-left,
  .reveal-clip,
  .reveal-scale,
  .stagger-children > * {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════════════
   KEYFRAMES
══════════════════════════════════════════════════════════════════════════════ */

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

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

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

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

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

@keyframes clipRevealH {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0% 0 0); }
}

@keyframes clipRevealV {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0% 0); }
}

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

@keyframes lineGrow {
  from { width: 0; }
  to   { width: 100%; }
}

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

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.4); }
  50%       { box-shadow: 0 0 0 12px rgba(245, 166, 35, 0); }
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Loading bar ───────────────────────────────────────────────────────────── */
@keyframes loadBar {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

/* ══════════════════════════════════════════════════════════════════════════════
   SCROLL REVEAL CLASSES
   JS adds .is-visible to elements with these classes when they enter viewport.
══════════════════════════════════════════════════════════════════════════════ */

/* Base state — hidden */
.reveal,
.reveal-up,
.reveal-left,
.reveal-right,
.reveal-clip,
.reveal-scale {
  opacity: 0;
  will-change: opacity, transform;
  transition-property: opacity, transform;
  transition-timing-function: var(--ease-out);
  transition-duration: var(--duration-slow);
}

.reveal         { }

.reveal-up      { transform: translateY(30px); }

.reveal-left    { transform: translateX(-30px); }

.reveal-right   { transform: translateX(30px); }

.reveal-scale   { transform: scale(0.94); }

.reveal-clip {
  clip-path: inset(0 100% 0 0);
  transition-property: clip-path, opacity;
}

/* Visible state — triggered by JS */
.reveal.is-visible,
.reveal-up.is-visible,
.reveal-left.is-visible,
.reveal-right.is-visible,
.reveal-scale.is-visible {
  opacity: 1;
  transform: none;
}

.reveal-clip.is-visible {
  opacity: 1;
  clip-path: inset(0 0% 0 0);
}

/* ── Stagger children ──────────────────────────────────────────────────────── */
.stagger-children > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.stagger-children.is-visible > *:nth-child(1)  { opacity: 1; transform: none; transition-delay: 0ms;   }
.stagger-children.is-visible > *:nth-child(2)  { opacity: 1; transform: none; transition-delay: 80ms;  }
.stagger-children.is-visible > *:nth-child(3)  { opacity: 1; transform: none; transition-delay: 160ms; }
.stagger-children.is-visible > *:nth-child(4)  { opacity: 1; transform: none; transition-delay: 240ms; }
.stagger-children.is-visible > *:nth-child(5)  { opacity: 1; transform: none; transition-delay: 320ms; }
.stagger-children.is-visible > *:nth-child(6)  { opacity: 1; transform: none; transition-delay: 400ms; }
.stagger-children.is-visible > *:nth-child(7)  { opacity: 1; transform: none; transition-delay: 480ms; }
.stagger-children.is-visible > *:nth-child(8)  { opacity: 1; transform: none; transition-delay: 560ms; }

/* ── Hero entrance sequence (CSS-only fallback, also driven by hero.js) ──────── */
.hero-sequence > *:nth-child(1) { animation: fadeInDown 0.6s var(--ease-out) 0.3s both; }
.hero-sequence > *:nth-child(2) { animation: fadeInUp  0.8s var(--ease-out) 0.5s both; }
.hero-sequence > *:nth-child(3) { animation: fadeInUp  0.8s var(--ease-out) 0.7s both; }
.hero-sequence > *:nth-child(4) { animation: fadeIn    0.6s var(--ease-out) 1.0s both; }
.hero-sequence > *:nth-child(5) { animation: fadeIn    0.6s var(--ease-out) 1.2s both; }

/* ── Gold divider line grow animation ──────────────────────────────────────── */
.line-grow {
  display: block;
  height: 2px;
  background-color: var(--color-accent-gold);
  width: 0;
  transition: width 0.8s var(--ease-out);
}

.line-grow.is-visible {
  width: 100%;
}

/* ── Hover micro-animations ─────────────────────────────────────────────────── */
.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--duration-normal) var(--ease-out);
}
.hover-scale:hover {
  transform: scale(1.03);
}

/* ── Image zoom on parent hover ─────────────────────────────────────────────── */
.img-zoom-wrap {
  overflow: hidden;
}
.img-zoom-wrap img,
.img-zoom-wrap .wp-post-image {
  transition: transform 0.6s var(--ease-out);
  will-change: transform;
}
.img-zoom-wrap:hover img,
.img-zoom-wrap:hover .wp-post-image {
  transform: scale(1.06);
}

/* ── Underline slide animation for nav links ────────────────────────────────── */
.underline-slide {
  position: relative;
}
.underline-slide::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--color-accent-gold);
  transition: width var(--duration-normal) var(--ease-out);
}
.underline-slide:hover::after,
.underline-slide.active::after {
  width: 100%;
}

/* ── Skeleton loading shimmer ───────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-bg-elevated) 25%,
    var(--color-bg-card) 50%,
    var(--color-bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

/* ── Page transition overlay ────────────────────────────────────────────────── */
.page-transition {
  position: fixed;
  inset: 0;
  background: var(--color-bg-primary);
  z-index: var(--z-modal);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out);
}
.page-transition.is-active {
  opacity: 1;
}
