/* =========================================================
   The Crate — Editorial Dark Accent Design System
   ========================================================= */

/* --- Custom fonts ---------------------------------------- */
@font-face {
  font-family: 'JA Jayagiri Sans';
  src: url('fonts/JAJayagiriSans.woff2') format('woff2'),
       url('fonts/JAJayagiriSans.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* --- Design Tokens --------------------------------------- */
:root {
  /* Backgrounds */
  --bg-page:        #fafaf8;
  --bg-surface:     #ffffff;
  --bg-muted:       #f1f1ef;
  --bg-dark:        #0f2a1d;
  --bg-dark-hover:  #2a2a2d;

  /* Borders */
  --border-light:   #e6e6e3;
  --border-medium:  #d0d0cc;
  --border-dark:    #3a3a3c;

  /* Text */
  --text-primary:        #111111;
  --text-secondary:      #666666;
  --text-muted:          #999999;
  --text-on-dark:        #f5f5f5;
  --text-muted-on-dark:  #888888;

  /* Accent */
  --accent:      #e8a020;
  --accent-dim:  #7a5010;
  --accent-bg:   #fdf3e0;

  /* UI Green */
  --blue:      #0F2A1D;
  --blue-dark: #0a1e14;
  --blue-bg:   #daeee4;

  /* Score tiers */
  --score-gold:   #e8a020;
  --score-blue:   #4a90d9;
  --score-green:  #3a9e6a;
  --score-gray:   #cccccc;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.14), 0 4px 8px rgba(0,0,0,0.08);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* --- Reset & Base ---------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  /* Prevent black flash on iOS Safari during same-origin navigation: the
     area behind <body> is briefly visible; match the page background. */
  background-color: #fafaf8;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
}

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

ul { list-style: none; }

/* --- Sidebar --------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--bg-dark);
  border-right: 1px solid var(--border-dark);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar__logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-dark);
}

.sidebar__brand {
  font-family: 'JA Jayagiri Sans', sans-serif;
  font-size: 18px;
  font-weight: normal;
  color: var(--text-on-dark);
  letter-spacing: 0;
  text-decoration: none;
}
.sidebar__brand:hover { text-decoration: none; color: var(--accent); }

.sidebar__logo-img {
  display: block;
  max-width: 180px;
  height: auto;
}

.sidebar__nav {
  padding: 12px 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted-on-dark);
  padding: 10px 20px;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar__icon {
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.sidebar__link:hover .sidebar__icon { opacity: 0.85; }
.sidebar__link--active .sidebar__icon { opacity: 1; }

.sidebar__link:hover {
  background: var(--bg-dark-hover);
  color: var(--text-on-dark);
  text-decoration: none;
}

.sidebar__link--active {
  border-left-color: #f4f1ea;
  color: #f4f1ea;
  font-weight: 500;
}

.sidebar__instagram {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 8px 0 12px;
}

/* --- Layout ---------------------------------------------- */
.main-content {
  margin-left: 220px;
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

/* --- Mobile top bar (hidden on desktop) ------------------ */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-dark);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 150;
}

.mobile-topbar__brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.mobile-topbar__brand:hover { text-decoration: none; }

.mobile-topbar__logo {
  height: 32px;
  width: auto;
  display: block;
}

.mobile-topbar__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-topbar__toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-on-dark);
  border-radius: 2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

.sidebar-overlay--visible { display: block; }

/* --- Home logo ------------------------------------------- */
.home-logo {
  display: block;
  max-height: 160px;
  width: auto;
  margin-bottom: 0.75rem;
}

/* --- Page header ----------------------------------------- */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 26px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* --- Error banner ---------------------------------------- */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 14px;
  margin-bottom: 1.5rem;
}

/* --- Stat cards ------------------------------------------ */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border-top: 2px solid var(--border-light);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-card__value {
  font-size: 36px;
  font-weight: 300;
  line-height: 1;
  letter-spacing: -1.5px;
  color: var(--blue);
}

.stat-card__label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card__value--dark {
  color: #0A0A0A;
}

.stat-card__value--green {
  color: #0F2A1D;
}

