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

:root {
  --accent1: #a78bfa;
  --accent2: #60a5fa;
  --station-bg1: #6d28d9;
  --station-bg2: #4c1d95;
}

body {
  background: #080810;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow: hidden;
}

/* ── Animated Background Blobs ─────────────────────────────── */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.25;
  pointer-events: none;
}
.blob-1 { width: 500px; height: 500px; background: var(--station-bg1); top: -150px; left: -150px; animation: blob1 10s ease-in-out infinite; }
.blob-2 { width: 400px; height: 400px; background: var(--station-bg2); bottom: -120px; right: -100px; animation: blob2 12s ease-in-out infinite; }
.blob-3 { width: 300px; height: 300px; background: var(--accent2); top: 40%; left: 60%; animation: blob3 9s ease-in-out infinite; opacity: 0.15; }

@keyframes blob1 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(40px,-30px) scale(1.15)} }
@keyframes blob2 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-30px,40px) scale(1.1)} }
@keyframes blob3 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-20px,-25px) scale(1.12)} }

/* ── Phone Frame ────────────────────────────────────────────── */
.phone {
  width: 390px;
  height: 844px;
  background: linear-gradient(165deg, #14141e 0%, #0d0d16 100%);
  border-radius: 52px;
  border: 1.5px solid rgba(255,255,255,0.08);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.5),
    0 60px 120px rgba(0,0,0,0.9),
    inset 0 1px 0 rgba(255,255,255,0.07);
  transition: box-shadow 0.8s ease;
}

/* Dynamic Island */
.dynamic-island {
  position: absolute;
  top: 13px; left: 50%;
  transform: translateX(-50%);
  width: 126px; height: 37px;
  background: #000;
  border-radius: 20px;
  z-index: 200;
  display: flex;
  align-items: center; justify-content: center;
  overflow: hidden;
  transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1), height 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.dynamic-island.expanded { width: 280px; height: 50px; }
.island-live {
  display: flex; align-items: center; gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease 0.2s;
  color: #fff; font-size: 11px; font-weight: 600;
}
.dynamic-island.expanded .island-live { opacity: 1; }
.island-dot {
  width: 8px; height: 8px;
  background: #ef4444; border-radius: 50%;
  animation: pulse-dot 1.2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Status Bar */
.status-bar {
  padding: 58px 30px 0;
  display: flex; justify-content: space-between; align-items: center;
  color: rgba(255,255,255,0.85);
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.status-time { font-size: 16px; font-weight: 700; }
.status-icons { display: flex; gap: 6px; align-items: center; }
.status-icons svg { width: 16px; height: 16px; fill: rgba(255,255,255,0.85); }
.battery-bar {
  width: 22px; height: 11px;
  border: 1.5px solid rgba(255,255,255,0.7);
  border-radius: 3px;
  position: relative;
  display: flex; align-items: center; padding: 1.5px;
}
.battery-bar::after {
  content: '';
  position: absolute; right: -4px; top: 50%;
  transform: translateY(-50%);
  width: 2.5px; height: 5px;
  background: rgba(255,255,255,0.7); border-radius: 0 1px 1px 0;
}
.battery-fill { height: 100%; width: 70%; background: #4ade80; border-radius: 1px; }

/* Header */
.header {
  padding: 16px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.header-title { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.header-subtitle { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 1px; }
.icon-btn {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }
.icon-btn svg { width: 18px; height: 18px; stroke: rgba(255,255,255,0.8); fill: none; }

/* ── Now Playing Card ───────────────────────────────────────── */
.now-playing {
  margin: 16px 20px 0;
  padding: 24px;
  padding-top: 50px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.now-playing::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% -20%, var(--station-bg1) 0%, transparent 65%);
  opacity: 0.25; transition: all 1s ease;
}

/* Album Art */
.art-wrapper {
  position: relative;
  width: 120px; height: 120px;
  margin-bottom: 18px;
}
.art-ring {
  position: absolute; inset: -12px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.08);
  animation: ring-spin 12s linear infinite;
  opacity: 0; transition: opacity 0.5s ease;
}
.art-ring:nth-child(2) { inset: -22px; animation-duration: 18s; animation-direction: reverse; }
.art-ring:nth-child(3) { inset: -34px; animation-duration: 25s; border-style: dashed; }
.playing .art-ring { opacity: 1; }
@keyframes ring-spin { to { transform: rotate(360deg); } }

.art-circle {
  width: 120px; height: 120px; margin: auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--station-bg1), var(--station-bg2));
  display: flex; align-items: center; justify-content: center;
  font-size: 52px;
  position: relative; z-index: 2;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 60px rgba(167,139,250,0.15);
  transition: background 0.8s ease, box-shadow 0.8s ease;
  animation: none;
}
.playing .art-circle { animation: art-pulse 3s ease-in-out infinite; }
@keyframes art-pulse {
  0%,100% { transform: scale(1);    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 40px rgba(167,139,250,0.15); }
  50%      { transform: scale(1.03); box-shadow: 0 8px 60px rgba(0,0,0,0.5), 0 0 80px rgba(167,139,250,0.35); }
}

/* Equalizer Bars */
.eq-bars {
  position: absolute; bottom: 18px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 4px;
  height: 28px; z-index: 3;
  opacity: 0; transition: opacity 0.4s ease;
}
.playing .eq-bars { opacity: 1; }
.eq-bar {
  width: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.9);
  animation: none; height: 6px;
}
.playing .eq-bar { animation: eq-bounce var(--dur, 0.8s) ease-in-out infinite alternate; }
.eq-bar:nth-child(1) { --dur: 0.6s; }
.eq-bar:nth-child(2) { --dur: 0.8s; }
.eq-bar:nth-child(3) { --dur: 0.5s; }
.eq-bar:nth-child(4) { --dur: 0.9s; }
.eq-bar:nth-child(5) { --dur: 0.7s; }
.eq-bar:nth-child(6) { --dur: 1.0s; }
.eq-bar:nth-child(7) { --dur: 0.55s; }
.eq-bar:nth-child(8) { --dur: 0.85s; }
@keyframes eq-bounce { 0%{height:4px} 100%{height:24px} }

