/* RAND Forecasting Initiative - static archive
 *
 * Themed to match the live randforecastinginitiative.org: white surface, RAND
 * purple, a heavy grotesque for headings over a slab-serif body, 4px radii, and
 * uppercase letter-spaced buttons. Light-only, because the live site was
 * light-only - there is deliberately no dark mode and no theme toggle.
 *
 * TYPOGRAPHY NOTE: the live site sets `adelle` (body) and `franklin-gothic-urw`
 * (headings), both served from Adobe Fonts. Those cannot be self-hosted under
 * their licence, and pulling the Typekit kit would give this archive an external
 * dependency that dies with the Adobe account. So we use the exact fallback
 * stacks the live site itself declares - Georgia/Times for body, a Franklin
 * Gothic / Helvetica grotesque for headings - and stay fully self-contained.
 *
 * Self-contained by design: no web fonts, no CDN, no framework. The archive has
 * to keep rendering years after the platform it documents is gone.
 *
 * Chart series colors are a separate, validated categorical palette - brand
 * purple identifies the site, series colors identify data, and the two jobs
 * never share a swatch.
 */

:root {
  color-scheme: light;

  --brand:          #663399;  /* RAND purple - links, buttons, accents */
  --brand-dark:     #4b197c;
  --brand-darker:   #3e1466;
  --brand-ink:      #ffffff;
  --accent-blue:    #4155a4;
  --wash-blue:      #eaf0fb;
  --wash-blue-soft: #f6f9fe;

  --surface-0:      #ffffff;
  --surface-1:      #ffffff;
  --surface-2:      #f4f4f4;
  --surface-3:      #ececec;
  --border:         #dfdfdf;
  --border-strong:  #cbcbcb;

  --text-primary:   #11161b;
  --text-secondary: #4a4f55;
  --text-muted:     #6f747a;

  --good:           #1b7a4b;
  --bad:            #cf0404;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  --font-head: "Franklin Gothic Medium", "Franklin Gothic", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: adelle, Georgia, "Times New Roman", Times, serif;

  --radius: 4px;
  --maxw: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  line-height: 1.12;
  margin: 0 0 .5em;
  font-weight: 700;
  color: #000;
}
h1 { font-size: 2.6rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

strong, b { font-weight: 700; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---------- header ---------- */

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

.masthead .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
}

/* The RAND lockup, set in type rather than as an image: the original logo lives
 * on the assets subdomain that is being decommissioned with the rest of the
 * infrastructure, and the archive must not depend on it. */
.wordmark {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}
.wordmark:hover { text-decoration: none; }

.wordmark-rand {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .04em;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 12px;
  border-radius: 2px;
  line-height: 1;
}

.wordmark-rfi {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: .74rem;
  line-height: 1.15;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.wordmark .tag {
  font-family: var(--font-head);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  align-self: center;
}

.nav { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }

.nav a {
  color: var(--brand);
  font-size: 1rem;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.nav a:hover { text-decoration: none; border-bottom-color: var(--border-strong); }
.nav a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--brand);
  font-weight: 700;
}

/* ---------- shutdown notice ---------- */

.notice {
  background: var(--wash-blue);
  border-bottom: 1px solid #d6e2f5;
  font-size: .94rem;
  color: var(--text-secondary);
}
.notice .wrap { padding-top: 11px; padding-bottom: 11px; }
.notice strong { color: var(--text-primary); }

/* ---------- layout ---------- */

/* Echoes the live site's pale blue gradient wash behind the hero. */
main {
  padding: 44px 0 72px;
  background:
    radial-gradient(120% 340px at 82% -40px, var(--wash-blue) 0%, rgba(234,240,251,0) 72%),
    linear-gradient(180deg, var(--wash-blue-soft) 0%, rgba(255,255,255,0) 420px);
}

.lede { max-width: 66ch; }
.lede p { color: var(--text-secondary); font-size: 1.08rem; line-height: 1.55; }

.section { margin-top: 48px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.muted { color: var(--text-muted); }
.small { font-size: .9rem; }

/* ---------- stat tiles ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .value {
  font-family: var(--font-head);
  font-size: 1.85rem;
  font-weight: 700;
  color: #000;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.stat .label {
  font-family: var(--font-head);
  font-size: .72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 24px 0 14px;
}

.controls input[type="search"],
.controls select {
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 11px;
}
.controls input[type="search"] { min-width: 240px; flex: 1 1 240px; }
.controls input:focus-visible, .controls select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.result-count { font-size: .9rem; color: var(--text-muted); margin-left: auto; }

/* ---------- tables ---------- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}

table { border-collapse: collapse; width: 100%; font-size: .95rem; }

th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-family: var(--font-head);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
  z-index: 1;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--wash-blue-soft); }

.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.rank {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  width: 1%;
  white-space: nowrap;
}
.username { font-weight: 700; }

.medal-1 .rank, .medal-2 .rank, .medal-3 .rank { color: var(--brand); font-weight: 700; }

.empty { padding: 30px; text-align: center; color: var(--text-muted); }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  font-family: var(--font-head);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge.yes { color: var(--good); border-color: currentColor; }
.badge.no  { color: var(--bad);  border-color: currentColor; }

/* ---------- question detail ---------- */

.q-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}
.q-meta span { white-space: nowrap; }

.q-body { max-width: 72ch; color: var(--text-secondary); line-height: 1.6; }
.q-body table { font-size: .9rem; margin: 1em 0; }
.q-body :is(h3, h4, h5, h6) { color: var(--text-primary); margin-top: 1.35em; }

.chart-figure { margin: 0; }
.chart-figure figcaption {
  font-size: .88rem;
  color: var(--text-muted);
  margin-top: 12px;
  max-width: 72ch;
  line-height: 1.55;
}

.chart-holder { position: relative; }

svg.trajectory { display: block; width: 100%; height: auto; overflow: visible; }
svg.trajectory .grid { stroke: var(--border); stroke-width: 1; }
svg.trajectory .axis-label {
  fill: var(--text-muted);
  font-family: var(--font-head);
  font-size: 11px;
}
svg.trajectory .series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.trajectory .series-dot { stroke: var(--surface-1); stroke-width: 2; }
svg.trajectory .series-label {
  fill: var(--text-muted);
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 500;
}
svg.trajectory .series-label-value { fill: var(--text-primary); font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: .88rem; }
.legend .item { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); }
.legend .swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }

