/* Cecil Animations */

/* ─── Scan line ─── */
.scan-line {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(59, 130, 246, 0.08) 20%,
    rgba(59, 130, 246, 0.15) 50%,
    rgba(59, 130, 246, 0.08) 80%,
    transparent 100%
  );
  animation: scan-sweep 8s ease-in-out infinite;
  pointer-events: none;
  z-index: 9999;
}

@keyframes scan-sweep {
  0% {
    top: -2px;
    opacity: 0;
  }
  2% {
    opacity: 1;
  }
  90% {
    opacity: 0.6;
  }
  95% {
    top: 100vh;
    opacity: 0;
  }
  100% {
    top: 100vh;
    opacity: 0;
  }
}

/* ─── Background grid pattern ─── */
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(59, 130, 246, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 1;
}

/* Subtle radial vignette overlay */
.bg-grid::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(59, 130, 246, 0.04) 0%,
    transparent 60%
  );
}

/* ─── Critical badge pulse ─── */
@keyframes critical-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.6), 0 0 8px rgba(255, 59, 59, 0.3);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 59, 59, 0), 0 0 16px rgba(255, 59, 59, 0.5);
  }
}

.pulse-critical {
  animation: critical-pulse 2s ease infinite;
}

/* ─── Monitor heartbeat dot ─── */
@keyframes heartbeat-healthy {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
  }
}

@keyframes heartbeat-stale {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 214, 0, 0.6);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(255, 214, 0, 0);
  }
}

@keyframes heartbeat-error {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.7);
  }
  40% {
    box-shadow: 0 0 0 5px rgba(255, 59, 59, 0);
  }
  60% {
    box-shadow: 0 0 0 0 rgba(255, 59, 59, 0);
  }
}

.dot-healthy {
  animation: heartbeat-healthy 2.5s ease infinite;
}

.dot-stale {
  animation: heartbeat-stale 3s ease infinite;
}

.dot-error {
  animation: heartbeat-error 1.2s ease infinite;
}

/* ─── New item entrance ─── */
@keyframes item-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item-enter {
  animation: item-enter var(--transition-entrance) forwards;
}

/* Staggered children */
.item-enter-1 { animation: item-enter var(--transition-entrance) 50ms forwards; opacity: 0; }
.item-enter-2 { animation: item-enter var(--transition-entrance) 100ms forwards; opacity: 0; }
.item-enter-3 { animation: item-enter var(--transition-entrance) 150ms forwards; opacity: 0; }
.item-enter-4 { animation: item-enter var(--transition-entrance) 200ms forwards; opacity: 0; }
.item-enter-5 { animation: item-enter var(--transition-entrance) 250ms forwards; opacity: 0; }

/* ─── View transition ─── */
@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-enter {
  animation: view-enter 280ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ─── Expand/collapse ─── */
@keyframes expand-down {
  from {
    opacity: 0;
    max-height: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    max-height: 600px;
    transform: translateY(0);
  }
}

@keyframes collapse-up {
  from {
    opacity: 1;
    max-height: 600px;
  }
  to {
    opacity: 0;
    max-height: 0;
  }
}

.expand-enter {
  animation: expand-down 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow: hidden;
}

/* ─── Spinner ─── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--bg-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ─── Blink cursor ─── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.cursor-blink::after {
  content: '▊';
  animation: blink 1.2s step-end infinite;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* ─── Tooltip fade in ─── */
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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