/* ═══════════════════════════════════════════════════════
   ChronoForge Pulse — Animations & Dynamic UI
   ═══════════════════════════════════════════════════════ */

/* ─── PAGE LOAD FADE-IN ─── */
@keyframes cfp-page-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cfp-page-enter {
  animation: cfp-page-fade-in 0.55s var(--ease-out-expo) both;
}

/* ─── CARD HOVER LIFT ─── */
.card-lift {
  transition: transform 0.22s var(--ease-out-quart),
              box-shadow 0.22s var(--ease-out-quart);
}
.card-lift:hover {
  transform: translateY(-5px) scale(1.008);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border-hover);
}

/* ─── GLASSMORPHISM PANELS ─── */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

/* ─── SKELETON LOADING ─── */
@keyframes cfp-skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton,
.skeleton-block,
.skeleton-row {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    rgba(56, 189, 248, 0.07) 50%,
    var(--bg-card) 75%
  );
  background-size: 800px 100%;
  animation: cfp-skeleton-shimmer 1.6s infinite linear;
  border-radius: 6px;
}
.skeleton-block { height: 120px; width: 100%; margin-bottom: 12px; }
.skeleton-row   { height: 18px;  width: 100%; margin-bottom: 8px; }
.skeleton-row:last-child { width: 60%; }

/* ─── CHAT MESSAGE SLIDE-IN ─── */
@keyframes cfp-slide-in-right {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes cfp-slide-in-left {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}
.chat-msg.user     { animation: cfp-slide-in-right 0.28s var(--ease-out-quart) both; }
.chat-msg.assistant { animation: cfp-slide-in-left  0.28s var(--ease-out-quart) both; }

/* ─── STATUS DOT PULSE ─── */
@keyframes cfp-pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
  70%  { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.chat-status-dot.connected {
  animation: cfp-pulse-ring 2s ease-out infinite;
}

/* ─── SEND BUTTON SPINNER ─── */
@keyframes cfp-spin {
  to { transform: rotate(360deg); }
}
.chat-send-btn.loading svg {
  display: none;
}
.chat-send-btn.loading::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: cfp-spin 0.7s linear infinite;
}

/* ─── GENERIC SPINNER ─── */
.cfp-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(56, 189, 248, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: cfp-spin 0.75s linear infinite;
}

/* ─── COUNTER ANIMATION FLASH ─── */
@keyframes cfp-counter-flash {
  0%, 100% { color: inherit; }
  50% { color: var(--accent); }
}
.cfp-counter-updated {
  animation: cfp-counter-flash 0.5s ease;
}

/* ─── BUTTON RIPPLE ─── */
.cfp-ripple {
  position: relative;
  overflow: hidden;
}
.cfp-ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transform: scale(0);
  animation: cfp-ripple-anim 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes cfp-ripple-anim {
  to { transform: scale(2.5); opacity: 0; }
}

/* ─── BACK-TO-TOP BUTTON ─── */
#cfpBackToTop {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
#cfpBackToTop.visible {
  opacity: 1;
  pointer-events: auto;
}
#cfpBackToTop:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.2);
}

/* ─── TYPING INDICATOR WAVE ─── */
@keyframes cfp-typing-wave {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}
.chat-typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin: 0 2px;
  animation: cfp-typing-wave 1.2s infinite ease-in-out;
}
.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ─── TOAST DOT INDICATOR ─── */
.cfp-toast-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
  background: currentColor;
}
.cfp-toast.success .cfp-toast-dot { background: var(--success); }
.cfp-toast.error   .cfp-toast-dot { background: var(--danger); }
.cfp-toast.info    .cfp-toast-dot { background: var(--accent); }
.cfp-toast.warning .cfp-toast-dot { background: var(--warning); }

/* ─── FOCUS GLOW ─── */
.chat-input:focus,
.chat-setting-select:focus,
input:focus,
textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
  transition: box-shadow 0.18s ease;
}

