/* ═══════════════════════════════════════════════════════════════════
   SONGMAKER VISUALIZER — Side-Scroller Play Mode (View 2)
   Design: dark cinematic, narrow header/footer, wide scrolling stage
═══════════════════════════════════════════════════════════════════ */

/* ── Overlay container ─────────────────────────────────────────── */
#visualizer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  background: #0a0a0f;
  color: #fff;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  transition: opacity 0.3s ease;
  isolation: isolate;
}

#visualizer-overlay.viz-hidden {
  display: none;
}

/* ── Beat pulse background ─────────────────────────────────────── */
#viz-pulse-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0) 60%, rgba(255,255,255,0) 100%);
  transition: background 0.05s ease;
}

#viz-pulse-bg.beat-flash {
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%);
  animation: bg-beat-flash 0.22s ease-out forwards;
}

#viz-pulse-bg.downbeat-flash {
  background: radial-gradient(ellipse at center, rgba(255,220,80,0.35) 0%, rgba(255,180,0,0.08) 55%, rgba(255,220,80,0) 80%);
  animation: bg-downbeat-flash 0.35s ease-out forwards;
}

@keyframes bg-beat-flash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes bg-downbeat-flash {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Beat stripe — disabled; vertical now-line is the sole beat indicator */
#viz-beat-stripe {
  display: none;
}

#viz-beat-stripe.beat-stripe-on {
  animation: stripe-beat 0.18s ease-out forwards;
}

#viz-beat-stripe.beat-stripe-down {
  height: 6px;
  background: #fff;
  box-shadow: 0 0 20px rgba(255,220,80,1), 0 2px 40px rgba(255,200,0,0.6);
  animation: stripe-downbeat 0.32s ease-out forwards;
}

@keyframes stripe-beat {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}

@keyframes stripe-downbeat {
  0%   { opacity: 1; height: 6px; }
  40%  { opacity: 0.8; height: 4px; }
  100% { opacity: 0; height: 3px; }
}

/* ── Narrow header ─────────────────────────────────────────────── */
.viz-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  height: 40px;
  background: rgba(0,0,0,0.7);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.viz-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}

.viz-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.viz-ctrl-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.viz-ctrl-btn:hover {
  background: rgba(255,255,255,0.2);
}

.viz-close-btn {
  background: rgba(220,60,60,0.3);
  border-color: rgba(220,60,60,0.5);
}

.viz-close-btn:hover {
  background: rgba(220,60,60,0.6);
}