.stat-card__sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.delta-pos { color: #00875A; }
.delta-neg { color: #E8001C; }

.stat-card__delta {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 20px;
  margin-top: 10px;
}

.delta--positive { background: #d1fae5; color: #065f46; }
.delta--negative { background: #fee2e2; color: #991b1b; }
.delta--neutral  { background: var(--bg-muted); color: var(--text-secondary); }

/* --- Shelves / Carousels --------------------------------- */
.shelf {
  margin-bottom: 2.5rem;
}

.shelf__header {
  margin-bottom: 14px;
}

.shelf__title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.shelf__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.shelf__track {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.shelf__track::-webkit-scrollbar { display: none; }

/* --- Carousel arrow buttons ------------------------------ */
.shelf__track-wrap {
  position: relative;
}

.shelf__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, background 0.15s;
  user-select: none;
}

.shelf:hover .shelf__arrow {
  opacity: 1;
  pointer-events: auto;
}

.shelf__arrow:hover {
  background: rgba(0, 0, 0, 0.78);
}

.shelf__arrow--prev { left: 0; }
.shelf__arrow--next { right: 0; }

@media (max-width: 768px) {
  .shelf__arrow { display: none; }
}

/* --- Poster cards (carousel) ----------------------------- */
.shelf-card {
  min-width: 232px;
  max-width: 232px;
  scroll-snap-align: start;
  flex-shrink: 0;
}

.shelf-card__poster {
  position: relative;
  width: 232px;
  height: 232px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.shelf-card__poster:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.shelf-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shelf-card__cover--placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-muted);
}

.shelf-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0.45) 55%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px 14px;
}

.shelf-card__artist {
  font-size: 10px;
  color: rgba(255,255,255,0.70);
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shelf-card__name {
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shelf-card__score {
  font-size: 14px;
  font-weight: 600;
  color: #748b58;
  margin-top: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}


/* --- Album list (Top Albums + Search) -------------------- */
.result-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.album-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.album-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s, border-left-color 0.2s;
}

.album-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-left-color: var(--blue);
}

.album-card__inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
}

.album-card__cover {
  flex-shrink: 0;
}

.album-card__cover img {
  width: 232px;
  height: 232px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
}

.album-card__cover-placeholder {
  width: 232px;
  height: 232px;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
}

.album-card__info {
  flex: 1;
  min-width: 0;
  padding: 0 1rem;
}

