/* Section: GitHub Ranking
   Per-repo quality table + provenance footer. Owned by
   shared/dashboard/sections/github_ranking/. */

.section--github-ranking {
  margin-top: 2rem;
}

.section--github-ranking .section-title {
  margin-bottom: 0.5rem;
}

.section--github-ranking .section-desc {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.55;
}

.section--github-ranking .ghr-org-suffix {
  color: var(--color-text-muted);
  font-size: 0.85em;
  font-weight: 500;
  margin-left: 0.4rem;
}

.ghr-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  color: var(--color-text-muted);
}

.ghr-summary .ghr-kpi strong {
  color: var(--protocol-accent, var(--color-text));
  font-variant-numeric: tabular-nums;
}

.ghr-table-wrap {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.25rem 0;
  overflow-x: auto;          /* mobile: scroll horizontally before truncating */
  margin-bottom: 1rem;
}

.ghr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  /* table-layout: fixed makes the column widths declared below
     authoritative — without it the browser auto-sizes and the score
     column drifts away from the SCORE header. */
  table-layout: fixed;
}

/* Column widths (percentages, table-layout: fixed).
   Iter-3: 10 columns, distributed for visual balance — REPO + STACK
   flex with mid-weight; numeric columns (score, quality, age, push,
   commits, contribs, stars) are equal-narrow so the eye scans each
   metric without "jumping" across a wide column.
   Selectors include .ghr-table to clear the base thead/tbody
   specificity (0,1,2). */
.ghr-table .ghr-th-rank,    .ghr-table td.ghr-rank    { width:  5%; }
.ghr-table .ghr-th-repo,    .ghr-table td.ghr-repo    { width: 18%; }
.ghr-table .ghr-th-score,   .ghr-table td.ghr-score   { width:  9%; }
.ghr-table .ghr-th-quality, .ghr-table td.ghr-quality { width: 10%; }
.ghr-table .ghr-th-age,     .ghr-table td.ghr-age     { width:  8%; }
.ghr-table .ghr-th-push,    .ghr-table td.ghr-push    { width: 10%; }
.ghr-table .ghr-th-commits, .ghr-table td.ghr-commits { width: 12%; }
.ghr-table .ghr-th-ctrb,    .ghr-table td.ghr-ctrb    { width:  9%; }
.ghr-table .ghr-th-stars,   .ghr-table td.ghr-stars   { width:  6%; }
.ghr-table .ghr-th-lang,    .ghr-table td.ghr-lang    { width: 13%; }

/* Per-column text alignment — every numeric column is center-aligned
   (header + cell) so values line up vertically and the score column
   doesn't drift from its header. */
.ghr-table .ghr-th-rank,    .ghr-table td.ghr-rank,
.ghr-table .ghr-th-score,   .ghr-table td.ghr-score,
.ghr-table .ghr-th-quality, .ghr-table td.ghr-quality,
.ghr-table .ghr-th-age,     .ghr-table td.ghr-age,
.ghr-table .ghr-th-push,    .ghr-table td.ghr-push,
.ghr-table .ghr-th-commits, .ghr-table td.ghr-commits,
.ghr-table .ghr-th-ctrb,    .ghr-table td.ghr-ctrb,
.ghr-table .ghr-th-stars,   .ghr-table td.ghr-stars {
  text-align: center;
}

.ghr-table .ghr-th-repo, .ghr-table td.ghr-repo,
.ghr-table .ghr-th-lang, .ghr-table td.ghr-lang {
  text-align: left;
}

.ghr-table thead th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.ghr-table tbody td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  white-space: nowrap;
}

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

.ghr-table tbody tr.ghr-load-bearing td {
  background: rgba(212, 175, 55, 0.06);   /* gold tint on the leader row */
}

