/*
 * ╔══════════════════════════════════════════════════════════════╗
 * ║  XEYROSHEN — Your Own AI Model                              ║
 * ║  Codename: Rewire                                            ║
 * ║  © Adeshjeet_Official 2025 — All Rights Reserved            ║
 * ║  File: css/animations.css — All Animations & Keyframes      ║
 * ╚══════════════════════════════════════════════════════════════╝
 */

/* ─── Typewriter Effect ──────────────────────────────────────── */
.typewriter {
  font-family:  var(--font-display);
  font-size:    clamp(1.6rem, 4vw, 2.8rem);
  font-weight:  800;
  color:        var(--text-primary);
  white-space:  nowrap;
  overflow:     hidden;
  letter-spacing: -0.03em;
}

.typewriter-line {
  display:    block;
  overflow:   hidden;
  white-space: nowrap;
  opacity:    0;
  max-width:  0;
  animation:  typeReveal 0s forwards;
}

@keyframes typeReveal {
  to {
    opacity:   1;
    max-width: 100%;
  }
}

/* Blinking cursor */
.typewriter-cursor {
  display:          inline-block;
  width:            3px;
  height:           1.1em;
  background:       var(--accent);
  margin-left:      2px;
  vertical-align:   middle;
  border-radius:    2px;
  animation:        cursorBlink 1.1s infinite;
}

@keyframes cursorBlink {
  0%, 45% { opacity: 1; }
  55%, 100% { opacity: 0; }
}

/* ─── AI Writing Animation (Message Streams In) ──────────────── */
.writing-animation {
  position: relative;
}

.writing-animation::after {
  content:       '';
  display:       inline-block;
  width:         2px;
  height:        1em;
  background:    var(--accent);
  margin-left:   2px;
  vertical-align: bottom;
  border-radius: 1px;
  animation:     writingCursor 0.7s infinite;
}

.writing-animation.done::after {
  display: none;
}

@keyframes writingCursor {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ─── Thinking Animation ─────────────────────────────────────── */
.thinking-animation {
  display:     inline-flex;
  align-items: center;
  gap:         6px;
  padding:     var(--space-2) var(--space-4);
  background:  var(--accent-dim);
  border:      1px solid var(--border-accent);
  border-radius: var(--radius-pill);
}

.thinking-animation .think-text {
  font-size:  0.8rem;
  color:      var(--accent);
  font-family: var(--font-mono);
  animation:  thinkTextFade 2.5s infinite;
}

@keyframes thinkTextFade {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1;   }
}

/* Brainwave animation SVG bars */
.brainwave {
  display:     inline-flex;
  align-items: center;
  gap:         2px;
  height:      18px;
}

.brainwave span {
  display:       block;
  width:         3px;
  border-radius: 2px;
  background:    var(--accent);
  animation:     waveBar 1.2s infinite ease-in-out;
}

.brainwave span:nth-child(1) { height: 6px;  animation-delay: 0.0s; }
.brainwave span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.brainwave span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.brainwave span:nth-child(4) { height: 10px; animation-delay: 0.3s; }
.brainwave span:nth-child(5) { height: 14px; animation-delay: 0.15s; }
.brainwave span:nth-child(6) { height: 8px;  animation-delay: 0.25s; }

@keyframes waveBar {
  0%, 100% { transform: scaleY(0.3); opacity: 0.4; }
  50%      { transform: scaleY(1.0); opacity: 1.0; }
}

/* ─── Fade Animations ─────────────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.3s ease forwards;
}
.fade-in-up {
  opacity:   0;
  animation: fadeInUp 0.4s ease forwards;
}
.fade-in-down {
  opacity:   0;
  animation: fadeInDown 0.3s ease forwards;
}

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

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0);     }
}

/* Stagger helper classes */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.30s; }
.delay-7 { animation-delay: 0.40s; }
.delay-8 { animation-delay: 0.50s; }