/* ── Stage (scrolling track area) ──────────────────────────────── */
.viz-stage {
  position: relative;
  z-index: 5;
  flex: 0 0 160px;
  overflow: visible;  /* allow now-line labels to show above/below */
  background: linear-gradient(180deg, #0d0d18 0%, #111122 100%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Clip the scrolling track itself so cards don't overflow */
.viz-track-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

/* The "now" vertical line at 30% from left */
.viz-now-line {
  position: absolute;
  left: 30%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,220,80,0.7);
  box-shadow: 0 0 12px rgba(255,220,80,0.5);
  z-index: 20;
  pointer-events: none;
  transform-origin: center center;
  /* NO transition — keyframe animations control transform/shadow/bg */
  overflow: visible;
}

/* Measure/beat count label — sits above the stage */
.viz-now-top {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(255,220,80,0.95);
  text-shadow: 0 0 8px rgba(255,200,0,0.8);
  background: rgba(0,0,0,0.65);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 25;
}

/* Real-time / duration label — sits below the stage */
.viz-now-bottom {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  color: rgba(200,200,200,0.7);
  background: rgba(0,0,0,0.55);
  padding: 1px 5px;
  border-radius: 3px;
  pointer-events: none;
  z-index: 25;
}

/* Beat flash overlay — a separate full-height div centered on the now-line */
.viz-beat-flash {
  position: absolute;
  left: 30%;
  top: 0;
  bottom: 0;
  width: 4px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 30;
  opacity: 0;
}
.viz-beat-flash.beat-flash-on {
  animation: beat-flash-anim 0.18s ease-out forwards;
}
.viz-beat-flash.downbeat-flash-on {
  animation: downbeat-flash-anim 0.22s ease-out forwards;
}

@keyframes beat-flash-anim {
  0%   { opacity: 1; width: 20px; background: rgba(255,230,80,1);   box-shadow: 0 0 40px 12px rgba(255,220,80,1); }
  60%  { opacity: 0.5; width: 8px; background: rgba(255,220,80,0.5); box-shadow: 0 0 12px 4px rgba(255,220,80,0.4); }
  100% { opacity: 0; width: 4px;  background: rgba(255,220,80,0.0); box-shadow: 0 0 0px 0px rgba(255,220,80,0); }
}

@keyframes downbeat-flash-anim {
  0%   { opacity: 1; width: 70px; background: #ffffff;              box-shadow: 0 0 140px 50px rgba(255,255,255,1), 0 0 220px 70px rgba(255,220,80,0.8); }
  25%  { opacity: 1; width: 28px; background: rgba(255,245,140,1);  box-shadow: 0 0 70px 24px rgba(255,220,80,0.9); }
  100% { opacity: 0; width: 4px;  background: rgba(255,220,80,0.0); box-shadow: 0 0 0px 0px rgba(255,220,80,0); }
}

/* Keep the now-line itself simple — no competing animations */
.viz-now-line.now-beat, .viz-now-line.now-downbeat {
  /* legacy classes kept for compatibility but no animation here */
}

/* Scrolling track — JS sets transform: translateX() */
.viz-track {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  will-change: transform;
  /* NO transition — scroll is driven frame-by-frame from audio clock */
}


/* Individual block cards on the track */
.viz-block-card {
  position: relative;
  height: 120px;
  min-width: 120px;
  border-radius: 10px;
  margin: 0 4px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;   /* JS overrides per-card to flex-start/center/flex-end */
  padding: 8px 14px;
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.55;
  border: 2px solid transparent;
  transition: opacity 0.3s, border-color 0.2s, box-shadow 0.2s;
  cursor: default;
  overflow: visible;     /* never clip labels */
  flex-shrink: 0;
}

.viz-block-card.viz-active {
  opacity: 1;
  border-color: rgba(255,220,80,0.8);
  box-shadow: 0 0 20px rgba(255,220,80,0.3), inset 0 0 30px rgba(0,0,0,0.3);
}

.viz-block-card.viz-upcoming {
  opacity: 0.85;
  border-right-color: rgba(255,220,80,0.35);
}

.viz-block-card .viz-card-part {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 4px;
  width: 100%;
  box-sizing: border-box;
}

.viz-block-card .viz-card-key {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  width: 100%;
  box-sizing: border-box;
}

.viz-block-card .viz-card-measures {
  font-size: 0.62rem;
  opacity: 0.6;
  margin-top: 4px;
  width: 100%;
  box-sizing: border-box;
}

/* Measure tic marks overlay — absolute, full card size, pointer-events none */
.viz-tic-marks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 3;
}

/* Lead-in card */
.viz-block-card.viz-leadin {
  background: rgba(80,80,120,0.5) !important;
  border-color: rgba(150,150,200,0.4);
}

/* ── Centre info zone ──────────────────────────────────────────── */
.viz-info-zone {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 5px;
  background: #0a0a0f;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,220,80,0.2) transparent;
}

.viz-part-label {
  font-size: clamp(1.1rem, 3vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,220,80,0.9);
  text-shadow: 0 0 30px rgba(255,220,80,0.4);
  transition: opacity 0.3s;
}

.viz-key-label {
  font-size: clamp(0.85rem, 2vw, 1.3rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  opacity: 0.7;
  transition: opacity 0.3s;
}

.viz-lyrics {
  font-size: clamp(0.9rem, 2.5vw, 1.6rem);
  font-style: italic;
  text-align: center;
  max-width: 80vw;
  opacity: 0.85;
  line-height: 1.4;
  transition: opacity 0.4s;
  min-height: 2em;
}

/* ── Energy bars ───────────────────────────────────────────────── */
.viz-energy-bars {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 50px;
}

.viz-energy-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 28px;
}

.vez-fill {
  width: 100%;
  border-radius: 3px 3px 0 0;
  transition: height 0.25s ease, background 0.25s;
  min-height: 2px;
}

.vez-fill.drums  { background: linear-gradient(180deg, #ff4444, #aa2222); }
.vez-fill.bass   { background: linear-gradient(180deg, #4488ff, #2244aa); }
.vez-fill.guitar { background: linear-gradient(180deg, #ff8822, #aa5511); }
.vez-fill.keys   { background: linear-gradient(180deg, #cc44ff, #7722aa); }
.vez-fill.vocals { background: linear-gradient(180deg, #22cc66, #117733); }

.viz-energy-bar span {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.6;
  text-transform: uppercase;
}

/* ── Scale display (fretboard + piano) ─────────────────────── */
.viz-scale-display {
  width: 100%;
  max-width: 900px;
  margin-top: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 8px 12px 10px;
  flex-shrink: 0;
}

.viz-scale-display.viz-hidden {
  display: none;
}

.viz-scale-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
  flex-wrap: wrap;
}

.viz-scale-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,220,80,0.85);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viz-scale-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.viz-ctrl-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  opacity: 0.8;
  cursor: pointer;
}

.viz-ctrl-label span {
  font-size: 0.85rem;
  line-height: 1;
}

.viz-ctrl-select {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  color: #fff;
  font-size: 0.62rem;
  font-family: 'Courier New', monospace;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
  max-width: 130px;
}

.viz-ctrl-select:hover {
  background: rgba(255,255,255,0.12);
}

.viz-ctrl-select option {
  background: #1a1a2e;
  color: #fff;
}

.viz-color-input {
  width: 28px;
  height: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  padding: 1px;
  background: transparent;
  cursor: pointer;
  vertical-align: middle;
}

/* Radial mode floating controls */
.viz-radial-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 6px 10px;
  backdrop-filter: blur(6px);
}

.viz-radial-controls.viz-hidden {
  display: none;
}

.viz-scale-panels {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.viz-scale-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 200px;
}

.viz-scale-panel-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.45;
}

.viz-fretboard-svg {
  width: 100%;
  height: auto;
  border-radius: 4px;
  overflow: visible;
}

.viz-piano-svg {
  width: 100%;
  height: auto;
  border-radius: 4px;
  overflow: visible;
}

/* ── Narrow footer ──────────────────────────────────────────── */
.viz-footer {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  height: 32px;
  background: rgba(0,0,0,0.7);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  font-size: 0.72rem;
  opacity: 0.7;
  letter-spacing: 0.06em;
}

.viz-beat {
  color: rgba(255,220,80,0.9);
  font-weight: 700;
  min-width: 120px;
}

.viz-time {
  text-align: center;
  flex: 1;
}

.viz-block-info {
  text-align: right;
  min-width: 200px;
}

/* ── Beat pulse animation on the active card ───────────────────── */
@keyframes viz-card-pulse {
  0%   { box-shadow: 0 0 20px rgba(255,220,80,0.3), inset 0 0 30px rgba(0,0,0,0.3); border-color: rgba(255,220,80,0.8); }
  30%  { box-shadow: 0 0 60px rgba(255,220,80,0.9), 0 0 100px rgba(255,200,0,0.4), inset 0 0 10px rgba(255,220,80,0.15); border-color: rgba(255,240,120,1); }
  100% { box-shadow: 0 0 20px rgba(255,220,80,0.3), inset 0 0 30px rgba(0,0,0,0.3); border-color: rgba(255,220,80,0.8); }
}

@keyframes viz-card-downbeat {
  0%   { box-shadow: 0 0 20px rgba(255,220,80,0.3), inset 0 0 30px rgba(0,0,0,0.3); border-color: rgba(255,220,80,0.8); filter: brightness(1); }
  20%  { box-shadow: 0 0 80px rgba(255,220,80,1), 0 0 150px rgba(255,200,0,0.6), inset 0 0 40px rgba(255,220,80,0.25); border-color: #fff; filter: brightness(1.6); }
  60%  { box-shadow: 0 0 40px rgba(255,220,80,0.6); border-color: rgba(255,230,100,0.9); filter: brightness(1.2); }
  100% { box-shadow: 0 0 20px rgba(255,220,80,0.3), inset 0 0 30px rgba(0,0,0,0.3); border-color: rgba(255,220,80,0.8); filter: brightness(1); }
}

.viz-block-card.viz-active.viz-beat-pulse {
  animation: viz-card-pulse 0.22s ease-out forwards;
}

.viz-block-card.viz-active.viz-downbeat-pulse {
  animation: viz-card-downbeat 0.35s ease-out forwards;
}

/* ── Visualizer nav button ─────────────────────────────────────── */
.nav-btn-visualizer {
  background: linear-gradient(135deg, #1a1a3e, #2d2d6e) !important;
  border-color: rgba(100,100,220,0.5) !important;
  color: #aaaaff !important;
}

.nav-btn-visualizer:hover {
  background: linear-gradient(135deg, #2d2d6e, #4444aa) !important;
  color: #fff !important;
}

/* ── Energy wave SVG inside each card ─────────────────────────── */
.viz-energy-wave {
  position: absolute;
  bottom: 6px;
  left: 12px;
  right: 12px;
  height: 40px;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.3s;
}

.viz-block-card.viz-active .viz-energy-wave {
  opacity: 1;
}

/* ── Part-type colour map for viz cards ────────────────────────── */
.viz-block-card[data-part="intro"]    { background: linear-gradient(160deg, #1a3a2a, #0d1f15); }
.viz-block-card[data-part="verse"]    { background: linear-gradient(160deg, #1e2a4a, #0d1525); }
.viz-block-card[data-part="chorus"]   { background: linear-gradient(160deg, #3a1a1a, #1f0d0d); }
.viz-block-card[data-part="bridge"]   { background: linear-gradient(160deg, #2a1a3a, #150d1f); }
.viz-block-card[data-part="outro"]    { background: linear-gradient(160deg, #2a2a1a, #15150d); }
.viz-block-card[data-part="solo"]     { background: linear-gradient(160deg, #3a2a1a, #1f150d); }
.viz-block-card[data-part="interlude"]{ background: linear-gradient(160deg, #1a2a3a, #0d151f); }
.viz-block-card[data-part="breakdown"]{ background: linear-gradient(160deg, #2a1a2a, #150d15); }
.viz-block-card[data-part="pre-chorus"]{ background: linear-gradient(160deg, #1a3a3a, #0d1f1f); }
.viz-block-card[data-part="hook"]     { background: linear-gradient(160deg, #3a3a1a, #1f1f0d); }

/* ── Radial Pulse canvas mode ───────────────────────────────────── */
.viz-radial-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9010;
  display: block;
  background: #0a0a0f;
}

.viz-radial-canvas.viz-hidden {
  display: none;
}

/* Mode button styling */
.viz-mode-btn {
  background: rgba(100, 80, 200, 0.25) !important;
  border-color: rgba(150, 120, 255, 0.5) !important;
  color: rgba(200, 180, 255, 0.9) !important;
  font-size: 11px !important;
  padding: 4px 10px !important;
}

.viz-mode-btn:hover {
  background: rgba(120, 100, 220, 0.45) !important;
  color: #fff !important;
}
