/* =========================================================================
   PubArx — reputation, rankings and "helpful" votes.
   Loaded on every page after pubarx.css and panel.css. Colours come from the
   design tokens only, so everything follows the dark theme automatically.
   ========================================================================= */

/* ------------------------------------------------------------------ reviewer level badge */

.reviewer-badge { height: 20px; padding: 0 8px; gap: 4px; font-size: 0.72rem; vertical-align: 1px; }
.reviewer-badge svg { width: 11px; height: 11px; }
.name .reviewer-badge { margin-left: 6px; }
.badge.badge-lg { height: 30px; padding: 0 14px; font-size: 0.86rem; gap: 6px; }
.badge.badge-lg svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ "helpful" control on reviews */

.review .review-foot { flex-wrap: wrap; row-gap: 8px; }
.helpful-form { display: inline-flex; margin: 0; }
.helpful {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 0.82rem; font-weight: 600; line-height: 1; white-space: nowrap;
}
.helpful svg { width: 14px; height: 14px; }
.helpful-count { font-variant-numeric: tabular-nums; font-weight: 500; }
button.helpful { cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
button.helpful:hover { border-color: var(--brand); color: var(--brand); }
button.helpful[aria-pressed="true"] { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); color: var(--brand); }
button.helpful[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--brand) 22%, transparent); }
.helpful.is-static { border-color: transparent; background: transparent; padding: 0; color: var(--text-3); font-weight: 500; }
.helpful-note { flex: 1 1 100%; order: -1; font-size: 0.82rem; font-weight: 500; color: var(--success); }
.helpful-note.is-error { color: var(--danger); }

/* ------------------------------------------------------------------ rankings page */

.rankings-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 32px; flex-wrap: wrap; }
.rankings-intro { flex: 1 1 520px; min-width: 0; }
.rankings-updated { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 0.84rem; color: var(--text-3); }
.rankings-updated time { color: var(--text-2); font-weight: 500; }

