/**
 * daisyradio.org - Stylesheet
 * 
 * Design System:
 * - Glassmorphism UI with backdrop-filter blur
 * - Pink (#ff69b4) and deep purple gradient theme
 * - Hardware-accelerated animations (60fps)
 * - Mobile-first responsive design
 * 
 * Performance:
 * - CSS containment for layout optimization
 * - will-change hints for animated elements
 * - transform: translateZ(0) for GPU acceleration
 * 
 * Accessibility:
 * - High contrast text
 * - Focus indicators
 * - ARIA-friendly structure
 * - Touch-friendly 44px+ targets
 */

/* ===== Reset & Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== CSS Variables / Design Tokens ===== */
:root {
  --primary: #ff69b4; /* Hot pink */
  --secondary: #ff1493; /* Deep pink */
  --accent: #ffd700; /* Gold accent */
  --bg: #0a0a0a; /* Deep black */
  --card-bg: rgba(30, 30, 30, 0.95); /* Dark glass */
  --text: #ffffff; /* Pure white */
  --text-muted: #c0c0c0; /* Silver gray */
}

/* ===== Canvas Layers ===== */
/* Background: Music-reactive radio waves */
#particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
  filter: blur(1px);
}

/* Foreground: Audio frequency visualizer */
#visualizer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.5;
  mix-blend-mode: screen; /* Blend with album art */
  pointer-events: none;
  border-radius: 16px;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

/* ===== Body & Background ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-display: swap;
  background: linear-gradient(135deg, #0a0a0a 0%, #1a0a1a 50%, #0a0a1a 100%);
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  will-change: background-position;
  position: relative;
  overflow-x: hidden;
}

/* Animated gradient background */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ===== Layout Container ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 2;
}

/* ===== Header Section ===== */
header {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 30px;
}

/* Main title with gradient text effect */
header h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 900;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 20px rgba(255, 105, 180, 0.4),
    0 0 40px rgba(255, 105, 180, 0.2);
  background: linear-gradient(135deg, #fff 0%, #ff69b4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255, 105, 180, 0.3));
}

header h1 .subtitle {
  display: inline-block;
  font-size: 0.4em;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 0.5em;
}

/* Subtitle/tagline */
.tagline {
  color: var(--text-muted);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 600;
  opacity: 0.8;
}

