/* ══════════ SoundStats — tema scuro brandizzato ══════════
   Chrome UI: verde Spotify su superfici scure.
   Grafici: singola tonalità verde, testo con token d'inchiostro. */

:root {
  color-scheme: dark;
  --page:           #0b0b0f;
  --surface:        #16161c;
  --surface-2:      #1e1e26;
  --text-primary:   #ffffff;
  --text-secondary: #b8b8c2;
  --text-muted:     #84848e;
  --grid:           #26262e;
  --baseline:       #3a3a44;
  --border:         rgba(255, 255, 255, 0.08);
  --accent:         #1db954;
  --accent-soft:    rgba(29, 185, 84, 0.14);
  --series:         #1db954;
  --danger:         #e66767;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

a { color: var(--accent); }

/* ── sfondo animato ── */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  animation: drift 26s ease-in-out infinite alternate;
}
.b1 { background: radial-gradient(circle, #1db954, transparent 60%); top: -20vmax; left: -10vmax; }
.b2 { background: radial-gradient(circle, #4a3aa7, transparent 60%); bottom: -25vmax; right: -12vmax; animation-delay: -8s; }
.b3 { background: radial-gradient(circle, #1c5cab, transparent 60%); top: 30%; left: 55%; width: 38vmax; height: 38vmax; animation-delay: -16s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, -5vmax) scale(1.15); }
}

/* ── landing ── */
#landing { max-width: 1060px; margin: 0 auto; padding: 8vh 28px 64px; }
.hero { text-align: center; padding: 6vh 0 8vh; }
.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  animation: pop-in 0.6s ease-out backwards;
}
.hero h1 {
  font-size: clamp(38px, 6.5vw, 64px);
  line-height: 1.1;
  margin: 22px 0 16px;
  letter-spacing: -0.02em;
  animation: rise 0.7s ease-out 0.1s backwards;
}
.grad {
  background: linear-gradient(90deg, #1db954, #4bd680, #3987e5);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.hero-sub {
  max-width: 560px;
  margin: 0 auto 34px;
  color: var(--text-secondary);
  font-size: 17px;
  animation: rise 0.7s ease-out 0.2s backwards;
}
.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #06130a;
  font-weight: 700;
  font-size: 17px;
  padding: 15px 34px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 0 0 0 rgba(29, 185, 84, 0.45);
  animation: rise 0.7s ease-out 0.3s backwards, pulse 2.6s ease-out 1.2s infinite;
  transition: transform 0.15s ease;
}
.cta:hover { transform: scale(1.05); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(29, 185, 84, 0.45); }
  60%  { box-shadow: 0 0 0 18px rgba(29, 185, 84, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 185, 84, 0); }
}
.hero-note { margin-top: 18px; font-size: 13px; color: var(--text-muted); }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px 24px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.feature:hover { transform: translateY(-4px); border-color: rgba(29, 185, 84, 0.4); }
.feature-icon { font-size: 30px; }
.feature h3 { margin: 12px 0 6px; font-size: 16px; }
.feature p { margin: 0; color: var(--text-secondary); font-size: 14px; }

.admin-card { margin-top: 40px; }
.admin-card ol { color: var(--text-secondary); padding-left: 20px; }
.admin-card code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
}

/* ── navbar ── */
nav {
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(14px);
  background: rgba(11, 11, 15, 0.75);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo { font-size: 15px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: none;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.now-playing {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
}
.now-playing img { width: 22px; height: 22px; border-radius: 4px; }
.now-playing .np-text { overflow: hidden; text-overflow: ellipsis; }
.now-playing strong { color: var(--text-primary); font-weight: 600; }
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  flex: none;
}
.eq i {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: eq 1s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: 0.2s; }
.eq i:nth-child(3) { animation-delay: 0.4s; }
@keyframes eq {
  0%, 100% { height: 4px; }
  50% { height: 12px; }
}

.avatar-wrap { position: relative; }
.avatar-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-2) center/cover no-repeat;
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 700;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.avatar-btn:hover { border-color: var(--accent); transform: scale(1.06); }
.avatar-menu {
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  min-width: 170px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  animation: pop-in 0.15s ease-out;
}
.menu-name {
  padding: 8px 10px;
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.avatar-menu button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--danger);
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.avatar-menu button:hover { background: rgba(230, 103, 103, 0.12); }

/* ── layout app ── */
main { max-width: 1100px; margin: 0 auto; padding: 24px 24px 64px; }
.view { display: flex; flex-direction: column; gap: 16px; }
.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}
.view-head h1 { font-size: 24px; margin: 0; letter-spacing: -0.01em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.card-head h2 { margin: 0; }
.note { font-size: 12.5px; color: var(--text-muted); margin: 6px 0 10px; }

/* animazione d'ingresso */
.reveal { animation: rise 0.5s ease-out backwards; }
.reveal:nth-child(2) { animation-delay: 0.06s; }
.reveal:nth-child(3) { animation-delay: 0.12s; }
.reveal:nth-child(4) { animation-delay: 0.18s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: none; }
}

/* ── filtri e bottoni ── */
.filters, .seg { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button, .seg button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.filters button:hover, .seg button:hover { color: var(--text-primary); border-color: var(--baseline); }
.filters button.active, .seg button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn {
  display: inline-block;
  background: var(--accent);
  border: 0;
  color: #06130a;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn:hover { transform: scale(1.04); filter: brightness(1.1); }
.btn.small { padding: 5px 14px; font-size: 12.5px; }
.btn.ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-weight: 500;
  align-self: flex-start;
}
.btn.ghost:hover { color: var(--danger); border-color: var(--danger); }

.inline-form { display: flex; gap: 8px; }
.inline-form input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  outline: none;
  transition: border-color 0.15s ease;
}
.inline-form input:focus { border-color: var(--accent); }

/* ── KPI ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.tile:hover { transform: translateY(-3px); border-color: rgba(29, 185, 84, 0.35); }
.tile-label { font-size: 13px; color: var(--text-secondary); }
.tile-value { font-size: 30px; font-weight: 700; margin-top: 2px; letter-spacing: -0.01em; }
.tile-sub { font-size: 12px; color: var(--text-muted); }
.tile-sub .delta-up { color: var(--accent); font-weight: 600; }
.tile-sub .delta-down { color: var(--text-secondary); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* lista con scorrimento interno (es. ascolti recenti) */
.track-list.scrollable {
  max-height: 430px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--baseline) transparent;
}

