/* Page-level composition: hero headers, home shelves, history table, stats. */

/* ---------- Shared hero (Spotify album-page header) ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 232px) minmax(0, 1fr);
  gap: 24px;
  align-items: end;
  padding: 12px 0 28px;
}

.hero-art {
  position: relative;
  width: 100%;
  max-width: 232px;
}

.hero-art .cover,
.hero-art .cover-fallback {
  width: 100%;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-cover);
}

.hero-art .cover-fallback {
  font-size: 3rem;
}

.hero-copy {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding-bottom: 4px;
}

.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 700;
}

.hero-title {
  color: var(--text);
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
}

.hero-facts .muted {
  color: var(--subdued);
}

.hero-facts a:hover {
  text-decoration: underline;
}

.hero-artist {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.hero-artist .cover,
.hero-artist .cover-fallback {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
}

.hero-progress {
  width: min(100%, 460px);
}

.hero-progress .progress-fill {
  background: var(--green);
}

/* Action strip under the hero */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 20px 0 8px;
}

.actions .play-fab {
  width: 56px;
  height: 56px;
}

.actions .play-fab svg {
  width: 24px;
  height: 24px;
}

.hero-compact {
  display: grid;
  gap: 12px;
  padding: 16px 0 26px;
}

.hero-compact .hero-facts {
  color: var(--subdued);
}

/* ---------- Home ---------- */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}

.feature {
  position: relative;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 16px;
  border-radius: var(--r-lg);
  background: linear-gradient(120deg, var(--elevated-hover), var(--elevated) 62%);
  transition: background var(--dur-3) var(--ease);
}

.feature:hover {
  background: linear-gradient(120deg, #333, var(--elevated-hover) 62%);
}

.feature-art {
  position: relative;
  width: 104px;
}

.feature-art .cover,
.feature-art .cover-fallback {
  width: 104px;
  height: 104px;
  border-radius: var(--r-md);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
}

.feature-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.feature .play-fab {
  position: relative;
  z-index: 2;
}

.feature-title {
  color: var(--text);
  font-size: clamp(1.25rem, 0.9rem + 1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

/* ---------- History ---------- */

.table-head {
  position: sticky;
  top: 64px;
  z-index: 10;
  display: grid;
  grid-template-columns: var(--row-columns);
  gap: 16px;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--base);
  color: var(--subdued);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.table-head span:last-child {
  text-align: right;
}

.history-table {
  --row-columns: 32px 40px minmax(0, 1.5fr) minmax(0, 1fr) 132px;
}

.history-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 430px);
  min-height: 48px;
  padding: 0 8px 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--subdued);
  background: rgba(0, 0, 0, 0.35);
  transition: border-color var(--dur-2) var(--ease), background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.search-field:focus-within {
  border-color: var(--green);
  background: var(--elevated);
  box-shadow: var(--shadow-focus);
}

.search-field svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: currentcolor;
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.search-field input::placeholder { color: var(--quiet); }
.search-field kbd {
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xs);
  color: var(--quiet);
  font: 700 0.75rem/1.4 var(--font);
}

.search-field button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--subdued);
  font-size: 1.35rem;
}

.search-field button:hover { color: var(--text); background: var(--row-hover); }
.filter-empty { margin-bottom: 16px; }

.row-album {
  color: var(--subdued);
  font-size: 0.8125rem;
}

.loader {
  min-height: 40px;
  padding: 20px 0;
  color: var(--subdued);
  font-size: 0.8125rem;
  text-align: center;
}

.sentinel {
  height: 1px;
}

