/* Reusable pieces: cards, rating badges, covers, lists, tracklist, chips,
   buttons, detail pages. Ported from the Notes site's glossy cards (tables,
   code blocks), tag chips and buttons. */

/* ═════════════ 1. Glossy card ═════════════ */
/* One shared look: light surface, hairline border, top sheen, soft shadow. */
.stat,
.album-card,
.tracklist,
.home-aside .song-list,
#search-results {
  border: 1px solid var(--ui-border);
  border-radius: var(--radius);
  background: var(--ui-sheen), var(--ui-surface);
  background-size: 100% 48px, auto;
  background-repeat: no-repeat;
  box-shadow: var(--ui-shadow-sm), var(--ui-highlight);
}

/* ═════════════ 2. Stats ═════════════ */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 140px;
  padding: 1rem 1.3rem;
}

.stat-value {
  font-family: var(--headerFont);
  color: var(--ui-heading);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--ui-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

/* ═════════════ 3. Covers ═════════════ */
.cover {
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--ui-surface-2);
  flex-shrink: 0;
}

/* Hairline edge on artwork (an inset shadow would be hidden under an <img>) */
img.cover {
  outline: 1px solid var(--ui-border);
  outline-offset: -1px;
}

.cover-xs { width: 38px; border-radius: 6px; }
.cover-sm { width: 44px; border-radius: 7px; }
.cover-md { width: 100%; }

/* Images: rounded with a soft lift */
.cover-lg {
  width: min(280px, 70vw);
  border-radius: var(--radius-lg);
  box-shadow: var(--ui-shadow);
}

.cover-placeholder {
  display: grid;
  place-items: center;
  /* Powder-slate to raven; --hue (0–359, from the album name) varies the shade */
  background: linear-gradient(
    135deg,
    hsl(187 calc(12% + var(--hue) * 0.04%) calc(30% + var(--hue) * 0.06%)),
    hsl(220 8% calc(9% + var(--hue) * 0.02%))
  );
  color: rgba(176, 224, 230, 0.92);
  font-family: var(--headerFont);
  font-weight: 700;
  font-size: 2.5rem;
}

.cover-xs.cover-placeholder,
.cover-sm.cover-placeholder { font-size: 1rem; }
.cover-lg.cover-placeholder { font-size: 5rem; }

/* ═════════════ 4. Rating badges ═════════════ */
/* Glossy capsules. The tiers keep their own colours, so a score still reads
   at a glance; the gloss, highlight and shadow follow the theme. */