.album-card__heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.album-card__position {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.album-card__title {
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  line-height: 1.3;
}

.album-card__artist {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.album-card__best-track {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

/* Genre tags */
.album-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.genre-tag {
  font-size: 11px;
  color: var(--blue);
  background: var(--blue-bg);
  border-radius: 20px;
  padding: 2px 8px;
}

.genre-tag--gray {
  color: #555555;
  background: #E8E8E8;
}

.mood-tag {
  font-size: 11px;
  color: #c2610a;
  background: #fef0e0;
  border-radius: 20px;
  padding: 2px 8px;
}

/* Notes */
.album-notes {
  margin: 4px 0;
}

.album-notes__text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.album-notes__text--clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.album-notes__toggle {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  padding: 0;
  margin-top: 4px;
  font-family: inherit;
  display: block;
}
.album-notes__toggle:hover { text-decoration: underline; color: var(--blue-dark); }

/* Score block (top-right of card) */
.album-card__score-block {
  flex-shrink: 0;
  align-self: flex-start;
  text-align: right;
  padding-top: 2px;
  min-width: 52px;
}

.album-card__score-numeral {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 36px;
  font-weight: 400;
  color: #222222;
  line-height: 1;
  letter-spacing: -0.5px;
}

.album-card__score-meta {
  font-size: 11px;
  color: #888888;
  margin-top: 4px;
  white-space: nowrap;
}

/* Score details */
.score-details {
  border-top: 1px solid var(--border-light);
  padding: 10px 20px 14px;
}

.score-details__summary {
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.score-details__summary::-webkit-details-marker { display: none; }
.score-details__summary::before { content: '▸ '; }
details[open] .score-details__summary::before { content: '▾ '; }

.score-details__body {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  padding-top: 10px;
}

.score-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-metric__label {
  font-size: 11px;
  color: var(--text-muted);
}

.score-metric__value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.detail-value {
  color: #0F2A1D;
  font-weight: bold;
}

.score-details__tracks {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  width: 100%;
}

/* Audio preview + streaming links */
.preview-block {
  margin-top: 8px;
}

.preview-audio {
  width: 100%;
  height: 32px;
  margin-top: 4px;
}

/* Loading state: pulse the placeholder audio bar while the API resolves */
.preview-audio-container--loading .preview-audio {
  opacity: 0.35;
  animation: preview-pulse 1.8s ease-in-out infinite;
}

@keyframes preview-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.18; }
}

/* Unavailable state: hide the audio bar, show a same-height text message */
.preview-audio-container--unavailable .preview-audio {
  display: none;
}

.preview-audio-container--unavailable::after {
  content: 'Anteprima non disponibile';
  display: flex;
  align-items: center;
  height: 32px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.streaming-links {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.streaming-links__icons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.created-date {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.streaming-links img {
  height: 24px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.streaming-links img:hover {
  opacity: 1;
}

/* --- Filter panel ---------------------------------------- */
.filter-panel {
  margin-bottom: 1.5rem;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
  box-shadow: var(--shadow-sm);
}
.filter-toggle:hover { background: var(--bg-muted); }

.filter-toggle__icon { flex-shrink: 0; }

/* Sort pills row (genre + archivio pages) */
.sort-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.sort-pills__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 2px;
}

.sort-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-medium);
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sort-pill:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sort-pill--active {
  background: #0f2a1d;
  border-color: #0f2a1d;
  color: #fafaf8;
}

/* Language pills row (genre page) */
.lang-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-medium);
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lang-pill:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.lang-pill--active {
  background: #0f2a1d;
  border-color: #0f2a1d;
  color: #fafaf8;
}

/* Sort pills row (genre + archivio pages) */
.sort-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.sort-pills__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 2px;
}

.sort-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-medium);
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sort-pill:hover {
  background: var(--bg-muted);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sort-pill--active {
  background: #0f2a1d;
  border-color: #0f2a1d;
  color: #fafaf8;
}

/* Active filters summary */
.filter-summary {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-form {
  margin-top: 16px;
}

.filter-form--hidden { display: none; }

.filter-section {
  margin-bottom: 20px;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  display: block;
}

/* Genre pill toggles */
.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-medium);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  position: relative;
}

.genre-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.genre-pill:hover {
  border-color: var(--accent);
}

.genre-pill:has(input:checked) {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  border-color: var(--bg-dark);
}

/* Year + score row */
.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group {
  border: none;
}

.filter-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-sublabel {
  font-size: 11px;
  color: var(--text-muted);
}

.filter-select {
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-width: 80px;
}

.filter-range {
  width: 100%;
  accent-color: var(--blue);
  margin-top: 4px;
}

.filter-select--multi {
  min-height: 132px;
  accent-color: var(--blue);
}

.filter-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.filter-year-score {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.filter-year-score .filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-score-group {
  min-width: 200px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* --- Buttons --------------------------------------------- */
.btn {
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  display: inline-block;
}

.btn--primary {
  background: var(--bg-dark);
  color: var(--text-on-dark);
  border-color: var(--bg-dark);
}
.btn--primary:hover { background: var(--bg-dark-hover); text-decoration: none; color: var(--text-on-dark); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}
.btn--ghost:hover { background: var(--bg-muted); color: var(--text-primary); text-decoration: none; }

.btn--large {
  font-size: 15px;
  padding: 12px 40px;
  border-radius: var(--radius-md);
}

/* --- Search page ----------------------------------------- */
.search-form {
  margin-bottom: 2rem;
}

.search-input-wrap {
  display: flex;
  gap: 10px;
  max-width: 600px;
}

.search-input {
  flex: 1;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  outline: none;
  transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}
.search-input:focus { border-color: var(--accent); }

.search-btn {
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-on-dark);
  background: var(--bg-dark);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-btn:hover { background: var(--bg-dark-hover); }

/* --- Empty state ----------------------------------------- */
.empty-state {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 2rem 0;
}

/* --- Random form ----------------------------------------- */
.random-form {
  margin-bottom: 2rem;
}

.random-actions {
  margin-top: 24px;
  text-align: center;
}

/* --- Random grid ----------------------------------------- */
.random-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 1.5rem;
}

.random-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  aspect-ratio: 1;
  cursor: default;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.random-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.random-card__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.random-card__cover--placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-muted);
}