/* ---------- Stats ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 16px;
}

.stat-tile {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 20px;
  overflow: hidden;
  border-radius: var(--r-md);
  background: linear-gradient(155deg, rgba(30, 215, 96, 0.11), transparent 48%), var(--elevated);
  transition: background var(--dur-3) var(--ease);
}

.stat-tile::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -38px;
  width: 116px;
  height: 116px;
  border: 18px solid color-mix(in srgb, var(--green) 28%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.stat-tile:nth-child(2)::after { border-color: color-mix(in srgb, var(--cyan) 26%, transparent); }
.stat-tile:nth-child(3)::after { border-color: color-mix(in srgb, var(--violet) 30%, transparent); }

.ranking-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 36px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.3);
}

.segmented button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  color: var(--subdued);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: color var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}

.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { color: var(--on-green); background: var(--green); }

.stat-tile:hover {
  background: linear-gradient(155deg, rgba(30, 215, 96, 0.16), transparent 48%), var(--elevated-hover);
}

.stat-value {
  color: var(--text);
  font-size: clamp(1.9rem, 1.2rem + 1.6vw, 2.75rem);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  line-height: 1;
}

.stat-sub {
  color: var(--subdued);
  font-size: 0.75rem;
  line-height: 1.4;
}

.stats-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 24px;
  align-items: start;
  margin-top: 16px;
}

.artist-rows {
  --row-columns: 28px 48px minmax(0, 1fr) auto;
}

.artist-rows .row-art .cover,
.artist-rows .row-art .cover-fallback {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.top-rows {
  --row-columns: 28px 48px minmax(0, 1fr) auto;
}

.top-rows .row-art .cover,
.top-rows .row-art .cover-fallback {
  width: 48px;
  height: 48px;
  border-radius: var(--r-sm);
}

/* ---------- Heatmap ---------- */

.heatmap-card {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(circle at 100% 0%, rgba(30, 215, 96, 0.1), transparent 40%),
    var(--elevated);
}

.heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
}

.heatmap-layout {
  display: grid;
  grid-template-columns: 30px max-content;
  gap: 8px;
  width: max-content;
  min-width: 100%;
}

.heatmap-weekdays,
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 18px);
  gap: 5px;
}

.heatmap-weekdays span {
  align-self: center;
  color: var(--quiet);
  font-size: 0.625rem;
  font-weight: 700;
}

.heatmap-grid {
  grid-auto-flow: column;
  grid-auto-columns: 18px;
}

.heatmap-cell {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: var(--r-xs);
  background: rgba(255, 255, 255, 0.06);
  transition: transform var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}

.heatmap-grid .heatmap-cell:hover {
  position: relative;
  z-index: 1;
  transform: scale(1.25);
  box-shadow: 0 0 0 1px var(--green), 0 0 14px var(--green-glow);
}

.heatmap-level-1 {
  background: rgba(30, 215, 96, 0.26);
}

.heatmap-level-2 {
  background: rgba(30, 215, 96, 0.48);
}

.heatmap-level-3 {
  background: rgba(30, 215, 96, 0.72);
}

.heatmap-level-4 {
  background: var(--green);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  color: var(--subdued);
  font-size: 0.6875rem;
  font-weight: 700;
}

.heatmap-legend .heatmap-cell {
  width: 12px;
  height: 12px;
}

/* ---------- Detail pages ---------- */

.detail-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-top: 36px;
}

.artist-hero {
  position: relative;
  isolation: isolate;
  margin: 0 calc(-1 * var(--pad-panel));
  padding: 24px var(--pad-panel) 28px;
  overflow: hidden;
}

.artist-hero-bg {
  position: absolute;
  inset: -20%;
  z-index: -2;
  background-image: var(--art);
  background-size: cover;
  background-position: center;
  filter: blur(60px) saturate(1.3);
  opacity: 0.5;
  transform: scale(1.1);
}

.artist-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.25), var(--base));
}

.artist-hero .hero {
  padding-bottom: 4px;
}

.artist-hero .hero-art {
  max-width: 200px;
}

.artist-hero .hero-art .cover,
.artist-hero .hero-art .cover-fallback {
  border-radius: 50%;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .stats-columns,
  .detail-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .history-table {
    --row-columns: 28px 40px minmax(0, 1fr) 96px;
  }

  .history-table .row-album,
  .table-head .col-album {
    display: none;
  }
}

@media (max-width: 720px) {
  .history-tools { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .ranking-toolbar { align-items: flex-end; flex-direction: column; }
  .hero {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 18px;
    padding-top: 8px;
    text-align: center;
  }

  .hero-art {
    max-width: 190px;
  }

  .hero-copy {
    justify-items: center;
  }

  .hero-facts,
  .hero-eyebrow {
    justify-content: center;
  }

  .actions {
    justify-content: center;
    padding: 8px 0 4px;
  }

  .feature {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
  }

  .feature-art,
  .feature-art .cover,
  .feature-art .cover-fallback {
    width: 72px;
    height: 72px;
  }

  .feature .play-fab {
    display: none;
  }

  .shelf {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }

  .table-head {
    top: 56px;
  }
}

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

  .history-table {
    --row-columns: 40px minmax(0, 1fr) 84px;
  }

  .history-table .row-index,
  .table-head .col-index {
    display: none;
  }
}
