/* DiscoverPhysics — refined editorial styling
   Aesthetic: physics journal meets contemporary web. Serif headlines,
   monospace for data, ink-on-paper palette with a single signal accent. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,800&family=Inconsolata:wght@400;500;600&family=Source+Sans+3:wght@400;500;600&display=swap');

:root {
  /* Deep-space blue palette — phosphor-blue text on navy-black,
     CRT amber accent. */
  --ink: #a8c8ff;          /* phosphor blue text */
  --paper: #050a18;        /* deep navy-black background */
  --surface: #0a1428;      /* slightly lighter than paper, for table/card backgrounds */
  --rule: #1d2d56;         /* dim grid lines */
  --muted: #6080b8;        /* faded phosphor blue */
  --soft: #0e1c3a;         /* dim blue-black highlight */
  --accent: #ffb000;       /* CRT amber, used sparingly */
  --accent-soft: #3d2700;  /* deep amber-black */
  --teal: #5ec8e8;         /* phosphor cyan secondary */
  --good: #6dd96d;
  --ok: #ffb000;
  --bad: #e85a5a;

  --serif: 'Fraunces', 'Iowan Old Style', 'Palatino', Georgia, serif;
  --sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Inconsolata', 'SF Mono', Menlo, monospace;

  --max-w: 1180px;
  --gutter: clamp(1rem, 4vw, 3rem);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      rgba(255,255,255,0.025) 31px,
      rgba(255,255,255,0.025) 32px
    );
  font-feature-settings: "kern", "liga", "onum";
}

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

.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 2.5rem var(--gutter) 2rem;
  max-width: var(--max-w);
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  justify-content: center;
  color: var(--muted);
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.eyebrow::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.site-header h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0 0 0.5rem;
  font-variation-settings: "opsz" 144;
}

.site-header h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--muted);
  margin: 0 auto 1.75rem;
  max-width: 42rem;
}

.author-line {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 1.5rem;
}

nav.primary {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.85rem;
}

nav.primary a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color 0.15s, color 0.15s;
}

nav.primary a:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ---------------- Sections ---------------- */

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

section {
  padding: 4rem 0;
  border-bottom: 1px solid var(--rule);
}

section:last-of-type { border-bottom: none; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 0.5rem;
}

.section-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.85rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.section-num {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.section-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ---------------- Abstract ---------------- */

.pipeline-fig {
  margin: 0 0 2.75rem;
}

.pipeline-fig img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 1rem;
}

.pipeline-fig figcaption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink);
  line-height: 1.6;
  margin-top: 1.1rem;
  max-width: 52rem;
}

.pipeline-fig figcaption strong {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.45rem;
}

.abstract-prose {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.65;
}

.abstract-prose p:first-child::first-letter {
  font-family: var(--serif);
  font-size: 3.5em;
  font-weight: 600;
  float: left;
  line-height: 0.85;
  margin: 0.05em 0.08em -0.05em 0;
  color: var(--accent);
}

.key-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.key-stats .stat {
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--rule);
}

.key-stats .stat:last-child { border-right: none; }

.key-stats .num {
  font-family: var(--serif);
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  letter-spacing: -0.02em;
  display: block;
}

.key-stats .label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.4rem;
  display: block;
}

/* ---------------- Leaderboard ---------------- */

