/* ============================================================
   SPROAT SYSTEMS MOTION LAYER
   Scroll reveals, micro-interactions, and ambient animation.
   Loaded after style.css. Everything here is progressive
   enhancement:
   - Reveal-hidden states only apply under html.js, so content
     is fully visible without JavaScript.
   - prefers-reduced-motion collapses all of it (tokens.css
     zeroes durations globally; the .no-motion class set by
     motion.js prevents hidden states entirely).
   ============================================================ */

/* ------------------------------------------------------------
   SCROLL REVEALS
   motion.js tags elements with .reveal (+ optional direction)
   and flips .is-visible in an IntersectionObserver. Stagger is
   set per element via --reveal-delay.
   ------------------------------------------------------------ */
html.js:not(.no-motion) .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0s);
  will-change: opacity, transform;
}

html.js:not(.no-motion) .reveal--left  { transform: translateX(-32px); }
html.js:not(.no-motion) .reveal--right { transform: translateX(32px); }
html.js:not(.no-motion) .reveal--scale { transform: scale(0.96); }

html.js:not(.no-motion) .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ------------------------------------------------------------
   SCROLL PROGRESS BAR (created by motion.js)
   ------------------------------------------------------------ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--color-accent);
  z-index: 1200;
  pointer-events: none;
}

/* ------------------------------------------------------------
   HEADER: compact on scroll
   ------------------------------------------------------------ */
.site-header {
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.site-header .header-inner {
  transition: padding 0.3s ease;
}

.site-header.scrolled .header-inner {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* ------------------------------------------------------------
   PRIMARY BUTTON SHEEN
   A light sweep crosses the button once on hover/focus.
   ------------------------------------------------------------ */
.btn {
  position: relative;
  overflow: hidden;
}

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

.btn-primary:hover::before,
.btn-primary:focus-visible::before {
  left: 130%;
}

/* ------------------------------------------------------------
   CARD MICRO-INTERACTIONS
   Lift + accent border on hover; icon chips pop.
   ------------------------------------------------------------ */
.pricing-card,
.service-pillar-card,
.feature-card,
.pain-point-card,
.value-card,
.comparison-option {
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s ease,
    border-color 0.35s ease;
}

.pricing-card:hover,
.service-pillar-card:hover,
.feature-card:hover,
.pain-point-card:hover {
  transform: translateY(-6px);
}

.service-pillar-icon,
.pain-icon-placeholder,
.feature-icon,
.value-card-icon {
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.35s ease;
}

.service-pillar-card:hover .service-pillar-icon,
.pain-point-card:hover .pain-icon-placeholder,
.feature-card:hover .feature-icon,
.value-card:hover .value-card-icon {
  transform: translateY(-4px) scale(1.08) rotate(-3deg);
}

/* Arrow links slide their arrow on hover */
.service-pillar-link,
.split-cta-links a,
.home-hero-link {
  transition: color 0.25s ease, letter-spacing 0.25s ease;
}

.service-pillar-link:hover,
.split-cta-links a:hover,
.home-hero-link:hover {
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------
   HERO AMBIENT MOTION
   Soft accent glows drifting slowly behind hero sections.
   ------------------------------------------------------------ */
.home-hero,
.hero-minimal,
.hero-gradient,
.hero-pattern {
  position: relative;
  overflow: hidden;
}

.hero-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
  opacity: 0.5;
  z-index: 0;
  animation: hero-orb-drift 16s ease-in-out infinite alternate;
}

.hero-orb--a {
  width: 420px;
  height: 420px;
  top: -140px;
  right: -120px;
  background: rgba(59, 184, 196, 0.18);
}

.hero-orb--b {
  width: 320px;
  height: 320px;
  bottom: -160px;
  left: -100px;
  background: rgba(59, 184, 196, 0.10);
  animation-duration: 22s;
  animation-direction: alternate-reverse;
}

@keyframes hero-orb-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-48px, 36px, 0) scale(1.12); }
}

/* Keep hero content above the orbs */
.home-hero .container,
.hero-minimal .container,
.hero-gradient .container,
.hero-pattern .container {
  position: relative;
  z-index: 1;
}

