/**
 * Tracklist block.
 *
 * Front end restyles the semantic <table> as a credits grid, then collapses it
 * into stacked rows on narrow screens. The editor half styles the row builder.
 * Falls back to sane values when the theme's tokens aren't present (editor
 * iframe, other themes).
 */

.sg-tl {
  --tl-line: var(--sg-line, rgba(255, 255, 255, 0.14));
  --tl-faint: var(--sg-faint, rgba(255, 255, 255, 0.42));
  --tl-muted: var(--sg-muted, rgba(255, 255, 255, 0.66));
  --tl-accent: var(--sg-signature, #ff3b12);

  margin-block: 2rem;
}

.sg-tl__table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

/* Column labels */
.sg-tl__table thead th {
  padding: 0 0.75rem 0.85rem;
  border-bottom: 1px solid var(--tl-line);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--tl-faint);
  text-align: left;
  white-space: nowrap;
}

.sg-tl__table tbody td,
.sg-tl__table tbody th {
  padding: 0.95rem 0.75rem;
  border-bottom: 1px solid var(--tl-line);
  text-align: left;
  font-weight: 400;
  vertical-align: baseline;
}

.sg-tl__table tbody tr:hover td,
.sg-tl__table tbody tr:hover th {
  background: rgba(255, 255, 255, 0.035);
}

/* Number */
.sg-tl__num {
  width: 3.25rem;
  color: var(--tl-faint);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

/* Title carries the most weight in the row. */
.sg-tl__title {
  font-weight: 700 !important;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  min-width: 12ch;
}

.sg-tl__name {
  margin-right: 0.5rem;
}

/* Linked titles lead to the song's own page. */
a.sg-tl__name {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

a.sg-tl__name:hover,
a.sg-tl__name:focus-visible {
  border-bottom-color: currentColor;
  opacity: 1;
}

/* "Acoustic", "Live at…", etc. */
.sg-tl__version {
  display: inline-block;
  margin-right: 0.4rem;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--tl-faint);
  white-space: nowrap;
}

.sg-tl__version::before { content: "("; }
.sg-tl__version::after { content: ")"; }

/* Explicit marker */
.sg-tl__e {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 3px;
  background: var(--tl-faint);
  color: #05060a;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  border: 0;
  vertical-align: 0.08em;
}

/* Credit columns read quieter than titles. */
.sg-tl__features,
.sg-tl__writers,
.sg-tl__producers {
  color: var(--tl-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.sg-tl__len {
  width: 6rem;
  color: var(--tl-muted);
  font-size: 0.9rem;
  text-align: right !important;
  white-space: nowrap;
}

.sg-tl__table thead .sg-tl__len {
  text-align: right !important;
}

/* Total */
.sg-tl__table tfoot td {
  padding: 1.1rem 0.75rem 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--tl-faint);
}

.sg-tl__total-time {
  color: inherit;
  text-align: right;
}

.sg-tl__note {
  margin-left: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  opacity: 0.75;
}

/* Stacked rows once the columns stop fitting. */
@media (max-width: 760px) {
  .sg-tl__table,
  .sg-tl__table tbody,
  .sg-tl__table tfoot,
  .sg-tl__table tr {
    display: block;
    width: 100%;
  }

  .sg-tl__table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
  }

  .sg-tl__table tbody tr {
    position: relative;
    padding: 1rem 0 1rem 3rem;
    border-bottom: 1px solid var(--tl-line);
  }

  .sg-tl__table tbody td,
  .sg-tl__table tbody th {
    display: block;
    padding: 0;
    border: 0;
  }

  .sg-tl__table tbody .sg-tl__num {
    position: absolute;
    left: 0;
    top: 1rem;
    width: auto;
  }

  .sg-tl__table tbody .sg-tl__len {
    text-align: left !important;
    width: auto;
  }

  /* Label each credit inline, since the header row is hidden. */
  .sg-tl__table tbody td[data-label]:not(:empty)::before {
    content: attr(data-label) " — ";
    color: var(--tl-faint);
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  .sg-tl__table tbody td:empty {
    display: none;
  }

  .sg-tl__table tfoot tr {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-top: 1rem;
  }

  .sg-tl__table tfoot td {
    padding: 0;
  }
}

/* ------------------------------------------------------------- editor -- */

.sg-tl-editor {
  border: 1px solid rgba(127, 127, 127, 0.35);
  border-radius: 8px;
  padding: 1rem;
}

.sg-tl-editor__title {
  margin: 0 0 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.6;
}

.sg-tl-editor__empty {
  margin: 0 0 1rem;
  opacity: 0.6;
}

.sg-tl-editor__row {
  border: 1px solid rgba(127, 127, 127, 0.3);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.sg-tl-editor__bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.sg-tl-editor__num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}

.sg-tl-editor__actions {
  margin-left: auto;
  display: flex;
  gap: 0.15rem;
}

/* Title gets more room than the credit fields. */
.sg-tl-editor__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.sg-tl-editor__field.is-title {
  grid-column: span 2;
}

.sg-tl-editor__field.is-length {
  max-width: 8rem;
}

.sg-tl-editor__footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

.sg-tl-editor__total {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.65;
}

@media (max-width: 600px) {
  .sg-tl-editor__field.is-title {
    grid-column: auto;
  }
}

/* Inheritance hint above the override fields. */
.sg-tl-editor__hint {
  margin: 0.75rem 0 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  opacity: 0.65;
}

.sg-tl-editor__song {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.sg-tl-editor__song > *:first-child { flex: 1; }

.sg-tl-editor__field.is-version { max-width: 22rem; }
