/**
 * 8bitflow Live System Animated Visualization
 * Premium SVG data flow animation with interactive nodes,
 * glowing connections, and animated data packets.
 */

/* ── Container ── */
.hero-viz {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-width: 72rem;
  margin: 0 auto;
  border-radius: 0.75rem;
  border: 1px solid rgba(39, 39, 42, 0.6);
  background: linear-gradient(135deg, #0c0c0f 0%, #121215 50%, #0f0f12 100%);
  overflow: hidden;
  contain: layout paint;
  isolation: isolate;
  box-shadow: 0 25px 60px -12px rgba(167, 139, 250, 0.12),
              0 0 0 1px rgba(167, 139, 250, 0.04);
}

/* subtle grid overlay */
.hero-viz::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(167, 139, 250, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(167, 139, 250, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* gradient bloom behind the viz */
.hero-viz::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60%;
  height: 60%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(167, 139, 250, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hero-viz svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

/* ── Decorative Top Bar ── */
.hero-viz-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  background: rgba(18, 18, 25, 0.8);
  border-bottom: 1px solid rgba(39, 39, 42, 0.5);
  z-index: 5;
  backdrop-filter: blur(8px);
}

.hero-viz-bar .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.hero-viz-bar .dot-red { background: rgba(239, 68, 68, 0.7); }
.hero-viz-bar .dot-yellow { background: rgba(234, 179, 8, 0.7); }
.hero-viz-bar .dot-green { background: rgba(34, 197, 94, 0.7); }

.hero-viz-bar .bar-title {
  margin-left: 12px;
  font-size: 12px;
  color: #6b6b80;
  letter-spacing: 0.05em;
  font-weight: 500;
  font-family: 'Geist', monospace;
}

.hero-viz-bar .bar-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #34d399;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hero-viz-bar .bar-status .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  position: relative;
}

.hero-viz-bar .bar-status .pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid #34d399;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 0.6; transform: scale(0.8); }
  50% { opacity: 0; transform: scale(1.8); }
}

/* ── SVG Nodes ── */
.node-group {
  cursor: pointer;
  transition: filter 0.3s ease;
}

.node-group:hover {
  filter: brightness(1.2);
}

/* node body */
.node-body {
  fill: #18171d;
  stroke: #3e3e4c;
  stroke-width: 1.5;
  rx: 12;
  ry: 12;
  transition: fill 0.3s ease, stroke 0.3s ease, filter 0.3s ease;
}

.node-group:hover .node-body {
  stroke: #a78bfa;
  fill: #1e1b2e;
  filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.25));
}

.node-group.active .node-body {
  stroke: #a78bfa;
  fill: #1e1b2e;
  filter: drop-shadow(0 0 20px rgba(167, 139, 250, 0.35));
}

/* node icon background */
.node-icon-bg {
  fill: rgba(167, 139, 250, 0.1);
  rx: 8;
  ry: 8;
  transition: fill 0.3s ease;
}

.node-group:hover .node-icon-bg,
.node-group.active .node-icon-bg {
  fill: rgba(167, 139, 250, 0.2);
}

/* node icon circle (for central node) */
.node-icon-circle {
  fill: rgba(167, 139, 250, 0.08);
  stroke: rgba(167, 139, 250, 0.3);
  stroke-width: 1;
  transition: fill 0.3s ease, stroke 0.3s ease;
}

.node-group:hover .node-icon-circle,
.node-group.active .node-icon-circle {
  fill: rgba(167, 139, 250, 0.15);
  stroke: rgba(167, 139, 250, 0.6);
}

/* node text */
.node-label {
  fill: #fafafa;
  font-family: 'Geist', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.node-sublabel {
  fill: #6b6b80;
  font-family: 'Geist', sans-serif;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.node-icon-text {
  fill: #a78bfa;
  font-family: 'Material Symbols Outlined';
  font-size: 20px;
  dominant-baseline: central;
  text-anchor: middle;
  font-variation-settings: 'FILL' 1;
}

/* ── Central Hub Node ── */
.central-node .node-body {
  fill: #121215;
  stroke: #a78bfa;
  stroke-width: 2;
  filter: drop-shadow(0 0 15px rgba(167, 139, 250, 0.2));
}

.central-node:hover .node-body {
  fill: #1a1625;
  filter: drop-shadow(0 0 25px rgba(167, 139, 250, 0.4));
}

.central-node .node-label {
  fill: #a78bfa;
  font-size: 15px;
  font-weight: 700;
}

/* ── Connection Lines ── */
.connection-line {
  stroke: #262630;
  stroke-width: 1.5;
  fill: none;
  transition: stroke 0.4s ease;
}

.connection-line-glow {
  stroke: url(#lineGradient);
  stroke-width: 2;
  fill: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.3));
}

.connection-active .connection-line {
  stroke: #3e3e4c;
}

.connection-active .connection-line-glow {
  opacity: 1;
}

/* ── Data Packets ── */
.data-packet {
  r: 3;
  fill: #a78bfa;
  filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.6));
  opacity: 0;
}

.data-packet.packet-green {
  fill: #34d399;
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.6));
}

.data-packet.packet-blue {
  fill: #60a5fa;
  filter: drop-shadow(0 0 6px rgba(96, 165, 250, 0.6));
}

.data-packet.packet-amber {
  fill: #fbbf24;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
}

/* ── Stats Panel ── */
.stats-panel {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 12px;
  z-index: 5;
}