/* Station Info */
.station-meta { text-align: center; position: relative; z-index: 2; width: 100%; }
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(239,68,68,0.18);
  border: 1px solid rgba(239,68,68,0.35);
  color: #f87171; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; padding: 3px 9px;
  border-radius: 20px; text-transform: uppercase; margin-bottom: 8px;
}
.live-badge .dot { width: 5px; height: 5px; background: #ef4444; border-radius: 50%; animation: pulse-dot 1.2s ease-in-out infinite; }
.station-name { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -0.3px; margin-bottom: 3px; transition: all 0.4s ease; }
.station-genre { font-size: 12px; color: rgba(255,255,255,0.45); font-weight: 500; margin-bottom: 6px; }
.station-desc { font-size: 11px; color: rgba(255,255,255,0.28); line-height: 1.4; }

/* ── Wave Visualizer ────────────────────────────────────────── */
.wave-container {
  margin: 16px 24px 0;
  height: 48px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  gap: 3px; padding: 0 14px; flex-shrink: 0;
}
.wave-bar {
  flex: 1; max-width: 5px; border-radius: 3px;
  background: linear-gradient(to top, var(--station-bg1), var(--accent1));
  height: 6px; opacity: 0.5; transition: opacity 0.4s;
}
.playing-wave .wave-bar {
  opacity: 1;
  animation: wave-anim var(--spd, 0.8s) ease-in-out infinite alternate;
}
@keyframes wave-anim { 0%{height:4px} 100%{height:var(--h, 32px)} }

/* ── Controls ───────────────────────────────────────────────── */
.controls {
  margin: 18px 80px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ctrl-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 50%;
  transition: transform 0.15s ease, background 0.2s;
}
.ctrl-btn:hover  { transform: scale(1.1); }
.ctrl-btn:active { transform: scale(0.92); }
.ctrl-btn svg { width: 22px; height: 22px; stroke: rgba(255,255,255,0.6); fill: none; }
.ctrl-btn.side { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); }
.ctrl-btn.side:hover { background: rgba(255,255,255,0.12); }