.board-tabs { margin-bottom: 16px; }
.board-tabs svg { width: 16px; height: 16px; }
.board-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented a { padding: 6px 14px; border-radius: 999px; color: var(--text-2); font-size: 0.87rem; font-weight: 500; white-space: nowrap; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.field-filter { display: flex; align-items: center; gap: 8px; }
.field-filter .select { width: auto; min-width: 210px; height: 40px; padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 560px) {
  .field-filter { width: 100%; }
  .field-filter .select { flex: 1; min-width: 0; }
}
.board-blurb { margin: 0 0 26px; max-width: 80ch; }

/* Podium: 2nd · 1st · 3rd on wide screens, a simple list on phones */
.podium { list-style: none; margin: 18px 0 22px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }
.podium-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0;
  padding: 26px 16px 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.podium-pos-1 {
  grid-column: 2; grid-row: 1; padding-top: 34px; padding-bottom: 24px; box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, var(--surface)), var(--surface) 65%);
}
.podium-pos-2 { grid-column: 1; grid-row: 1; }
.podium-pos-3 { grid-column: 3; grid-row: 1; }
.podium-card .rank { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); box-shadow: var(--shadow-sm); border: 2px solid var(--surface); }
.podium-pos-1 .avatar { width: 84px; height: 84px; font-size: 1.6rem; }
.podium-who { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.podium-who .name { font-family: var(--font-serif); font-size: 1.08rem; font-weight: 600; line-height: 1.3; color: var(--text); overflow-wrap: anywhere; }
.podium-who .aff { font-size: 0.82rem; color: var(--text-3); overflow-wrap: anywhere; }
.podium-metrics { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; font-size: 0.8rem; color: var(--text-2); }
.podium-score { display: flex; flex-direction: column; align-items: center; margin-top: 2px; }
.podium-score .score { font-size: 1.6rem; line-height: 1.1; }
.podium-pos-1 .podium-score .score { font-size: 2rem; color: var(--accent); }
.podium-score .unit { font-size: 0.7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.podium-card.is-me { outline: 2px solid var(--brand); outline-offset: 2px; }
.podium-who .you-badge { margin-left: 0; }
@media (max-width: 720px) {
  .podium { grid-template-columns: 1fr; gap: 10px; margin-top: 4px; }
  .podium-pos-1, .podium-pos-2, .podium-pos-3 { grid-column: auto; grid-row: auto; }
  .podium-card, .podium-pos-1 { flex-direction: row; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; }
  .podium-card .rank { position: static; transform: none; border: 0; flex-shrink: 0; }
  .podium-card .avatar, .podium-pos-1 .avatar { width: 48px; height: 48px; font-size: 1rem; }
  .podium-who { align-items: flex-start; flex: 1; }
  .podium-metrics { justify-content: flex-start; }
  .podium-score { margin: 0 0 0 auto; }
  .podium-score .score, .podium-pos-1 .podium-score .score { font-size: 1.35rem; }
}

/* Leaderboard table */
.rank-table td { vertical-align: middle; }
.rank-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-table .col-rank { width: 72px; }
.rank-table .score { font-size: 1.1rem; }
.rank-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rank-who { min-width: 0; }
.rank-who .name { font-weight: 600; color: var(--text); }
.rank-who .aff { font-size: 0.82rem; color: var(--text-3); margin-bottom: 2px; }
.rank-who .reviewer-badge { margin-top: 2px; }
.you-badge { height: 20px; padding: 0 8px; font-size: 0.72rem; margin-left: 6px; vertical-align: 1px; }
.rank-table tr.is-me td { background: color-mix(in srgb, var(--brand-soft) 75%, transparent); }
.mobile-metrics { display: none; flex-wrap: wrap; gap: 2px 10px; margin-top: 4px; font-size: 0.8rem; color: var(--text-2); }
@media (max-width: 640px) {
  .rank-table .col-metric { display: none; }
  .mobile-metrics { display: flex; }
  .rank-table th, .rank-table td { padding: 10px; }
  .rank-table .col-rank { width: 52px; }
  .rank-person .avatar { width: 30px; height: 30px; font-size: 0.72rem; }
}

/* Sidebar */
.rankings-aside .card + .card { margin-top: 16px; }
.review-cta { background: linear-gradient(160deg, var(--brand-soft), var(--surface) 60%); border-color: color-mix(in srgb, var(--brand) 22%, var(--border)); }
.cta-title { display: flex; align-items: center; gap: 8px; font-size: 1.12rem; margin-bottom: 8px; }
.cta-title svg { width: 20px; height: 20px; color: var(--brand); }
.mini-papers { list-style: none; margin: 0 0 16px; padding: 0; }
.mini-papers li { padding: 9px 0; border-bottom: 1px dashed var(--border); }
.mini-papers li:last-child { border-bottom: 0; }
.mini-papers a { display: block; font-family: var(--font-serif); font-weight: 600; line-height: 1.35; color: var(--text); overflow-wrap: anywhere; }
.mini-papers a:hover { color: var(--link); text-decoration: none; }
.mini-papers span { display: block; margin-top: 2px; font-size: 0.8rem; color: var(--text-3); }
.formula-title { font-family: var(--font-sans); font-size: 0.92rem; font-weight: 650; margin: 0 0 6px; }
.formula { list-style: none; margin: 0 0 16px; padding: 0; }
.formula li { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; font-size: 0.88rem; color: var(--text-2); }
.pts {
  flex-shrink: 0; min-width: 42px; padding: 2px 6px; border-radius: 6px; text-align: center;
  background: var(--success-soft); color: var(--success); font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.pts.is-negative { background: var(--danger-soft); color: var(--danger); }
.level-list { list-style: none; margin: 0; padding: 0; }
.level-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; color: var(--text-3); }
.level-list li:last-child { border-bottom: 0; }
.standing { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.standing > div { padding: 10px 6px; border-radius: var(--radius-sm); background: var(--surface-2); text-align: center; min-width: 0; }
.standing dt { font-size: 0.7rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.standing dd { margin: 2px 0 0; font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; line-height: 1.2; }
.standing small { display: block; font-size: 0.74rem; color: var(--text-3); }

/* ------------------------------------------------------------------ researcher profile */

.reputation { margin-bottom: 36px; }
.reputation .section-head { flex-wrap: wrap; margin-bottom: 14px; }
.reputation .stat-grid { margin-bottom: 14px; }
.reputation-empty { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.level-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px 32px; }
.level-now .panel-title { margin-bottom: 8px; }
.level-metrics { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 32px; margin: 0; }
.level-metrics dt { font-size: 0.78rem; color: var(--text-3); }
.level-metrics dd { margin: 0; font-family: var(--font-serif); font-size: 1.3rem; font-weight: 600; }
@media (max-width: 640px) { .level-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px 20px; } }
.level-meter { height: 8px; }
.profile-reviews { margin-top: 40px; }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.review-list li:first-child { padding-top: 4px; }
.review-list li:last-child { border-bottom: 0; }
.review-list-main { flex: 1 1 320px; min-width: 0; }
.review-list-title { display: block; font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; line-height: 1.35; color: var(--text); margin-bottom: 2px; overflow-wrap: anywhere; }
.review-list-title:hover { color: var(--link); text-decoration: none; }

/* ------------------------------------------------------------------ researchers directory */

.list-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; margin: -4px 0 18px; }
.sort-control { display: flex; align-items: center; gap: 8px; }
.sort-control label { font-size: 0.88rem; color: var(--text-2); white-space: nowrap; }
.sort-control .select { width: auto; min-width: 170px; height: 34px; padding-top: 4px; padding-bottom: 4px; font-size: 0.9rem; }
.researcher-card .rep { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 8px; font-size: 0.82rem; color: var(--text-3); }
.rep-score { display: inline-flex; align-items: center; gap: 5px; }
.rep-score svg { color: var(--accent); }
.rep-score strong { font-family: var(--font-serif); font-size: 1rem; font-weight: 600; color: var(--text); }

/* ------------------------------------------------------------------ home page */

.credit-band { padding-top: 40px; }
.credit-callout {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 24px 44px;
  padding: clamp(22px, 4vw, 36px); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--border));
  background:
    radial-gradient(520px 220px at 100% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    linear-gradient(135deg, var(--brand-soft), var(--surface) 72%);
}
@media (max-width: 860px) { .credit-callout { grid-template-columns: 1fr; } }
.credit-callout h2 { margin-bottom: 10px; }
.credit-callout-text > p { color: var(--text-2); max-width: 60ch; }
.credit-status {
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 9px 14px;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 0.9rem; color: var(--text);
}
.credit-status svg { width: 18px; height: 18px; color: var(--success); }
.credit-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.credit-steps li {
  display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 2px 14px;
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.credit-steps .step-icon { grid-row: span 2; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); }
.credit-steps .step-icon svg { width: 20px; height: 20px; }
.credit-steps li:nth-child(2) .step-icon { background: var(--success-soft); color: var(--success); }
.credit-steps li:nth-child(3) .step-icon { background: var(--accent-soft); color: var(--accent); }
.credit-steps strong { font-size: 0.97rem; }
.credit-steps li > span:last-child { font-size: 0.86rem; color: var(--text-2); }

.leader-list { list-style: none; margin: 0; padding: 0; }
.leader-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.leader-list li:first-child { padding-top: 0; }
.leader-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.leader-list .rank { min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px; font-size: 0.8rem; }
.leader-who { flex: 1; min-width: 0; }
.leader-who > a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 0.92rem; color: var(--text); }
.leader-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.78rem; color: var(--text-3); }
.leader-list .score { font-size: 1rem; }
