/* pTrack — app-specific styles.
 *
 * Tokens, reset, body base, buttons, modals, toasts, user-menu chrome,
 * auth overlay, body-scroll-lock, dropdown menus, themed scrollbars all
 * come from /ui/.
 *
 * What lives here:
 *   - 720px sticky header with brand "home" button + tabs row
 *   - .view containers + .empty-state + .list-info
 *   - .episode-list / .episode rows (art, title, progress, actions)
 *   - .podcast-grid (cover tiles) + .podcast-header (detail)
 *   - .search-results
 *   - .player (persistent mini bar) + .now-playing (expanded sheet)
 */

:root {
  --player-h: 4.25rem;
}

/* ── header ──────────────────────────────────────────────────────── */
body > header {
  padding: 0.85rem 1rem 0;
  max-width: 720px;
  margin: 0 auto;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ui-bg);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
body > header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ui-accent);
}
.home-btn {
  background: transparent; border: 0; padding: 0; margin: 0;
  color: inherit; text-align: left; cursor: pointer; font: inherit;
}
.home-btn:hover h1 { filter: brightness(1.15); }
.header-actions { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.user-menu { position: relative; }
.user-dropdown-item { display: flex; align-items: center; justify-content: space-between; }

/* tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--ui-border);
  margin: 0.5rem -1rem 0;
  padding: 0 0.5rem;
}
.tab {
  flex: 1; background: none; border: 0; color: var(--ui-muted);
  font: inherit; font-size: 0.92rem; font-weight: 600;
  padding: 0.55rem 0.2rem; border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 0.3rem;
}
.tab:hover { color: var(--ui-text); }
.tab.is-active { color: var(--ui-accent); border-bottom-color: var(--ui-accent); }
.tab:focus, .tab:focus-visible { outline: none; }
.tab-count {
  display: inline-block; min-width: 1.3rem; padding: 0 0.35rem;
  background: var(--ui-border); color: var(--ui-text);
  border-radius: var(--ui-radius-pill); font-size: 0.68rem; font-weight: 700;
  line-height: 1.25rem; font-variant-numeric: tabular-nums;
}
.tab-count[data-zero="1"] { background: transparent; color: var(--ui-muted); font-weight: 600; }

/* ── main ────────────────────────────────────────────────────────── */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--player-h) + 2rem);
}
.view { display: block; }
.view[hidden] { display: none; }
body.has-player main { padding-bottom: calc(var(--player-h) + 2.5rem); }

.list-info {
  color: var(--ui-muted); text-align: center; padding: 1.5rem 1rem;
  font-style: italic; font-size: 0.9rem;
}
.empty-state {
  text-align: center; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem;
  min-height: calc(100vh - 12rem); padding: 1rem;
}
.empty-msg { color: var(--ui-text); font-size: 1.1rem; font-weight: 600; }
.empty-sub { color: var(--ui-muted); font-size: 0.9rem; max-width: 22rem; }
.back-link { margin-bottom: 0.5rem; }