/* ─── CHART ENTRANCE ─── */
@keyframes cfp-chart-in {
  from { opacity: 0; transform: scaleY(0.92) translateY(8px); }
  to   { opacity: 1; transform: scaleY(1) translateY(0); }
}
.chat-chart-wrap {
  animation: cfp-chart-in 0.45s var(--ease-out-quart) both;
  transform-origin: bottom center;
}

/* ─── STARTER BUTTON STAGGER ─── */
.chat-starter-btn {
  opacity: 0;
  transform: translateY(8px);
  animation: cfp-page-fade-in 0.35s var(--ease-out-quart) both;
}
.chat-starter-btn:nth-child(1) { animation-delay: 0.05s; }
.chat-starter-btn:nth-child(2) { animation-delay: 0.10s; }
.chat-starter-btn:nth-child(3) { animation-delay: 0.15s; }
.chat-starter-btn:nth-child(4) { animation-delay: 0.20s; }
.chat-starter-btn:nth-child(5) { animation-delay: 0.25s; }
.chat-starter-btn:nth-child(6) { animation-delay: 0.30s; }

/* ─── NAV LOGO HOVER GLOW ─── */
.nav-logo:hover .nav-logo-icon,
.fp-logo:hover .fp-logo-icon {
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
  transition: box-shadow 0.25s ease;
}

/* ─── CHAT WELCOME ICON BREATHE ─── */
@keyframes cfp-breathe {
  0%, 100% { transform: scale(1);    opacity: 0.85; }
  50%       { transform: scale(1.08); opacity: 1; }
}
.chat-welcome-icon {
  animation: cfp-breathe 3s ease-in-out infinite;
}

