/* Beiranking — dense, csrankings-flavoured table UI. Light and dark aware. */

:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --bg-sunk: #eceef2;
  --fg: #1a1d21;
  --fg-dim: #5c636e;
  --fg-faint: #8a919c;
  --line: #dcdfe5;
  --accent: #1c4f9c;
  --accent-soft: #e8eefa;
  --bar: #4a7fd4;
  --up: #1a7f4b;
  --down: #b03a2e;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --bg-alt: #1b1f25;
    --bg-sunk: #23282f;
    --fg: #e6e9ee;
    --fg-dim: #a3abb7;
    --fg-faint: #767e8a;
    --line: #2e343d;
    --accent: #7aa7ee;
    --accent-soft: #1e2836;
    --bar: #5b8ede;
    --up: #4ec98a;
    --down: #e8796b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
  padding: 28px 0 22px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.wordmark span { color: var(--accent); }

.tagline {
  margin: 0;
  max-width: 62ch;
  color: var(--fg-dim);
  font-size: 14.5px;
}

/* ---- Layout ---- */

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  padding-top: 26px;
  padding-bottom: 48px;
}

.sidebar {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding-right: 4px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 15px 16px;
  margin-bottom: 16px;
  background: var(--bg);
}

.panel h2 {
  font-family: var(--serif);
  font-size: 16px;
  margin: 0 0 10px;
  font-weight: 600;
}

.panel h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  margin: 16px 0 7px;
  font-weight: 600;
}

.panel-note {
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--fg-faint);
  line-height: 1.45;
}

/* ---- Presets ---- */

.preset-list { display: flex; flex-wrap: wrap; gap: 6px; }

.preset {
  font: inherit;
  font-size: 12.5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
  color: var(--fg-dim);
  cursor: pointer;
}
.preset:hover { border-color: var(--accent); color: var(--accent); }
.preset.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
@media (prefers-color-scheme: dark) {
  .preset.active { color: #10141a; }
}

/* ---- Sliders ---- */

.slider-row { margin-bottom: 13px; }

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.slider-label { font-size: 13px; }

.slider-val {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-reset {
  width: 100%;
  margin-top: 6px;
  font: inherit;
  font-size: 12.5px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-alt);
  color: var(--fg-dim);
  cursor: pointer;
}
.btn-reset:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Filters ---- */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 4px;
}
.check-row input { margin: 3px 0 0; accent-color: var(--accent); flex: none; }

.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
}
.check-grid .check-row { margin-bottom: 0; font-size: 12.5px; }

select, input[type="search"] {
  width: 100%;
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
}
select:focus, input[type="search"]:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

/* ---- Table ---- */

.caveat {
  margin: 0 0 14px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: var(--bg-alt);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg-dim);
}
.caveat strong { color: var(--fg); }
.caveat a { color: var(--accent); }

.table-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--fg-faint);
}
.delta-note { color: var(--accent); }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-faint);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
}
thead th:hover { color: var(--accent); }
thead th.sorted::after { content: " \25BC"; font-size: 8px; }

.col-rank { width: 54px; }
.col-score { width: 92px; text-align: right; }
.col-loc { width: 210px; }

tbody tr.row {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
tbody tr.row:hover { background: var(--bg-alt); }
tbody tr.row.open { background: var(--accent-soft); }

tbody td { padding: 7px 10px; vertical-align: baseline; }

.rank-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
}

.delta {
  font-size: 10px;
  font-family: var(--mono);
  margin-left: 3px;
}
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

.abbr { font-weight: 600; }
.full-name { color: var(--fg-dim); font-size: 12.5px; }
.tier-tag {
  display: inline-block;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--fg-faint);
  margin-left: 5px;
  vertical-align: 1px;
}

.loc { color: var(--fg-dim); font-size: 13px; }

.score {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.est-flag { color: var(--fg-faint); cursor: help; }

/* ---- Expanded detail ---- */

tr.detail > td {
  padding: 4px 10px 18px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
}
@media (max-width: 860px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.bars { display: grid; gap: 5px; }

.bar-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
}
.bar-row .bl { color: var(--fg-dim); }
/* These are spans inside a grid row; they must be block-level or the height
   and the percentage width on the fill are both ignored. */
.bar-track {
  display: block;
  height: 7px;
  background: var(--bg-sunk);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  background: var(--bar);
  border-radius: 4px;
}
.bar-val {
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}
.bar-row.muted .bar-fill { background: var(--fg-faint); opacity: .45; }

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 14px;
  font-size: 12.5px;
  align-content: start;
}
.stats dt { color: var(--fg-faint); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---- Footer ---- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-alt);
  padding: 30px 0 46px;
  font-size: 14px;
}
.site-footer h2 {
  font-family: var(--serif);
  font-size: 19px;
  margin: 20px 0 8px;
  font-weight: 600;
}
.site-footer h2:first-child { margin-top: 0; }
.site-footer p { max-width: 78ch; color: var(--fg-dim); }
.site-footer code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-sunk);
  padding: 1px 5px;
  border-radius: 4px;
}

.factor-docs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px 22px;
  margin: 14px 0 18px;
}
.factor-docs .fd-name { font-weight: 600; font-size: 13px; }
.factor-docs .fd-blurb { color: var(--fg-dim); font-size: 12.5px; }

.disclaimer {
  border-left: 3px solid var(--line);
  padding-left: 12px;
  font-size: 13px;
  color: var(--fg-faint);
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .wordmark { font-size: 32px; }
}