.random-card__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 55%, transparent 100%);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
}

.random-card:hover .random-card__overlay { opacity: 1; }

.random-card__name {
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  line-height: 1.2;
}

.random-card__artist {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  margin-top: 2px;
}

.random-card__score {
  font-size: 13px;
  font-weight: 600;
  color: #748b58;
  margin-top: 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}

/* --- Perché page ----------------------------------------- */
.perche-content {
  max-width: 900px;
  line-height: 1.75;
}

.perche-content p { margin-bottom: 1.2em; }
.perche-content ul { margin: 0.5rem 0 1.2em 1.2rem; list-style: disc; }
.perche-content li { margin-bottom: 0.4rem; }
.perche-content h2 { font-size: 18px; font-weight: 500; margin: 2em 0 0.5em; letter-spacing: -0.3px; }
.perche-content h2:first-child { margin-top: 0; }

.perche-divider {
  border: none;
  border-top: 1px solid #EFEFEF;
  margin: 32px 0;
}

.perche-crate-box {
  margin-top: 40px;
  background: #F5F5F5;
  border-radius: 10px;
  padding: 20px 24px;
}

.perche-crate-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 0.75rem;
  letter-spacing: -0.3px;
}

.tier-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tier-table th, .tier-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.tier-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-muted);
}

.tier-cell {
  text-align: center;
  font-weight: 600;
  width: 60px;
}

.tier-cell--gold   { color: var(--score-gold); }
.tier-cell--silver { color: var(--text-secondary); }
.tier-cell--bronze { color: var(--score-green); }

.tier-row { border-left: 3px solid transparent; }
.tier-row--gold   { border-left-color: var(--score-gold); }
.tier-row--silver { border-left-color: var(--border-medium); }
.tier-row--bronze { border-left-color: var(--score-green); }

.tier-desc { color: #555; }

/* --- Radar example (Perché page) ----------------------------- */
.radar-example {
  max-width: 360px;
  margin: 1.5rem auto;
  text-align: center;
}

.radar-example__caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
  line-height: 1.5;
}

/* --- Instagram box (Perché page) ----------------------------- */
.perche-instagram-box {
  margin-bottom: 1.5rem;
}

.perche-instagram-cta {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 13px;
  font-weight: 500;
  color: #0f2a1d;
  text-decoration: none;
  border: 1px solid #0f2a1d;
  padding: 6px 14px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.perche-instagram-cta:hover {
  background: #0f2a1d;
  color: #fafaf8;
  text-decoration: none;
}

/* --- Shelf card date ------------------------------------- */
.shelf-card__date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555555;
  margin-top: 6px;
  white-space: nowrap;
}

/* --- Section divider & header row ----------------------- */
.section-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 2.5rem 0;
}

.shelf__header--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.shelf__see-all {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1px;
  transition: color 0.12s, border-color 0.12s;
}
.shelf__see-all:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
  text-decoration: none;
}
@media (max-width: 768px) {
  .esplora-label { display: none; }
}

/* --- Home ranking table --------------------------------- */
.home-ranking {
  margin-bottom: 2.5rem;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
}

.ranking-table thead tr {
  border-bottom: 1.5px solid var(--text-primary);
}

.ranking-table thead th {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0 8px;
  text-align: left;
  font-weight: 500;
}
.ranking-table thead th:last-child { text-align: right; }

.ranking-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
.ranking-table tbody tr:hover { background: var(--bg-muted); }

.ranking-table tbody td {
  padding: 10px 0;
  vertical-align: middle;
}

.rank-n {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  color: #0A0A0A;
  width: 28px;
  padding-right: 8px;
}

