/* PLAY — hoja de estilos única (móvil primero). */

:root {
  color-scheme: dark;
  --bg: #0b0d14;
  --bg-2: #141827;
  --card: #171b2b;
  --card-2: #1f2438;
  --line: #2b3150;
  --text: #eef1fb;
  --muted: #8e97b8;
  --accent: #6c5ce7;
  --accent-2: #00d2ff;
  --gold: #f0b429;
  --ok: #3ecf8e;
  --err: #ff6b6b;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 700px at 50% -10%, #232a4d 0%, transparent 60%),
    radial-gradient(700px 500px at 110% 110%, #1b2a4a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* ─────────── pantallas ─────────── */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + var(--safe-b));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.screen.is-active { display: flex; animation: entrar .28s ease both; }

@keyframes entrar {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ─────────── inicio ─────────── */

.screen--home { justify-content: space-between; gap: 18px; }

.corner {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 5;
}

.seg {
  display: inline-flex;
  padding: 3px;
  background: rgba(23, 27, 43, .8);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.seg__btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.seg__btn.is-on { background: var(--accent); color: #fff; }

.hero {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 0;
}

/* ─────────── logotipo (assets/logo.svg) ─────────── */

.logo {
  width: min(78vw, 420px);
  height: auto;
  filter: drop-shadow(0 14px 44px rgba(74, 183, 195, .28));
  animation: latir 5s ease-in-out infinite;
}

@keyframes latir {
  0%, 100% { filter: drop-shadow(0 14px 44px rgba(74, 183, 195, .28)); }
  50%      { filter: drop-shadow(0 14px 58px rgba(108, 92, 231, .35)); }
}

.lists { flex: 0 0 auto; }

.lists__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.lists__title {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--muted);
}

/* Botón "+" para importar: pequeño, junto al título. */
.plus {
  width: 30px;
  height: 30px;
  margin-left: -4px;
  font: 20px/1 system-ui, sans-serif;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.plus:hover { color: var(--text); border-color: var(--accent); }
.plus.is-on { color: #fff; background: var(--accent); border-color: var(--accent); }

/* Importación en línea: mínima, ~12 caracteres. */
.import {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 7px 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.import__label {
  font-size: 12px;
  color: var(--accent-2);
  white-space: nowrap;
}

.import__input {
  flex: 0 0 auto;
  width: 12ch;
  min-width: 0;
  padding: 5px 6px;
  font: 13px ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.import__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.import__go {
  width: 30px;
  height: 30px;
  font: 18px/1 system-ui, sans-serif;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.import__msg {
  flex: 1 0 100%;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.import__msg.ok { color: var(--ok); }
.import__msg.err { color: var(--err); }

.playlist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 42dvh;
  overflow-y: auto;
}

.playlist-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.playlist-list li:hover { border-color: var(--accent); }
.playlist-list li:active { transform: scale(.985); }
.playlist-list li.is-selected {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(108, 92, 231, .22), rgba(23, 27, 43, .9));
}

.pl-name { font-weight: 650; font-size: 16px; }
.pl-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pl-go { margin-left: auto; color: var(--muted); font-size: 18px; }

.lists__empty { margin: 0; font-size: 14px; color: var(--muted); }

.home-actions { flex: 0 0 auto; }

/* ─────────── botones ─────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 13px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn--wide { width: 100%; }
.btn--secondary { background: var(--accent-2); color: #04121a; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--plus { font-size: 26px; line-height: 1; min-height: 56px; }

/* ─────────── overlay de importar (retirado: ahora es en línea) ─────────── */

/* ─────────── escáner ─────────── */

.screen--scanner { justify-content: center; gap: 14px; }

.float-close {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 6;
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 1;
  color: var(--text);
  background: rgba(23, 27, 43, .78);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.float-close:hover { background: var(--card-2); }

.scanner-box {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.scanner-box video { width: 100%; height: 100%; object-fit: cover; display: block; }

#reader { position: absolute; inset: 0; }
#reader > div { border: 0 !important; }
#reader video { display: none !important; }

.reticle { position: absolute; inset: 20% 8%; pointer-events: none; }
.reticle span {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 210, 255, .85);
}
.reticle span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.reticle span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.reticle span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.reticle span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }

.torch {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  width: 46px;
  height: 46px;
  font-size: 20px;
  color: var(--text);
  background: rgba(0, 0, 0, .5);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.torch.is-on { background: var(--gold); color: #10131c; }

.screen-hint {
  margin: 0;
  min-height: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.screen-hint.ok { color: var(--ok); }
.screen-hint.err { color: var(--err); }

/* ─────────── reproductor ─────────── */

.screen--player { justify-content: center; gap: 14px; }

/* El reproductor real (audio) queda detrás del panel, invisible. */
.player-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
}

.player-media iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Panel con la información: 70 % del alto, borrosa hasta que se revela. */
.reveal-panel {
  position: relative;
  z-index: 2;
  flex: 0 1 70%;
  height: 70%;
  max-height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.reveal-panel__inner {
  text-align: center;
  transition: filter .35s ease, opacity .35s ease;
  filter: blur(16px);
  opacity: .5;
}

.reveal-panel.is-revealed .reveal-panel__inner { filter: none; opacity: 1; }

.reveal-panel__icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 56px;
  height: 56px;
  color: var(--muted);
  transition: opacity .3s ease, transform .3s ease;
}

.reveal-panel.is-revealed .reveal-panel__icon { opacity: 0; transform: scale(.8); }

/* Error al cargar el reproductor: sustituye al icono de "oculto". */
.reveal-panel__error {
  position: absolute;
  inset: 0;
  margin: auto;
  height: fit-content;
  padding: 0 24px;
  font-size: 16px;
  font-weight: 600;
  color: #ffd7d7;
  text-align: center;
}

.reveal-panel h3 { margin: 0 0 10px; font-size: 30px; line-height: 1.15; color: var(--gold); }
.reveal-artist { margin: 0 0 6px; font-size: 22px; line-height: 1.2; }
.reveal-year { margin: 0; font-size: 16px; color: var(--muted); letter-spacing: .04em; }

.player-actions {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
}

/* Alerta del escáner (p. ej. no hay canción de ese año). */
.scanner-alert {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 18px;
  background: rgba(255, 107, 107, .12);
  border: 1px solid var(--err);
  border-radius: 14px;
  color: #ffd7d7;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  animation: entrar .2s ease both;
}

@media (min-width: 640px) {
  .playlist-list { grid-template-columns: 1fr 1fr; }
  .logo { font-size: 140px; }
}
