@font-face {
  font-family: 'LinBiolinum';
  src: url('../fonts/LinBiolinum_R.otf') format('opentype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'LinBiolinum';
  src: url('../fonts/LinBiolinum_RB.otf') format('opentype');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'LinBiolinum';
  src: url('../fonts/LinBiolinum_RI.otf') format('opentype');
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --surface: #ffffff;
  --ink: #191919;
  --ink-2: #666666;
  --rule: rgba(0, 0, 0, 0.12);
  --tile: #f3f3f3;
  --hover: #f2f6fc;
  --link: #1a73e8;
  --link-hover: #155ab6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  font-family: 'LinBiolinum', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.5;
}
a { color: var(--link); text-decoration: none; }
a:hover, a:focus-visible { color: var(--link-hover); text-decoration: underline; }

.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 80px; }

/* ---------- top navigation ---------- */
.topnav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  font-size: 15px; margin-bottom: 18px;
}
.scene-nav { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.scene-nav a {
  display: inline-block; padding: 1px 9px; border: 1px solid var(--rule); border-radius: 6px; color: var(--ink);
}
.scene-nav a:hover { background: var(--hover); text-decoration: none; }
.scene-nav a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--rule); padding-bottom: 14px; margin-bottom: 28px; }
header h1 { font-size: 36px; line-height: 1.1; margin: 0; }
header .kicker { display: block; font-size: 15px; font-weight: 400; font-style: italic; color: var(--ink-2); margin-bottom: 2px; }
.prevnext { display: flex; gap: 16px; font-size: 15px; white-space: nowrap; }

section { margin-bottom: 44px; }
h2 { font-size: 24px; margin: 0 0 4px; }
h2 .ref { font-size: 15px; font-weight: 400; color: var(--ink-2); margin-left: 6px; }
h3 { font-size: 18px; margin: 22px 0 10px; }
.lede { margin: 0 0 18px; max-width: 80ch; color: var(--ink-2); font-size: 16px; }

/* ---------- images ---------- */
.thumb {
  display: block; width: 100%; padding: 0; border: 0; background: var(--tile); cursor: zoom-in;
  border-radius: 4px; overflow: hidden; aspect-ratio: 944 / 1080;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.thumb:hover img { transform: scale(1.02); }
.thumb:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* 5x5 illumination vs reflectance matrix with axis labels */
.matrix {
  display: grid;
  grid-template-columns: 28px 44px repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  /* size the 5x5 so the whole matrix fits in one screen height (images are 944x1080) */
  max-width: max(720px, calc((100vh - 150px) * 0.874 + 120px));
  margin: 0 auto;
}
.matrix .axis-x {
  grid-column: 3 / -1; text-align: center; font-size: 15px; color: var(--ink-2);
}
.matrix .axis-y {
  grid-column: 1; grid-row: 3 / span 5; writing-mode: vertical-rl; transform: rotate(180deg);
  text-align: center; font-size: 15px; color: var(--ink-2); justify-self: center;
}
.matrix .col-head, .matrix .row-head {
  font-size: 14px; font-variant-numeric: tabular-nums; text-align: center; color: var(--ink);
}
.matrix .row-head { text-align: right; padding-right: 2px; }
.matrix .corner { grid-column: 2; }

/* metric optimisation grids */
.gallery { display: grid; gap: 14px 10px; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); }
.gallery figure { margin: 0; }
.gallery figcaption { text-align: center; font-size: 14px; margin-top: 5px; line-height: 1.3; }
.gallery figcaption .vs { color: var(--ink-2); font-style: italic; }

@media (max-width: 760px) {
  .page { padding: 20px 14px 60px; }
  header { flex-direction: column; }
  .matrix { grid-template-columns: 18px 34px repeat(5, minmax(0, 1fr)); gap: 4px; }
  .matrix .col-head, .matrix .row-head { font-size: 12px; }
  .gallery { --cols: 2 !important; }
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(20, 20, 20, 0.94); color: #eee;
  align-items: center; justify-content: center; flex-direction: column; gap: 10px; padding: 24px 72px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; display: block; }
.lightbox .lb-caption { font-size: 16px; text-align: center; }
.lightbox .lb-count { color: #aaa; font-size: 13px; margin-left: 8px; }
.lightbox button {
  position: absolute; background: rgba(255,255,255,0.08); color: #fff; border: 0; cursor: pointer;
  font: inherit; font-size: 26px; line-height: 1; width: 48px; height: 48px; border-radius: 50%;
}
.lightbox button:hover { background: rgba(255,255,255,0.18); }
.lightbox .lb-close { top: 16px; right: 16px; font-size: 22px; }
.lightbox .lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 14px; top: 50%; transform: translateY(-50%); }

/* =================================================================
   Per-metric pages
   ================================================================= */
:root {
  --enc-0: #257de0;
  --enc-1: #ec4647;
  --enc-2: #f2a600;
  --enc-3: #00b894;
  --enc-4: #008a17;
}
.metric-select { font: inherit; font-size: 15px; padding: 2px 6px; border: 1px solid #c2c2c2; border-radius: 6px; background: #fff; color: var(--ink); }
.topnav .jump { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); }

/* summary table */
.summary { border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.summary th, .summary td { padding: 5px 14px; text-align: center; border-bottom: 1px solid #e7e7e7; white-space: nowrap; }
.summary thead th { font-weight: 400; color: var(--ink-2); border-bottom: 1px solid #c2c2c2; }
.summary tbody th { text-align: left; font-weight: 400; padding-left: 0; }
.summary tr.mean th, .summary tr.mean td { border-bottom: 1px solid #c2c2c2; }
.summary td.best { font-weight: 700; }
.summary-wrap { overflow-x: auto; }
.swatch { vertical-align: -1px; margin-right: 5px; }

/* scatter plot grid: encodings as columns, datasets as rows */
.plot-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px 10px; }
.plot-grid .enc-head {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  text-align: center; font-size: 15px; font-weight: 700; padding: 8px 0 6px; border-bottom: 1px solid var(--rule);
}
.plot-grid .ds-head { grid-column: 1 / -1; margin: 18px 0 2px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.plot-grid .ds-head h3 { margin: 0; }
.plot-grid .ds-head cite { font-style: normal; font-size: 14px; color: var(--ink-2); }
.thumb.plot { aspect-ratio: 904 / 956; background: #fff; }
.thumb.plot img { object-fit: contain; }
.thumb.plot:hover img { transform: none; }
.thumb.plot:hover { outline: 1px solid var(--rule); }

@media (max-width: 760px) {
  .plot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plot-grid .enc-head { display: none; }
}
.plot-grid .enc-label { display: none; }
@media (max-width: 760px) {
  .plot-grid .enc-label { display: block; text-align: center; font-size: 13px; }
}
