/* CSS Variables */
:root {
  --primary: #e63946;
  --primary-light: #ff6b6b;
  --dark: #0d1117;
  --dark-surface: #161b22;
  --dark-card: #21262d;
  --light: #f8f9fa;
  --text-muted: #8b949e;
  --gradient-primary: linear-gradient(135deg, #e63946 0%, #ff6b6b 100%);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--dark);
  color: var(--light);
}

/* Background */
.bg-animation {
  position: fixed;
  inset: 0;
  z-index: -1;
}

.bg-gradient {
  position: absolute;
  inset: 0;
  /* Cor sólida enquanto a imagem carrega, evitando flash preto */
  background-color: #0f0a1e;
  /* image-set(): o navegador escolhe WebP e cai para JPEG onde não houver suporte */
  background-image: image-set(
    url('../img/fundo.webp') type('image/webp'),
    url('../img/fundo.jpg') type('image/jpeg')
  );
  background-image: -webkit-image-set(
    url('../img/fundo.webp') type('image/webp'),
    url('../img/fundo.jpg') type('image/jpeg')
  );
  background-size: cover;
  background-position: center;
}

/* Telas menores recebem a variante leve (1280px) */
@media (max-width: 900px) {
  .bg-gradient {
    background-image: image-set(
      url('../img/fundo-1280.webp') type('image/webp'),
      url('../img/fundo-1280.jpg') type('image/jpeg')
    );
    background-image: -webkit-image-set(
      url('../img/fundo-1280.webp') type('image/webp'),
      url('../img/fundo-1280.jpg') type('image/jpeg')
    );
  }
}

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

/* Logo */
.logo-section {
  margin-bottom: 2rem;
}

.logo-image {
  max-width: 180px;
  height: auto;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

/* Player Wrapper */
.player-wrapper {
  width: 100%;
  max-width: 600px;
}

/* Player Card */
.player-card {
  background: var(--dark-card);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Main Content Row */
.player-main-row {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

/* Album Cover */
.album-cover-wrapper {
  width: 180px;
  height: 180px;
  min-width: 180px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  position: relative;
  flex-shrink: 0;
}

.album-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.album-cover.visible {
  display: block;
}

.album-cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-cover-placeholder.hidden {
  display: none;
}

.album-cover-placeholder svg {
  width: 45%;
  height: 45%;
  color: rgba(255, 255, 255, 0.7);
}

/* Right Content */
.player-right-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

/* Track Info */
.track-info {
  text-align: left;
  width: 100%;
}

.now-playing-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.track-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 6px 0;
  color: var(--light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

/* Marquee container for scrolling effect */
.track-title-wrapper {
  overflow: hidden;
  width: 100%;
  position: relative;
}

.track-title.marquee {
  display: inline-block;
  animation: marquee-pingpong 8s ease-in-out infinite;
  text-overflow: unset;
}

@keyframes marquee-pingpong {
  0%, 15% {
    transform: translateX(0);
  }
  35%, 65% {
    transform: translateX(var(--scroll-distance, -100px));
  }
  85%, 100% {
    transform: translateX(0);
  }
}

/* Container query support for the ping-pong effect */
.track-title-wrapper {
  overflow: hidden;
  width: 100%;
  position: relative;
  container-type: inline-size;
}

/* Pause marquee on hover */
.track-title.marquee:hover {
  animation-play-state: paused;
}

.track-artist {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Visualizer */
.visualizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 70px;
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 8px 12px;
}

.spectrum {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.spectrum-bar {
  flex: 1;
  max-width: 10px;
  min-height: 4px;
  height: 4px;
  background: var(--gradient-primary);
  border-radius: 2px;
  transition: height 0.06s ease-out;
  position: relative;
}

.spectrum-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 2px 2px 0 0;
  opacity: 0;
  transition: opacity 0.1s ease;
}

.spectrum-bar.active::after {
  opacity: 1;
}

/* Peak indicator animation */
@keyframes peak-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.spectrum-bar.peak {
  animation: peak-pulse 0.3s ease-in-out;
}

/* Idle state */
.player-card:not(.playing) .spectrum-bar {
  background: rgba(255, 255, 255, 0.08);
  height: 4px !important;
  min-height: 4px;
  box-shadow: none;
}

/* Player Controls */
.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

/* Play Button */
.play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(230, 57, 70, 0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 25px rgba(230, 57, 70, 0.6);
}

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

.icon-pause {
  display: none;
}

.player-card.playing .icon-play {
  display: none;
}

.player-card.playing .icon-pause {
  display: block;
}

/* Volume */
.volume-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.volume-icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.volume-wrapper:hover .volume-icon {
  color: var(--light);
}

.volume-slider {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.2s;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Status */
.status-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s, box-shadow 0.3s;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
}

.status-dot.connecting {
  background: #f59e0b;
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 85px;
  font-weight: 500;
}

/* Responsive */
@media (max-width: 600px) {
  .player-wrapper {
    max-width: 100%;
  }
  
  .player-main-row {
    flex-direction: column;
    align-items: center;
  }
  
  .album-cover-wrapper {
    width: 160px;
    height: 160px;
    min-width: 160px;
  }
  
  .player-right-content {
    width: 100%;
  }
  
  .track-info {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .logo-image {
    max-width: 140px;
  }
  
  .player-card {
    padding: 20px;
    gap: 16px;
  }
  
  .album-cover-wrapper {
    width: 140px;
    height: 140px;
    min-width: 140px;
  }
  
  .visualizer {
    height: 55px;
    padding: 6px 10px;
  }
  
  .spectrum-bar {
    max-width: 8px;
  }
  
  .play-btn {
    width: 50px;
    height: 50px;
  }
  
  .volume-slider {
    width: 60px;
  }
  
  .status-text {
    min-width: 70px;
    font-size: 0.8rem;
  }
  
  .track-title {
    font-size: 1.1rem;
  }
}

/* Logo Below Player */
.logo-below-section {
  margin-top: 2rem;
  text-align: center;
}

.logo-below-image {
  max-width: 350px;
  height: auto;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.5));
}

@media (max-width: 480px) {
  .logo-below-image {
    max-width: 280px;
  }
}