.rating-badge {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  font-family: var(--headerFont);
  font-weight: 700;
  border-radius: 999px;
  background-image: var(--badge-gloss);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  box-shadow: var(--ui-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.rating-sm { min-width: 42px; padding: 0.15em 0.55em; font-size: 0.8rem; }
.rating-md { min-width: 48px; padding: 0.25em 0.6em; font-size: 0.95rem; }
.rating-lg {
  min-width: 116px;
  padding: 0.25em 0.55em;
  font-size: 3rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--ui-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.tier-great { background-color: var(--tier-great); color: var(--on-tier); }
.tier-good  { background-color: var(--tier-good);  color: var(--on-tier); }
.tier-okay  { background-color: var(--tier-okay);  color: var(--on-tier); }
.tier-bad   { background-color: var(--tier-bad);   color: var(--on-tier); }
/* Unrated: an outline, so it never reads as a low score */
.tier-none {
  background-color: transparent;
  background-image: none;
  color: var(--ui-muted);
  box-shadow: inset 0 0 0 1px var(--ui-border-strong);
}

/* ═════════════ 5. Progress (tracks rated): the poppy load bar ═════════════ */
.progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.progress-bar {
  flex: 1;
  max-width: 200px;
  height: 4px;
  background: var(--ui-active);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--ui-accent);
  box-shadow: 0 0 10px var(--ui-accent-soft);
  border-radius: 999px;
}

.progress-label {
  color: var(--ui-muted);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ═════════════ 6. Album card ═════════════ */
.album-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.5rem 0.5rem 0.75rem;
  color: var(--ui-text);
  font-weight: 400;
  transition:
    transform var(--dur) var(--spring),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    background-color var(--dur-slow) var(--ease),
    color var(--dur-slow) var(--ease);
}

@media (hover: hover) {
  .album-card:hover {
    transform: translateY(-2px);
    border-color: var(--ui-border-strong);
    box-shadow: var(--ui-shadow), var(--ui-highlight);
  }
}

.album-card:active {
  transform: scale(0.98);
  transition-duration: var(--dur-fast);
}

.album-card .rating-badge {
  position: absolute;
  top: 0.95rem;
  right: 0.95rem;
  box-shadow: 0 4px 12px rgba(22, 23, 26, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Unrated badge over artwork: raven tinted glass */
.album-card .tier-none {
  background-color: rgba(22, 23, 26, 0.6);
  color: var(--brand-powder);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 0 0 1px rgba(176, 224, 230, 0.2);
}

.album-card-body {
  min-width: 0;
  padding: 0 0.3rem;
  line-height: 1.3;
}

.album-title,
.song-title {
  margin: 0;
  font-family: var(--bodyFont);
  color: var(--ui-heading);
  font-size: 0.93rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-artist,
.song-artist {
  margin: 0;
  color: var(--ui-muted);
  font-size: 0.86rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ═════════════ 7. Song lists: table-style rows in a glossy card ═════════════ */
.home-aside .song-list,
#search-results {
  overflow: hidden;
}

#search-results:empty { display: none; }

.song-list > .muted {
  margin: 0;
  padding: 0.9rem 1rem;
}

/* Section label inside a list (e.g. suggestions on the Add page): a header row */
.list-label {
  margin: 0;
  padding: 0.5rem 0.95rem;
  background-color: var(--ui-surface-2);
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-heading);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0.95rem;
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-weight: 400;
  transition: background-color var(--dur-fast) var(--ease);
}

.song-row:last-child { border-bottom: none; }
.song-row:hover { background-color: var(--ui-hover); }
.song-row:active { background-color: var(--ui-active); }

.song-rank {
  width: 1.5rem;
  text-align: right;
  color: var(--ui-faint);
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.song-row-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.song-row-body .song-artist { font-size: 0.82rem; }

/* Add page: catalog results are buttons dressed as rows */
.search-result {
  width: 100%;
  margin: 0;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ui-border);
  border-radius: 0;
  cursor: pointer;
}

/* "+ Rate": a soft poppy chip */
.add-hint {
  flex-shrink: 0;
  padding: 0.08rem 0.65rem;
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background-color: var(--ui-accent-soft);
  color: var(--ui-heading);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.song-row:hover .add-hint {
  background-color: var(--ui-accent);
  color: var(--ui-on-accent);
}

/* ═════════════ 8. Search sheet results ═════════════ */
.result-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ui-border);
  color: var(--ui-text);
  font-weight: 400;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  outline: none;
  transition: background-color var(--dur-fast) var(--ease);
}

.result-card:last-child { border-bottom: none; }

.result-card:hover,
.result-card:focus-visible,
.result-card.focus {
  background: var(--ui-hover);
}

.result-card.no-match {
  cursor: default;
  background: none;
}

.result-body {
  flex: 1;
  min-width: 0;
}

.result-card h3 {
  margin: 0;
  color: var(--ui-heading);
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card p {
  margin: 0.3rem 0 0;
  color: var(--ui-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card .highlight {
  background: var(--ui-accent-soft);
  color: var(--ui-heading);
  border-radius: 3px;
}

/* "Find … in the catalog": a round + where the artwork would be */
.result-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ui-sheen), var(--ui-pill-bg);
  color: var(--ui-pill-text);
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1;
  box-shadow: var(--ui-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* ═════════════ 9. Tracklist: the rating table ═════════════ */
.tracklist {
  margin-top: 2rem;
  overflow: hidden;
  font-size: 0.94rem;
}

.tracklist-head,
.track-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto 3.5rem;
  gap: 1rem;
  align-items: center;
  padding: 0.55rem 0.95rem;
  border-bottom: 1px solid var(--ui-border);
  line-height: 1.5;
}

.tracklist-head {
  background-color: var(--ui-surface-2);
  color: var(--ui-heading);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tracklist-head span:first-child,
.track-number { text-align: right; }

.tracklist-head span:last-child { text-align: center; }

.track-row {
  color: var(--ui-text);
  font-weight: 400;
  transition: background-color var(--dur-fast) var(--ease);
}

.track-row:last-child { border-bottom: none; }
.track-row:hover { background-color: var(--ui-hover); }
.track-row:active { background-color: var(--ui-active); }

.track-number,
.track-duration {
  color: var(--ui-faint);
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
}

.track-title {
  min-width: 0;
  color: var(--ui-heading);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-row.unrated .track-title { color: var(--ui-muted); font-weight: 400; }
.track-row.unrated:hover .track-title { color: var(--ui-heading); }

/* ═════════════ 10. Filters ═════════════ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.75rem;
}

.filters input { flex: 1 1 260px; min-width: 0; }
.filters select { flex: 0 1 auto; }

.empty-state {
  grid-column: 1 / -1;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ui-muted);
}

/* ═════════════ 11. Album & song detail pages ═════════════ */

/* Back link: small and quiet, like the Notes breadcrumbs, with an iOS-style
   chevron (on phones it grows into an iOS back button, section 15). */
.back-link {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 1rem;
  color: var(--ui-muted);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.back-link::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.95em;
  margin-right: 0.4em;
  vertical-align: -0.1em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 18'%3E%3Cpath d='M8.5 1.5 1.5 9l7 7.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 18'%3E%3Cpath d='M8.5 1.5 1.5 9l7 7.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.back-link:hover { color: var(--ui-heading); }

.detail-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  padding-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-family: var(--headerFont);
  color: var(--ui-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-hero h1 { margin-bottom: 0.2rem; }

.detail-hero-artist {
  margin: 0;
  color: var(--ui-text);
  font-family: var(--headerFont);
  font-size: clamp(1.25rem, 2.5vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.detail-hero-sub { color: var(--ui-muted); margin: 0.25rem 0 0.9rem; }

.detail-hero-info .tags { margin-top: 0.7rem; }
.detail-hero-info .tags:empty { display: none; }

.detail-hero-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.score-label { color: var(--ui-muted); font-size: 0.8rem; font-weight: 500; }

/* Chips: song tags and genres (the Notes tag chips) */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-block;
  padding: 0.08rem 0.65rem;
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background-color: var(--ui-accent-soft);
  color: var(--ui-heading);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

/* Song tags read as tags; genre chips don't need the # */
.tag-hash::before { content: "#"; }

/* Genre chips link to the filtered Albums page */
a.tag {
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease),
    transform var(--dur) var(--spring);
}

a.tag:hover {
  background-color: var(--ui-accent);
  color: var(--ui-on-accent);
  transform: translateY(-1px);
}

.review {
  max-width: 720px;
  padding-top: 1.5rem;
  font-size: 1.02rem;
}

.review p { line-height: 1.7; }

.review-date {
  margin-top: 2rem;
  color: var(--ui-muted);
  font-size: 0.85rem;
}

.track-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid;
  border-image: linear-gradient(90deg, transparent, var(--ui-border-strong), transparent) 1;
}

/* About page scale */
.scale {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.scale li {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.scale .rating-badge { min-width: 64px; }

/* ═════════════ 12. Buttons ═════════════ */
/* The round-button look from the Notes toolbar, as a pill. Primary buttons
   wear the glossy "current page" pill: raven in light mode, poppy in dark. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.25rem;
  padding: 0.45em 1.15em;
  font: inherit;
  font-weight: 550;
  font-size: 0.9rem;
  color: var(--ui-heading);
  text-decoration: none;
  border: 1px solid var(--ui-border);
  border-radius: 999px;
  background: var(--ui-sheen), var(--ui-surface);
  box-shadow: var(--ui-shadow-sm), var(--ui-highlight);
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--dur) var(--spring),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    background-color var(--dur-slow) var(--ease),
    color var(--dur-slow) var(--ease);
}

.button:hover {
  border-color: var(--ui-border-strong);
  box-shadow: var(--ui-shadow), var(--ui-highlight);
}

.button:active {
  transform: scale(0.97);
  transition-duration: var(--dur-fast);
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.button-primary {
  color: var(--ui-pill-text);
  border-color: transparent;
  background: var(--ui-sheen), var(--ui-pill-bg);
  background-size: 100% 100%, auto;
  box-shadow:
    var(--ui-shadow-sm),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.button-primary:hover {
  border-color: transparent;
  box-shadow:
    var(--ui-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.button-danger { color: var(--ui-heading); }

.button-danger:hover {
  border-color: var(--ui-accent);
  background: var(--ui-sheen), var(--ui-accent-soft);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.empty-state .button { margin-top: 0.5rem; }

/* "Load more" under the Albums grid */
.load-more {
  display: flex;
  width: fit-content;
  margin: 2rem auto 0;
}

.load-more[hidden] { display: none; }

.detail-hero-score .button { margin-top: 0.5rem; }

.danger-zone {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid;
  border-image: linear-gradient(90deg, transparent, var(--ui-border-strong), transparent) 1;
}

/* ═════════════ 13. Rating form ═════════════ */
.rate-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 720px;
  padding-top: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-label {
  padding-left: 0.4rem;
  color: var(--ui-heading);
  font-size: 0.85rem;
  font-weight: 600;
}

.field-label .muted { font-weight: 400; }

.score-input {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* The score slider is the one control that wears the poppy accent */
.score-input input[type="range"] {
  flex: 1;
  margin: 0;
  accent-color: var(--ui-accent);
  cursor: pointer;
}

.score-input input[type="number"] {
  width: 5.5em;
  padding-inline: 0.8em;
  text-align: center;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ═════════════ 14. Narrow content column ═════════════ */
/* Container queries: the column is narrower than the window by the sidebar. */
@container main (max-width: 640px) {
  .detail-hero {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .detail-hero-score {
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .rating-lg { font-size: 2.2rem; min-width: 90px; }

  .tracklist-head,
  .track-row { gap: 0.6rem; padding-inline: 0.6rem; }
}

/* The three stats share one row */
@container main (max-width: 540px) {
  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .stat { min-width: 0; padding: 0.8rem 0.9rem; }
  .stat-value { font-size: 1.4rem; }

  .album-card { padding: 0.4rem 0.4rem 0.65rem; }
  .album-card .rating-badge { top: 0.8rem; right: 0.8rem; }
  .album-card-body { padding: 0 0.2rem; }
}

@container main (max-width: 440px) {
  .score-input { flex-wrap: wrap; }
  .score-input input[type="range"] { flex-basis: 100%; }
}

/* Where list separators start on phones (iOS insets them to the text) */
.song-row { --sep-inset: 4.5rem; }
.home-aside .song-row { --sep-inset: 6.8rem; }
.track-row { --sep-inset: 3.95rem; }

@container main (max-width: 640px) {
  .track-row { --sep-inset: 3.2rem; }
}

/* ═════════════ 15. Phones: iOS details ═════════════ */
@media (max-width: 800px) {
  /* Title, then subtitle and actions below it, like an iOS large title */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  /* iOS back button: chevron + previous page, 17pt, level with the theme
     button on the right (which it keeps clear of). */
  .back-link {
    max-width: calc(100% - 3.25rem);
    margin-bottom: 0.5rem;
    color: var(--ui-link);
    font-size: 1.0625rem;
    line-height: 2.5rem;
  }

  .back-link:active { opacity: 0.45; }

  /* Inset separators: rows divide at the text, not the artwork */
  .song-row,
  .track-row,
  .results-container .result-card {
    position: relative;
    border-bottom: none;
  }

  .song-row::after,
  .track-row::after,
  .results-container .result-card::after {
    content: "";
    position: absolute;
    left: var(--sep-inset);
    right: 0;
    bottom: 0;
    border-bottom: 1px solid var(--ui-border);
    pointer-events: none;
  }

  .results-container .result-card { --sep-inset: 4.125rem; }

  .song-row:last-child::after,
  .track-row:last-child::after,
  .results-container .result-card:last-child::after { content: none; }
}

/* Shown when browser storage is blocked */
.storage-warning {
  padding: 0.9rem 2.5rem;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-accent-soft);
  color: var(--ui-heading);
  text-align: center;
}