.rank-thumb {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.rank-thumb--placeholder {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  background: var(--bg-muted);
  flex-shrink: 0;
}

.rank-info-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rank-text .r-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.rank-text .r-artist {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.rank-genre {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #0A0A0A;
  padding: 0 16px;
}

.rank-score-cell {
  text-align: center;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* --- Album detail page ----------------------------------- */
.album-detail-nav {
  margin-bottom: 1.5rem;
}

.detail-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px 6px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  text-decoration: none;
}
.detail-back:hover { background: var(--bg-muted); text-decoration: none; }

.album-detail-page {
  width: 100%;
}

.album-detail-page .album-card__cover img {
  width: 100%;
  max-width: 300px;
  height: auto;
  display: block;
}

/* Clickable cards in Archivio/Cerca */
.album-card[data-detail-url] {
  cursor: pointer;
}

/* Carousel poster as anchor link */
a.shelf-card__poster {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* --- Desktop: narrower centered album list --------------- */
@media (min-width: 641px) {
  .album-list {
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
  }
}

/* --- Album del giorno ------------------------------------ */
.album-del-giorno {
  margin-bottom: 2.5rem;
}

/* --- Radar chart (album detail page, inside cover column) --- */
.album-card__cover {
  display: flex;
  flex-direction: column;
}

.radar-chart-cover {
  width: 100%;
  max-width: 300px;
  margin-top: 1rem;
  overflow: hidden;
}

.radar-chart-cover canvas {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: 300px;
}

/* --- Responsive (mobile ≤ 640px) ------------------------- */
@media (max-width: 640px) {
  /* Mobile top bar */
  .mobile-topbar { display: flex; }
  .sidebar__logo { display: none; }

  /* Sidebar: off-screen by default. No transition here — it is added
     dynamically by JS (sidebar--animated) only on explicit user toggle,
     preventing a slide animation on every page load. */
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar--animated { transition: transform 0.25s ease; }
  .sidebar--open { transform: translateX(0); }

  /* Layout */
  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 68px; /* clear 52px topbar + 16px gap */
  }

  /* Page header */
  .page-title { font-size: 21px; }

  /* Stat cards: 3 columns on mobile too */
  .stat-cards { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card__value { font-size: 24px; letter-spacing: -1px; }

  /* Carousel cards */
  .shelf-card { min-width: 150px; max-width: 150px; }
  .shelf-card__poster { width: 150px; height: 150px; }
  .shelf-card__date { flex-direction: column; align-items: flex-start; gap: 4px; }

  /* Radar chart */
  .radar-chart-cover { max-width: 100%; margin-top: 1.5rem; }
  .radar-chart-cover canvas { max-width: 100%; }

  /* Detail page: cover image full width */
  .album-detail-page .album-card__cover img { max-width: 100%; }

  /* Detail page: unwrap cover div so img and radar become direct flex children
     of .album-card__inner; then order:1 on radar pushes it after the score block */
  .album-detail-page .album-card__cover { display: contents; }
  .album-detail-page .radar-chart-cover { order: 1; }

  /* Album del giorno: hide verbose fields on mobile to keep the card compact */
  .album-del-giorno .album-notes__text,
  .album-del-giorno .album-notes__toggle { display: none; }
  .album-del-giorno .album-card__best-track { display: none; }

  /* Album cards: vertical stack */
  .album-card { border-left: none; }

  .album-card__inner {
    flex-direction: column;
    gap: 0;
    padding: 0;
  }

  .album-card__cover { width: 100%; }

  .album-card__cover img,
  .album-card__cover-placeholder {
    width: 100%;
    height: 200px;
    border-radius: 0;
  }

  .album-card__info {
    padding: 14px 16px 8px;
  }

  .album-card__score-block {
    align-self: auto;
    text-align: left;
    padding: 0 16px 14px;
    min-width: 0;
  }

  .album-card__score-numeral { font-size: 28px; }

  /* Random grid: 2 columns */
  .random-grid { grid-template-columns: repeat(2, 1fr); }

  /* Search */
  .search-input-wrap { flex-direction: column; }
  .search-btn { width: 100%; }

  /* Filter panel */
  .filter-year-score { flex-direction: column; gap: 16px; }

}

@media (max-width: 768px) {
}

/* =========================================================
   Stats page
   ========================================================= */

/* Summary bar: 6 columns on desktop */
.stats-summary {
  grid-template-columns: repeat(6, 1fr);
}

/* Best album card: text value instead of a large number */
.stat-card__value--best {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.2px;
  line-height: 1.35;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sections */
.stats-section {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  padding: 24px;
  margin-bottom: 1.5rem;
}

.stats-section__title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  margin-bottom: 20px;
}

/* Horizontal bar chart (Tier distribution) */
.stats-hbar-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-hbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stats-hbar-label {
  min-width: 148px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.stats-hbar-track {
  flex: 1;
  height: 20px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stats-hbar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: var(--radius-sm);
  min-width: 4px;
}

.stats-hbar-count {
  min-width: 32px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  flex-shrink: 0;
}

/* Vertical bar chart (Albums per year) */
.stats-year-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.stats-year-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.stats-year-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1;
}

.stats-year-bar-container {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
}

.stats-year-bar {
  width: 100%;
  background: var(--blue);
  border-radius: 3px 3px 0 0;
  min-height: 3px;
}

.stats-year-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}

/* Two-column layout (genre breakdown, artist spotlight) */
.stats-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

/* Panel label (sub-heading inside a section) */
.stats-panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

.stats-panel-label__note {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Ranked list */
.stats-ranked-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.stats-ranked-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
}

.stats-ranked-item:last-child {
  border-bottom: none;
}

.stats-ranked-item__pos {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 18px;
  flex-shrink: 0;
}

.stats-ranked-item__name {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats-ranked-item__value {
  font-size: 13px;
  font-weight: 500;
  color: var(--blue);
  flex-shrink: 0;
}

/* --- Stats responsive (mobile ≤ 640px) -------------------- */
@media (max-width: 640px) {
  .stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-two-col {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .stats-year-label {
    font-size: 9px;
  }

  .stats-year-bar-container {
    height: 100px;
  }

  .stats-section {
    padding: 16px;
  }

  /* Filter row: stack on mobile */
  #filterPanel .filter-row {
    flex-direction: column;
    gap: 16px;
  }
}

/* Back link on genere page */
.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-decoration: none;
  transition: color 0.15s;
}

.page-back:hover {
  color: var(--text-primary);
  text-decoration: none;
}

/* =========================================================
   Scopri / Crateometro page
   ========================================================= */

.scopri-page {
  max-width: none;
}

.scopri-header {
  margin-bottom: 2rem;
}

.scopri-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.scopri-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/*
  Three-area grid:
    Desktop: [chart | result]
             [controls    ]
    Mobile:  [chart] → [controls] → [result]

  DOM order: chart → result → controls.
  grid-template-areas reorders controls before result on mobile.
*/
.scopri-body {
  display: grid;
  grid-template-areas: "chart controls";
  grid-template-columns: 2fr 3fr;
  gap: 2rem 3rem;
  align-items: start;
}

/* Chart column — left half on desktop; fills its full grid cell */
.scopri-chart-col {
  grid-area: chart;
  min-width: 0;   /* prevent grid blowout */
}

.scopri-chart-col canvas {
  display: block;
  width: 100%;
  max-width: 300px;   /* 300×225px at 4:3 — keeps radar compact inside 40% column */
  max-height: 225px;
}

/* Result column — right half on desktop, after controls on mobile */
.scopri-result-col {
  grid-area: result;
  min-width: 0;
}

/* Controls row — spans both columns on desktop */
.scopri-controls-col {
  grid-area: controls;
  max-width: 470px;   /* ~15% narrower than the unconstrained 3fr column width */
}

/*
  Dimension filter rows: each dimension is a horizontal row
  (label on the left, 1–5 buttons on the right) so all 5 rows
  align consistently regardless of label length.
*/
.scopri-dims {
  border-top: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.dim-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
}

.dim-control:last-child {
  border-bottom: none;
}

.dim-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 90px;   /* keeps labels left-aligned across all rows */
}

.dim-buttons {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.dim-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-medium);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.dim-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-bg);
}

