/* ============================================================
   ANIMATIONS.CSS — Progress fills, pulses, glows, transitions
   ============================================================ */

/* ── Keyframes ── */

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes pulse-red {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(248,81,73,0.4); }
  50%      { opacity: 0.85; box-shadow: 0 0 8px 4px rgba(248,81,73,0.15); }
}

@keyframes pulse-yellow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes shimmer {
  0%      { background-position: -200% 0; }
  100%    { background-position: 200% 0; }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(-4px); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes progress-stripe {
  0%      { background-position: 0 0; }
  100%    { background-position: 30px 0; }
}

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

@keyframes glow-cyan {
  0%, 100% { box-shadow: 0 0 4px rgba(57,210,224,0.1); }
  50%      { box-shadow: 0 0 12px rgba(57,210,224,0.25); }
}

@keyframes row-enter {
  from {
    opacity: 0;
    background-color: rgba(57, 210, 224, 0.06);
  }
  to {
    opacity: 1;
    background-color: transparent;
  }
}

@keyframes row-fail {
  0%   { background-color: transparent; }
  15%  { background-color: rgba(248, 81, 73, 0.12); }
  30%  { background-color: rgba(248, 81, 73, 0.04); }
  45%  { background-color: rgba(248, 81, 73, 0.10); }
  60%  { background-color: rgba(248, 81, 73, 0.02); }
  100% { background-color: transparent; }
}

@keyframes row-complete {
  0%   { background-color: transparent; }
  20%  { background-color: rgba(63, 185, 80, 0.08); }
  100% { background-color: transparent; }
}

/* ── Animation Classes ── */

/* Status dot pulses */
.cluster-status-badge--operational .cluster-status-badge__dot {
  animation: pulse-green 2s ease-in-out infinite;
}

.cluster-status-badge--degraded .cluster-status-badge__dot {
  animation: pulse-yellow 1.5s ease-in-out infinite;
}

.cluster-status-badge--fatal .cluster-status-badge__dot {
  animation: pulse-red 1s ease-in-out infinite;
}

/* Progress bar striped animation for running jobs */
.progress-bar__fill--R::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    rgba(255,255,255,0.06) 6px,
    rgba(255,255,255,0.06) 12px
  );
  background-size: 30px 30px;
  animation: progress-stripe 0.8s linear infinite;
}

/* Pending jobs — shimmer to show waiting */
.progress-bar__fill--PD::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(210, 153, 34, 0.15) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

/* Table row animations */
.job-table tbody tr.row-new {
  animation: row-enter 0.6s var(--ease-out) forwards;
}

.job-table tbody tr.row-failed {
  animation: row-fail 1.2s var(--ease-out) forwards;
}

.job-table tbody tr.row-completed {
  animation: row-complete 0.8s var(--ease-out) forwards;
}

/* Modal transitions */
.modal-overlay {
  transition: opacity var(--duration-normal) var(--ease-out),
              visibility var(--duration-normal);
}

.modal-overlay--active .modal {
  animation: fade-in 0.25s var(--ease-out) forwards;
}

/* Glow on running job rows */
.job-table tbody tr:has(.state-badge--R) {
  animation: glow-cyan 3s ease-in-out infinite;
}

/* Fallback for browsers without :has() */
.job-table tbody tr.row-running {
  animation: glow-cyan 3s ease-in-out infinite;
}

/* Blink for cursor in header */
.blink-cursor::after {
  content: '█';
  animation: blink 1s step-end infinite;
  color: var(--c-cyan);
  margin-left: 2px;
}

/* Fade in for stat cards */
.stat-card {
  animation: fade-in 0.4s var(--ease-out) forwards;
}

.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }
.stat-card:nth-child(4) { animation-delay: 0.24s; }

/* Node grid cell transitions */
.node-grid__cell {
  transition: background var(--duration-slow) var(--ease-out),
              box-shadow var(--duration-slow) var(--ease-out);
}

.node-grid__cell--running {
  box-shadow: 0 0 4px rgba(57, 210, 224, 0.2);
}

.node-grid__cell--failed {
  box-shadow: 0 0 4px rgba(248, 81, 73, 0.2);
}

/* Button press feedback */
.btn:active {
  transition-duration: 60ms;
}

/* Smooth row removal */
.job-table tbody tr.row-removing {
  animation: fade-out 0.3s var(--ease-out) forwards;
}

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

