/* ========================================
   Music section (/music/)
   Loaded only on music pages, after style.css.
   Compact, Last.fm-style lists: photo tiles, tight rows, play-count bars.
   ======================================== */

:root {
  --bar:        #2a78d6;   /* strongest blue: "loved", active bars */
  --bar-soft:   #a9c8ef;   /* "fine" */
  --tint:       #dce9fa;   /* play-count bar fill (text sits on it) */
  --tint-old:   #e9e9e9;   /* the earlier year in paired bars */
  --v-skip:     #d2d2d2;
  --row-hover:  #f5f5f5;
  --blank:      #2b2b2b;   /* tile with no photo */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bar:       #3987e5;
    --bar-soft:  #2b4f7d;
    --tint:      #1e3453;
    --tint-old:  #2a2a2a;
    --v-skip:    #484848;
    --row-hover: #1d1d1d;
    --blank:     #262626;
  }
}

:root[data-theme="dark"] {
  --bar:       #3987e5;
  --bar-soft:  #2b4f7d;
  --tint:      #1e3453;
  --tint-old:  #2a2a2a;
  --v-skip:    #484848;
  --row-hover: #1d1d1d;
  --blank:     #262626;
}

/* ========== PAGE HEADER ========== */

.music-head { padding-top: 2rem; }
.music-head .page-title { margin: 0 0 0.5rem; }
.crumb { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.music-intro { font-size: 0.975rem; }
.music-intro > * + * { margin-top: 0.6rem; }

.counts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; margin-top: 1.25rem; }
.counts dt, .figure-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.counts dd, .figure-value {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin-top: 1rem; font-size: 0.9rem; }

/* ========== SECTIONS ========== */

.music-section { margin-top: 2.25rem; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.section-head h2 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.01em; }
.section-meta { color: var(--text-muted); font-size: 0.8rem; }
.more { display: block; text-align: right; font-size: 0.8rem; margin-top: 0.5rem; }

.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 0.7rem; }
.key {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: -0.02rem;
}

/* ========== PHOTO TILES ========== */

