/* ==========================================================================
   4. FULLSCREEN VIDEO VISUALIZER VIEW & OVERLAY MODAL
   ========================================================================== */
.visualizer-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem 0;
  box-sizing: border-box;
}

.visualizer-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.visualizer-overlay .visualizer-stage {
  min-height: auto;
  position: relative;
}

.visualizer-close-x {
  position: absolute;
  top: clamp(1rem, 2.5vh, 2rem);
  right: clamp(1rem, 3.5vw, 2.5rem);
  background: transparent;
  border: none;
  border-radius: 0;
  width: 42px;
  height: 42px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  z-index: 100;
}

.visualizer-close-x:hover {
  color: #ffffff;
  transform: scale(1.18);
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.8);
}

.view-visualizer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 160px);
  padding: 1.5rem 0 3.5rem 0;
  position: relative;
  width: 100vw;
  max-width: 100vw;
  overflow-x: hidden;
}

.visualizer-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  max-width: 100vw;
  margin: 0;
  padding: 0;
  min-height: calc(100vh - 220px);
}

.visualizer-video-container {
  width: 100vw;
  max-width: 100vw;
  height: auto;
  aspect-ratio: 1920 / 628;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 2rem 0;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
}

.visualizer-video {
  width: 100vw;
  max-width: 100vw;
  height: 100%;
  aspect-ratio: 1920 / 628;
  object-fit: cover;
  display: block;
}

.visualizer-canvas-fallback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100%;
}

/* ==========================================================================
   VISUALIZER CONTROLS SUITE & EXPANDABLE PROJECT TRACK DRAWER
   ========================================================================== */
.visualizer-controls-wrap {
  width: min(92vw, 840px);
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
}

/* Drawer Toggle Button */
.visualizer-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.visualizer-drawer-toggle {
  background: transparent;
  border: none;
  border-radius: 0;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  user-select: none;
}

.visualizer-drawer-toggle:hover {
  color: #ffffff;
  background: transparent;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

.visualizer-drawer-toggle .toggle-arrow {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.85rem;
  line-height: 1;
}

.visualizer-drawer-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

.visualizer-drawer-toggle.open {
  color: #ffffff;
  background: transparent;
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

/* Expandable Tracklist Drawer */
.visualizer-track-drawer {
  width: 100%;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  background: rgba(10, 10, 10, 0.94);
  border: none;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease,
              visibility 0.3s,
              margin 0.3s;
  margin-bottom: 0;
  box-sizing: border-box;
}

.visualizer-track-drawer.open {
  max-height: 320px;
  opacity: 1;
  visibility: visible;
  padding: 12px 16px 14px 16px;
  margin-bottom: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 255, 255, 0.05);
}

.visualizer-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.visualizer-drawer-tracklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 4px 12px;
}

.visualizer-drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.visualizer-drawer-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.visualizer-drawer-item.playing {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}

.visualizer-drawer-item .track-idx {
  opacity: 0.45;
  margin-right: 6px;
  font-size: 0.78rem;
}

.visualizer-drawer-item.playing .track-idx {
  opacity: 0.9;
  color: #ffffff;
}

.visualizer-drawer-item .track-dur {
  font-size: 0.8rem;
  opacity: 0.6;
}

.visualizer-drawer-item.playing .track-dur {
  opacity: 1;
}

/* Visualizer Controls & Scrubber Bar */
.visualizer-player-bar {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  gap: 12px;
  margin-bottom: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  box-sizing: border-box;
}

/* Center Column: Drawer, Arrow & Glassmorphic HUD Bar perfectly aligned */
.visualizer-hud-center {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  min-width: 0;
}

/* Glassmorphic Center HUD Bar with Title & Timeline (Matches Home Visualizer) */
.visualizer-hud-bar {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 0;
  padding: 10px 20px;
  height: 52px;
  box-sizing: border-box;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-width: 0;
}

.visualizer-nav-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--font-mono);
  font-size: 1.18rem;
  line-height: 1;
  padding: 0 8px;
  height: 52px;
  cursor: pointer;
  transition: color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.visualizer-nav-btn:hover {
  color: #ffffff;
  transform: scale(1.15);
}

.visualizer-track-title {
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: clamp(0.82rem, 1.3vw, 0.95rem);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast), opacity var(--transition-fast);
  min-width: 0;
}

.visualizer-track-title:hover {
  color: #ffffff;
  opacity: 0.85;
}

.visualizer-timeline-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 1;
  max-width: 260px;
  flex-shrink: 0;
}

.visualizer-time {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.04em;
  user-select: none;
}

.visualizer-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  position: relative;
  border-radius: 3px;
}

.visualizer-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 35%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
  transition: width 0.1s linear;
}

.visualizer-retour-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-primary);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  padding: 10px 28px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  transition: all var(--transition-fast);
}

.visualizer-retour-btn:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

@media (max-width: 768px) and (orientation: portrait), (max-width: 500px) {
  /* Fullscreen 100vh Vertical Visualizer on Mobile */
  .visualizer-overlay {
    padding: 0;
    overflow: hidden;
  }

  .view-visualizer {
    padding: 0;
    margin: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
    z-index: 95;
  }

  .visualizer-stage {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
  }

  /* Video container fills 100vh full-screen */
  .visualizer-video-container {
    position: absolute;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    overflow: hidden;
    z-index: 1;
    container-type: size;
    border-radius: 0;
    background: #000000;
  }

  /* Video rotated 90deg to cover full 100vh */
  .visualizer-video {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    width: 100cqh;
    height: 100cqw;
    min-width: 100cqh;
    min-height: 100cqw;
    max-width: none;
    max-height: none;
    aspect-ratio: unset;
    object-fit: cover;
    object-position: center;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  .visualizer-canvas-fallback {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100cqh;
    height: 100cqw;
    transform: translate(-50%, -50%) rotate(90deg);
  }

  /* Controls pinned as floating HUD over bottom of video */
  .visualizer-controls-wrap {
    position: relative;
    z-index: 20;
    width: min(92vw, 420px);
    margin-bottom: clamp(14px, 4vh, 32px);
  }

  /* Close button pinned on top right */
  .visualizer-close-x {
    top: max(14px, env(safe-area-inset-top, 14px));
    right: max(14px, env(safe-area-inset-right, 14px));
    z-index: 30;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
  }

  /* Return button pinned on top left in standalone view */
  .visualizer-retour-btn {
    position: absolute;
    top: max(14px, env(safe-area-inset-top, 14px));
    left: max(14px, env(safe-area-inset-left, 14px));
    z-index: 30;
    padding: 6px 14px;
    font-size: 0.78rem;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

@media (max-width: 768px) {
  .visualizer-hud-bar {
    padding: 8px 14px;
    gap: 10px;
    height: 48px;
  }
  .visualizer-nav-btn {
    height: 48px;
    font-size: 1.05rem;
  }
  .visualizer-timeline-wrap {
    max-width: 140px;
  }
  .visualizer-drawer-tracklist {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .visualizer-track-drawer.open {
    max-height: 240px;
  }
}


