/* ==========================================================================
   Capa compartida por Home y Search.
   Se carga ANTES de style.css/search.css; mobile.css sigue mandando en móvil.
   ========================================================================== */

/* El buscador del header solo se ve en la pantalla de búsqueda. */
body.home-page #arrowMenu .div--hun {
  display: none !important;
}

/* --- Selector de idioma -------------------------------------------------- */

.lang-toggle {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  height: 28px;
  margin: 14px 16px 0;
  padding: 0 11px;
  color: #d6d6d6;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
}

.lang-toggle svg {
  fill: currentColor;
}

/* --- Saludo del Home ---------------------------------------------------- */

.greeting {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.26em;
  margin: 0 0 22px;
  color: #fff;
  font-size: clamp(1.65rem, 3.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.02;
}

.greeting__name {
  color: #1ed760;
  overflow-wrap: anywhere;
}

/* --- Enlaces a la app en la sidebar ------------------------------------- */

#principal #latNav #getAppLink {
  color: #1ed760;
  font-size: 0.9em;
  font-weight: 600;
  text-decoration: none;
}

#principal #latNav #getAppLink:hover {
  color: #3be477;
}

/* --- Transiciones de pantalla y tarjetas -------------------------------- */

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

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#main.page-enter {
  animation: page-enter 320ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

#main .playlists > li,
#main #playlistsRecentes > li {
  animation: card-enter 420ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

#main .playlists > li:nth-child(2),
#main #playlistsRecentes > li:nth-child(2) {
  animation-delay: 45ms;
}

#main .playlists > li:nth-child(3),
#main #playlistsRecentes > li:nth-child(3) {
  animation-delay: 90ms;
}

#main .playlists > li:nth-child(4),
#main #playlistsRecentes > li:nth-child(4) {
  animation-delay: 135ms;
}

#main .playlists > li:nth-child(5),
#main #playlistsRecentes > li:nth-child(5) {
  animation-delay: 180ms;
}

#main .playlists > li:nth-child(6),
#main #playlistsRecentes > li:nth-child(6) {
  animation-delay: 225ms;
}

/* --- Bienvenida: la interfaz entra escalonada al abrir la web ----------- */

@keyframes welcome-drop {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes welcome-slide {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#latNav > a,
#topNav {
  animation: welcome-drop 480ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

#latNav .lang-toggle,
#latNav .nav-item,
#latNav .profile-card {
  animation: welcome-slide 480ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

#latNav .lang-toggle {
  animation-delay: 60ms;
}

#latNav .nav-item:nth-child(1) {
  animation-delay: 120ms;
}

#latNav .nav-item:nth-child(2) {
  animation-delay: 170ms;
}

#latNav .nav-item:nth-child(3) {
  animation-delay: 220ms;
}

#latNav .nav-item:nth-child(4) {
  animation-delay: 270ms;
}

#latNav .nav-item:nth-child(5) {
  animation-delay: 320ms;
}

#latNav .profile-card {
  animation-delay: 240ms;
}

#latNav #getAppLink {
  animation-delay: 300ms;
}

#main .greeting {
  animation: page-enter 560ms 120ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

/* Pantallas sin contenido todavía (search, recientes del home). */
.empty-state {
  max-width: 34rem;
  margin: 4px 0 0;
  color: #b3b3b3;
  font-size: 0.95rem;
  line-height: 1.55;
}

/* Las estanterías del Home no reservan hueco hasta tener canciones. */
#main .feedPlaylist:has(.playlists:empty),
#main #playlistsRecentes:empty {
  display: none;
}

/* --- Perfil del usuario ------------------------------------------------ */

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  margin-top: auto;
  padding: 12px 16px;
  color: #fff;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.profile-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.profile-avatar {
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.profile-avatar svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-name {
  overflow: hidden;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tag {
  color: #a7a7a7;
  font-size: 0.66rem;
  line-height: 1.2;
}

/* --- Nombre obligatorio la primera vez --------------------------------- */

.name-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: trial-fade 200ms ease backwards;
}

.name-gate__card {
  width: min(420px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 30px 28px 22px;
  color: #fff;
  background: #181818;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  animation: trial-rise 320ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

.name-gate__eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: #1ed760;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.name-gate__card h2 {
  margin: 0 0 10px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.name-gate__card p {
  margin: 0 0 18px;
  color: #b3b3b3;
  font-size: 0.84rem;
  line-height: 1.5;
}

.name-gate__card input {
  width: 100%;
  height: 46px;
  margin: 0 0 6px;
  padding: 0 14px;
  color: #0a0a0a;
  background: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.95rem;
}

.name-gate__card input:focus {
  outline: 2px solid #1ed760;
  outline-offset: 1px;
}

.name-gate__error {
  min-height: 16px;
  margin: 0 0 10px;
  color: #ff6b6b;
  font-size: 0.72rem;
}

.name-gate__card .trial-btn--cta {
  width: 100%;
  height: 44px;
  font-size: 0.85rem;
}

.name-gate__cancel {
  width: 100%;
  margin-top: 10px;
  padding: 6px 0;
  color: #a7a7a7;
  font-size: 0.78rem;
  background: none;
  border: 0;
  cursor: pointer;
}

.name-gate__cancel:hover {
  color: #fff;
}

/* --- Aviso de versión de prueba ---------------------------------------- */

@keyframes trial-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes trial-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.trial-toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 120;
  width: min(380px, calc(100vw - 32px));
  padding: 16px 40px 16px 16px;
  color: #fff;
  background: #1c1c1c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  animation: trial-rise 320ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

.trial-toast__body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.84rem;
  letter-spacing: 0.02em;
}

.trial-toast__body p {
  margin: 0 0 12px;
  color: #b3b3b3;
  font-size: 0.76rem;
  line-height: 1.4;
}

.trial-toast__body b {
  color: #fff;
}

.trial-toast__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  color: #a7a7a7;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.trial-toast__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.trial-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 16px;
  font-size: 0.76rem;
  font-weight: 700;
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.trial-btn--cta {
  color: #000;
  background: #1ed760;
}

.trial-btn--cta:hover {
  color: #000;
  background: #3be477;
  transform: scale(1.02);
}

.trial-btn--ghost {
  color: #fff;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.trial-btn--ghost:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.trial-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: trial-fade 200ms ease backwards;
}

.trial-modal__card {
  width: min(400px, 100%);
  padding: 28px 26px 22px;
  color: #fff;
  text-align: center;
  background: #181818;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  animation: trial-rise 320ms cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

.trial-modal__eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: #1ed760;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.trial-modal__card h2 {
  margin: 0 0 8px;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.2;
}

.trial-modal__card p {
  max-width: 300px;
  margin: 0 auto 20px;
  color: #b3b3b3;
  font-size: 0.84rem;
  line-height: 1.5;
}

.trial-modal__card .trial-btn--cta {
  width: 100%;
  height: 44px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.trial-modal__card .trial-btn--ghost {
  width: 100%;
  height: 40px;
}

/* En el teléfono el aviso flota sobre el pie (canción + seek + pestañas). */
@media (max-width: 767px) {
  .trial-toast {
    right: 12px;
    left: 12px;
    bottom: calc(148px + env(safe-area-inset-bottom));
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #main.page-enter,
  #main .playlists > li,
  #main #playlistsRecentes > li,
  #main .greeting,
  #latNav > a,
  #latNav .lang-toggle,
  #latNav .nav-item,
  #latNav .profile-card,
  #latNav #getAppLink,
  #topNav,
  .trial-toast,
  .trial-modal,
  .trial-modal__card,
  .name-gate,
  .name-gate__card {
    animation: none !important;
  }
}