/* Series slots. Kept as classes rather than inline styles so the palette lives
 * entirely in this file. The slot ORDER is the colorblind-safety mechanism from
 * the validated categorical palette; do not reorder it. */
.sw-1 { background: var(--series-1); }
.sw-2 { background: var(--series-2); }
.sw-3 { background: var(--series-3); }
.sw-4 { background: var(--series-4); }
.sw-5 { background: var(--series-5); }
.sw-6 { background: var(--series-6); }
.sw-7 { background: var(--series-7); }
.sw-8 { background: var(--series-8); }

svg.trajectory .s-1 { stroke: var(--series-1); }
svg.trajectory .s-2 { stroke: var(--series-2); }
svg.trajectory .s-3 { stroke: var(--series-3); }
svg.trajectory .s-4 { stroke: var(--series-4); }
svg.trajectory .s-5 { stroke: var(--series-5); }
svg.trajectory .s-6 { stroke: var(--series-6); }
svg.trajectory .s-7 { stroke: var(--series-7); }
svg.trajectory .s-8 { stroke: var(--series-8); }

svg.trajectory .d-1 { fill: var(--series-1); }
svg.trajectory .d-2 { fill: var(--series-2); }
svg.trajectory .d-3 { fill: var(--series-3); }
svg.trajectory .d-4 { fill: var(--series-4); }
svg.trajectory .d-5 { fill: var(--series-5); }
svg.trajectory .d-6 { fill: var(--series-6); }
svg.trajectory .d-7 { fill: var(--series-7); }
svg.trajectory .d-8 { fill: var(--series-8); }

/* hover layer (progressive enhancement) */
.crosshair { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }

.tooltip {
  position: absolute;
  z-index: 5;
  min-width: 150px;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: .86rem;
  box-shadow: 0 4px 14px rgba(17,22,27,.13);
  opacity: 0;
  transition: opacity .1s linear;
}
.tooltip[data-visible="true"] { opacity: 1; }
.tooltip .tt-date { font-weight: 700; margin-bottom: 5px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.tooltip .tt-row .swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tooltip .tt-row .tt-val {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* ---------- footer ---------- */

.foot {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  padding: 32px 0;
  font-size: .9rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.foot p { margin-bottom: .7em; }

/* ---------- utility ---------- */

.stack > * + * { margin-top: 14px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 700px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.3rem; }
  .result-count { margin-left: 0; }
  th, td { padding: 9px 10px; }
  .wordmark-rfi { display: none; }
  .nav { gap: 16px; }
}

@media print {
  .masthead, .nav, .controls, .notice { display: none; }
  main { background: none; }
  body { background: #fff; }
}
