/* ============================================================
   Archive Trust — track-table.css
   Single source of truth for all track table styles.

   Used by:
     audio.html  — stacks table (.playlist-table-wrap)
     audio.html  — curated playlist table (.curated-track-table-wrap)

   Class prefix: tt-  (track-table)
   The .playlist-table-wrap and .curated-track-table-wrap wrappers
   remain section-specific in playlist.css / curated.css; everything
   inside the <table> element is styled here.
   ============================================================ */

/* ── Base table ───────────────────────────────────────────── */
.tt-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* ── Column widths ────────────────────────────────────────── */
.tt-col-play     { width: 52px; }
/* 100%, not auto: in Chromium's fixed layout an auto col only receives
   part of the leftover space at some table widths, leaving a blank
   strip of header/row background at the right edge of the table. */
.tt-col-title    { width: 100%; }
.tt-col-speaker  { width: 280px; }
.tt-col-venue    { width: 380px; }
.tt-col-year     { width: 80px; }
.tt-col-duration { width: 90px; }
.tt-col-cite     { width: 40px; }
.tt-col-bookmark { width: 40px; }

/* ── Header row ───────────────────────────────────────────── */
.tt-table thead tr {
  background: var(--paper-mid);
  border-bottom: 2px solid var(--rule-dark);
}

/* Paint cells too — tr-only backgrounds can drop out on zoomed/
   subpixel rendering, leaving the trailing header cells white. */
.tt-table thead th { background: var(--paper-mid); }

.tt-table th {
  font-family: var(--ff-mono);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-align: left;
  padding: 12px 14px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  position: relative;
}

.tt-table th:hover      { color: var(--ink); }
.tt-table th.sort-asc,
.tt-table th.sort-desc  { color: var(--gold); }

.tt-table th.sort-asc::after  { content: ' ↑'; }
.tt-table th.sort-desc::after { content: ' ↓'; }

/* Year + duration headers: right-aligned to match their cells */
.tt-table th.tt-col-year,
.tt-table th[data-sort="year"],
.tt-table th[data-sort="duration"] { text-align: right; padding-right: 14px; }

/* Non-sortable headers */
.tt-table th.no-sort           { cursor: default; }
.tt-table th.no-sort:hover     { color: var(--ink-muted); }

/* Bookmark header: no visual chrome, centred */
.tt-table th.tt-col-bookmark   { padding: 0; text-align: center; }

/* ── Body rows ────────────────────────────────────────────── */
.tt-table tbody tr {
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.12s;
}

.tt-table tbody tr:last-child { border-bottom: none; }

/* Hover + playing backgrounds are painted on the cells, not the row:
   tr-level backgrounds can stop rendering partway across the row in
   Chromium under fractional zoom / Windows display scaling. */
.tt-table tbody tr:hover td { background: var(--paper-warm); }

/* Currently-playing row */
.tt-table tbody tr.tt-playing td {
  background: rgba(139, 105, 20, 0.07);
}

.tt-table tbody tr.tt-playing td.tt-col-title { color: var(--gold); }

/* Unavailable row (no src URL) */
.tt-table tbody tr.tt-unavailable {
  cursor: default;
  opacity: 0.45;
}

.tt-table tbody tr.tt-unavailable:hover td {
  background: transparent;
}

.tt-table tbody tr.tt-unavailable .tt-play-btn {
  cursor: default;
  opacity: 0.4;
}

.tt-table tbody tr.tt-unavailable .tt-play-btn:hover {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--rule-dark);
}

.tt-table tbody tr.tt-unavailable .at-bookmark-btn {
  display: none;
}

/* ── Resume-progress indicator ────────────────────────────── */
/* (stacks table only, but harmless on curated) */
.tt-row.tt-has-resume {
  position: relative;
}

.tt-row.tt-has-resume::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: var(--resume-pct, 0%);
  background: var(--gold);
  opacity: 0.4;
  pointer-events: none;
}

.tt-row.tt-has-resume:hover::after { opacity: 0.7; }

