/*
 * Clarmont — Shared Animation System
 * Scroll-triggered + load-triggered animations via IntersectionObserver.
 * Performance-first: transform/opacity only, no layout thrashing.
 * Respects prefers-reduced-motion for accessibility.
 */

/* ====================================================
   CUSTOM EASING PROPERTIES
   ==================================================== */

:root {
  --ease-spring:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:  cubic-bezier(0.65, 0, 0.35, 1);
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ====================================================
   REVEAL BASE — elements start invisible, JS adds .is-visible
   ==================================================== */

[data-reveal] {
  opacity: 0;
  transition-property: opacity, transform;
  transition-timing-function: var(--ease-spring);
  transition-duration: 0.7s;
  will-change: opacity, transform;
}

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

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

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

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

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

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

[data-reveal="scale-up"] {
  transform: scale(0.95) translateY(16px);
}

/* When visible */
[data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* ====================================================
   STAGGER DELAYS — data-stagger groups
   ==================================================== */

[data-stagger] > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.65s var(--ease-spring),
              transform 0.65s var(--ease-spring);
  will-change: opacity, transform;
}

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

/* ====================================================
   WORD REVEAL — text splits into words, each animates up
   The parent container wraps each word in an overflow:hidden
   clip box so the slide-up is masked.
   ==================================================== */

/* Each word is wrapped in a clip box */
.word-clip {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  /* small horizontal space between words */
  margin-right: 0.28em;
  margin-bottom: 0.05em;
}

.word-clip:last-child {
  margin-right: 0;
}

.word-clip .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(110%);
  transition: opacity 0.6s var(--ease-spring),
              transform 0.6s var(--ease-spring);
  will-change: transform, opacity;
}

/* When parent element gets words-visible, all words animate */
[data-words].words-visible .word-clip .word {
  opacity: 1;
  transform: none;
}

/* Headline text reveal via clip — used for hero h1 lines */
.line-clip-reveal {
  overflow: hidden;
  display: block;
}

.line-clip-reveal > .line-inner {
  display: block;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.0s,
              transform 0.65s var(--ease-spring);
}

.line-clip-reveal.line-visible > .line-inner {
  opacity: 1;
  transform: none;
}

/* ====================================================
   CHAR REVEAL — staggered character entrance
   ==================================================== */

.char-reveal .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(60%) scaleY(0.6);
  transform-origin: bottom center;
  transition: opacity 0.4s var(--ease-spring),
              transform 0.4s var(--ease-spring);
  will-change: transform, opacity;
}

.char-reveal.chars-visible .char {
  opacity: 1;
  transform: none;
}

/* ====================================================
   HOVER LIFT — universal card/block lift on hover
   ==================================================== */

.hover-lift {
  transition: transform 0.25s var(--ease-spring),
              box-shadow 0.25s var(--ease-spring);
  will-change: transform, box-shadow;
}

.hover-lift:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 48px rgba(26, 31, 46, 0.13), 0 6px 16px rgba(26, 31, 46, 0.08);
}

.hover-lift-sm {
  transition: transform 0.2s var(--ease-spring);
  will-change: transform;
}

.hover-lift-sm:hover {
  transform: translateY(-2px);
}

/* ====================================================
   HOVER GLOW — green accent glow on hover
   ==================================================== */

.hover-glow {
  transition: box-shadow 0.3s var(--ease-spring),
              transform 0.25s var(--ease-spring);
  will-change: transform, box-shadow;
}

.hover-glow:hover {
  box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15), 0 8px 32px rgba(45, 106, 79, 0.12);
  transform: translateY(-2px);
}

/* ====================================================
   BUTTON SHINE — shimmer on primary CTA hover
   ==================================================== */

.btn-shine {
  position: relative;
  overflow: hidden;
}

.btn-shine::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(255, 255, 255, 0.18) 50%,
    transparent 80%
  );
  transform: skewX(-15deg);
  transition: left 0s;
  pointer-events: none;
}

.btn-shine:hover::before {
  left: 160%;
  transition: left 0.55s var(--ease-out);
}

/* ====================================================
   NAV SCROLL STATE
   ==================================================== */

.nav-scrolled {
  box-shadow: 0 1px 20px rgba(26, 31, 46, 0.10) !important;
}

/* Active nav link highlight */
.nav-link-active {
  color: #2d6a4f !important;
  background: rgba(45, 106, 79, 0.07) !important;
  border-radius: 8px;
}

/* ====================================================
   SECTION DIVIDER LINE ANIMATION
   ==================================================== */

.reveal-line {
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #2d6a4f, #40916c, transparent);
  border-radius: 100px;
  transition: width 1.0s var(--ease-spring);
  will-change: width;
}

.reveal-line.is-visible {
  width: 60px;
}

/* ====================================================
   FLOATING / BREATHING DECORATION
   ==================================================== */

.float-slow {
  animation: floatY 6s ease-in-out infinite;
  will-change: transform;
}

.float-medium {
  animation: floatY 4.5s ease-in-out infinite;
  will-change: transform;
}

.float-fast {
  animation: floatY 3.5s ease-in-out infinite;
  will-change: transform;
}

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

.breathe {
  animation: breatheScale 5s ease-in-out infinite;
  will-change: transform, opacity;
}

@keyframes breatheScale {
  0%, 100% { opacity: 0.7; transform: scale(0.97); }
  50%       { opacity: 1;   transform: scale(1.03); }
}

/* ====================================================
   COUNTER ANIMATION (number stat scroll)
   ==================================================== */

.stat-number {
  display: inline-block;
  transition: none;
}

/* ====================================================
   PARALLAX WRAPPER
   (JS sets --parallax-y via CSS custom property)
   ==================================================== */

.parallax-bg {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ====================================================
   REDUCED MOTION — static fallback for everything
   ==================================================== */

@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  [data-stagger] > *,
  .hover-lift,
  .hover-lift-sm,
  .hover-glow,
  .reveal-line,
  .word-clip .word,
  .line-clip-reveal > .line-inner,
  .char-reveal .char,
  .float-slow,
  .float-medium,
  .float-fast,
  .breathe {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  .reveal-line {
    width: 60px !important;
  }

  [data-words] .word-clip .word,
  .line-clip-reveal.line-visible > .line-inner,
  .char-reveal.chars-visible .char {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ====================================================
   MOBILE — simplify for performance + no parallax
   ==================================================== */

@media (max-width: 640px) {
  [data-reveal] {
    transition-duration: 0.5s;
  }

  [data-reveal="left"],
  [data-reveal="right"] {
    /* Simplify horizontal reveals to vertical on mobile */
    transform: translateY(20px);
  }

  .float-slow,
  .float-medium,
  .float-fast {
    /* Reduce floating on mobile for battery */
    animation-duration: 8s;
  }
}
