/* ==========================================================
   ANIMATIONS — Scroll Reveal, Counters, Micro-interactions
   phamducanh.vn
   ========================================================== */

/* ── Scroll Reveal Base ── */
[data-reveal] {
  opacity: 0;
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}

[data-reveal].revealed {
  opacity: 1;
  transform: none !important;
}

/* Reveal directions */
[data-reveal="up"] {
  transform: translateY(40px);
}

[data-reveal="down"] {
  transform: translateY(-40px);
}

[data-reveal="left"] {
  transform: translateX(-40px);
}

[data-reveal="right"] {
  transform: translateX(40px);
}

[data-reveal="fade"] {
  transform: none;
}

[data-reveal="scale"] {
  transform: scale(0.92);
}

/* Stagger delays for children */
[data-reveal-stagger] > [data-reveal] {
  transition-delay: calc(var(--reveal-index, 0) * 0.1s);
}

/* ── Parallax ── */
[data-parallax] {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ── Counter Animation ── */
.counter-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ── Hover Lift ── */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-xl);
}

/* ── Shimmer / Loading Effect ── */
.shimmer {
  background: linear-gradient(
    90deg,
    var(--gray-100) 25%,
    var(--gray-50) 50%,
    var(--gray-100) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

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

/* ── Pulse Glow ── */
.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 165, 207, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(0, 165, 207, 0); }
}

/* ── Float Animation (subtle) ── */
.float {
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ── Underline Slide ── */
.underline-slide {
  position: relative;
  display: inline-block;
}

.underline-slide::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background: var(--ocean-400);
  transition: width var(--transition-base);
}

.underline-slide:hover::after {
  width: 100%;
}

/* ── Gradient Border Animation ── */
.gradient-border {
  position: relative;
  z-index: 0;
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, var(--ocean-400), var(--coral-400));
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: -1;
}

.gradient-border:hover::before {
  opacity: 1;
}

/* ── Image Reveal ── */
.img-reveal {
  position: relative;
  overflow: hidden;
}

.img-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--navy-900);
  transform-origin: right;
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.img-reveal.revealed::after {
  transform: scaleX(0);
}

/* ── Text Highlight on Scroll ── */
.text-highlight-scroll mark {
  background: linear-gradient(135deg, rgba(0, 165, 207, 0.2), rgba(72, 202, 228, 0.2));
  color: inherit;
  padding: 0 4px;
  border-radius: 3px;
  text-decoration: none;
}

/* ── Section background subtle animation ── */
.bg-gradient-shift {
  background-size: 200% 200%;
  animation: gradientShift 12s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

  [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .hero-scroll-line::after {
    animation: none;
  }
}