/* ─── Slide Animations ────────────────────────────────────────── */
.slide-in-right {
  animation: slideInRight 0.35s var(--transition-bounce) forwards;
}
.slide-in-left {
  animation: slideInLeft 0.35s var(--transition-bounce) forwards;
}

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

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

/* ─── Scale / Pop Animations ─────────────────────────────────── */
.pop-in {
  animation: popIn 0.3s var(--transition-bounce) forwards;
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ─── Pulse / Glow ────────────────────────────────────────────── */
.pulse-glow {
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 0 8px transparent; }
}

/* Pulse ring (for mic button active state) */
.pulse-ring {
  position: relative;
}
.pulse-ring::before {
  content:       '';
  position:      absolute;
  inset:         -4px;
  border-radius: inherit;
  border:        2px solid var(--accent);
  animation:     pulseRing 1.5s infinite;
}

@keyframes pulseRing {
  0%   { transform: scale(1);    opacity: 0.8; }
  100% { transform: scale(1.35); opacity: 0;   }
}

/* ─── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width:         24px;
  height:        24px;
  border:        2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation:     spin 0.7s linear infinite;
  flex-shrink:   0;
}

.spinner-sm {
  width:  16px;
  height: 16px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Shimmer (Loading Skeleton) ─────────────────────────────── */
.shimmer {
  background:          var(--surface-2);
  background-image:    linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size:  200% 100%;
  animation:        shimmerSlide 1.4s infinite;
  border-radius:    var(--radius-md);
}

@keyframes shimmerSlide {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ─── File Upload Drop Zone ──────────────────────────────────── */
.drop-zone {
  border:        2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding:       var(--space-8);
  text-align:    center;
  transition:    all var(--transition-base);
  cursor:        pointer;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color:   var(--accent);
  background:     var(--accent-dim);
  transform:      scale(1.01);
}
.drop-zone.drag-over {
  animation: dropPulse 0.5s infinite alternate;
}

@keyframes dropPulse {
  from { border-color: var(--accent); }
  to   { border-color: var(--accent-light); }
}

/* ─── AI "Thoughts" Marquee / Fade-Cycle ────────────────────── */
.thoughts-container {
  position:   relative;
  overflow:   hidden;
  height:     1.6em;
}

.thought-item {
  position:   absolute;
  inset:      0;
  opacity:    0;
  transform:  translateY(8px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  text-align: center;
  color:      var(--text-muted);
  font-style: italic;
  font-size:  0.9rem;
}

.thought-item.active {
  opacity:   1;
  transform: translateY(0);
}

/* ─── Voice Wave (mic active indicator) ─────────────────────── */
.voice-wave {
  display:     flex;
  align-items: center;
  gap:         3px;
  padding:     4px 8px;
}

.voice-wave span {
  width:         3px;
  background:    var(--accent);
  border-radius: var(--radius-pill);
  animation:     voiceWave 1s infinite ease-in-out;
}

.voice-wave span:nth-child(1) { height: 4px;  animation-delay: 0.0s; }
.voice-wave span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { height: 20px; animation-delay: 0.05s; }
.voice-wave span:nth-child(4) { height: 14px; animation-delay: 0.15s; }
.voice-wave span:nth-child(5) { height: 6px;  animation-delay: 0.08s; }

@keyframes voiceWave {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(1.2); }
}

/* ─── Training Progress Bar ──────────────────────────────────── */
.progress-bar {
  width:         100%;
  height:        4px;
  background:    var(--surface-3);
  border-radius: var(--radius-pill);
  overflow:      hidden;
}

.progress-fill {
  height:     100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
  position:   relative;
  overflow:   hidden;
}

.progress-fill::after {
  content:    '';
  position:   absolute;
  inset:      0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
  background-size: 200% 100%;
  animation:  shimmerSlide 1.2s infinite;
}

/* ─── Knowledge Node appearing ───────────────────────────────── */
.node-appear {
  animation: nodeAppear 0.4s var(--transition-bounce) forwards;
}

@keyframes nodeAppear {
  from { transform: scale(0) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

/* ─── Reduce Motion Override ─────────────────────────────────── */
@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;
  }
}
