/* ========================================
   DISCOVERY - Discovery Mode Spatial
   Network Graph with bottom player
   ======================================== */

/* ========== DISCOVERY PAGE ========== */
#discovery-content {
  display: none;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transition: background 0.3s ease;
}

#discovery-content.active {
  display: block;
}

/* Dark mode */
[data-theme="dark"] #discovery-content {
  background: #0f0f14;
}

/* Graph Container (Full Screen) */
.discovery-graph-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  overflow: hidden;
  z-index: 1;
  transition: background 0.3s ease;
}

[data-theme="dark"] .discovery-graph-container {
  background: #0f0f14;
}

#discoveryCanvas {
  width: 100%;
  height: 100%;
  cursor: grab;
  display: block;
}

#discoveryCanvas:active {
  cursor: grabbing;
}

/* ========== PLAYER CARD (Bottom) ========== */
.discovery-player-card {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.08);
  width: 850px;
  max-width: calc(100vw - 40px);
  z-index: 1000;
  backdrop-filter: blur(20px);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="dark"] .discovery-player-card {
  background: rgba(24, 24, 32, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Waveform Container */
.discovery-waveform-container {
  flex: 1;
  height: 48px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.discovery-waveform-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.discovery-waveform-wrapper [id^="waveform-"] {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Player Cover */
.discovery-player-cover {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-secondary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  flex-shrink: 0;
}

.discovery-player-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discovery-cover-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  color: var(--text-secondary);
}

.discovery-cover-placeholder::before {
  content: "";
  width: 48px;
  height: 48px;
  background: currentColor;
  mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18V5L21 3V16"/><path d="M6 21C7.65685 21 9 19.6569 9 18C9 16.3431 7.65685 15 6 15C4.34315 15 3 16.3431 3 18C3 19.6569 4.34315 21 6 21Z"/><path d="M18 19C19.6569 19 21 17.6569 21 16C21 14.3431 19.6569 13 18 13C16.3431 13 15 14.3431 15 16C15 17.6569 16.3431 19 18 19Z"/></svg>');
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

/* Player Info */
.discovery-player-info {
  min-width: 0;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.discovery-loop-name {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'Satoshi', 'Plus Jakarta Sans', sans-serif;
  transition: color 0.3s ease;
}

[data-theme="dark"] .discovery-loop-name {
  color: #ffffff;
}

.discovery-loop-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #666;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.3s ease;
}

[data-theme="dark"] .discovery-loop-meta {
  color: #999;
}

.meta-separator {
  color: #ccc;
  transition: color 0.3s ease;
}

[data-theme="dark"] .meta-separator {
  color: #555;
}

/* Player Controls + Actions Combined */
.discovery-player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.discovery-ctrl-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.discovery-ctrl-btn svg {
  width: 18px;
  height: 18px;
}

.discovery-ctrl-btn:hover {
  color: #1a1a1a;
  background: rgba(0, 0, 0, 0.05);
  transform: scale(1.05);
}

[data-theme="dark"] .discovery-ctrl-btn {
  color: #999;
}

[data-theme="dark"] .discovery-ctrl-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.discovery-play-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a1a;
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

[data-theme="dark"] .discovery-play-btn {
  background: #ffffff;
  color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.discovery-play-btn svg {
  width: 18px;
  height: 18px;
}

.discovery-play-btn .play-icon {
  margin-left: 2px;
}

.discovery-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .discovery-play-btn:hover {
  box-shadow: 0 6px 16px rgba(255, 255, 255, 0.3);
}

.discovery-play-btn:active {
  transform: scale(0.95);
}

/* Separator between controls and actions */
.discovery-controls-separator {
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.1);
  margin: 0 4px;
  flex-shrink: 0;
  transition: background 0.3s ease;
}

[data-theme="dark"] .discovery-controls-separator {
  background: rgba(255, 255, 255, 0.15);
}

.discovery-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

[data-theme="dark"] .discovery-action-btn {
  border-color: rgba(255, 255, 255, 0.15);
  color: #999;
}

.discovery-action-btn svg {
  width: 16px;
  height: 16px;
}

.discovery-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
  color: #1a1a1a;
  transform: scale(1.05);
}

[data-theme="dark"] .discovery-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.discovery-action-btn.liked {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.discovery-action-btn.liked svg {
  fill: #ef4444;
}

.discovery-action-btn.liked:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

.discovery-action-btn.loading {
  pointer-events: none;
  opacity: 1 !important;
}

.discovery-action-btn .discovery-icon {
  display: block;
}

.discovery-action-btn.loading .discovery-icon {
  display: none !important;
}

.discovery-action-btn .discovery-spinner {
  display: none;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  margin: auto;
  will-change: transform, opacity;
}

.discovery-action-btn.loading .discovery-spinner {
  display: flex !important;
}

.discovery-action-btn .discovery-spinner svg {
  animation: rotate 1s linear infinite;
  width: 100%;
  height: 100%;
  display: block;
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.discovery-action-btn .discovery-spinner circle {
  stroke: #333;
  stroke-width: 4;
  fill: none;
  stroke-dasharray: 80, 200;
  stroke-dashoffset: 0;
  animation: dash 1.5s ease-in-out infinite;
  stroke-linecap: round;
  will-change: stroke-dasharray, stroke-dashoffset;
}

.discovery-action-btn.downloaded {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
}

.discovery-action-btn.downloaded .discovery-icon {
  stroke: #10b981;
}

/* Empty state */
.discovery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: #666;
  width: 100%;
}

.discovery-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  opacity: 0.4;
  color: #999;
}

.discovery-empty h3 {
  font-size: 20px;
  color: #333;
  margin: 0 0 8px 0;
}

.discovery-empty p {
  font-size: 14px;
  margin: 0 0 20px 0;
}

.discovery-empty-btn {
  padding: 12px 24px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.discovery-empty-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Loading state */
.discovery-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
}

.discovery-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid #e0e0e0;
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive */
@media (max-width: 890px) {
  .discovery-player-card {
    width: calc(100vw - 40px);
    gap: 12px;
    padding: 10px 16px;
    bottom: 16px;
  }
  
  .discovery-player-info {
    width: 160px;
  }
  
  .discovery-player-cover {
    width: 56px;
    height: 56px;
  }
  
  .discovery-loop-name {
    font-size: 13px;
  }
  
  .discovery-loop-meta {
    font-size: 10px;
  }
  
  .discovery-waveform-container {
    height: 40px;
  }
}

@media (max-width: 600px) {
  .discovery-player-card {
    gap: 8px;
    padding: 8px 12px;
    bottom: 12px;
    flex-wrap: wrap;
  }
  
  .discovery-player-info {
    width: 140px;
  }
  
  .discovery-player-cover {
    width: 48px;
    height: 48px;
  }
  
  .discovery-waveform-container {
    order: 10;
    width: 100%;
    height: 32px;
    margin-top: 8px;
  }
  
  .discovery-ctrl-btn {
    width: 28px;
    height: 28px;
  }
  
  .discovery-ctrl-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .discovery-play-btn {
    width: 36px;
    height: 36px;
  }
  
  .discovery-play-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .discovery-action-btn {
    width: 28px;
    height: 28px;
  }
  
  .discovery-action-btn svg {
    width: 14px;
    height: 14px;
  }
  
  .discovery-controls-separator {
    height: 20px;
  }
}
