/* ==========================================================================
   Me contro Te — Musica
   Interfaccia mobile-first, ad alto contrasto, pensata per essere usata
   senza saper leggere: immagini grandi, icone, pulsanti enormi.
   ========================================================================== */

:root {
  --bg: #150a2e;
  --bg-2: #33116a;
  --surface: rgba(255, 255, 255, 0.09);
  --surface-strong: rgba(255, 255, 255, 0.16);
  --pink: #ff2e93;
  --yellow: #ffd60a;
  --cyan: #22e0ff;
  --ink: #1a0730;
  --white: #ffffff;

  --radius: 26px;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
  color: var(--white);
  background: var(--bg);
  background-image: radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg) 62%);
  background-attachment: fixed;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
}

.sprite {
  display: none;
}

svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  display: block;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
   Accesso
   ------------------------------------------------------------------ */

.login {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  padding: calc(var(--safe-top) + 24px) 26px calc(var(--safe-bottom) + 24px);
}

.login__badge {
  width: 122px;
  height: 122px;
  padding: 28px;
  color: var(--ink);
  border-radius: 50%;
  background: linear-gradient(150deg, var(--yellow), var(--pink) 130%);
  box-shadow: 0 18px 44px rgba(255, 46, 147, 0.45);
  animation: bob 3.4s ease-in-out infinite;
}

.login__form {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.field {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 6px 20px 6px 18px;
  background: var(--surface);
  border: 3px solid transparent;
  border-radius: var(--radius);
  transition: border-color 0.2s, background 0.2s;
}

.field:focus-within {
  border-color: var(--cyan);
  background: var(--surface-strong);
}

.field__icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  color: var(--cyan);
}

.field input {
  flex: 1 1 auto;
  min-width: 0;
  height: 62px;
  border: 0;
  background: none;
  color: var(--white);
  font: inherit;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.14em;
  outline: none;
}

.login__submit {
  width: 116px;
  height: 116px;
  margin-top: 12px;
  padding: 28px 24px 28px 32px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 14px 32px rgba(255, 214, 10, 0.4);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.2s;
}

.login__submit:active {
  transform: scale(0.92);
}

.login__submit:disabled {
  opacity: 0.5;
}

.login__error {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  color: var(--pink);
  animation: shake 0.4s ease;
}

/* ------------------------------------------------------------------ *
   Libreria
   ------------------------------------------------------------------ */

.library__header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(var(--safe-top) + 18px) var(--gutter) 12px;
  background: linear-gradient(to bottom, rgba(21, 10, 46, 0.96) 55%, rgba(21, 10, 46, 0));
  backdrop-filter: blur(8px);
}

/* Pulsante "torna indietro": freccia grande, sempre nello stesso posto. */
.back {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  padding: 17px;
  border: 0;
  border-radius: 50%;
  color: var(--ink);
  background: var(--cyan);
  box-shadow: 0 8px 22px rgba(34, 224, 255, 0.35);
  cursor: pointer;
  transition: transform 0.14s ease;
}

.back:active {
  transform: scale(0.9);
}

.library__folder {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.library__logo {
  width: 54px;
  height: 54px;
  padding: 13px;
  color: var(--ink);
  border-radius: 50%;
  background: linear-gradient(150deg, var(--yellow), var(--pink) 140%);
}

/* Una sola colonna sul telefono: copertine grandi a tutta larghezza. */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 8px var(--gutter) 0;
}

.card {
  position: relative;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  animation: rise 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  transition: transform 0.16s ease;
}

.card:active {
  transform: scale(0.97);
}