.dim-btn--active {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.dim-btn--active:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #ffffff;
}

.scopri-submit {
  margin-top: 1.5rem;
  padding: 10px 28px;
  background: var(--bg-dark);
  color: var(--text-on-dark);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  touch-action: manipulation;
}

.scopri-submit:hover {
  background: var(--bg-dark-hover);
}

/* No-result state */
.scopri-no-result {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
  padding-top: 1rem;
}

/* Result card wrapper — mirrors .album-del-giorno structure.
   On mobile, verbose fields (notes, best-track) are hidden to keep
   the card compact, exactly matching Album del Giorno behavior. */
.scopri-album-card {
  margin-bottom: 2.5rem;
}

/* Make the album card fill its grid column fully. */
.scopri-result-col .album-card {
  width: 100%;
  box-sizing: border-box;
}

/* Shrink the cover image so it fits inside a 50%-wide column without
   squeezing the text area. The full 232px image is designed for full-width
   display; inside a grid column ~420–450px wide it leaves too little room. */
.scopri-album-card .album-card__cover img,
.scopri-album-card .album-card__cover-placeholder {
  width: 140px;
  height: 140px;
}

/* Responsive — single column */
@media (max-width: 640px) {
  .scopri-body {
    grid-template-areas:
      "chart"
      "controls";
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .scopri-chart-col canvas {
    max-width: 100%;
    max-height: 200px;
  }

  .scopri-submit {
    width: 100%;
  }
}

/* --- Scopri range sliders -------------------------------- */
.dim-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border-medium);
  outline: none;
  cursor: pointer;
}