/* ── episode list ────────────────────────────────────────────────── */
.episode-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.episode {
  display: flex; gap: 0.7rem; align-items: center;
  background: var(--ui-panel); border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius); padding: 0.6rem;
  position: relative;
}
.ep-art {
  width: 52px; height: 52px; border-radius: var(--ui-radius-sm);
  object-fit: cover; flex: none; background: var(--ui-panel-2);
}
.ep-body { flex: 1; min-width: 0; }
.ep-title-btn {
  display: block; width: 100%; text-align: left; background: none;
  border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit;
}
.ep-podcast {
  font-size: 0.72rem; color: var(--ui-accent); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ep-title {
  font-size: 0.95rem; font-weight: 600; color: var(--ui-text);
  line-height: 1.25; margin: 0.1rem 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ep-meta { font-size: 0.78rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; }
.ep-progress {
  margin-top: 0.4rem; height: 3px; background: var(--ui-border);
  border-radius: 2px; overflow: hidden;
}
.ep-progress span { display: block; height: 100%; background: var(--ui-accent); }
.ep-actions { display: flex; align-items: center; gap: 0.15rem; flex: none; }
.ep-play.is-playing { color: var(--ui-accent); }
.ep-queue.is-on { color: var(--ui-success); }
.episode.is-archived { opacity: 0.5; }
.episode.is-archived .ep-title { color: var(--ui-muted); }
.q-move { font-size: 0.7rem; padding: 0.15rem; }

/* ── podcasts grid ───────────────────────────────────────────────── */
.podcasts-head { margin-bottom: 1rem; display: flex; justify-content: flex-end; }
.podcast-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.9rem;
}
.pod-card {
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit;
  text-align: left; position: relative; display: flex; flex-direction: column; gap: 0.4rem;
}
.pod-cover {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: var(--ui-radius); background: var(--ui-panel-2);
  border: 1px solid var(--ui-border);
}
.pod-card:hover .pod-cover { border-color: var(--ui-accent); }
.pod-badge {
  position: absolute; top: 0.35rem; right: 0.35rem;
  background: var(--ui-accent); color: var(--ui-on-accent);
  font-size: 0.7rem; font-weight: 700; border-radius: var(--ui-radius-pill);
  padding: 0.05rem 0.45rem; min-width: 1.3rem; text-align: center;
}
.pod-name {
  font-size: 0.82rem; font-weight: 600; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── podcast detail ──────────────────────────────────────────────── */
.podcast-header { display: flex; gap: 1rem; margin-bottom: 1rem; align-items: flex-start; }
.pod-detail-cover {
  width: 120px; height: 120px; flex: none; object-fit: cover;
  border-radius: var(--ui-radius); border: 1px solid var(--ui-border); background: var(--ui-panel-2);
}
.pod-detail-meta { flex: 1; min-width: 0; }
.pod-detail-title { margin: 0; font-size: 1.25rem; }
.pod-detail-author { color: var(--ui-muted); font-size: 0.9rem; margin-top: 0.1rem; }
.pod-detail-actions { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
.pod-detail-desc {
  font-size: 0.85rem; color: var(--ui-muted); line-height: 1.45;
  max-height: 7.5rem; overflow: auto;
}
.pod-detail-desc a { color: var(--ui-accent); }
.episode-list-head { display: flex; align-items: center; justify-content: space-between; margin: 0.5rem 0; }
.episode-list-head h3 { margin: 0; font-size: 1rem; }
.archived-toggle { font-size: 0.8rem; color: var(--ui-muted); display: flex; align-items: center; gap: 0.3rem; }

/* ── search ──────────────────────────────────────────────────────── */
.search-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-form input { flex: 1; }
.search-results { display: flex; flex-direction: column; gap: 0.5rem; max-height: 60vh; overflow: auto; }
.search-result {
  display: flex; gap: 0.7rem; align-items: center;
  padding: 0.5rem; border: 1px solid var(--ui-border); border-radius: var(--ui-radius);
}
.sr-art { width: 56px; height: 56px; border-radius: var(--ui-radius-sm); object-fit: cover; flex: none; background: var(--ui-panel-2); }
.sr-meta { flex: 1; min-width: 0; }
.sr-title { font-weight: 600; font-size: 0.92rem; }
.sr-author { font-size: 0.8rem; color: var(--ui-muted); }
.sr-count { font-size: 0.75rem; color: var(--ui-muted); }

.notes-body { line-height: 1.5; font-size: 0.92rem; max-height: 65vh; overflow: auto; }
.notes-body a { color: var(--ui-accent); }
.notes-body img { max-width: 100%; height: auto; border-radius: var(--ui-radius-sm); }

/* form inputs in modals */
.prefs-form { display: flex; flex-direction: column; gap: 0.9rem; }
.prefs-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.88rem; color: var(--ui-muted); }
.prefs-form label.prefs-check { flex-direction: row; align-items: center; gap: 0.5rem; }
.prefs-form input[type="text"], .prefs-form input[type="number"], .prefs-form select {
  padding: 0.5rem; border-radius: var(--ui-radius-sm);
  border: 1px solid var(--ui-border); background: var(--ui-panel-2); color: var(--ui-text); font: inherit;
}
.modal-actions { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.5rem; }

/* ── selection / bulk actions ────────────────────────────────────── */
.list-toolbar { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; min-height: 1.3rem; }
.episode-list-head-actions { display: flex; align-items: center; gap: 1rem; }
.episode.selectable { cursor: pointer; user-select: none; }
.episode.selectable .ep-body { pointer-events: none; }
.episode.is-selected { border-color: var(--ui-accent); background: var(--ui-panel-hover); }
.ep-check {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  border: 2px solid var(--ui-border); display: flex; align-items: center;
  justify-content: center; color: var(--ui-on-accent); font-size: 0.85rem; font-weight: 700;
}
.episode.is-selected .ep-check { background: var(--ui-accent); border-color: var(--ui-accent); }
.bulk-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: var(--ui-panel); border-top: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow); display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.75rem; max-width: 720px; margin: 0 auto; flex-wrap: wrap;
}
.bulk-bar[hidden] { display: none; }
.bulk-all { display: flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; color: var(--ui-muted); }
.bulk-count { font-size: 0.85rem; font-weight: 600; }
.bulk-actions { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; position: relative; }
.bulk-actions .btn-ghost { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
body.select-mode .player { display: none; }

/* ── transport icons (inline SVG; shared by bar + now-playing) ───── */
.ic { display: block; width: 1em; height: 1em; }
.player-skip, .np-skip {
  background: none; border: 0; cursor: pointer; color: var(--ui-text); padding: 0.15rem;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.7rem;
}
.np-skip { font-size: 2.45rem; }
.ep-play { font-size: 1.05rem; }

/* ── player bar ──────────────────────────────────────────────────── */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--ui-panel); border-top: 1px solid var(--ui-border); box-shadow: var(--ui-shadow);
}
.player[hidden] { display: none; }
.player-progress { height: 3px; background: var(--ui-border); }
.player-progress span { display: block; height: 100%; width: 0; background: var(--ui-accent); }
.player-bar {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.85rem; max-width: 1100px; margin: 0 auto; min-height: var(--player-h);
}
.player-art {
  width: 44px; height: 44px; border-radius: var(--ui-radius-sm); object-fit: cover;
  flex: none; cursor: pointer; background: var(--ui-panel-2);
}
.player-meta { min-width: 0; cursor: pointer; width: 12rem; flex: none; }
.player-title { font-weight: 600; font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { font-size: 0.74rem; color: var(--ui-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-transport { display: flex; align-items: center; gap: 0.4rem; flex: none; }
.player-play {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ui-accent); color: var(--ui-on-accent); font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.player-scrub { display: flex; align-items: center; gap: 0.5rem; flex: 1; min-width: 0; }
.ptime { font-size: 0.72rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#player-seek { flex: 1; min-width: 0; accent-color: var(--ui-accent); cursor: pointer; }
.player-extra { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.player-speed-btn {
  background: var(--ui-panel-2); border: 1px solid var(--ui-border); color: var(--ui-text);
  border-radius: var(--ui-radius-pill); padding: 0.2rem 0.55rem; font-weight: 700; font-size: 0.78rem;
  cursor: pointer; font-variant-numeric: tabular-nums; min-width: 3rem;
}
.player-vol { display: flex; align-items: center; gap: 0.2rem; }
#player-vol { width: 5rem; accent-color: var(--ui-accent); cursor: pointer; }

/* compact bar on narrow screens: art + title + play, tap to expand */
@media (max-width: 760px) {
  .player-scrub, .player-extra,
  .player-transport #player-back, .player-transport #player-fwd { display: none; }
  .player-meta { width: auto; flex: 1; }
}
@media (min-width: 761px) { .player-progress { display: none; } }

/* ── now-playing (expanded sheet) ────────────────────────────────── */
.now-playing {
  position: fixed; inset: 0; z-index: 60; background: var(--ui-bg);
  display: flex; flex-direction: column; animation: np-rise 0.18s ease-out;
}
.now-playing[hidden] { display: none; }
@keyframes np-rise { from { transform: translateY(8%); opacity: 0.6; } to { transform: none; opacity: 1; } }
.np-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1rem 0; max-width: 600px; margin: 0 auto; width: 100%;
}
.np-tabs { display: flex; gap: 1.2rem; flex: 1; justify-content: center; }
.np-tab {
  background: none; border: 0; color: var(--ui-muted); font: inherit; font-weight: 700;
  font-size: 1rem; padding: 0.3rem 0; border-bottom: 2px solid transparent; cursor: pointer;
}
.np-tab.is-active { color: var(--ui-text); border-bottom-color: var(--ui-accent); }
.np-pane { flex: 1; overflow: auto; max-width: 600px; margin: 0 auto; width: 100%; padding: 1rem 1.5rem; }
.np-pane[hidden] { display: none; }
.np-pane-playing { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.np-art {
  width: min(72vw, 340px); aspect-ratio: 1; object-fit: cover;
  border-radius: var(--ui-radius-lg); box-shadow: var(--ui-shadow);
  background: var(--ui-panel-2); margin-bottom: 1.25rem;
}
.np-title { font-size: 1.25rem; font-weight: 700; text-align: center; line-height: 1.3; }
.np-podcast { color: var(--ui-accent); font-size: 0.9rem; font-weight: 600; text-align: center; margin-top: 0.3rem; }
.np-details-title { margin: 0 0 0.75rem; font-size: 1.05rem; }
.np-footer {
  max-width: 600px; margin: 0 auto; width: 100%;
  padding: 0.4rem 1.5rem calc(env(safe-area-inset-bottom) + 1.25rem);
}
.np-scrubber { width: 100%; }
#np-seek { width: 100%; accent-color: var(--ui-accent); cursor: pointer; }
.np-times { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ui-muted); font-variant-numeric: tabular-nums; margin-top: 0.2rem; }
.np-controls { display: flex; align-items: center; justify-content: center; gap: 1.3rem; margin: 1.1rem 0 0.6rem; }
.np-play-btn {
  width: 68px; height: 68px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ui-accent); color: var(--ui-on-accent); font-size: 1.95rem;
  display: flex; align-items: center; justify-content: center;
}
.np-speed-btn {
  background: var(--ui-panel-2); border: 1px solid var(--ui-border); color: var(--ui-text);
  border-radius: var(--ui-radius-pill); padding: 0.3rem 0.7rem; font-weight: 700; font-size: 0.85rem; cursor: pointer;
  font-variant-numeric: tabular-nums; min-width: 3.2rem;
}
.np-actions { display: flex; gap: 0.5rem; justify-content: center; }

/* ── responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body > header { padding: 0.7rem 0.75rem 0; }
  main { padding: 0.75rem 0.75rem calc(var(--player-h) + 2rem); }
  body > header h1 { font-size: 1.15rem; }
  .tab { font-size: 0.82rem; }
  .pod-detail-cover { width: 88px; height: 88px; }
}