.stat-card {
  background: rgba(18, 18, 25, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(39, 39, 42, 0.5);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 100px;
  transition: border-color 0.3s ease, transform 0.3s ease;
}

.stat-card:hover {
  border-color: rgba(167, 139, 250, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px -8px rgba(167, 139, 250, 0.2);
}

.stat-card .stat-value {
  font-family: 'Geist', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #fafafa;
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-value .stat-accent {
  color: #a78bfa;
}

.stat-card .stat-label {
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  color: #6b6b80;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* ── Activity Feed Panel ── */
.activity-panel {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 220px;
  z-index: 5;
}

.activity-feed {
  background: rgba(18, 18, 25, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(39, 39, 42, 0.5);
  border-radius: 10px;
  padding: 12px;
  overflow: hidden;
}

.activity-feed .feed-title {
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  color: #6b6b80;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.activity-feed .feed-title .live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #34d399;
  animation: liveDotPulse 1.5s ease-in-out infinite;
}

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

.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(39, 39, 42, 0.3);
  opacity: 0;
  transform: translateY(10px);
  animation: feedItemIn 0.4s ease both;
}

.activity-item:first-child {
  border-top: none;
}

.activity-item .activity-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  font-family: 'Material Symbols Outlined';
  font-variation-settings: 'FILL' 1;
}

.activity-item .activity-icon.icon-purple {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

.activity-item .activity-icon.icon-green {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.activity-item .activity-icon.icon-blue {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

.activity-item .activity-icon.icon-amber {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.activity-item .activity-text {
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  color: #9d9db5;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.activity-item .activity-text strong {
  color: #fafafa;
  font-weight: 600;
}

  .activity-item .activity-time {
    margin-left: auto;
    font-family: 'Geist', monospace;
    font-size: 12px;
    color: #505060;
    white-space: nowrap;
    flex-shrink: 0;
  }

@keyframes feedItemIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Tooltip (on node hover) ── */
.node-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  background: rgba(12, 12, 15, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 180px;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 30px -8px rgba(0, 0, 0, 0.6),
              0 0 0 1px rgba(167, 139, 250, 0.08);
}

.node-tooltip.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.node-tooltip .tooltip-title {
  font-family: 'Geist', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #fafafa;
  margin-bottom: 6px;
}

.node-tooltip .tooltip-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.node-tooltip .tooltip-metric .metric-label {
  font-family: 'Geist', sans-serif;
  font-size: 12px;
  color: #6b6b80;
}

  .node-tooltip .tooltip-metric .metric-value {
    font-family: 'Geist', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: #34d399;
    font-variant-numeric: tabular-nums;
  }

.node-tooltip .tooltip-bar {
  margin-top: 6px;
  height: 3px;
  background: #262630;
  border-radius: 2px;
  overflow: hidden;
}

.node-tooltip .tooltip-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #a78bfa, #34d399);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Animated gradient line (SVG defs) ── */
@keyframes lineFlowDash {
  to { stroke-dashoffset: -20; }
}

.connection-flow {
  stroke-dasharray: 6 4;
  animation: lineFlowDash 1s linear infinite;
}

/* ── Entry animation for the entire viz ── */
.hero-viz {
  opacity: 0;
  transform: perspective(1200px) rotateX(4deg) translateY(30px) scale(0.97);
  transition: opacity 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-viz.is-visible {
  opacity: 1;
  transform: perspective(1200px) rotateX(0) translateY(0) scale(1);
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  .hero-viz,
  .data-packet,
  .node-pulse-ring,
  .connection-flow,
  .activity-item,
  .stat-card,
  .node-group {
    animation: none !important;
    transition: none !important;
  }
  .hero-viz {
    opacity: 1 !important;
    transform: none !important;
  }
  .connection-line-glow {
    opacity: 0.5 !important;
  }
}

/* ── Mobile responsive ── */
@media (max-width: 767.98px) {
  .hero-viz {
    aspect-ratio: 10 / 9;
    min-height: 300px;
    border-radius: 1rem;
    padding-bottom: 72px;
    box-shadow: 0 18px 42px -18px rgba(167, 139, 250, 0.22),
                0 0 0 1px rgba(167, 139, 250, 0.08);
  }

  .hero-viz {
    opacity: 0;
    transform: perspective(1200px) rotateX(2deg) translateY(20px) scale(0.98);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .hero-viz.is-visible {
    opacity: 1;
    transform: perspective(1200px) rotateX(0) translateY(0) scale(1);
  }

  .hero-viz-bar {
    height: 28px;
    padding: 0 10px;
    gap: 5px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(18, 18, 25, 0.95);
  }

  .hero-viz-bar .dot {
    width: 7px;
    height: 7px;
  }

  .hero-viz-bar .bar-title {
    font-size: 12px;
    margin-left: 6px;
  }

  .hero-viz-bar .bar-status {
    font-size: 12px;
  }

  .stats-panel {
    right: 8px;
    bottom: 8px;
    left: 8px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat-card {
    padding: 7px 6px;
    min-width: 0;
    border-radius: 8px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(18, 18, 25, 0.95);
    transition: border-color 0.2s ease, transform 0.15s ease;
  }

  .stat-card:active {
    transform: scale(0.95);
    border-color: rgba(167, 139, 250, 0.4);
  }

  .stat-card .stat-value {
    font-size: 12px;
    text-align: center;
  }

  .stat-card .stat-label {
    font-size: 12px;
    text-align: center;
    letter-spacing: 0.05em;
  }

  .activity-panel {
    display: none;
  }

  .node-label {
    font-size: 12px;
  }

  .node-sublabel {
    display: none;
  }

  .node-icon-text {
    font-size: 16px;
  }

  .node-tooltip {
    display: block;
    bottom: 8px;
    left: 8px;
    right: 8px;
    min-width: 0;
  }

  .node-group {
    transition: filter 0.2s ease;
  }

  .data-packet {
    r: 2.5;
  }

  .connection-flow,
  .pulse-dot::after {
    animation: none !important;
  }
}

}
