/* ============================================
   Waveform Component - Audio Visualizer Patterns
   ============================================ */

/* Background container for waveform patterns */
.waveform-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.waveform-bg--bottom {
  top: auto;
  bottom: 0;
  height: 200px;
}

.waveform-bg--subtle {
  opacity: 0.08;
}

/* SVG Waveform container */
.waveform {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

/* Individual waveform bars - GPU optimized */
.waveform__bar {
  width: 4px;
  background: var(--gradient-audio);
  background-size: 100% 200%;
  border-radius: var(--radius-full);
  transform-origin: bottom center;
  animation: wave-pulse var(--wave-duration, 1.5s) ease-in-out infinite; /* GPU optimized: slowed from 1.2s to 1.5s */
  animation-delay: var(--wave-delay, 0s);
  will-change: transform, opacity;
}

/* Bar size variants */
.waveform__bar--sm {
  width: 3px;
}

.waveform__bar--lg {
  width: 6px;
}

/* Waveform animations */
@keyframes wave-pulse {
  0%, 100% {
    transform: scaleY(0.3);
    opacity: 0.6;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@keyframes wave-flow {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* wave-glow: static drop-shadow instead of animated filter (GPU optimization) */

/* Continuous flowing waveform - GPU optimized: slowed from 20s to 30s */
.waveform--flowing {
  animation: wave-flow 30s linear infinite;
}

/* Glowing waveform variant - static glow instead of animated filter */
.waveform--glow .waveform__bar {
  filter: drop-shadow(0 0 8px rgba(138, 43, 226, 0.6));
}

/* SVG-based waveform - GPU optimized: slowed from 25s to 40s */
.waveform-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200%;
  height: 150px;
  opacity: 0.2;
  animation: wave-flow 40s linear infinite;
}

.waveform-svg path {
  fill: none;
  stroke: url(#waveform-gradient);
  stroke-width: 2;
  stroke-linecap: round;
}

/* Inline waveform for decorative use */
.waveform-inline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 24px;
}

.waveform-inline__bar {
  width: 3px;
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  animation: wave-pulse 1.2s ease-in-out infinite; /* GPU optimized: slowed from 0.8s to 1.2s */
}

/* Stagger delays for bars (applied via inline styles or JS) */
.waveform__bar:nth-child(1) { --wave-delay: 0s; }
.waveform__bar:nth-child(2) { --wave-delay: 0.1s; }
.waveform__bar:nth-child(3) { --wave-delay: 0.2s; }
.waveform__bar:nth-child(4) { --wave-delay: 0.3s; }
.waveform__bar:nth-child(5) { --wave-delay: 0.4s; }
.waveform__bar:nth-child(6) { --wave-delay: 0.5s; }
.waveform__bar:nth-child(7) { --wave-delay: 0.6s; }
.waveform__bar:nth-child(8) { --wave-delay: 0.7s; }
.waveform__bar:nth-child(9) { --wave-delay: 0.8s; }
.waveform__bar:nth-child(10) { --wave-delay: 0.9s; }
.waveform__bar:nth-child(11) { --wave-delay: 1s; }
.waveform__bar:nth-child(12) { --wave-delay: 1.1s; }
.waveform__bar:nth-child(13) { --wave-delay: 0.05s; }
.waveform__bar:nth-child(14) { --wave-delay: 0.15s; }
.waveform__bar:nth-child(15) { --wave-delay: 0.25s; }
.waveform__bar:nth-child(16) { --wave-delay: 0.35s; }
.waveform__bar:nth-child(17) { --wave-delay: 0.45s; }
.waveform__bar:nth-child(18) { --wave-delay: 0.55s; }
.waveform__bar:nth-child(19) { --wave-delay: 0.65s; }
.waveform__bar:nth-child(20) { --wave-delay: 0.75s; }

/* Randomize heights for more organic feel - GPU optimized: unified to 2 durations instead of 4 */
.waveform__bar:nth-child(odd) { --wave-duration: 1.4s; }
.waveform__bar:nth-child(even) { --wave-duration: 1.8s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .waveform__bar,
  .waveform-inline__bar,
  .waveform-svg,
  .waveform--flowing {
    animation: none;
  }

  .waveform__bar {
    transform: scaleY(0.6);
    opacity: 0.8;
  }
}