.controls {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.controls select, .controls .filter-pill {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 0.4rem 0.7rem;
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
}

.controls select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-group {
  display: inline-flex;
  border: 1px solid var(--ink);
}

.filter-group .filter-pill {
  border: none;
  border-right: 1px solid var(--ink);
  background: var(--paper);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-group .filter-pill:last-child { border-right: none; }
.filter-group .filter-pill.active { background: var(--ink); color: var(--paper); }

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

table.leaderboard {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-family: var(--sans);
}

table.leaderboard thead {
  background: var(--ink);
  color: var(--paper);
}

table.leaderboard th {
  text-align: left;
  padding: 0.85rem 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: relative;
}

table.leaderboard th[data-sortable]:hover {
  background: var(--accent);
}

table.leaderboard th[data-sortable]::after {
  content: '\2195';
  margin-left: 0.4rem;
  opacity: 0.4;
  font-size: 0.85em;
}

table.leaderboard th.sorted-desc::after { content: '\25BC'; opacity: 1; }
table.leaderboard th.sorted-asc::after { content: '\25B2'; opacity: 1; }

table.leaderboard td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

table.leaderboard tbody tr:hover {
  background: var(--soft);
}

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

.rank {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  width: 2rem;
}

.rank-1 { color: var(--accent); font-weight: 600; }

.model-cell {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.02rem;
}

.model-org {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.15rem;
  font-weight: 400;
}

.type-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.15rem 0.45rem;
  border: 1px solid currentColor;
}

.type-badge.proprietary { color: var(--ink); }
.type-badge.open-source { color: var(--teal); }

.num-cell {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.num-cell .se {
  color: var(--muted);
  font-size: 0.75em;
}

/* Pass@5 visual bar */
.pass-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.pass-bar .bar {
  width: 60px;
  height: 8px;
  background: var(--soft);
  position: relative;
  overflow: hidden;
}

.pass-bar .bar .fill {
  height: 100%;
  background: var(--ink);
  transition: width 0.4s ease;
}

.pass-bar.is-top .bar .fill { background: var(--accent); }

/* ---------------- Heatmap ---------------- */

.heatmap-wrap {
  overflow-x: auto;
  border: 1px solid var(--ink);
  background: var(--surface);
}

table.heatmap {
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 0.85rem;
  width: 100%;
}

table.heatmap thead {
  background: var(--ink);
  color: var(--paper);
}

table.heatmap thead th {
  padding: 0.7rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

table.heatmap thead th.hm-world {
  text-align: center;
  min-width: 78px;
}

table.heatmap th.hm-corner {
  min-width: 14rem;
  text-align: left;
}

table.heatmap tbody th.hm-model {
  background: var(--surface);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 1;
}

table.heatmap td.hm-cell {
  padding: 0.55rem 0.4rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
  font-variant-numeric: tabular-nums;
  background-color: rgba(255, 176, 0, var(--score, 0));
  color: var(--ink);
  cursor: help;
}

table.heatmap td.hm-cell.hm-dark {
  color: var(--paper);
}

table.heatmap td.hm-cell.hm-empty {
  background: var(--soft);
  color: var(--muted);
  cursor: default;
}

table.heatmap tbody tr:last-child th.hm-model,
table.heatmap tbody tr:last-child td { border-bottom: none; }

/* ---------------- Figures ---------------- */

.figures-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
}

.figures-grid figure {
  margin: 0;
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 1rem;
}

.figures-grid figure img {
  width: 100%;
  height: auto;
  display: block;
}

.plotly-fig {
  width: 100%;
  min-height: 540px;
}

#passk-plot {
  min-height: 620px;
}

.figures-grid figcaption {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.92rem;
  color: var(--ink);
  margin-top: 0.85rem;
  line-height: 1.5;
}

.figures-grid figcaption strong {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.3rem;
}

/* ---------------- Worlds ---------------- */

.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0;
  border: 1px solid var(--ink);
  background: var(--surface);
}

.world-card {
  padding: 1.25rem 1.25rem 1.5rem;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  position: relative;
  transition: background 0.15s;
}

.world-card:hover {
  background: var(--soft);
}

.world-card .world-num {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.1em;
}

.world-card h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0.25rem 0 0.25rem;
  letter-spacing: -0.01em;
}

.world-card .world-tag {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.world-card .world-eq {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--paper);
  padding: 0.4rem 0.6rem;
  border-left: 2px solid var(--accent);
  display: inline-block;
  margin-top: 0.5rem;
}

.world-card .world-desc {
  font-size: 0.92rem;
  color: var(--ink);
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

/* ---------------- Submit ---------------- */

.submit-block {
  background: var(--surface);
  color: var(--ink);
  padding: 2.5rem var(--gutter);
  margin: 0 calc(-1 * var(--gutter));
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.submit-block h2 {
  font-family: var(--serif);
  font-size: 2rem;
  margin: 0 0 1rem;
  color: var(--ink);
}

.submit-block p {
  max-width: 38rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
}

.submit-block code {
  font-family: var(--mono);
  background: rgba(255,255,255,0.08);
  padding: 0.1rem 0.4rem;
  border: 1px solid rgba(255,255,255,0.15);
  font-size: 0.9em;
}

.submit-block .btn {
  display: inline-block;
  margin-top: 1rem;
  background: var(--accent);
  color: var(--paper);
  padding: 0.75rem 1.5rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border: none;
  transition: background 0.15s;
}

.submit-block .btn:hover { background: #ffc933; }

.submit-block .btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  margin-left: 0.5rem;
}

.submit-block .btn-ghost:hover { background: var(--ink); color: var(--paper); }

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

footer.site-footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 3rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

footer.site-footer a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}

footer.site-footer a:hover { border-bottom-color: var(--accent); color: var(--accent); }

/* ---------------- Responsive ---------------- */

@media (max-width: 800px) {
  .key-stats { grid-template-columns: 1fr; }
  .key-stats .stat { border-right: none; border-bottom: 1px solid var(--rule); }
  .key-stats .stat:last-child { border-bottom: none; }
  .section-head { flex-wrap: wrap; }
  .section-meta { margin-left: 0; width: 100%; }
}

/* Loading state */
.loading {
  padding: 3rem 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
