/**
 * Beat Lab — Modern Interactive Beat Maker
 * A visual, tactile experience for creating beats
 */

/* ========== Section Container ========== */
.rhythm-explorer {
  background: color-mix(in srgb, var(--brand-footer-bg) 95%, black);
  padding: 5rem 2rem;
  position: relative;
  overflow: hidden;
}

/* Animated gradient background */
.rhythm-explorer::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, color-mix(in srgb, var(--brand-secondary) 12%, transparent) 0%, transparent 50%),
    radial-gradient(ellipse 50% 35% at 80% 70%, color-mix(in srgb, var(--brand-accent) 10%, transparent) 0%, transparent 50%);
  pointer-events: none;
  animation: bgPulse 8s ease-in-out infinite;
}

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

/* Grid pattern overlay */
.rhythm-explorer::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.re-inner {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ========== Header ========== */
.re-header {
  text-align: center;
  margin-bottom: 3rem;
}

.re-title {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: var(--brand-gradient-highlight);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientTextShimmer 4s ease-in-out infinite;
}

.re-subtitle {
  font-size: 1.125rem;
  color: #94a3b8;
  max-width: 500px;
  margin: 0 auto;
}

/* ========== Beat Machine ========== */
.beat-machine {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border-radius: 24px;
  padding: 2rem;
  border: 1px solid rgba(148, 163, 184, 0.1);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 20px 50px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  margin-bottom: 2rem;
}

/* Transport Controls */
.transport-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.transport-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--brand-gradient-cta);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 15px color-mix(in srgb, var(--brand-secondary) 40%, transparent),
    0 2px 6px rgba(0, 0, 0, 0.2);
}

.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 
    0 6px 20px color-mix(in srgb, var(--brand-secondary) 50%, transparent),
    0 3px 10px rgba(0, 0, 0, 0.25);
}

.play-btn.playing {
  animation: playPulse 1s ease-in-out infinite;
}

@keyframes playPulse {
  0%, 100% { box-shadow: 0 4px 15px color-mix(in srgb, var(--brand-secondary) 40%, transparent); }
  50% { box-shadow: 0 4px 25px color-mix(in srgb, var(--brand-secondary) 60%, transparent); }
}

.play-btn svg {
  width: 24px;
  height: 24px;
}

.bpm-display {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bpm-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f1f5f9;
  font-family: var(--brand-font-mono);
}

.bpm-label {
  font-size: 0.6875rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.transport-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.tempo-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tempo-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.8);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tempo-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #f1f5f9;
  border-color: var(--brand-secondary);
}

.clear-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.clear-btn:hover {
  background: rgba(210, 63, 87, 0.1);
  color: var(--brand-tertiary);
  border-color: var(--brand-tertiary);
}

/* ========== Track Grid ========== */
.tracks-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.track {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.track-info {
  width: 80px;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.track-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #e2e8f0;
}

.track-sound {
  font-size: 0.6875rem;
  color: #64748b;
}

/* Step Grid */
.steps {
  display: flex;
  gap: 4px;
  flex: 1;
}

.step {
  flex: 1;
  aspect-ratio: 1;
  max-width: 48px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: rgba(51, 65, 85, 0.4);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.step::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.2) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.step:hover {
  background: rgba(71, 85, 105, 0.6);
  transform: scale(1.05);
}

.step:hover::after {
  opacity: 1;
}

/* Beat marker every 4 steps */
.step:nth-child(4n+1) {
  border-left: 2px solid rgba(148, 163, 184, 0.15);
}

/* Active steps per track type */
.track[data-track="kick"] .step.active {
  background: linear-gradient(135deg, var(--brand-success), color-mix(in srgb, var(--brand-success) 70%, var(--brand-secondary)));
  border-color: var(--brand-success);
  box-shadow: 0 0 12px color-mix(in srgb, var(--brand-success) 50%, transparent);
}

.track[data-track="snare"] .step.active {
  background: linear-gradient(135deg, var(--brand-accent), color-mix(in srgb, var(--brand-accent) 70%, var(--brand-primary)));
  border-color: var(--brand-accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--brand-accent) 50%, transparent);
}

.track[data-track="hihat"] .step.active {
  background: linear-gradient(135deg, var(--brand-secondary), color-mix(in srgb, var(--brand-secondary) 70%, var(--brand-accent)));
  border-color: var(--brand-secondary);
  box-shadow: 0 0 12px color-mix(in srgb, var(--brand-secondary) 50%, transparent);
}

.track[data-track="perc"] .step.active {
  background: linear-gradient(135deg, var(--brand-info), color-mix(in srgb, var(--brand-info) 70%, var(--brand-accent)));
  border-color: var(--brand-info);
  box-shadow: 0 0 12px color-mix(in srgb, var(--brand-info) 50%, transparent);
}

/* Playing step highlight */
.step.playing {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.step.playing::before {
  content: '';
  position: absolute;
  inset: -2px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 10px;
  animation: stepFlash 0.15s ease-out;
}

@keyframes stepFlash {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.3); }
}

/* ========== Presets ========== */
.presets-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.presets-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}

.presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-btn {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.6);
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preset-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  color: #f1f5f9;
  border-color: color-mix(in srgb, var(--brand-secondary) 50%, transparent);
}

.preset-btn.active {
  background: var(--brand-gradient-cta);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--brand-secondary) 30%, transparent);
}

.preset-emoji {
  font-size: 1rem;
}

/* ========== Waveform Visualizer ========== */
.visualizer {
  height: 60px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 12px;
  margin-top: 1.5rem;
  overflow: hidden;
  position: relative;
}

.visualizer-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding: 8px;
  gap: 3px;
}

.viz-bar {
  flex: 1;
  max-width: 8px;
  background: var(--brand-gradient-cta);
  border-radius: 4px 4px 0 0;
  height: 10%;
  transition: height 0.1s ease-out;
}

.viz-bar.active {
  animation: vizPulse 0.3s ease-out;
}

@keyframes vizPulse {
  0% { height: 100%; }
  100% { height: 10%; }
}

/* ========== CTA Section ========== */
.re-cta {
  text-align: center;
  margin-top: 2.5rem;
}

.re-cta-text {
  font-size: 1rem;
  color: #94a3b8;
  margin-bottom: 1.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.re-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 2.5rem;
  background: var(--brand-gradient-cta);
  color: white;
  border: none;
  border-radius: 3rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 4px 20px color-mix(in srgb, var(--brand-secondary) 40%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.re-cta-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow:
    0 8px 30px color-mix(in srgb, var(--brand-secondary) 50%, transparent),
    0 4px 16px rgba(0, 0, 0, 0.25);
  color: white;
}

.re-cta-note {
  display: block;
  margin-top: 1rem;
  font-size: 0.8125rem;
  color: #64748b;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .rhythm-explorer {
    padding: 3rem 1rem;
  }
  
  .re-title {
    font-size: 2rem;
  }
  
  .beat-machine {
    padding: 1.25rem;
  }
  
  .transport-bar {
    flex-direction: column;
    gap: 1rem;
  }
  
  .transport-left,
  .transport-right {
    width: 100%;
    justify-content: center;
  }
  
  .track {
    flex-direction: column;
    align-items: stretch;
  }
  
  .track-info {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 0.5rem;
  }
  
  .step {
    max-width: none;
  }
  
  .presets-grid {
    justify-content: center;
  }
}

/* ========== Animation Utilities ========== */
@keyframes gradientTextShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
