/* Discovery Engine leaderboard. Hand-written, no framework, no build step.
   Dense and scannable: rank and counts dominate, chrome recedes. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #68707c;
  --border: #e2e5ea;
  --accent: #e0552c;
  --accent-soft: #fdeee7;
  --up: #1a7f37;
  --down: #cf222e;
  --shadow: 0 1px 2px rgba(20, 24, 31, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #171a20;
    --text: #e8eaee;
    --muted: #98a1ad;
    --border: #272c35;
    --accent: #ff7a50;
    --accent-soft: #2c1f1a;
    --up: #3fb950;
    --down: #f85149;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; }

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header / footer chrome */

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .shell {
  display: flex;
  align-items: center;
  min-height: 52px;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand::before {
  content: "▲ ";
  color: var(--accent);
}

.site-footer {
  margin-top: 48px;
  padding: 20px 0 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer p { margin: 0; }

/* Page head */

.page-head { margin: 28px 0 16px; }

.page-head h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.page-head .sub {
  margin: 0 0 6px;
  color: var(--muted);
  max-width: 60ch;
}

.crumb {
  margin: 0 0 10px;
  font-size: 0.85rem;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
}

.crumb a:hover { color: var(--text); }

.crumb a::before { content: "← "; }

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.dot { margin: 0 6px; color: var(--muted); }

/* Collections index */

.collection-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.collection-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.collection-link {
  display: block;
  padding: 16px 18px;
  text-decoration: none;
}

.collection-link h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}

.collection-link .desc {
  margin: 0 0 8px;
  color: var(--muted);
}

.collection-card:hover { border-color: var(--accent); }

/* Sort tabs */

.sorts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 10px;
}

.sort {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.sort:hover { color: var(--text); }

.sort.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Filter chips */

.filter-row {
  margin: 0 0 8px;
  font-size: 0.82rem;
}

.filter-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 2px 0;
}
.filter-summary::-webkit-details-marker { display: none; }
.filter-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--muted);
  transform: rotate(-90deg);
  transition: transform 0.12s ease;
}
.filter-row[open] > .filter-summary .caret { transform: none; }
@media (prefers-reduced-motion: reduce) {
  .caret { transition: none; }
}

.filter-count {
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 1.5;
}
.filter-row[open] .filter-count { display: none; }

.filter-row .chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 0 2px 14px;
}

.filter-label {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  margin-right: 2px;
}

.chip {
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  background: var(--surface);
}

.chip:hover { color: var(--text); }

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Leaderboard cards */

.board {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.card {
  display: grid;
  grid-template-columns: 3.25rem 10.5rem minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card:hover { border-color: var(--accent); }

.rank {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.rank-num {
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.board > .card:nth-child(-n + 3) .rank-num { color: var(--accent); }

.move {
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.move-up { color: var(--up); }
.move-down { color: var(--down); }
.move-same { color: var(--muted); }

.thumb {
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}

.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: cover;
}

.thumb-empty {
  display: block;
  width: 100%;
  height: 100%;
}

.info { min-width: 0; }

.video-title {
  margin: 0 0 3px;
  font-size: 1rem;
  line-height: 1.3;
}

.video-title a { text-decoration: none; }

.video-title a:hover { color: var(--accent); }

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}

.byline {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.83rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speakers { color: var(--text); font-weight: 600; }

.counts {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.83rem;
  color: var(--muted);
}

.counts strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.counts-pending { font-style: italic; }

/* Notice, empty, error */

.notice {
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent-soft);
}

.notice p { margin: 0; color: var(--muted); }

.empty {
  margin: 32px 0;
  color: var(--muted);
  text-align: center;
}

.error-page {
  margin: 64px 0;
  text-align: center;
}

.error-code {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.error-page h1 { margin: 4px 0 8px; }

.error-page .sub { color: var(--muted); margin: 0 auto 20px; max-width: 46ch; }

.button {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

/* Mobile: cards stay a tight three-column row with a small thumbnail. */

@media (max-width: 640px) {
  .card {
    grid-template-columns: 2.1rem 6rem minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    align-items: start;
  }

  .rank-num { font-size: 1.15rem; }

  .byline { white-space: normal; }

  .counts { gap: 10px; font-size: 0.8rem; }
}

/* --- pagination --- */
.pager {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.pager-info {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.pager-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pager-nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.pager-btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}
.pager-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
@media (max-width: 480px) {
  .pager-nav { margin-left: 0; width: 100%; }
  .pager-btn { flex: 1; text-align: center; }
}
