:root {
  --bg: #000000;
  --fg: #e8e4dc;
  --muted: #8a857a;
  --accent: #c9a227;
  --panel: rgba(10, 10, 10, 0.82);
  --border: rgba(201, 162, 39, 0.35);
  --active: rgba(201, 162, 39, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  min-height: 100dvh;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  width: fit-content;
  min-width: min(40rem, calc(100vw - 2.5rem));
  max-width: calc(100vw - 2.5rem);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
  position: relative;
  z-index: 1;
}

.wrap-music-index {
  width: min(720px, 100%);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.topnav .brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--fg);
  text-decoration: none;
}

.topnav .brand:hover {
  color: var(--accent);
  text-decoration: none;
}

.topnav .crumb {
  color: var(--muted);
  font-size: 0.95rem;
}

.page-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  margin-bottom: 1.25rem;
}

.page-lead {
  color: var(--muted);
  margin-bottom: 1.75rem;
  max-width: 40rem;
}

/* —— Lista album —— */
.album-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  list-style: none;
  max-width: 36rem;
}

.album-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  color: inherit;
  text-decoration: none;
  border-radius: 0.75rem;
  padding: 0.75rem;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.album-card:hover {
  text-decoration: none;
  border-color: var(--border);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.album-art {
  position: relative;
  width: 100%;
  max-width: 36rem;
  border-radius: 0.5rem;
  background: #111;
  overflow: hidden;
  line-height: 0;
}

.album-art img {
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  border-radius: 0.5rem;
}

.album-art-front {
  position: relative;
  z-index: 1;
}

.album-art-back {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.album-card:hover .album-art-back,
.album-card:focus-visible .album-art-back {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .album-art-back {
    transition: none;
  }
}

.album-card .album-title {
  font-weight: 700;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  line-height: 1.3;
}

/* —— Pagina album: grafica a sfondo —— */
.album-page {
  position: relative;
  background: #000;
}

.album-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  /* path relativo al CSS in /musica/style.css */
  background:
    linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.72)),
    url("la-vittoriosa-sconfitta-degli-incapaci/bg.png") center / cover no-repeat;
  pointer-events: none;
}

.album-header {
  margin-bottom: 1.35rem;
}

.album-header h1 {
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  line-height: 1.2;
  margin-bottom: 0.35rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.75);
}

.album-header .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.85rem;
  backdrop-filter: blur(6px);
}

.panel-tracks {
  flex: 1 1 18rem;
  min-width: min(18rem, 100%);
  max-width: 32rem;
}

.panel-lyrics {
  flex: 0 0 auto;
  width: 12rem; /* JS adatta alla riga piu' lunga del brano */
  max-width: 100%;
  box-sizing: border-box;
  transition: width 0.18s ease;
}

@media (prefers-reduced-motion: reduce) {
  .panel-lyrics {
    transition: none;
  }
}

.panel h2 {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.65rem;
}

.track-list {
  list-style: none;
  overflow: visible;
}

.track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem 0.75rem;
  align-items: center;
  padding: 0.15rem 0;
  border-radius: 0.5rem;
}

.track-row.is-active {
  background: var(--active);
  padding: 0.35rem 0.45rem;
  margin: 0 -0.15rem;
}

.track-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 2.1rem 1fr;
  gap: 0.55rem;
  align-items: baseline;
  text-align: left;
  padding: 0.4rem 0.35rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  min-width: 0;
}

.track-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.track-row.is-active .track-btn {
  color: var(--accent);
  background: transparent;
}

.track-btn .num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.track-row.is-active .track-btn .num {
  color: var(--accent);
}

.track-btn .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-player-host {
  display: none;
  min-width: 0;
}

.track-row.is-active .track-player-host {
  display: block;
}

.track-row.is-active .track-player-host:empty {
  display: none;
}

.player {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: min(16rem, 42vw);
  max-width: 22rem;
}

.player[hidden] {
  display: none !important;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
}

.controls button {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--fg);
  border-radius: 999px;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 0.68rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.controls button:hover {
  border-color: rgba(201, 162, 39, 0.75);
  color: var(--accent);
}

.controls .play-main {
  width: 1.95rem;
  height: 1.95rem;
  font-size: 0.72rem;
  background: rgba(201, 162, 39, 0.18);
}

.progress-row {
  display: grid;
  grid-template-columns: 2.1rem 1fr 2.1rem;
  gap: 0.3rem;
  align-items: center;
}

.progress-row .time {
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.progress {
  appearance: none;
  width: 100%;
  height: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  outline: none;
  cursor: pointer;
}

.progress::-webkit-slider-thumb {
  appearance: none;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
}

.progress::-moz-range-thumb {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
}

.lyrics {
  /* solo a capo del booklet; larghezza impostata da player.js sul pannello */
  white-space: pre;
  font-size: 0.98rem;
  line-height: 1.55;
  min-height: 0;
  max-height: none;
  overflow: visible;
  color: var(--fg);
  width: max-content;
  max-width: none;
}

.album-note {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  line-height: 1.2;
  scrollbar-width: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .layout {
    flex-direction: column;
  }

  .panel-tracks,
  .panel-lyrics {
    max-width: 100%;
    width: 100% !important;
  }

  .lyrics {
    white-space: pre-wrap;
    width: auto;
    max-width: 100%;
  }

  .track-row {
    grid-template-columns: 1fr;
  }

  .track-row.is-active .track-player-host {
    width: 100%;
  }

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

  .controls {
    justify-content: flex-start;
  }

  .album-bg {
    background-size: cover;
  }
}

@media (prefers-reduced-motion: reduce) {
  .album-card {
    transition: none;
  }

  .album-card:hover {
    transform: none;
  }
}