/* ── grafici ── */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .empty { color: var(--text-muted); font-size: 13.5px; padding: 24px 0; }
.chart path.bar {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: grow 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) backwards;
}
@keyframes grow { from { transform: scaleY(0); } }

/* ── liste ── */
.track-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.track-list li {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.track-list li:hover { background: var(--surface-2); }
.track-list .rank {
  width: 20px;
  text-align: right;
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.track-list img, .track-list .img-ph {
  width: 38px; height: 38px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.track-list .meta { min-width: 0; }
.track-list .name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-list .sub { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-list .val { font-size: 13px; color: var(--text-secondary); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.track-list .bar-track { grid-column: 3 / 5; height: 6px; position: relative; margin-top: 2px; }
.track-list .bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0 3px 3px 0;
  background: var(--series);
  min-width: 2px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* ── gruppi ── */
.group-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.group-card:hover { transform: translateY(-4px); border-color: rgba(29, 185, 84, 0.4); }
.group-card h3 { margin: 0 0 4px; font-size: 16px; }
.group-card p { margin: 0; color: var(--text-muted); font-size: 13px; }

.invite-box { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.invite-box code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
}

.leaderboard { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: grid;
  grid-template-columns: 26px 38px 1fr auto;
  align-items: center;
  gap: 10px;
}
.lb-rank { text-align: center; font-size: 15px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.lb-rank.first { font-size: 18px; }
.lb-row img, .lb-row .img-ph {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.lb-meta { min-width: 0; }
.lb-name { font-weight: 600; font-size: 14px; }
.lb-track { position: relative; height: 8px; margin-top: 4px; }
.lb-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0 4px 4px 0;
  background: var(--series);
  min-width: 2px;
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.lb-val { font-size: 13px; color: var(--text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }

.member-tops { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.member-top {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.member-top img, .member-top .img-ph {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--page);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.member-top .who { font-size: 12px; color: var(--text-muted); }
.member-top .what { font-size: 13.5px; font-weight: 600; }
.member-top .by { font-size: 12.5px; color: var(--text-secondary); }

/* ── rewind ── */
.rewind { display: flex; flex-direction: column; gap: 16px; }

.rw-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 48px 24px 44px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background:
    radial-gradient(60% 120% at 15% 0%, rgba(29, 185, 84, 0.22), transparent 60%),
    radial-gradient(60% 120% at 85% 100%, rgba(74, 58, 167, 0.30), transparent 60%),
    var(--surface);
}
.rw-hero .rw-year {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--accent);
  text-transform: uppercase;
}
.rw-hero .rw-big {
  font-size: clamp(52px, 9vw, 88px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 8px 0 2px;
  background: linear-gradient(90deg, #1db954, #4bd680, #3987e5);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 6s linear infinite;
}
.rw-hero .rw-label { font-size: 17px; color: var(--text-secondary); }
.rw-hero .rw-sub { margin-top: 10px; font-size: 13.5px; color: var(--text-muted); }
.rw-hero .rw-sub .delta-up { color: var(--accent); font-weight: 600; }
.rw-hero .rw-sub .delta-down { color: var(--text-secondary); font-weight: 600; }

.rw-champion {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.rw-champion:hover { transform: translateY(-3px); border-color: rgba(29, 185, 84, 0.4); }
.rw-champion img, .rw-champion .img-ph {
  width: 92px; height: 92px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  flex: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}
.rw-champion.round img, .rw-champion.round .img-ph { border-radius: 50%; }
.rw-champion .rw-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.rw-champion .rw-name {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 3px 0 2px;
}
.rw-champion .rw-meta { font-size: 13.5px; color: var(--text-secondary); }

.rw-slices { display: flex; flex-direction: column; gap: 12px; }
.rw-slice { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 12px; }
.rw-slice .s-label { font-size: 13.5px; color: var(--text-secondary); white-space: nowrap; }
.rw-slice .s-track { position: relative; height: 10px; }
.rw-slice .s-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0 5px 5px 0;
  background: var(--series);
  min-width: 2px;
  transition: width 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.rw-slice .s-val {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── import ── */
.steps { color: var(--text-secondary); padding-left: 20px; }
.steps code, .dropzone code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
}
.dropzone {
  border: 2px dashed var(--baseline);
  border-radius: 16px;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 40px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.progress-track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.3s ease;
}

/* ── tooltip e toast ── */
.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 260px;
}
.tooltip .tt-value { color: var(--text-primary); font-weight: 700; font-size: 14px; }

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: rise 0.25s ease-out;
}
.toast.ok { border-color: rgba(29, 185, 84, 0.5); }
.toast.err { border-color: rgba(230, 103, 103, 0.5); }

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