/* Le immagini incorporate nei brani sono fotogrammi 16:9: niente ritaglio. */
.card__art {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(150deg, #4b1b8f, #7a1f6a);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
}

.card__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Segnaposto quando il brano non ha copertina. */
.card__art--empty::after {
  content: "";
  position: absolute;
  inset: 26%;
  background: currentColor;
  color: rgba(255, 255, 255, 0.55);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 3.2v11.3a3.8 3.8 0 1 1-2.5-3.55V6.7l-7 1.7v8.4a3.8 3.8 0 1 1-2.5-3.55V6.4a1.5 1.5 0 0 1 1.15-1.46l9-2.2A1.25 1.25 0 0 1 20 3.2Z"/></svg>')
    center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 3.2v11.3a3.8 3.8 0 1 1-2.5-3.55V6.7l-7 1.7v8.4a3.8 3.8 0 1 1-2.5-3.55V6.4a1.5 1.5 0 0 1 1.15-1.46l9-2.2A1.25 1.25 0 0 1 20 3.2Z"/></svg>')
    center / contain no-repeat;
}

/* Pulsante play grande, sempre visibile sopra la copertina. */
.card__play {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 82px;
  height: 82px;
  padding: 22px 20px 22px 27px;
  color: var(--ink);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* Titolo sovrapposto: presente ma discreto, l'immagine resta protagonista. */
.card__title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 34px 30% 14px 18px;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  background: linear-gradient(to top, rgba(12, 4, 26, 0.88), rgba(12, 4, 26, 0));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Cartelle: linguetta in alto (forma inequivocabile di cartella), bordo e
   pulsante ciano al posto del play giallo. Riconoscibili senza leggere. */
.card--folder {
  padding-top: 18px;
}

.card--folder::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  width: 42%;
  max-width: 150px;
  height: 30px;
  border-radius: 12px 12px 0 0;
  background: var(--cyan);
  box-shadow: 0 -2px 12px rgba(34, 224, 255, 0.35);
}

.card--folder .card__art {
  border: 4px solid var(--cyan);
  position: relative;
  z-index: 1;
}

.card--folder .card__play {
  color: var(--ink);
  background: var(--cyan);
  padding: 24px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.card--folder .card__art img {
  filter: brightness(0.82) saturate(1.1);
}

/* Brano attualmente in riproduzione. */
.card.is-active .card__art {
  outline: 4px solid var(--yellow);
  outline-offset: 3px;
}

.card.is-active .card__play {
  background: var(--pink);
  color: var(--white);
}

.library__spacer {
  height: calc(var(--safe-bottom) + 120px);
}

.empty {
  display: block;
  width: 110px;
  height: 110px;
  margin: 22vh auto 0;
  color: rgba(255, 255, 255, 0.28);
}

/* ------------------------------------------------------------------ *
   Barra del brano in corso
   ------------------------------------------------------------------ */

.minibar {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--safe-bottom) + 14px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px 10px 10px;
  border: 0;
  border-radius: 24px;
  color: var(--white);
  font: inherit;
  text-align: left;
  background: rgba(38, 12, 74, 0.92);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  animation: slide-up 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.minibar:active {
  transform: scale(0.98);
}

.minibar__cover {
  width: 86px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
}

.minibar__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.minibar__equalizer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 26px;
  flex: 0 0 auto;
}

.minibar__equalizer i {
  width: 5px;
  height: 30%;
  border-radius: 3px;
  background: var(--yellow);
}

.is-playing .minibar__equalizer i {
  animation: bounce 0.9s ease-in-out infinite;
}

.minibar__equalizer i:nth-child(2) {
  animation-delay: 0.15s;
}

.minibar__equalizer i:nth-child(3) {
  animation-delay: 0.3s;
}

/* ------------------------------------------------------------------ *
   Lettore
   ------------------------------------------------------------------ */

.player {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* copertina e comandi come un blocco centrato */
  gap: 4px;
  padding: calc(var(--safe-top) + 84px) 22px calc(var(--safe-bottom) + 26px);
  background: radial-gradient(120% 70% at 50% 0%, var(--bg-2) 0%, var(--bg) 65%);
  overflow: hidden;
  isolation: isolate;
  animation: slide-up 0.34s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

/* Sfondo: la stessa copertina, sfocata. Riempie lo schermo di colore
   senza aggiungere elementi da interpretare. */
.player__backdrop {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(44px) saturate(1.5) brightness(0.68);
  transform: scale(1.25);
}

.player::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(11, 3, 24, 0.2) 0%, rgba(11, 3, 24, 0.78) 80%);
}

.player__close {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 22px;
  z-index: 2;
  width: 62px;
  height: 62px;
  padding: 14px;
  border: 0;
  border-radius: 50%;
  color: var(--white);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.14s ease;
}

.player__close:active {
  transform: scale(0.9);
}

.player__stage {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% + 28px);
  margin: 0 -14px;
  min-height: 0;
  padding: 10px 0;
}

.player__cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 28px;
  background: linear-gradient(150deg, #4b1b8f, #7a1f6a);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  transition: transform 0.4s ease;
}

.is-playing .player__cover {
  animation: bob 4.5s ease-in-out infinite;
}

/* Solo la copertina si adatta in altezza: titolo e comandi restano interi. */
.player__title,
.seek,
.controls,
.speed {
  flex: 0 0 auto;
}

