/* ==========================================================================
   /player/ — Mi música
   Reproductor de la colección de YouTube con artistas, búsqueda y cola.
   ========================================================================== */

/* `display` en varios componentes gana sobre el [hidden] del navegador. */
.player-page [hidden] {
  display: none !important;
}

/* El player no carga app.js, que es quien revela los .reveal del resto del
   sitio. Aquí el contenido debe verse desde el primer paint. */
.player-page .reveal {
  opacity: 1;
  transform: none;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.player-page {
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ */
/* hero                                                                */
/* ------------------------------------------------------------------ */

.player-hero {
  padding: clamp(40px, 6vw, 76px) 0 clamp(24px, 3vw, 38px);
}

.player-hero .hero__title {
  max-width: none;
}

.player-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}

.player-stat {
  min-width: 112px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012));
  box-shadow: var(--shadow-1);
}

.player-stat strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.player-stat span {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.player-stat--link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.player-stat--link:hover {
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.06));
  transform: translateY(-1px);
}

.player-stat--link strong {
  color: var(--accent-2);
}

/* ------------------------------------------------------------------ */
/* layout                                                              */
/* ------------------------------------------------------------------ */

.player-section {
  padding-bottom: 36px;
}

.player-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

/* ------------------------------------------------------------------ */
/* sidebar de artistas                                                 */
/* ------------------------------------------------------------------ */

.player-sidebar {
  position: sticky;
  top: 92px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-height: calc(100vh - 232px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-1);
}

.player-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-sidebar__head h2 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.player-sidebar__count {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.player-search {
  width: 100%;
  min-width: 0;
  max-width: none;
  flex: none;
}

.player-search input {
  padding-top: 9px;
  padding-bottom: 9px;
  font-size: 0.82rem;
}

.artist-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -6px;
  padding: 0 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

.artist-list::-webkit-scrollbar {
  width: 6px;
}

.artist-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.artist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}

.artist-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.artist-item.is-active {
  color: #fff;
  background: linear-gradient(120deg, rgba(124, 92, 255, 0.92), rgba(34, 211, 238, 0.66));
  box-shadow: 0 8px 20px -12px rgba(124, 92, 255, 0.9);
}

.artist-item__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist-item__count {
  flex-shrink: 0;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.artist-item.is-active .artist-item__count {
  color: rgba(255, 255, 255, 0.82);
}

.artist-list__empty {
  padding: 18px 10px;
  color: var(--muted-2);
  font-size: 0.8rem;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* lista de canciones                                                  */
/* ------------------------------------------------------------------ */

.player-main {
  min-width: 0;
}

.player-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 18px;
  margin-bottom: 14px;
}

.player-heading h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
  font-weight: 720;
  letter-spacing: -0.025em;
}

.player-heading p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--muted-2);
}

.player-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.player-search--songs {
  min-width: 220px;
  max-width: 320px;
  flex: 1 1 220px;
}

.song-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.song-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}

.song-row:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.song-row.is-current {
  border-color: rgba(124, 92, 255, 0.38);
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.055));
}

.song-row.is-unavailable {
  opacity: 0.42;
  cursor: not-allowed;
}

.song-row.is-unavailable:hover {
  border-color: transparent;
  background: transparent;
}

.song-row__num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.song-row.is-current .song-row__num {
  color: var(--accent-2);
}

.song-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.song-row__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.87rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.song-row.is-current .song-row__title {
  color: #fff;
}

.song-row__artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
  color: var(--muted-2);
}

.song-list.is-artist-view .song-row__artist {
  display: none;
}

.song-row__action {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted-2);
  transition: color 0.18s, background 0.18s;
}

.song-row:hover .song-row__action {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.song-row.is-current .song-row__action {
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
}

.song-row__action .i {
  width: 14px;
  height: 14px;
}

.song-row__action--none {
  width: auto;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.song-row.is-unavailable .song-row__action {
  background: none;
}

/* ------------------------------------------------------------------ */
/* estados vacíos / carga                                              */
/* ------------------------------------------------------------------ */

.player-empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 56px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
}

.player-empty__icon {
  width: 34px;
  height: 34px;
  color: var(--muted-2);
}

.player-empty__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.player-empty__text {
  margin: 0;
  max-width: 36ch;
  font-size: 0.82rem;
  color: var(--muted-2);
}

.player-skeleton {
  border-radius: 10px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 20%, rgba(255, 255, 255, 0.09) 40%, rgba(255, 255, 255, 0.04) 60%);
  background-size: 220% 100%;
  animation: player-shimmer 1.4s linear infinite;
}

