/* ============================================================
   EpiphanyMade — Animation System
   All keyframes, scroll-triggered classes, micro-interactions
   ============================================================ */

/* ----------------------------------------------------------
   SCROLL-TRIGGERED ANIMATIONS
   Works with main.js IntersectionObserver that adds .visible
   class to any .animate-in element when scrolled into view
   ---------------------------------------------------------- */

.animate-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1),
              transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}

.animate-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Slide from left — pair with animate-in: class="animate-in animate-in--left" */
.animate-in--left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1),
              transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}
.animate-in--left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide from right */
.animate-in--right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s cubic-bezier(0.19, 1, 0.22, 1),
              transform 0.6s cubic-bezier(0.19, 1, 0.22, 1);
}
.animate-in--right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Scale in */
.animate-in--scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.5s cubic-bezier(0.19, 1, 0.22, 1),
              transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.animate-in--scale.visible {
  opacity: 1;
  transform: scale(1);
}

/* Stagger children — add .stagger to parent, children get delayed */
.stagger > .animate-in:nth-child(1) { transition-delay: 0s; }
.stagger > .animate-in:nth-child(2) { transition-delay: 0.1s; }
.stagger > .animate-in:nth-child(3) { transition-delay: 0.2s; }
.stagger > .animate-in:nth-child(4) { transition-delay: 0.3s; }
.stagger > .animate-in:nth-child(5) { transition-delay: 0.4s; }
.stagger > .animate-in:nth-child(6) { transition-delay: 0.5s; }
.stagger > .animate-in:nth-child(7) { transition-delay: 0.6s; }
.stagger > .animate-in:nth-child(8) { transition-delay: 0.7s; }

/* ----------------------------------------------------------
   KEYFRAME DEFINITIONS
   ---------------------------------------------------------- */

/* Floating drift — organic, slow movement for accent elements */
@keyframes float-drift {
  0%   { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(8px, -12px) rotate(5deg); }
  50%  { transform: translate(-5px, 8px) rotate(-3deg); }
  75%  { transform: translate(10px, 5px) rotate(2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

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

/* Scroll indicator bounce */
@keyframes scroll-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%       { transform: translateY(8px); opacity: 1; }
}

/* Pulse glow — for interactive elements */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.3); }
  50%       { box-shadow: 0 0 20px 6px rgba(8, 145, 178, 0.12); }
}

@keyframes pulse-glow-lime {
  0%, 100% { box-shadow: 0 0 0 0 rgba(132, 204, 22, 0.3); }
  50%       { box-shadow: 0 0 20px 6px rgba(132, 204, 22, 0.15); }
}

/* Data enrichment cell animations */
@keyframes cell-fill {
  0%   { background: rgba(8, 145, 178, 0.2); }
  100% { background: transparent; }
}

@keyframes cell-pulse {
  0%, 100% { background: rgba(8, 145, 178, 0.04); }
  50%       { background: rgba(8, 145, 178, 0.12); }
}

/* Spin for loaders */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shimmer for skeleton loading */
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* Typing dots bounce */
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%            { transform: translateY(-6px); }
}

/* Chatbot toggle pulse */
@keyframes chatbot-pulse {
  0%   { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(132,204,22,0.5); }
  70%  { transform: scale(1.3); opacity: 0.7; box-shadow: 0 0 0 8px rgba(132,204,22,0); }
  100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(132,204,22,0); }
}

/* Chatbot outer ring pulse */
@keyframes chatbot-ring {
  0%   { box-shadow: 0 4px 24px rgba(8,145,178,0.45), 0 0 0 0 rgba(8,145,178,0.15); }
  60%  { box-shadow: 0 4px 24px rgba(8,145,178,0.45), 0 0 0 14px rgba(8,145,178,0); }
  100% { box-shadow: 0 4px 24px rgba(8,145,178,0.45), 0 0 0 0 rgba(8,145,178,0); }
}

/* Mic active pulse */
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4); }
  70%       { box-shadow: 0 0 0 14px rgba(8, 145, 178, 0); }
}

/* Waveform bars for voice demo */
@keyframes waveform-bar {
  0%, 100% { transform: scaleY(0.3); }
  50%       { transform: scaleY(1); }
}

