/* ── NetMap — Animations ── */

/* ── Input Card Entrance ── */
.input-card {
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Hop Marker Pulse ── */
.hop-marker {
  position: relative;
}

.hop-marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--hop);
  border: 2px solid rgba(34, 197, 94, 0.4);
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

.hop-marker:hover .hop-marker-dot {
  transform: scale(1.3);
}

.hop-marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.3);
  animation: markerPulse 2s ease-out infinite;
  z-index: 1;
}

@keyframes markerPulse {
  0% {
    width: 12px;
    height: 12px;
    opacity: 0.6;
  }
  100% {
    width: 36px;
    height: 36px;
    opacity: 0;
  }
}

/* Source marker */
.hop-marker-source .hop-marker-dot {
  width: 16px;
  height: 16px;
  background: var(--secondary);
  border-color: rgba(99, 102, 241, 0.4);
}

.hop-marker-source .hop-marker-pulse {
  background: rgba(99, 102, 241, 0.3);
  width: 16px;
  height: 16px;
}

@keyframes markerPulseSource {
  0% { width: 16px; height: 16px; opacity: 0.6; }
  100% { width: 44px; height: 44px; opacity: 0; }
}

.hop-marker-source .hop-marker-pulse {
  animation-name: markerPulseSource;
}

/* Destination marker */
.hop-marker-dest .hop-marker-dot {
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-color: rgba(0, 180, 216, 0.4);
}

.hop-marker-dest .hop-marker-pulse {
  background: rgba(0, 180, 216, 0.3);
  width: 16px;
  height: 16px;
  animation-name: markerPulseDest;
}

@keyframes markerPulseDest {
  0% { width: 16px; height: 16px; opacity: 0.6; }
  100% { width: 44px; height: 44px; opacity: 0; }
}

/* Error marker */
.hop-marker-error .hop-marker-dot {
  background: var(--error);
  border-color: rgba(239, 68, 68, 0.4);
}

.hop-marker-error .hop-marker-pulse {
  background: rgba(239, 68, 68, 0.3);
}

/* ── Hop Marker Pop-In ── */
.hop-marker-enter {
  animation: hopPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

/* ── Path Line Animation ── */
.animated-path {
  stroke-dasharray: 8 6;
  animation: pathFlow 1s linear infinite;
}

@keyframes pathFlow {
  from { stroke-dashoffset: 14; }
  to { stroke-dashoffset: 0; }
}

/* Path draw-in effect */
.path-draw-in {
  animation: pathDrawIn 0.6s ease forwards;
}

@keyframes pathDrawIn {
  from {
    stroke-dashoffset: var(--path-length, 1000);
    opacity: 0.3;
  }
  to {
    stroke-dashoffset: 0;
    opacity: 1;
  }
}

/* ── Animated Packet ── */
.packet-marker {
  z-index: 1000 !important;
}

.packet-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--packet);
  box-shadow:
    0 0 8px var(--packet-glow),
    0 0 20px var(--packet-glow),
    0 0 40px rgba(245, 158, 11, 0.15);
  position: relative;
  z-index: 2;
}

.packet-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.3) 0%, transparent 70%);
  animation: packetGlow 1.5s ease-in-out infinite alternate;
  z-index: 1;
}

@keyframes packetGlow {
  from { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
  to { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* ── Packet Trail ── */
.packet-trail {
  stroke: var(--packet);
  stroke-width: 3;
  fill: none;
  opacity: 0.6;
  filter: blur(1px);
}

/* ── Latency Count-Up ── */
.count-up {
  display: inline-block;
}

/* ── Trace Button Loading ── */
.trace-btn.loading .btn-icon {
  animation: btnSpin 1s linear infinite;
}

@keyframes btnSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Skeleton Loader ── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--border-light) 50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

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

/* ── Bottom Panel Slide ── */
#bottom-panel {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease;
}

/* ── Sidebar Slide ── */
#sidebar {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── General Fade In ── */
.fade-in {
  animation: fadeIn 0.5s ease forwards;
}

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

/* ── Scale In ── */
.scale-in {
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ── Progress bar animation ── */
#progress-fill {
  position: relative;
  overflow: hidden;
}

#progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: progressShine 1.5s ease-in-out infinite;
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