.listener-icon {
  font-size: 1.2rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* ===== Main Player Card ===== */
/* Glassmorphism card with backdrop blur */
.player-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transform: translateZ(0);
  will-change: transform;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.player-card:hover {
  transform: translateY(-2px) translateZ(0);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 80px rgba(255, 105, 180, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.15);
}

/* ===== Album Art Container ===== */
.album-art {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 24px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(255, 105, 180, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  transform: translateZ(0);
  will-change: transform;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.album-art:hover {
  transform: scale(1.02) translateZ(0);
  box-shadow: 0 25px 80px rgba(255, 105, 180, 0.5),
    0 0 100px rgba(255, 105, 180, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.album-art img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease, transform 0.3s ease;
  will-change: opacity, transform;
  transform: translateZ(0);
}

.album-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 3s infinite;
  pointer-events: none;
  border-radius: 16px;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

.live-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-indicator.hidden {
  display: none;
}

.pulse {
  width: 8px;
  height: 8px;
  background: #ff0000;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

.live-indicator .text {
  color: #ff0000;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 1px;
}

/* ===== Now Playing Section ===== */
.now-playing {
  text-align: center;
  margin-bottom: 24px;
}

.song-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
  line-height: 1.3;
  animation: fadeSlideIn 0.5s ease;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.song-artist {
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  color: var(--text-muted);
  font-weight: 500;
}

/* Progress */
.progress-container {
  margin-bottom: 24px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  transition: width 1s linear;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 105, 180, 0.6);
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: -2px;
  bottom: -2px;
  width: 4px;
  background: white;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.time-info {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

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

.play-button {
  width: 72px;
  height: 72px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(255, 105, 180, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: buttonGlow 3s ease-in-out infinite;
}

@keyframes buttonGlow {
  0%,
  100% {
    box-shadow: 0 8px 24px rgba(255, 105, 180, 0.4);
  }
  50% {
    box-shadow: 0 8px 40px rgba(255, 105, 180, 0.7),
      0 0 60px rgba(255, 105, 180, 0.3);
  }
}

.play-button:hover {
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 12px 50px rgba(255, 105, 180, 0.8),
    0 0 80px rgba(255, 105, 180, 0.4);
  animation: none;
}

.play-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(255, 105, 180, 0.4),
    0 0 40px rgba(255, 105, 180, 0.3);
}

.play-button:active {
  transform: scale(0.95);
}

.play-button svg {
  width: 28px;
  height: 28px;
}

.play-icon.hidden,
.pause-icon.hidden {
  display: none;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 200px;
}

.volume-icon {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#volumeSlider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

#volumeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

#volumeSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* Enhanced focus indicators for accessibility */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255, 105, 180, 0.3);
}

.play-button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 5px;
  box-shadow: 0 8px 40px rgba(255, 105, 180, 0.8),
    0 0 0 6px rgba(255, 105, 180, 0.4);
}

/* Volume tooltip */
.volume-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(0, 0, 0, 0.9);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
}

.volume-control:hover .volume-tooltip,
.volume-control:focus-within .volume-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(-12px);
}

.volume-control {
  position: relative;
}

/* Info Grid */
.info-grid {
  margin-bottom: 20px;
}

.next-section {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.next-section h3 {
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 600;
}

.next-track {
  display: flex;
  gap: 12px;
  align-items: center;
}

.next-track img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}

.next-info {
  flex: 1;
  min-width: 0;
}

.next-title {
  font-weight: 600;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.next-artist {
  color: #d0d0d0; /* Improved from #c0c0c0 for better contrast */
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
}

/* ===== Recently Played History ===== */
.history-section {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.history-section h3 {
  margin-bottom: 20px;
  font-size: 1rem;
  font-weight: 600;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateZ(0);
  will-change: transform, background, box-shadow;
  cursor: pointer;
}

.history-item:hover {
  background: rgba(255, 105, 180, 0.15);
  transform: translateX(8px) scale(1.02);
  box-shadow: 0 4px 20px rgba(255, 105, 180, 0.3);
  border-left: 3px solid var(--primary);
}

.history-art img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-weight: 600;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-artist {
  color: var(--text-muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ===== Footer & Share Button ===== */
footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.share-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 15px rgba(255, 105, 180, 0.4);
  margin-bottom: 16px;
  transform: translateZ(0);
}

.share-button svg {
  width: 18px;
  height: 18px;
}

.share-button:hover {
  transform: translateY(-3px) scale(1.05) translateZ(0);
  box-shadow: 0 8px 25px rgba(255, 105, 180, 0.6);
}

.share-button:active {
  transform: translateY(-1px) scale(0.98) translateZ(0);
}

footer a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.3s ease;
}

footer a:hover {
  color: var(--secondary);
}

/* ===== Empty States ===== */
.empty-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.empty-state.hidden {
  display: none;
}

.empty-state p {
  opacity: 0.7;
}

/* ========================================
   RESPONSIVE DESIGN
   Mobile-first breakpoints for all devices
   ======================================== */

/* Large screens / 4K TVs (1920px+) */
@media (min-width: 1920px) {
  .container {
    max-width: 1200px;
  }

  header h1 {
    font-size: 5rem;
  }

  .player-card {
    padding: 60px;
  }

  .album-art-container {
    max-width: 450px;
    max-height: 450px;
  }
}

/* Tablets and small laptops */
@media (max-width: 1024px) {
  .container {
    max-width: 90%;
  }

  .album-art-container {
    max-width: 320px;
    max-height: 320px;
  }
  /* Two-column layout for info sections on larger tablets */
  .info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
}

/* Tablets portrait */
@media (max-width: 768px) {
  .container {
    padding: 16px;
  }

  .player-card {
    padding: 24px 20px;
  }

  header h1 {
    font-size: 2.5rem;
  }

  .album-art-container {
    max-width: 280px;
    max-height: 280px;
  }

  .volume-control {
    max-width: 100%;
    width: 100%;
  }

  .history-item {
    padding: 12px;
  }
}

/* Mobile landscape */
@media (max-width: 640px) and (orientation: landscape) {
  header {
    padding: 20px 20px;
  }

  .player-card {
    padding: 20px 16px;
  }

  .album-art-container {
    max-width: 180px;
    max-height: 180px;
  }

  /* Stack controls horizontally to save vertical space */
  .player-controls {
    flex-direction: row;
  }

  /* Reduce vertical spacing */
  .now-playing {
    margin-bottom: 12px;
  }

  .progress-container {
    margin-bottom: 12px;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  header {
    padding: 30px 16px;
  }

  header h1 {
    font-size: 2rem;
  }

  .tagline {
    font-size: 0.85rem;
    letter-spacing: 2px;
  }

  .player-card {
    padding: 20px 16px;
  }

  .album-art-container {
    max-width: 240px;
    max-height: 240px;
  }

  .player-controls {
    flex-direction: column;
    gap: 16px;
  }

  .volume-control {
    width: 100%;
  }

  .history-item {
    padding: 10px;
    gap: 10px;
  }

  .history-art {
    width: 40px;
    height: 40px;
  }

  .history-title {
    font-size: 0.9rem;
  }

  .history-artist {
    font-size: 0.8rem;
  }
}

/* Extra small phones */
@media (max-width: 360px) {
  .container {
    padding: 12px;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .album-art-container {
    max-width: 200px;
    max-height: 200px;
  }

  .play-button {
    width: 60px;
    height: 60px;
  }
}

/* Galaxy Fold and ultra-narrow devices (< 360px) */
@media (max-width: 280px) {
  .container {
    padding: 8px;
  }

  header h1 {
    font-size: 1.5rem;
    letter-spacing: -0.05em;
  }

  header h1 .subtitle {
    display: block;
    margin-left: 0;
    margin-top: 0.25em;
  }

  .tagline {
    font-size: 0.75rem;
    letter-spacing: 1px;
  }

  .player-card {
    padding: 16px 12px;
  }

  .album-art-container {
    max-width: 160px;
    max-height: 160px;
  }

  .song-title {
    font-size: 1.25rem;
  }

  .song-artist {
    font-size: 1rem;
  }

  .play-button {
    width: 56px;
    height: 56px;
  }

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

  .volume-control {
    max-width: 100%;
  }

  .next-track img {
    width: 48px;
    height: 48px;
  }

  .history-art img {
    width: 36px;
    height: 36px;
  }
}