.dim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}

.dim-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}

.dim-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  min-width: 16px;
  text-align: center;
}

/* --- Scopri results grid --------------------------------- */
.scopri-results {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border-light);
  padding-top: 1.5rem;
}

.scopri-results__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 1rem;
}

.scopri-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

@media (max-width: 768px) {
  .scopri-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .scopri-grid::-webkit-scrollbar {
    display: none;
  }
  .scopri-grid .scopri-card {
    flex: 0 0 auto;
    width: 160px;
    scroll-snap-align: start;
  }
}

/* --- Scopri result card ---------------------------------- */
.scopri-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1.5px solid var(--border-light);
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.scopri-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-medium);
  text-decoration: none;
  color: inherit;
}

/* First result: subtle blue outline to mark it as top match */
.scopri-card--best {
  border-color: var(--blue);
}

.scopri-card--best:hover {
  border-color: var(--blue-dark);
}

.scopri-card__cover {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-muted);
}

.scopri-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scopri-card__cover-placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-muted);
}

/* Hover radar: fills the cover area with a translucent background */
.scopri-card__radar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.94);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 8px;
  box-sizing: border-box;
}

.scopri-card:hover .scopri-card__radar-overlay {
  display: flex;
}

.scopri-card__radar-canvas {
  width: 100% !important;
  height: 100% !important;
}

.scopri-card__info {
  padding: 8px 10px 10px;
}