/* Gradient border glow shift */
@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* n8n-style flow: node reveal (staggered left-to-right) */
@keyframes wf-node-reveal {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* n8n-style flow: connector draws in from left */
@keyframes wf-connector-draw {
  from { opacity: 0; transform: scaleX(0); }
  to   { opacity: 1; transform: scaleX(1); }
}

/* Dot traveling along dashed connector (Children's Services) */
@keyframes flow-dot-travel {
  0%   { left: 0; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { left: calc(100% - 6px); opacity: 0; }
}

/* Data packet traveling along gradient connector (Data Pipeline) */
@keyframes data-packet-flow {
  0%   { left: 0; opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.8; }
  100% { left: calc(100% - 8px); opacity: 0; }
}

/* Badge fade-in (e.g., "1,200 → 340") */
@keyframes wf-badge-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Pulse ring on healthcare trigger node (bright for dark bg) */
@keyframes wf-trigger-pulse {
  0%, 100% { box-shadow: 0 2px 16px rgba(8,145,178,0.12), 0 0 0 0 rgba(8,145,178,0.4); }
  50%      { box-shadow: 0 2px 16px rgba(8,145,178,0.12), 0 0 0 12px rgba(8,145,178,0); }
}

/* @property needed for CSS custom property animation (Chrome 85+, Safari 15.4+, FF 128+) */
/* Older browsers show a static gradient ring on hover — still looks nice as fallback */
@property --beam-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

/* Border beam — conic gradient rotating around card border */
@keyframes border-beam {
  to { --beam-angle: 360deg; }
}

/* Branch fan-out reveal — slides from left (behind connector) */
@keyframes wf-branch-reveal {
  from { opacity: 0; transform: translateX(10px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* Connector glow pulse — subtle pulse on connector lines */
@keyframes connector-glow-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(8,145,178,0.2); }
  50%      { box-shadow: 0 0 14px rgba(8,145,178,0.4); }
}

/* Teal cell flash when data fills in */
@keyframes cell-flash {
  0%   { opacity: 0; background: rgba(8,145,178,0.3); }
  35%  { opacity: 1; background: rgba(8,145,178,0.15); }
  100% { opacity: 1; background: transparent; }
}

/* Slide in from bottom (email response) */
@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------------------------
   COMPONENT ANIMATION CLASSES
   ---------------------------------------------------------- */

/* Loading spinner */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(8, 145, 178, 0.2);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner--lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* Floating accent dots */
.accent-dot {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}

.accent-dot--1 {
  width: 6px; height: 6px;
  background: var(--color-teal-light);
  animation: float-drift 8s ease-in-out infinite;
}
.accent-dot--2 {
  width: 4px; height: 4px;
  background: var(--color-lime);
  animation: float-drift 11s ease-in-out infinite reverse;
}
.accent-dot--3 {
  width: 8px; height: 8px;
  border: 1px solid rgba(8, 145, 178, 0.3);
  background: transparent;
  animation: float-drift 14s ease-in-out infinite;
}
.accent-dot--4 {
  width: 5px; height: 5px;
  background: rgba(132, 204, 22, 0.4);
  animation: float-drift 9s ease-in-out infinite;
  animation-delay: -3s;
}

/* Waveform bars */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
}

.waveform__bar {
  width: 3px;
  height: 100%;
  background: var(--color-teal);
  border-radius: 2px;
  transform-origin: bottom;
  transform: scaleY(0.3);
}


/* Email response slide in */
.slide-up {
  animation: slide-up 0.4s cubic-bezier(0.19, 1, 0.22, 1) both;
}

/* ----------------------------------------------------------
   SECTION BADGE LABELS
   ---------------------------------------------------------- */

.section-label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-teal);
  margin-bottom: 12px;
  padding: 4px 12px;
  border: 1px solid rgba(8, 145, 178, 0.25);
  border-radius: 20px;
  background: rgba(8, 145, 178, 0.05);
}

.section-label--light {
  color: var(--color-teal-light);
  border-color: rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.08);
}

.section-label--lime {
  color: var(--color-lime);
  border-color: rgba(132, 204, 22, 0.3);
  background: rgba(132, 204, 22, 0.05);
}

/* ----------------------------------------------------------
   GRADIENT BORDER CARD TECHNIQUE
   Used for quiz card, intake card, etc.
   ---------------------------------------------------------- */

.gradient-border {
  position: relative;
}


/* ----------------------------------------------------------
   REDUCED MOTION OVERRIDES
   ---------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .animate-in,
  .animate-in--left,
  .animate-in--right,
  .animate-in--scale {
    opacity: 1;
    transform: none;
    transition-duration: 0.01ms;
  }

  .accent-dot,
  .waveform__bar {
    animation: none !important;
  }

  .spinner {
    animation-duration: 1.5s;
  }

  /* Workflow flow elements: show immediately with no animation */
  .wf-flow__node,
  .wf-flow__branch,
  .wf-flow__connector,
  .wf-flow__connector-dot,
  .wf-flow__connector-packet,
  .wf-flow__connector-badge {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }

  /* Disable border beam rotation */
  .wf-flow::before {
    animation: none !important;
    opacity: 0 !important;
  }

  @keyframes float-drift { to {} }
  @keyframes float-slow { to {} }
  @keyframes scroll-bounce { to {} }
}
