/* Level colours: an ordinal orange ramp for exposure (darkest = strongest), blue for
   "not seen", neutral for "unknown". Every cell also carries a text label, so colour is
   never the only channel. Ramp validated with the dataviz ordinal check. The site is light-only. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --line: #e1e0d9;
  --link: #1c5cab;

  --lvl-test_seen: #8f2810;           --on-test_seen: #ffffff;
  --lvl-seen_split_unclear: #c2461a;  --on-seen_split_unclear: #ffffff;
  --lvl-train_seen: #df6f38;          --on-train_seen: #0b0b0b;
  --lvl-related: #ea9a62;             --on-related: #0b0b0b;
  --lvl-not_seen: #2a78d6;            --on-not_seen: #ffffff;
  --lvl-unknown: #ecebe6;             --on-unknown: #52514e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1 { font-size: 1.9rem; line-height: 1.2; margin: 1.5rem 0 0.75rem; }
h2 { font-size: 1.25rem; margin: 2.25rem 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lede { font-size: 1.125rem; color: var(--ink-2); max-width: 46rem; }
.crumb { margin: 1.5rem 0 0; font-size: 0.875rem; color: var(--muted); }
.links a { margin-right: 1rem; }

/* Header and footer */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-header .wrap { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; padding-block: 0.75rem; }
.brand { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand img { display: block; width: 36px; height: 36px; margin: -4px 0 -4px -6px; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.site-header nav a { color: var(--ink-2); text-decoration: none; }
.site-header nav a:hover { color: var(--ink); text-decoration: underline; }
.site-footer { margin-top: 4rem; border-top: 1px solid var(--line); padding-block: 1.25rem; font-size: 0.8125rem; color: var(--muted); }

/* Home */
.intro { max-width: 46rem; }
.intro h1 { font-size: 2.2rem; margin-top: 2.5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-top: 2rem; }
.card { display: block; padding: 1.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--muted); }
.card h2 { margin: 0 0 0.25rem; }

/* Levels: badges, swatches, legend, distribution bars */
.badge, .swatch {
  display: inline-block; border-radius: 4px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
}
.badge { padding: 0.05rem 0.45rem; }
.swatch { min-width: 2.6rem; padding: 0.05rem 0.3rem; text-align: center; margin-right: 0.4rem; }
.legend { list-style: none; padding: 0; margin: 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.875rem; }
.legend li { display: flex; align-items: center; }
.legend .count { margin-left: 0.35rem; }
.levels dt { margin-top: 0.75rem; font-weight: 600; }
.levels dd { margin: 0.15rem 0 0; color: var(--ink-2); }
.dist { display: flex; gap: 2px; height: 10px; margin: 0.6rem 0 0.25rem; border-radius: 4px; overflow: hidden; }
.dist span { min-width: 3px; }

.lvl-test_seen { background: var(--lvl-test_seen); color: var(--on-test_seen); }
.lvl-seen_split_unclear { background: var(--lvl-seen_split_unclear); color: var(--on-seen_split_unclear); }
.lvl-train_seen { background: var(--lvl-train_seen); color: var(--on-train_seen); }
.lvl-related { background: var(--lvl-related); color: var(--on-related); }
.lvl-not_seen { background: var(--lvl-not_seen); color: var(--on-not_seen); }
.lvl-unknown { background: var(--lvl-unknown); color: var(--on-unknown); }

/* Disclosure pills */
.disc { font-size: 0.8125rem; font-weight: 600; padding: 0.05rem 0.45rem; border-radius: 4px; border: 1px solid var(--line); white-space: nowrap; }
h2 .disc { font-size: 0.9rem; vertical-align: middle; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
table.data th, table.data td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
table.data tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Heatmap: datasets as rows, models as columns; 2px surface gap between cells */
table.heatmap { width: auto; border-collapse: separate; border-spacing: 2px; padding: 0.5rem; }
table.heatmap th { font-weight: 500; font-size: 0.875rem; }
table.heatmap tbody th { text-align: left; padding-right: 0.75rem; white-space: nowrap; position: sticky; left: 0; background: var(--surface); }
table.heatmap th.corner { text-align: left; vertical-align: bottom; color: var(--muted); font-size: 0.8125rem; position: sticky; left: 0; background: var(--surface); }
table.heatmap th.model { vertical-align: bottom; height: 9rem; padding: 0 0 0.4rem; }
table.heatmap th.model a { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; text-decoration: none; }
table.heatmap td.cell { padding: 0; border-radius: 4px; min-width: 3rem; }
table.heatmap td.cell a { display: block; padding: 0.35rem 0.25rem; text-align: center; font-size: 0.75rem; font-weight: 600; color: inherit; text-decoration: none; }
table.heatmap td.cell a:hover, table.heatmap td.cell a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 4px; }

/* Lists and facts */
ul.rows { list-style: none; padding: 0; margin: 0; }
ul.rows > li { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
ul.rows > li:last-child { border-bottom: 0; }
.inline-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 1rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.sources { padding-left: 1.1rem; }
.sources li { margin: 0.3rem 0; overflow-wrap: anywhere; }

/* Evidence */
details { margin: 0.35rem 0; }
summary { cursor: pointer; color: var(--ink-2); font-size: 0.875rem; }
.evidence { margin: 0.6rem 0 0.9rem; padding: 0.6rem 0.9rem; background: var(--surface); border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; }
.evidence blockquote { margin: 0 0 0.35rem; font-style: italic; }
.evidence figcaption { font-size: 0.8125rem; overflow-wrap: anywhere; }
.cell-detail { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.cell-detail p { margin: 0.25rem 0; }
.cell-detail:target { background: var(--surface); outline: 2px solid var(--link); outline-offset: 4px; border-radius: 4px; }

@media (max-width: 600px) {
  h1, .intro h1 { font-size: 1.6rem; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.5rem; }
}
.notes { white-space: pre-line; }

/* Domain switch (always visible in the header) */
.site-header .wrap { justify-content: flex-start; }
.domains { display: inline-flex; padding: 3px; gap: 2px; background: var(--page); border: 1px solid var(--line); border-radius: 8px; }
.domains a { padding: 0.3rem 0.85rem; border-radius: 6px; color: var(--ink-2); text-decoration: none; font-size: 0.9375rem; }
.domains a:hover { color: var(--ink); background: var(--surface); }
.domains a.active { background: var(--ink); color: var(--surface); font-weight: 600; }
.nav-link { margin-left: auto; color: var(--ink-2); text-decoration: none; }
.nav-link:hover { color: var(--ink); text-decoration: underline; }

/* Contamination map: one small square per model x benchmark dataset */
table.map { width: auto; border-collapse: separate; border-spacing: 2px; padding: 0.5rem 0.75rem 0.75rem; }
table.map th { font-weight: 500; font-size: 0.8125rem; white-space: nowrap; }
table.map th.corner { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; vertical-align: bottom; }
table.map th.group { text-align: left; padding: 0 0 0.25rem 6px; border-bottom: 1px solid var(--line); font-weight: 600; }
table.map th.group { vertical-align: bottom; }
table.map th.group a { display: block; min-width: 3rem; white-space: normal; line-height: 1.25; color: var(--ink); text-decoration: none; }
table.map th.group a:hover { text-decoration: underline; }
table.map th.col { vertical-align: bottom; height: 10.5rem; padding: 0 0 0.35rem; }
table.map th.col a { writing-mode: vertical-rl; transform: rotate(180deg); display: inline-block; color: var(--ink-2); text-decoration: none; font-size: 0.75rem; line-height: 16px; }
table.map th.col.hl a { color: var(--ink); font-weight: 700; }
table.map tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding-right: 0.75rem; }
table.map tbody th a { color: var(--ink-2); text-decoration: none; }
table.map tbody th a:hover { text-decoration: underline; }
table.map tr.hl th a { color: var(--ink); font-weight: 700; }
table.map td.sq { width: 16px; min-width: 16px; max-width: 16px; height: 16px; padding: 0; border-radius: 3px; }
table.map td.sq a { display: block; width: 16px; height: 16px; border-radius: 3px; }
table.map td.sq a:hover, table.map td.sq a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
table.map .gs { border-left: 8px solid var(--surface); background-clip: padding-box; }
table.map tr.fs > * { border-top: 6px solid var(--surface); background-clip: padding-box; }

.tip { position: fixed; z-index: 10; max-width: 22rem; padding: 0.55rem 0.7rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 16px rgba(11, 11, 11, 0.12); font-size: 0.8125rem; line-height: 1.4; pointer-events: none; }
.tip-head { display: flex; align-items: center; gap: 0.4rem; font-weight: 700; }
.tip-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.tip-pair { margin-top: 0.15rem; }
.tip-reason { margin-top: 0.3rem; color: var(--ink-2); }

/* Footer: "A project by ML Challenges" */
.by { display: inline-flex; align-items: center; gap: 0.75rem; color: var(--ink-2); text-decoration: none; font-size: 1rem; }
.by-logo { display: inline-flex; padding: 0.55rem 0.9rem; background: #ffffff; border: 1px solid var(--line); border-radius: 8px; transition: border-color 0.15s; }
.by:hover .by-logo { border-color: var(--muted); }
.by-logo img { display: block; height: 24px; width: auto; }
.site-footer .build { margin: 1rem 0 0; }
.third-party { display: inline-block; padding: 0 0.4rem; border-radius: 4px; background: #f3e8d6; color: #6b3d0a; font-size: 0.75rem; font-weight: 600; }
.facts dd details { margin-top: 0.15rem; }
table.map td.sq.na { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
table.map tbody th a { display: inline-block; max-width: 17rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