.scopri-card__artist {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scopri-card__title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.scopri-card__meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.scopri-card__score {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* Compatibility bar */
.compat-bar-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.compat-bar {
  flex: 1;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.compat-bar__fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
}

.compat-pct {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================
   Crateometro — album seed selection block
   ========================================================== */

.scopri-seed {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.scopri-seed__select {
  flex: 1;
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
}

.scopri-seed__select:focus {
  outline: none;
  border-color: var(--blue);
}

.scopri-seed__random {
  flex-shrink: 0;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.scopri-seed__random:hover {
  background: var(--bg-muted);
  border-color: var(--blue);
}

/* ==========================================================
   Crateometro — album preview block (radar + cover)
   ========================================================== */

.scopri-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.scopri-preview--hidden {
  display: none;
}

/* Fixed-width chart column so the radar is compact and square */
.scopri-preview__chart-col {
  flex: 0 0 360px;
  width: 360px;
}

.scopri-preview__chart-col canvas {
  display: block;
  width: 100%;
}

.scopri-preview__cover-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.scopri-preview__cover-img {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.scopri-preview__cover-img--hidden {
  display: none;
}

.scopri-preview__cover-placeholder {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.scopri-preview__meta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.scopri-preview__meta-artist {
  font-size: 12px;
  color: var(--text-secondary);
}

.scopri-preview__meta-year {
  font-size: 12px;
  color: var(--text-muted);
}

/* Mobile — stack seed row and preview block vertically */
@media (max-width: 640px) {
  .scopri-seed {
    flex-direction: column;
    align-items: stretch;
  }

  .scopri-seed__random {
    width: 100%;
    text-align: center;
  }

  .scopri-preview {
    flex-direction: column;
    align-items: center;
  }

  .scopri-preview__chart-col {
    flex: none;
    width: 100%;
    max-width: 360px;
  }
}

/* ==========================================================
   Scopri — two-tab layout
   ========================================================== */

.scopri-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.75rem;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 0;
}

.scopri-tab {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.scopri-tab:hover {
  color: var(--text-primary);
}

.scopri-tab--active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.scopri-tab-panel--hidden {
  display: none !important;
}

/* ==========================================================
   Crateometro — genre + mood filters
   ========================================================== */

.scopri-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-muted);
  border-radius: var(--radius-md);
}

.scopri-filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.scopri-filter-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.scopri-filter-select {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.scopri-filter-select:focus {
  outline: none;
  border-color: var(--blue);
}

.scopri-mood-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.scopri-mood-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 9px;
  border: 1px solid var(--border-light);
  border-radius: 99px;
  background: var(--bg-surface);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
}

.scopri-mood-check input[type="checkbox"] {
  display: none;
}

.scopri-mood-check:has(input:checked) {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* Fallback for browsers without :has() */
.scopri-mood-check--checked {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* ==========================================================
   Naviga tab — album preview
   ========================================================== */

.scopri-naviga-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  max-width: 900px;
  margin: 0 auto 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.scopri-naviga-preview--hidden {
  display: none;
}

.scopri-naviga-preview__chart-col {
  flex: 0 0 320px;
  width: 320px;
}

.scopri-naviga-preview__chart-col canvas {
  display: block;
  width: 100%;
}

.scopri-naviga-preview__cover-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.scopri-naviga-preview__cover-img {
  display: block;
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.scopri-naviga-preview__cover-img--hidden {
  display: none;
}

.scopri-naviga-preview__cover-placeholder {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.scopri-naviga-preview__meta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.scopri-naviga-preview__meta-artist {
  font-size: 12px;
  color: var(--text-secondary);
}

.scopri-naviga-preview__meta-year {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================
   Naviga tab — nudge buttons
   ========================================================== */

.scopri-nudge-section {
  margin-bottom: 1.5rem;
}

.scopri-nudge-section__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.naviga-nudge-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}

.scopri-nudge-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--border-light);
  border-radius: 99px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.scopri-nudge-btn:hover {
  background: var(--bg-muted);
  border-color: var(--blue);
  color: var(--text-primary);
}

.scopri-nudge-btn--active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.scopri-nudge-btn--active:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  opacity: 0.88;
}

.scopri-nudge-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nudge-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 99px;
  padding: 1px 5px;
  line-height: 1.4;
}

/* ==========================================================
   Naviga tab — surprise toggle + cerca button
   ========================================================== */

.scopri-naviga-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.scopri-surprise-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.scopri-surprise-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.scopri-naviga-cerca {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s;
}

.scopri-naviga-cerca:hover {
  opacity: 0.88;
}

.scopri-naviga-cerca:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .scopri-naviga-preview {
    flex-direction: column;
    align-items: center;
  }

  .scopri-naviga-preview__chart-col {
    flex: none;
    width: 100%;
    max-width: 320px;
  }

  .scopri-naviga-options {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Radar info icons + tooltip --------------------------------------- */
.radar-info-icon {
  position: absolute;
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: default;
  transform: translate(-50%, -50%);
  z-index: 10;
  opacity: 0;
}

.radar-info-tooltip {
  display: none;
  position: fixed;
  z-index: 9999;
  background: #0F2A1D;
  color: #FAFAF8;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 220px;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.radar-info-tooltip strong {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 4px;
  opacity: 0.7;
}

@media (min-width: 769px) {
  .scopri-naviga-preview__chart-col {
    flex: 0 0 416px;
    width: 416px;
  }

  .scopri-naviga-preview__cover-img,
  .scopri-naviga-preview__cover-placeholder {
    width: 234px;
    height: 234px;
  }
}