/* Hero visual gently floats */
html.js:not(.no-motion) .home-hero-visual img,
html.js:not(.no-motion) .hero-pattern-visual .ai-call-phone {
  animation: hero-float 7s ease-in-out infinite;
}

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

/* Accent underline that draws itself in after reveal */
.accent-underline {
  position: relative;
  white-space: nowrap;
}

.accent-underline::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0.04em;
  height: 0.09em;
  width: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.5s;
}

html.no-js .accent-underline::after,
html:not(.js) .accent-underline::after,
.is-visible .accent-underline::after,
html.no-motion .accent-underline::after {
  transform: scaleX(1);
}

/* ------------------------------------------------------------
   FLOW LINE: draws when scrolled into view (was on-load)
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  html.js .flow-line .flow-line-path {
    stroke-dasharray: 240;
    stroke-dashoffset: 240;
    animation: none;
  }

  html.js .flow-line.is-visible .flow-line-path {
    animation: flow-line-draw 1.2s ease-out forwards;
  }

  html.js .flow-line .flow-line-node {
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  html.js .flow-line.is-visible .flow-line-node {
    opacity: 1;
  }

  html.js .flow-line.is-visible .flow-line-node:last-of-type {
    transition-delay: 1s;
  }
}

/* Timeline dots pulse once revealed */
html.js:not(.no-motion) .timeline-v-step.is-visible .timeline-v-dot {
  animation: dot-pulse 2.4s ease-out 0.6s 3;
}

@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59, 184, 196, 0.45); }
  70%  { box-shadow: 0 0 0 14px rgba(59, 184, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 184, 196, 0); }
}

/* ------------------------------------------------------------
   DASHBOARD MOCKUP: live feel
   Feed rows light up in sequence (class cycled by motion.js).
   ------------------------------------------------------------ */
.auto-dashboard__feed-list li {
  transition: background 0.45s ease, transform 0.45s ease;
  border-radius: 6px;
}

.auto-dashboard__feed-list li.feed-active {
  background: rgba(59, 184, 196, 0.12);
  transform: translateX(4px);
}

.auto-dashboard__stat {
  transition: transform 0.3s ease;
}

.auto-dashboard__stat:hover {
  transform: translateY(-3px);
}

/* ------------------------------------------------------------
   FAQ: smooth expand/collapse (replaces display:none toggle)
   ------------------------------------------------------------ */
html.js .faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  padding: 0;
  overflow: hidden;
  transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1), padding 0.4s ease;
}

html.js .faq-answer > * {
  min-height: 0;
  overflow: hidden;
}

html.js .faq-item.open .faq-answer {
  /* display beats the legacy .faq-item.open display:block rule */
  display: grid;
  grid-template-rows: 1fr;
  padding: 0 0 20px;
}

.faq-toggle {
  transition: transform 0.3s ease;
}

.faq-item.open .faq-toggle {
  transform: rotate(180deg);
}

.faq-item {
  transition: background 0.25s ease;
}

/* ------------------------------------------------------------
   COMPARISON TOTALS: subtle emphasis once counted up
   ------------------------------------------------------------ */
.comparison-total-amount {
  display: inline-block;
  transition: transform 0.3s ease;
}

.comparison-total-amount.counted {
  animation: total-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes total-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------
   ICON DRAW-IN
   Icon strokes draw themselves when their reveal card enters;
   accent nodes pop in after the line completes. pathLength=100
   normalizes every stroke to one rule.
   ------------------------------------------------------------ */
html.js:not(.no-motion) .reveal .sproat-icon .icon-draw {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.33, 1, 0.68, 1) 0.3s;
}

html.js:not(.no-motion) .reveal.is-visible .sproat-icon .icon-draw {
  stroke-dashoffset: 0;
}

html.js:not(.no-motion) .reveal .sproat-icon .icon-node {
  transform: scale(0);
  transform-origin: center;
  transform-box: fill-box;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 1s;
}

html.js:not(.no-motion) .reveal.is-visible .sproat-icon .icon-node {
  transform: scale(1);
}