/* ── Cells ────────────────────────────────────────────────── */
.tt-table td {
  padding: 13px 14px;
  font-size: 0.88rem;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* Play button cell */
.tt-table td.tt-col-play {
  padding: 0 0 0 14px;
}

/* Title */
.tt-table td.tt-col-title {
  color: var(--ink);
  font-family: var(--ff-serif);
  font-size: 0.95rem;
  line-height: 1.3;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

/* Speaker */
.tt-table td.tt-col-speaker {
  font-style: italic;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

/* Venue */
.tt-table td.tt-col-venue {
  font-size: 0.8rem;
  color: var(--ink-muted);
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

/* Year */
.tt-table td.tt-col-year {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-align: right;
  padding-right: 14px;
  overflow: visible;
  white-space: nowrap;
}

.tt-unavailable td.tt-col-year { color: var(--ink-muted); }

/* Duration */
.tt-table td.tt-col-duration {
  font-family: var(--ff-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-align: right;
  padding-right: 14px;
  overflow: visible;
  white-space: nowrap;
}

/* Cite cell */
.tt-table td.tt-col-cite {
  padding: 0;
  text-align: center;
  overflow: visible;
}

/* Bookmark cell */
.tt-table td.tt-col-bookmark {
  padding: 0 4px 0 0;
  text-align: center;
  vertical-align: middle;
  overflow: visible;
}

/* ── Play button ──────────────────────────────────────────── */
.tt-play-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--rule-dark);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.tt-play-btn svg { width: 9px; height: 10px; flex-shrink: 0; }

tr:not(.tt-unavailable):hover .tt-play-btn,
.tt-play-btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

tr.tt-playing .tt-play-btn {
  background: var(--gold);
  color: var(--paper);
  border-color: var(--gold);
}

/* ── Bookmark button ──────────────────────────────────────── */
.at-bookmark-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--rule-dark);
  border-radius: 2px;
  transition: color 0.15s, opacity 0.15s;
  opacity: 0;
  padding: 0;
  transform: none;
}

.at-bookmark-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
}

/* Show on row hover or when bookmarked */
tr:hover .at-bookmark-btn,
.at-bookmark-btn.bookmarked {
  opacity: 1;
}

/* Touch devices: always visible (hover not available) */
@media (hover: none) {
  .at-bookmark-btn {
    opacity: 1;
  }
}

.at-bookmark-btn:hover         { color: var(--gold); }
.at-bookmark-btn.bookmarked    { color: var(--gold); }
.at-bookmark-btn.bookmarked svg { fill: var(--gold); }

/* ── Availability dot ─────────────────────────────────────── */
.tt-avail-dot {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  margin-right: 7px;
  vertical-align: middle;
  flex-shrink: 0;
}

.tt-unavailable .tt-avail-dot { display: none; }

/* ── Unknown label ────────────────────────────────────────── */
.tt-unknown {
  color: var(--ink-muted);
  font-style: italic;
}

/* ── Responsive: narrow desktop ────────────────────────────── */
@media (max-width: 1100px) {
  .tt-col-venue   { width: 260px; }
  .tt-col-speaker { width: 220px; }
}

@media (max-width: 960px) {
  .tt-col-venue { width: 200px; }
}

/* ── Responsive: tablet ────────────────────────────────────── */
@media (max-width: 760px) {
  .tt-col-venue   { display: none; }
  .tt-col-speaker { width: 180px; }
}

/* ── Responsive: small tablet ─────────────────────────────── */
@media (max-width: 520px) {
  .tt-col-speaker  { display: none; }
  .tt-col-duration { display: none; }
  .tt-col-year     { width: 50px; }
}

/* ── Responsive: mobile card layout (≤ 480px) ─────────────── */
/*
 * Below 480px both the stacks table and the curated table switch
 * to a card-per-row layout. Because they share this CSS, the two
 * sections are guaranteed to be identical at mobile widths.
 */
@media (max-width: 480px) {
  /* Each table element becomes block so flex can take over */
  .tt-table,
  .tt-table thead,
  .tt-table tbody,
  .tt-table th,
  .tt-table td,
  .tt-table tr {
    display: block;
    width: 100%;
  }

  /* Column header row — implicit from layout */
  .tt-table thead { display: none; }

  /* Each row: horizontal flex card, vertically centred */
  .tt-table tbody tr {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
  }

  .tt-table tbody tr:last-child { border-bottom: none; }

  /* Play button: fixed width, centred */
  .tt-table td.tt-col-play {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    flex-shrink: 0;
    width: 36px;
  }

  /* Title takes all remaining space */
  .tt-table td.tt-col-title {
    flex: 1;
    white-space: normal;
    overflow: visible;
    padding: 0 10px 0 0;
    font-size: 0.92rem;
    line-height: 1.35;
  }

  /* Year: fixed width, right-aligned, centred vertically */
  .tt-table td.tt-col-year {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0;
    flex-shrink: 0;
    width: 40px;
    font-size: 0.65rem;
    text-align: right;
  }

  /* Cite: fixed width, centred */
  .tt-table td.tt-col-cite {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    width: 32px;
  }

  /* Bookmark: visible on mobile, fixed width, centred */
  .tt-table td.tt-col-bookmark {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    width: 32px;
  }

  /* Bookmark button always visible on touch */
  .tt-table td.tt-col-bookmark .at-bookmark-btn {
    opacity: 1;
  }

  /* Speaker, venue and duration: hidden on mobile card */
  .tt-table td.tt-col-speaker,
  .tt-table td.tt-col-venue,
  .tt-table td.tt-col-duration {
    display: none;
  }
}