.player-skeleton--row {
  height: 36px;
}

.player-skeleton--song {
  height: 48px;
}

@keyframes player-shimmer {
  to {
    background-position: -220% 0;
  }
}

/* ------------------------------------------------------------------ */
/* barra del reproductor                                               */
/* ------------------------------------------------------------------ */

.player-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 80;
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: rgba(7, 7, 13, 0.9);
  backdrop-filter: blur(20px);
  box-shadow: 0 -18px 40px -24px rgba(0, 0, 0, 0.9);
}

.player-bar__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 1.5fr) minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  padding-block: 10px;
}

.player-now {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.player-art {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 25%, rgba(124, 92, 255, 0.35), rgba(7, 7, 13, 0.9));
}

.player-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-art__placeholder {
  width: 20px;
  height: 20px;
  color: var(--muted-2);
}

.player-now__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.player-now__text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  font-weight: 650;
}

.player-now__text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
  color: var(--muted-2);
}

.player-center {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.player-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.18s, background 0.18s, transform 0.18s;
}

.player-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.player-btn .i {
  width: 17px;
  height: 17px;
}

.player-btn--play {
  width: 44px;
  height: 44px;
  background: linear-gradient(120deg, var(--accent), #5b8cff 55%, var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 22px -8px rgba(124, 92, 255, 0.9);
}

.player-btn--play .i {
  width: 19px;
  height: 19px;
}

.player-btn--play:hover {
  color: #fff;
  transform: scale(1.04);
}

.player-btn.is-active {
  color: var(--accent-2);
}

.player-btn.is-active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.player-repeat-one {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.52rem;
  font-weight: 800;
  line-height: 1;
  opacity: 0;
}

.player-btn--repeat.is-one .player-repeat-one {
  opacity: 1;
}

.player-progress {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
}

.player-time {
  font-size: 0.66rem;
  color: var(--muted-2);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.player-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0 var(--value, 0%),
    rgba(255, 255, 255, 0.14) var(--value, 0%) 100%
  );
  cursor: pointer;
  outline: none;
}

.player-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.35);
  opacity: 0;
  transition: opacity 0.15s;
}

.player-range:hover::-webkit-slider-thumb,
.player-range:focus-visible::-webkit-slider-thumb {
  opacity: 1;
}

.player-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.35);
  opacity: 0;
}

.player-range:hover::-moz-range-thumb,
.player-range:focus-visible::-moz-range-thumb {
  opacity: 1;
}

.player-extra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.player-range--volume {
  max-width: 92px;
}

.player-btn--yt {
  color: #ff6b6b;
}

.player-btn--yt:hover {
  color: #ff8a8a;
  background: rgba(255, 107, 107, 0.12);
}

.yt-host {
  position: fixed;
  top: 0;
  left: -10000px;
  width: 200px;
  height: 200px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.player-page .toast {
  bottom: calc(118px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ */
/* responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1000px) {
  .player-layout {
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 20px;
  }
}

@media (max-width: 900px) {
  .player-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .player-sidebar {
    position: static;
    max-height: none;
    padding: 12px;
  }

  .artist-list {
    flex-direction: row;
    gap: 6px;
    margin: 0;
    padding: 0 0 4px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .artist-item {
    flex: 0 0 auto;
    width: auto;
    padding: 7px 11px;
    white-space: nowrap;
  }

  .artist-list__empty {
    padding: 10px;
  }

  .player-bar__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding-block: 8px;
  }

  .player-now {
    grid-column: 1;
    grid-row: 1;
  }

  .player-extra {
    grid-column: 2;
    grid-row: 1;
  }

  .player-center {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .player-range--volume,
  .player-btn--yt {
    display: none;
  }

  .player-page {
    padding-bottom: calc(178px + env(safe-area-inset-bottom));
  }

  .player-page .toast {
    bottom: calc(184px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .player-hero {
    padding-top: 32px;
  }

  .player-stat {
    min-width: 96px;
    padding: 10px 14px;
  }

  .player-stat strong {
    font-size: 1.25rem;
  }

  .player-toolbar__actions {
    width: 100%;
  }

  .player-search--songs {
    max-width: none;
    flex: 1 1 100%;
    order: -1;
  }

  .player-toolbar__actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .song-row {
    grid-template-columns: 30px minmax(0, 1fr) 28px;
    gap: 6px;
    padding: 8px 6px;
  }

  .song-row__title {
    font-size: 0.84rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-skeleton {
    animation: none;
  }

  .song-row,
  .player-btn,
  .artist-item,
  .player-range::-webkit-slider-thumb {
    transition: none;
  }
}