.play-btn {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--accent1), #818cf8);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
  box-shadow: 0 8px 32px rgba(167,139,250,0.45);
}
.play-btn:hover  { transform: scale(1.08); box-shadow: 0 12px 40px rgba(167,139,250,0.6); }
.play-btn:active { transform: scale(0.94); }
.play-btn svg { width: 30px; height: 30px; stroke: #fff; fill: #fff; }
.play-btn .pause-icon { display: none; }
.play-btn.playing .play-icon  { display: none; }
.play-btn.playing .pause-icon { display: block; }

/* ── Volume ─────────────────────────────────────────────────── */
.volume-row {
  margin: 16px 24px 0;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.vol-icon { color: rgba(255,255,255,0.4); flex-shrink: 0; }
.vol-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }
.vol-slider {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px; outline: none; cursor: pointer;
}
.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer; transition: transform 0.15s;
}
.vol-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* ── Stations Panel (absolute top overlay) ─────────────────── */
.stations-panel {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(165deg, #14141e 0%, #0d0d16 100%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 52px;
  overflow: hidden;
  padding-top: 58px;
  -webkit-overflow-scrolling: touch;
}
.stations-panel.open { transform: translateY(0); }
.stations-panel-header {
  padding: 14px 24px 12px;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 4px;
}
.stations-panel-title { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -0.3px; }
.stations-panel-sub   { font-size: 12px; color: rgba(255,255,255,0.35); margin-top: 2px; }

.stations-list {
  flex: 1; overflow-y: auto;
  padding: 0 24px 30px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: none;
}
.stations-list::-webkit-scrollbar { display: none; }

.station-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  flex-shrink: 0;
}
.station-item:hover { background: rgba(255,255,255,0.08); transform: translateX(2px); }
.station-item.active {
  background: rgba(167,139,250,0.12);
  border-color: rgba(167,139,250,0.35);
}
.station-icon {
  width: 46px; height: 46px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.station-info { flex: 1; min-width: 0; }
.station-item-name { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station-item-genre { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.station-item-action {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.station-item-action svg { width: 16px; height: 16px; stroke: rgba(255,255,255,0.3); fill: none; }
.station-item.active .station-item-action svg { stroke: var(--accent1); }

/* Mini EQ */
.mini-eq { display: none; align-items: flex-end; gap: 2px; height: 18px; }
.station-item.active.playing .mini-eq { display: flex; }
.station-item.active.playing .station-item-action svg { display: none; }
.mini-eq-bar {
  width: 3px; border-radius: 2px;
  background: var(--accent1);
  animation: eq-bounce var(--dur, 0.7s) ease-in-out infinite alternate;
}
.mini-eq-bar:nth-child(1) { --dur: 0.5s; }
.mini-eq-bar:nth-child(2) { --dur: 0.8s; }
.mini-eq-bar:nth-child(3) { --dur: 0.6s; }

/* Loading spinner */
.loading-ring {
  display: none;
  width: 28px; height: 28px;
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.play-btn.loading .loading-ring { display: block; }
.play-btn.loading svg            { display: none; }

/* While already playing, skip the spinner — keep pause icon visible */
.play-btn.playing.loading .loading-ring { display: none; }
.play-btn.playing.loading .pause-icon   { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Transitions */
.fade-in { animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Error toast */
.toast {
  position: absolute;
  bottom: 90px; left: 24px; right: 24px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; font-size: 12px; font-weight: 500;
  padding: 10px 16px; border-radius: 14px;
  text-align: center; z-index: 500;
  display: none; animation: fadeIn 0.3s ease;
}
.toast.show { display: block; }

/* ── Mobile: hide phone frame, fill screen ──────────────────── */
@media (max-width: 480px) {
  body { align-items: flex-start; overflow: hidden; }
  .blob-1, .blob-2, .blob-3 { display: none; }

  .phone {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  /* Hide fake phone chrome */
  .dynamic-island { display: none; }
  .status-bar     { display: none; }

  /* Header */
  .header { padding: 14px 18px 0; }
  .header-title { font-size: 19px; }

  /* Now playing — compact */
    .now-playing {         
        margin: 16px 16px 0px;
        padding: 50px 16px 16px;
    }
  .art-wrapper  { width: 120px; height: 120px; margin-bottom: 12px; }
  .art-circle   { width: 120px; height: 120px; font-size: 38px; }
  .station-name { font-size: 16px; }
  .station-desc { display: none; }

  /* Wave */
  .wave-container { margin: 16px 16px 16px; height: 50px; }

  /* Controls */
  .controls   { margin: 16px 16px 0; }
  .play-btn   { width: 66px; height: 66px; }
  .ctrl-btn   { width: 44px; height: 44px; }

  /* Volume */
  .volume-row { margin: 16px 16px 0; }

  /* Stations panel — no rounded frame gap */
  .stations-panel { border-radius: 0; padding-top: 10px; }

  /* Toast */
  .toast { left: 16px; right: 16px; bottom: 16px; }
}

/* ── Rotate overlay (portrait-only enforcement) ─────────────── */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #080810;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #fff;
}
.rotate-icon {
  font-size: 64px;
  animation: rotate-hint 1.8s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%,100% { transform: rotate(0deg); }
  40%      { transform: rotate(-90deg); }
  60%      { transform: rotate(-90deg); }
}
.rotate-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
}
.rotate-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.45);
}

/* Show rotate overlay & hide player in landscape on mobile */
@media (orientation: landscape) and (max-width: 800px) {
  .rotate-overlay { display: flex; }
  .blob-1, .blob-2, .blob-3 { display: none; }
  .phone { display: none; }
}