.ghr-load-bearing-mark {
  color: var(--protocol-accent, #d4af37);
  font-size: 0.85em;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.ghr-table tbody td.ghr-repo a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.ghr-table tbody td.ghr-repo a:hover {
  color: var(--protocol-accent, var(--color-text));
  text-decoration: underline;
}

/* Score pill — wider min-width + centered numeric so 3-digit scores
   don't shift the column. */
.ghr-score-pill {
  display: inline-block;
  min-width: 2.6em;
  text-align: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
  background: rgba(212, 175, 55, 0.10);
  color: var(--protocol-accent, #d4af37);
  border: 1px solid rgba(212, 175, 55, 0.30);
  line-height: 1.4;
}

.ghr-score-pill.ghr-score-low {
  background: rgba(239, 68, 68, 0.08);
  color: var(--color-negative, #ef4444);
  border-color: rgba(239, 68, 68, 0.25);
}

.ghr-score-pill.ghr-score-mid {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

/* Quality sub-score pill — tighter, less prominent than the composite
   pill so the operator's eye still treats Score as primary. */
.ghr-quality-pill {
  display: inline-block;
  min-width: 3em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.82em;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  line-height: 1.4;
}

.ghr-loading-cell {
  text-align: center;
  color: var(--color-text-muted);
  padding: 1.5rem !important;
  font-style: italic;
}

/* Provenance footer — the "where we check it" answer */
.ghr-provenance {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

.ghr-source-label {
  font-weight: 600;
  color: var(--color-text);
}

.ghr-source-link {
  color: var(--protocol-accent, var(--color-text));
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.ghr-source-link:hover { text-decoration: underline; }

.ghr-provenance code {
  font-family: var(--font-mono, monospace);
  font-size: 0.78rem;
  background: var(--color-bg-card);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.ghr-captured {
  display: inline-block;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  /* Hide the lowest-signal columns first on tablet — CONTRIBS is
     near-useless for solo-dev microcaps (always 1); STACK + LANG can
     be inferred from the repo name + readme. */
  .ghr-table .ghr-th-ctrb, .ghr-table td.ghr-ctrb { display: none; }
}

@media (max-width: 768px) {
  .ghr-table thead th,
  .ghr-table tbody td {
    padding: 0.55rem 0.35rem;
    font-size: 0.8rem;
  }
  /* On mobile keep the highest-signal columns visible:
     # · REPO · SCORE · QUALITY · AGE · LAST PUSH · COMMITS · ★
     Drop CONTRIBS + STACK to free horizontal space. */
  .ghr-table .ghr-th-lang, .ghr-table td.ghr-lang { display: none; }
  /* Re-weight the remaining columns so REPO + SCORE + QUALITY + AGE
     get reasonable share. Numeric columns stay equal-narrow. */
  .ghr-table .ghr-th-rank,    .ghr-table td.ghr-rank    { width:  8%; }
  .ghr-table .ghr-th-repo,    .ghr-table td.ghr-repo    { width: 26%; }
  .ghr-table .ghr-th-score,   .ghr-table td.ghr-score   { width: 13%; }
  .ghr-table .ghr-th-quality, .ghr-table td.ghr-quality { width: 14%; }
  .ghr-table .ghr-th-age,     .ghr-table td.ghr-age     { width: 11%; }
  .ghr-table .ghr-th-push,    .ghr-table td.ghr-push    { width: 12%; }
  .ghr-table .ghr-th-commits, .ghr-table td.ghr-commits { width: 12%; }
  .ghr-table .ghr-th-stars,   .ghr-table td.ghr-stars   { width:  9%; }
  .ghr-captured { margin-left: 0; flex-basis: 100%; }
}

@media (max-width: 480px) {
  /* Smallest screens: drop COMMITS/30D and ★ too — keep the four
     thesis-anchoring columns: REPO + SCORE + QUALITY + AGE. */
  .ghr-table .ghr-th-commits, .ghr-table td.ghr-commits,
  .ghr-table .ghr-th-stars,   .ghr-table td.ghr-stars { display: none; }
  .ghr-table .ghr-th-rank,    .ghr-table td.ghr-rank    { width: 10%; }
  .ghr-table .ghr-th-repo,    .ghr-table td.ghr-repo    { width: 34%; }
  .ghr-table .ghr-th-score,   .ghr-table td.ghr-score   { width: 16%; }
  .ghr-table .ghr-th-quality, .ghr-table td.ghr-quality { width: 18%; }
  .ghr-table .ghr-th-age,     .ghr-table td.ghr-age     { width: 11%; }
  .ghr-table .ghr-th-push,    .ghr-table td.ghr-push    { width: 11%; }
}