.player__title {
  margin: 6px 0 10px;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Barra di avanzamento: alta e facile da toccare. */
.seek {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  margin: 0 0 8px;
  background: none;
  cursor: pointer;
}

.seek::-webkit-slider-runnable-track {
  height: 16px;
  border-radius: 10px;
  background: linear-gradient(
    to right,
    var(--yellow) 0 var(--progress, 0%),
    rgba(255, 255, 255, 0.18) var(--progress, 0%) 100%
  );
}

.seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 34px;
  height: 34px;
  margin-top: -9px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
}

.seek::-moz-range-track {
  height: 16px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
}

.seek::-moz-range-progress {
  height: 16px;
  border-radius: 10px;
  background: var(--yellow);
}

.seek::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: var(--yellow);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.control {
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  padding: 22px;
  border: 0;
  border-radius: 50%;
  color: var(--white);
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.14s ease, background 0.2s;
}

.control:active {
  transform: scale(0.9);
  background: var(--surface-strong);
}

.control--main {
  width: 128px;
  height: 128px;
  padding: 32px;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 0 12px 30px rgba(255, 214, 10, 0.35);
}

.control--main:active {
  background: var(--yellow);
}

/* ------------------------------------------------------------------ *
   Velocità di riproduzione
   ------------------------------------------------------------------ */

/* Tre pulsanti sempre nella stessa posizione e sempre dello stesso colore:
   si riconoscono dalla figura e dal posto, senza leggere niente. */
.speed {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin-top: 18px;
}

.speed__button {
  position: relative;
  width: 78px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.2s, box-shadow 0.2s;
}

.speed__button span {
  display: block;
  transform: translateY(1px);
}

.speed__button:active {
  transform: scale(0.9);
}

.speed__button--slow {
  background: var(--cyan);
}

.speed__button--normal {
  background: var(--yellow);
}

.speed__button--fast {
  background: var(--pink);
}

/* Velocità in uso: anello bianco e pulsante più grande. */
.speed__button.is-current {
  transform: scale(1.12);
  box-shadow: 0 0 0 5px var(--white), 0 10px 26px rgba(0, 0, 0, 0.45);
}

.speed__button.is-current:active {
  transform: scale(1.02);
}

/* Limite raggiunto: non si può rallentare o accelerare oltre. Se però è
   anche la velocità in uso resta acceso, altrimenti sembrerebbe spento. */
.speed__button:disabled {
  cursor: default;
}

.speed__button:disabled:not(.is-current) {
  opacity: 0.3;
}

/* ------------------------------------------------------------------ *
   Animazioni
   ------------------------------------------------------------------ */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.94);
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
}

@keyframes bob {
  50% {
    transform: translateY(-10px);
  }
}

@keyframes bounce {
  0%,
  100% {
    height: 28%;
  }
  50% {
    height: 100%;
  }
}

@keyframes shake {
  25% {
    transform: translateX(-9px);
  }
  75% {
    transform: translateX(9px);
  }
}

/* ------------------------------------------------------------------ *
   Adattamenti
   ------------------------------------------------------------------ */

@media (min-width: 620px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-width: 1180px;
    margin: 0 auto;
  }

  .player {
    align-items: center;
  }

  .player__stage,
  .player__title,
  .seek,
  .controls {
    max-width: 620px;
  }
}

/* Schermi molto bassi: riduce il lettore per non tagliare i comandi. */
@media (max-height: 680px) {
  .control {
    width: 74px;
    height: 74px;
    padding: 18px;
  }

  .control--main {
    width: 104px;
    height: 104px;
    padding: 26px;
  }

  .player__title {
    font-size: 17px;
  }

  .speed {
    margin-top: 12px;
  }

  .speed__button {
    width: 66px;
    height: 66px;
    font-size: 30px;
  }
}

/* Telefono in orizzontale: la copertina si adatta all'altezza disponibile.
   Qui il riquadro deve prendersi lo spazio residuo, altrimenti l'immagine
   (dimensionata sull'altezza) si schiaccia. */
@media (orientation: landscape) and (max-height: 560px) {
  .player {
    padding-top: calc(var(--safe-top) + 10px);
  }

  .player__stage {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    margin: 0;
    padding: 4px 0;
  }

  .player__cover {
    width: auto;
    height: 100%;
    max-width: 100%;
  }

  .player__title {
    margin: 4px 0 6px;
    font-size: 16px;
    -webkit-line-clamp: 1;
  }

  .seek {
    margin-bottom: 4px;
  }

  /* In orizzontale i pulsanti velocità stanno accanto ai comandi. */
  .speed {
    margin-top: 10px;
    gap: 12px;
  }

  .speed__button {
    width: 58px;
    height: 58px;
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
