/* Estilo inspirado en Apple Music / Apple Podcasts: claro u oscuro según el sistema. */
:root {
  --bg: #ffffff;
  --bg-side: #f5f5f7;
  --text: rgba(0, 0, 0, 0.88);
  --muted: rgba(0, 0, 0, 0.56);
  --sep: rgba(0, 0, 0, 0.1);
  --hover: rgba(0, 0, 0, 0.05);
  --glass: rgba(252, 252, 253, 0.72);
  --glass-border: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  --accent: #fa233b;
  --station: #b91c1c;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mini-h: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1f;
    --bg-side: #252525;
    --text: rgba(255, 255, 255, 0.92);
    --muted: rgba(255, 255, 255, 0.55);
    --sep: rgba(255, 255, 255, 0.12);
    --hover: rgba(255, 255, 255, 0.07);
    --glass: rgba(44, 44, 46, 0.72);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
    --accent: #fa2d48;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

svg { display: block; fill: currentColor; }

/* ---------- Marca y barra lateral ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand img { border-radius: 7px; }

.sidebar { display: none; }

#nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}

#nav a:hover { background: var(--hover); }

#nav a svg { width: 18px; height: 18px; color: var(--accent); }

/* ---------- Contenido ---------- */

.content {
  padding: max(16px, env(safe-area-inset-top)) 20px calc(var(--mini-h) + 40px + env(safe-area-inset-bottom));
  max-width: 1280px;
}

.brand-mobile { font-size: 17px; margin-bottom: 18px; }

.title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

/* "12 personas escuchando ahora" */
.now-listening { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.now-listening[hidden] { display: none; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

.section { margin-top: 28px; scroll-margin-top: 20px; }

.section h2 {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--sep);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section h2 .count { margin-left: 6px; color: var(--muted); font-size: 15px; font-weight: 500; }

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 18px 14px;
}

.tile button { width: 100%; text-align: left; display: block; }

.tile .art { width: 100%; border-radius: 10px; box-shadow: var(--shadow); transition: transform 0.15s ease, filter 0.15s; }

.tile button:hover .art { filter: brightness(1.06); }
.tile button:active .art { transform: scale(0.97); }

.tile-name {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-dial {
  display: block;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Carátulas (cuadro con iniciales) ---------- */

.art {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: clamp(30px, 9vw, 46px);
  background:
    radial-gradient(120% 90% at 15% 10%, rgba(255, 255, 255, 0.28), transparent 55%),
    linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 60%, #000));
}

.art.has-logo {
  background-color: #fff;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.18);
}

/* Barritas animadas en la emisora que está sonando */
.eq {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  padding: 4px 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Cuántas personas escuchan esta emisora ahora */
.listeners {
  position: absolute;
  left: 8px;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
}
.listeners[hidden] { display: none; }
.listeners svg { width: 11px; height: 11px; }

.eq i { width: 3px; height: 100%; border-radius: 1px; background: #fff; transform-origin: bottom; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }

@keyframes eq { 0%, 100% { transform: scaleY(0.3); } 50% { transform: scaleY(1); } }

.tile[aria-current="true"] .tile-name { color: var(--accent); }
body[data-state="live"] .tile[aria-current="true"] .eq,
body[data-state="loading"] .tile[aria-current="true"] .eq { display: flex; }
body[data-state="loading"] .eq i { animation-play-state: paused; }

/* ---------- Mini reproductor (vidrio) ---------- */

.mini {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  height: var(--mini-h);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px 0 8px;
  border-radius: 16px;
  background: var(--glass);
  border: 0.5px solid var(--glass-border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}

.mini-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; height: 100%; text-align: left; }

.art-sm { width: 48px; flex: none; border-radius: 8px; font-size: 17px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); }

.mini-text { min-width: 0; display: flex; flex-direction: column; }

.mini-name, .mini-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mini-name { font-size: 15px; font-weight: 600; }

.mini-sub { font-size: 13px; color: var(--muted); }

body[data-state="live"] .mini-sub::before {
  content: "EN VIVO · ";
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
}

body[data-state="error"] .mini-sub { color: var(--accent); }

.icon-btn { width: 44px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }

.icon-pause { display: none; }
[data-playing="true"] .icon-play { display: none; }
[data-playing="true"] .icon-pause { display: block; }

/* ---------- Reproductor a pantalla completa ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  color: #fff;
  overflow: hidden;
  animation: sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet[hidden] { display: none; }

@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }

.sheet-bg {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(60% 50% at 25% 20%, color-mix(in srgb, var(--station) 90%, #fff 10%), transparent 70%),
    radial-gradient(60% 60% at 80% 70%, color-mix(in srgb, var(--station) 70%, #000), transparent 70%),
    color-mix(in srgb, var(--station) 55%, #000);
  filter: blur(40px) saturate(140%);
  transition: background 0.5s;
}

.sheet-inner {
  position: relative;
  height: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 28px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.grabber { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 64px; height: 28px; display: flex; align-items: center; justify-content: center; }
.grabber span { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.5); }

.art-lg {
  width: 100%;
  border-radius: 14px;
  font-size: clamp(64px, 24vw, 120px);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.4);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

body:not([data-state="live"]):not([data-state="loading"]) .art-lg { transform: scale(0.86); }

.np { display: flex; align-items: center; gap: 12px; margin-top: 32px; }

.np-text { flex: 1; min-width: 0; }

.np-name { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.np-dial { margin: 2px 0 0; font-size: 17px; color: rgba(255, 255, 255, 0.65); }

.live-tag { flex: none; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.22); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; }

.np-status { min-height: 20px; margin: 10px 0 0; font-size: 14px; color: rgba(255, 255, 255, 0.75); }

.np-controls { display: flex; align-items: center; justify-content: space-evenly; margin-top: 24px; }

.np-btn { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: transform 0.12s, background 0.15s; }
.np-btn:hover { background: rgba(255, 255, 255, 0.12); }
.np-btn:active { transform: scale(0.9); }
.np-btn svg { width: 40px; height: 40px; }
.np-toggle { width: 84px; height: 84px; }
.np-toggle svg { width: 56px; height: 56px; }

body.sheet-open { overflow: hidden; }

/* ---------- Computador ---------- */

@media (min-width: 720px) {
  .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 24px 18px; }
  .art { font-size: 52px; }
  .art-sm { font-size: 17px; }
  .art-lg { font-size: 120px; }
  .mini { left: 50%; right: auto; width: min(660px, calc(100% - 32px)); transform: translateX(-50%); bottom: 18px; border-radius: 18px; }
}

@media (min-width: 1000px) {
  body { display: grid; grid-template-columns: 260px 1fr; }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 30px 20px;
    background: var(--bg-side);
    border-right: 1px solid var(--sep);
  }
  .brand-mobile { display: none; }
  .content { padding: 40px 40px 140px; }
  .mini { left: calc(50% + 130px); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .eq i, .art-lg, .tile .art, .np-btn, .pulse { animation: none; transition: none; }
}