.tiles {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}
.tile a {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--blank);
  color: #ffffff;
}
.tile a:hover { text-decoration: none; }
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.tile a:hover img { transform: scale(1.04); }
.tile-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 2rem;
  color: #8a8a8a;
}
.tile-text {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2.5rem 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  line-height: 1.25;
}
.tile-name { font-size: 0.8rem; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.tile-plays { font-size: 0.7rem; opacity: 0.85; font-variant-numeric: tabular-nums; }

/* ========== ROWS ========== */

.rows { list-style: none; }
.row {
  display: grid;
  grid-template-columns: 1.4rem 2rem minmax(0, 1fr) minmax(7rem, 38%);
  gap: 0.65rem;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.3rem 0.25rem;
  border-top: 1px solid var(--border);
}
.row:last-child { border-bottom: 1px solid var(--border); }
.row:hover { background: var(--row-hover); }
.row-rank { color: var(--text-muted); font-size: 0.8rem; text-align: right; font-variant-numeric: tabular-nums; }
.row-cover {
  width: 2rem;
  height: 2rem;
  border-radius: 2px;
  object-fit: cover;
  background: var(--tint-old);
  display: block;
}
.row-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.row-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.row-title:hover { color: var(--link); }
.row-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rows without a rank (journal songs, keepers) */
.row-song { grid-template-columns: 2rem minmax(0, 1fr) auto; }

/* Play-count bar with the number inside it */
.plays-bar { position: relative; display: block; height: 1.4rem; }
.plays-fill { position: absolute; inset: 0 auto 0 0; background: var(--tint); min-width: 2px; }
.fill-old { background: var(--tint-old); }
.plays-label {
  position: relative;
  display: block;
  padding: 0 0.45rem;
  font-size: 0.75rem;
  line-height: 1.4rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.plays-unit { color: var(--text-muted); }

/* Verdict tags; the word is always there, color is a second cue */
.tag {
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 0 0.45rem;
  border-radius: 3px;
  white-space: nowrap;
  color: var(--text);
}
.v-grabbed { background: var(--bar); }
.tag.v-grabbed { color: #ffffff; }
.v-fine    { background: var(--bar-soft); }
.v-skip    { background: var(--v-skip); }
.v-unheard { background: transparent; box-shadow: inset 0 0 0 1px var(--v-skip); }
.v-pending { background: repeating-linear-gradient(135deg, var(--bar-soft) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px var(--bar-soft); }
/* As a tag, a hatch behind the word is hard to read: outline only */
.tag.v-pending { background: none; box-shadow: inset 0 0 0 1px var(--bar-soft); color: var(--text-muted); }
.tag.v-unheard { color: var(--text-muted); }

/* ========== JOURNAL ========== */

.round-row { grid-template-columns: 2rem minmax(0, 1fr) 5.5rem; }
.round-row .tally-text { display: none; }   /* counts are in the bar's tooltip */
.round-no {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  background: var(--tint);
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tally { display: flex; flex-direction: column; gap: 0.2rem; }
.tally-bar { display: flex; gap: 2px; height: 0.45rem; }
.tally-bar > span { border-radius: 1px; flex-basis: 0; }
.tally-text { color: var(--text-muted); font-size: 0.68rem; line-height: 1.3; }
.section-head .tally { flex-direction: row; align-items: center; gap: 0.5rem; }
.section-head .tally-bar { width: 6rem; }

.round-tracks { margin-top: 1.5rem; margin-bottom: 2rem; }
.round-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.music-article { padding-top: 0; }

/* ========== MOST PLAYED: PERIOD SWITCH ========== */

/* Radio buttons drive the switch, so no JavaScript is needed */
.period-input { position: absolute; opacity: 0; pointer-events: none; }
.period-switch {
  display: inline-flex;
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.period-switch label {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}
.period-switch label + label { border-left: 1px solid var(--border); }
.period-switch label:hover { color: var(--text); }
.period-panel { display: none; }
#period-1month:checked ~ .panel-1month,
#period-12month:checked ~ .panel-12month,
#period-overall:checked ~ .panel-overall { display: block; }
#period-1month:checked ~ .period-switch label[for="period-1month"],
#period-12month:checked ~ .period-switch label[for="period-12month"],
#period-overall:checked ~ .period-switch label[for="period-overall"] { background: var(--text); color: var(--bg); }
.period-input:focus-visible ~ .period-switch { outline: 2px solid var(--link); outline-offset: 2px; }
.foot { font-size: 0.8rem; margin-top: 1.5rem; }

/* ========== CHARTS (history page) ========== */

.music-chart { margin: 1.25rem 0; }
.bars { border-top: 1px solid var(--border); }
.bar-row {
  display: grid;
  grid-template-columns: minmax(7rem, 13rem) 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.bar-label { overflow-wrap: anywhere; line-height: 1.3; }
.shift-pair { display: flex; flex-direction: column; gap: 2px; }
.music-chart figcaption { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.4rem; }

.figures { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; }
.figure { display: flex; flex-direction: column; }
.figures-unit { font-size: 0.8rem; margin-top: 0.25rem; }
.article-content .rows { padding-left: 0; }
.article-content .rows li + li { margin-top: 0; }

/* ========== SMALL SCREENS ========== */

@media (max-width: 520px) {
  .tile-text { padding: 1.5rem 0.4rem 0.35rem; }
  .tile-name { font-size: 0.68rem; }
  .tile-plays { display: none; }
  .row { grid-template-columns: 1.1rem 2rem minmax(0, 1fr) 4.5rem; gap: 0.5rem; }
  .row-song { grid-template-columns: 2rem minmax(0, 1fr) auto; }
  .round-row { grid-template-columns: 2rem minmax(0, 1fr) 3.5rem; }
  .round-row .row-sub {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .plays-unit { display: none; }
  .legend { display: none; }
  .bar-row { grid-template-columns: 6.5rem 1fr; }
}