/* ─── API ENDPOINT HOVER ─── */
.api-endpoint {
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.api-endpoint:hover {
  transform: translateX(4px);
  border-left: 3px solid var(--accent);
}

/* ─── HERO BADGE DOT PULSE ─── */
@keyframes cfp-badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.hero-badge-dot {
  animation: cfp-badge-pulse 1.8s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════
   FLASHY EFFECTS — MAXIMALLY IMPRESSIVE VISUAL SUITE
   ═══════════════════════════════════════════════════════ */

/* ─── A. ANIMATED AURORA / GRADIENT BACKGROUND ─── */
@keyframes cfp-aurora {
  0%   { background-position: 0% 50%; }
  33%  { background-position: 60% 80%; }
  66%  { background-position: 100% 20%; }
  100% { background-position: 0% 50%; }
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(56, 189, 248, 0.028) 20%,
    rgba(6, 182, 212, 0.022) 40%,
    rgba(99, 102, 241, 0.018) 60%,
    rgba(56, 189, 248, 0.025) 80%,
    transparent 100%
  );
  background-size: 300% 300%;
  animation: cfp-aurora 14s ease-in-out infinite;
}

/* ─── B. NEON GLOW TEXT EFFECT ─── */
@keyframes cfp-neon-pulse {
  0%, 100% {
    text-shadow:
      0 0 8px  rgba(56, 189, 248, 0.75),
      0 0 18px rgba(56, 189, 248, 0.50),
      0 0 38px rgba(56, 189, 248, 0.28);
  }
  50% {
    text-shadow:
      0 0 14px rgba(56, 189, 248, 1.00),
      0 0 30px rgba(56, 189, 248, 0.80),
      0 0 60px rgba(56, 189, 248, 0.50),
      0 0 90px rgba(6,  182, 212, 0.30);
  }
}
.cfp-neon {
  animation: cfp-neon-pulse 2.5s ease-in-out infinite;
}

/* ─── C. PURE CSS FLOATING PARTICLES ─── */
/*
   Strategy: 12 <span class="cfp-p"> children inside .cfp-particles,
   each sized and timed differently via nth-child selectors.
   The container itself is position:absolute and covers the hero.
*/
.cfp-particles {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

@keyframes cfp-float-up {
  0%   { transform: translateY(0)   translateX(0)    scale(1);   opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 0.6; }
  100% { transform: translateY(-110vh) translateX(var(--drift)) scale(0.6); opacity: 0; }
}

.cfp-particles .cfp-p {
  position: absolute;
  bottom: -10%;
  width: var(--sz, 4px);
  height: var(--sz, 4px);
  border-radius: 50%;
  background: rgba(56, 189, 248, var(--op, 0.55));
  box-shadow: 0 0 calc(var(--sz, 4px) * 2) rgba(56, 189, 248, 0.6);
  animation: cfp-float-up var(--dur, 9s) var(--delay, 0s) ease-in infinite;
  --drift: 0px;
}

/* Particle positions, sizes, speeds, drifts */
.cfp-particles .cfp-p:nth-child(1)  { left: 8%;  --sz: 3px;  --op: 0.5; --dur: 8s;  --delay: 0s;    --drift: 20px; }
.cfp-particles .cfp-p:nth-child(2)  { left: 16%; --sz: 5px;  --op: 0.7; --dur: 12s; --delay: 1.2s;  --drift: -30px; }
.cfp-particles .cfp-p:nth-child(3)  { left: 24%; --sz: 2px;  --op: 0.4; --dur: 7s;  --delay: 2.4s;  --drift: 15px; }
.cfp-particles .cfp-p:nth-child(4)  { left: 32%; --sz: 6px;  --op: 0.6; --dur: 10s; --delay: 0.6s;  --drift: -20px; }
.cfp-particles .cfp-p:nth-child(5)  { left: 42%; --sz: 3px;  --op: 0.5; --dur: 9s;  --delay: 3.0s;  --drift: 40px; }
.cfp-particles .cfp-p:nth-child(6)  { left: 51%; --sz: 4px;  --op: 0.65;--dur: 11s; --delay: 1.8s;  --drift: -25px; }
.cfp-particles .cfp-p:nth-child(7)  { left: 60%; --sz: 2px;  --op: 0.4; --dur: 7.5s;--delay: 4.2s;  --drift: 10px; }
.cfp-particles .cfp-p:nth-child(8)  { left: 68%; --sz: 5px;  --op: 0.6; --dur: 13s; --delay: 0.3s;  --drift: -35px; }
.cfp-particles .cfp-p:nth-child(9)  { left: 76%; --sz: 3px;  --op: 0.5; --dur: 8.5s;--delay: 2.1s;  --drift: 18px; }
.cfp-particles .cfp-p:nth-child(10) { left: 83%; --sz: 6px;  --op: 0.7; --dur: 10.5s;--delay:3.6s;  --drift: -12px; }
.cfp-particles .cfp-p:nth-child(11) { left: 90%; --sz: 2px;  --op: 0.4; --dur: 6.5s;--delay: 5.0s;  --drift: 22px; }
.cfp-particles .cfp-p:nth-child(12) { left: 96%; --sz: 4px;  --op: 0.55;--dur: 9.5s;--delay: 1.5s;  --drift: -18px; }

/* ─── D. SCAN-LINE / HUD EFFECT ON CARDS ─── */
.card-lift {
  position: relative;
  overflow: hidden;
}
@keyframes cfp-scanline {
  0%   { transform: translateY(-100%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}
.card-lift::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(56, 189, 248, 0.5),
    rgba(6, 182, 212, 0.8),
    rgba(56, 189, 248, 0.5),
    transparent
  );
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  animation: cfp-scanline 3.5s linear infinite;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
}
.card-lift:hover::after {
  opacity: 1;
}

/* ─── E. WORD-BY-WORD REVEAL (wraps naturally, no layout break) ─── */
.cfp-typewriter-wrap {
  display: block;
  max-width: 100%;
}
.cfp-typewriter {
  display: block;
  white-space: normal;    /* allow text to wrap at container width */
  max-width: 100%;
}
@keyframes cfp-word-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cfp-word {
  display: inline-block;
  opacity: 0;
  animation: cfp-word-in 0.35s ease forwards;
}
/* Cursor blinks after last word */
.cfp-word.last::after {
  content: '|';
  margin-left: 2px;
  color: var(--accent);
  animation: cfp-cursor-blink 0.8s step-end infinite;
}
@keyframes cfp-cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
/* Remove cursor after 4s */
.cfp-word.last.done::after {
  display: none;
}

/* ─── F. GLITCH EFFECT ON LOGO HOVER ─── */
@keyframes cfp-glitch-1 {
  0%   { text-shadow: none; }
  20%  { text-shadow: -2px 0 rgba(255, 0, 80,  0.7), 2px 0 rgba(0, 220, 255, 0.7); clip-path: inset(10% 0 70% 0); }
  40%  { text-shadow:  2px 0 rgba(255, 0, 80,  0.7),-2px 0 rgba(0, 220, 255, 0.7); clip-path: inset(50% 0 20% 0); }
  60%  { text-shadow: -3px 0 rgba(255, 0, 80,  0.5), 3px 0 rgba(0, 220, 255, 0.5); clip-path: inset(30% 0 50% 0); }
  80%  { text-shadow:  1px 0 rgba(255, 0, 80,  0.7),-1px 0 rgba(0, 220, 255, 0.7); clip-path: inset(70% 0 5%  0); }
  100% { text-shadow: none; clip-path: none; }
}
@keyframes cfp-glitch-2 {
  0%   { transform: translate(0); }
  25%  { transform: translate(-2px, 1px) skewX(-1deg); }
  50%  { transform: translate(2px, -1px) skewX(1deg); }
  75%  { transform: translate(-1px, 2px); }
  100% { transform: translate(0); }
}
.nav-logo:hover {
  animation: cfp-glitch-2 0.35s steps(2, end) infinite;
}
.nav-logo:hover span {
  animation: cfp-glitch-1 0.35s steps(2, end) infinite;
}

/* ─── G. MAGNETIC BUTTON HOVER ─── */
.btn-primary {
  transition:
    transform  0.15s var(--ease-out-quart),
    box-shadow 0.15s ease,
    background 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 0 24px rgba(56, 189, 248, 0.45),
    0 0 48px rgba(56, 189, 248, 0.20),
    0 8px 32px rgba(0, 0, 0, 0.35);
}
.btn-primary:active {
  transform: translateY(-1px) scale(1.01);
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.35),
    0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ─── H. CHAT MESSAGE GLOW ON NEW MESSAGE ─── */
@keyframes cfp-msg-glow {
  0%   { box-shadow: 0 0 0 0   rgba(56, 189, 248, 0.5); }
  40%  { box-shadow: 0 0 22px 6px rgba(56, 189, 248, 0.18); }
  100% { box-shadow: none; }
}
.chat-msg-bubble.new {
  animation: cfp-msg-glow 1.1s ease-out forwards;
}

/* ─── I. PULSING GRID BACKGROUND ON HERO ─── */
@keyframes cfp-grid-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 1.00; }
}
.hero {
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: cfp-grid-pulse 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* ─── J. TOP PAGE LOADING BAR ─── */
@keyframes cfp-topbar-load {
  0%   { width: 0%;   opacity: 1; }
  65%  { width: 82%;  opacity: 1; }
  90%  { width: 98%;  opacity: 1; }
  100% { width: 100%; opacity: 0; }
}
#cfpTopLoader {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--pulse), var(--accent));
  background-size: 200% 100%;
  box-shadow:
    0 0 10px var(--accent),
    0 0 20px rgba(56, 189, 248, 0.4);
  animation:
    cfp-topbar-load     1.4s ease-out 0.05s both,
    cfp-aurora          3s   linear   infinite;
  pointer-events: none;
}

/* ─── REDUCE MOTION ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
