/* ============================================
   animations.css — ScrollTrigger Enhancement Layer
   红安润物 runwu.net.cn
   ============================================ */

/* ---------- 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;
  }
  .animate-on-scroll,
  .hero-eyebrow, .hero h1, .hero-sub, .hero-line,
  .tl-item, .card, .person-card, .route-card {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }
}

/* ---------- 1. Hero Parallax ---------- */
.hero {
  will-change: transform;
}
.hero-parallax-active {
  transform: translateY(calc(var(--parallax-offset, 0) * 1px));
}

/* Hero children stagger */
.hero-eyebrow,
.hero h1,
.hero-sub,
.hero-line {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero.hero-visible .hero-eyebrow {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.1s;
}
.hero.hero-visible h1 {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.35s;
}
.hero.hero-visible .hero-sub {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.6s;
}
.hero.hero-visible .hero-line {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.8s;
}

/* ---------- 2. Number Counter (data attributes set via JS) ---------- */
.counter-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ---------- 3. Animate-on-Scroll (generic) ---------- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.animate-on-scroll.in-view {
  opacity: 1;
  transform: translateY(0);
}

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

/* Card variants */
.card.animate-on-scroll,
.person-card.animate-on-scroll,
.route-card.animate-on-scroll {
  /* inherits generic style */
}

/* ---------- 4. Timeline Animation ---------- */
.timeline {
  position: relative;
}

/* Growing line */
.timeline::before {
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.timeline.timeline-visible::before {
  transform: scaleY(1);
}

/* Timeline items */
.tl-item {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.tl-item:nth-child(even) {
  transform: translateX(30px);
}
.tl-item.tl-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Timeline dot scale */
.tl-item::before {
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tl-item.tl-visible::before {
  transform: scale(1);
}

/* Stagger timeline items */
.timeline .tl-item:nth-child(1)  { transition-delay: 0ms; }
.timeline .tl-item:nth-child(2)  { transition-delay: 100ms; }
.timeline .tl-item:nth-child(3)  { transition-delay: 200ms; }
.timeline .tl-item:nth-child(4)  { transition-delay: 300ms; }
.timeline .tl-item:nth-child(5)  { transition-delay: 400ms; }
.timeline .tl-item:nth-child(6)  { transition-delay: 500ms; }
.timeline .tl-item:nth-child(7)  { transition-delay: 600ms; }
.timeline .tl-item:nth-child(8)  { transition-delay: 700ms; }
.timeline .tl-item:nth-child(9)  { transition-delay: 800ms; }
.timeline .tl-item:nth-child(10) { transition-delay: 900ms; }
.timeline .tl-item:nth-child(n+11) { transition-delay: 1000ms; }

/* ---------- 5. Breadcrumb Fade-in ---------- */
.breadcrumb {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.breadcrumb.breadcrumb-visible {
  opacity: 1;
}
/* Always show breadcrumb on pages that are scrolled slightly */
.breadcrumb.breadcrumb-always-visible {
  opacity: 1;
}

/* ---------- 6. Back-to-Top Button ---------- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--red, #CC0000);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 2px 12px rgba(204, 0, 0, 0.3);
  font-size: 1.2rem;
  line-height: 1;
}
.back-to-top.back-to-top-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: #a00;
  transform: translateY(-2px);
}
.back-to-top:active {
  transform: translateY(0);
}
.back-to-top svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

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

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

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

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

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

@keyframes growDown {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* ---------- Mobile adjustments ---------- */
@media (max-width: 600px) {
  .hero-eyebrow, .hero h1, .hero-sub, .hero-line {
    transition-duration: 0.5s;
  }
  .animate-on-scroll {
    transition-duration: 0.4s;
  }
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
  }
}
