:root {
  --paper-ink: #1e302d;
  --paper-muted: #4d5c58;
  --paper-rule: #d7dfdb;
  --paper-accent: #0b665b;
  --paper-serif: "Source Serif 4", Georgia, serif;
  --paper-sans: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  color: var(--paper-ink);
}

.site-shell {
  max-width: 1180px;
  padding: clamp(36px, 5vw, 64px) clamp(24px, 8vw, 128px) 64px;
  margin-inline: auto;
}

.paper-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  grid-template-areas: "paper contents";
  gap: clamp(28px, 5vw, 68px);
  align-items: start;
}

.paper { grid-area: paper; }

.paper-layout, .progression { font-family: var(--paper-sans); }

.paper h1, .progression h2, .viewer .top h2 {
  font-family: var(--paper-serif);
  font-weight: 400;
  line-height: 1.24;
  margin: 0;
}

.paper h1 {
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 700;
}

.abstract {
  font-size: 17px;
  line-height: 1.5;
}

.abstract p { margin: 0 0 9px; }

.abstract ul {
  margin: 0 0 9px;
  padding-left: 20px;
  display: grid;
  gap: 7px;
}

.abstract li::marker { color: var(--paper-muted); }

.contents {
  grid-area: contents;
  position: sticky;
  top: 26px;
  padding: 3px 0 3px 18px;
  border-left: 1px solid var(--paper-rule);
}

.contents h2 {
  font: 400 16px/1.24 var(--paper-serif);
  margin: 0 0 10px;
}

.contents ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.contents a {
  color: var(--paper-muted);
  font-size: 16px;
  text-decoration-color: var(--paper-rule);
  text-underline-offset: 3px;
}

.contents a:hover { color: var(--paper-accent); }

.site-main section[id] { scroll-margin-top: 24px; }

.progression { margin-top: 20px; }

.progression h2, .viewer .top h2 {
  font-size: 17px;
}

/* How many animations sit in a row, and so how big each one is.  The sources
   are 500 px square, and the shell's measure is ~1136 px, so three columns put
   a panel at ~365 px -- large enough to read the structure, still under its
   own resolution.  Six datasets divide evenly by 6, 3 and 2, so those are the
   counts that leave no ragged last row. */
.animation-grid {
  --animation-columns: 3;
  /* Each GIF carries a 6% white margin around its drawn frame, which is what
     actually separates the panels.  Letting the image spill --shot-bleed past
     its cell pulls the frames to 3.8%-96.2% of the cell, so the visible gap
     drops from 12% of a panel to 7.6%.  Only the white margins overlap --
     nothing is drawn outside 6%-94% of a GIF -- so the spill never shows.
     Raising the bleed tightens the gap further; 6% would close it entirely. */
  --shot-bleed: 2.5%;
  --frame-inset: 3.8%;
  display: grid;
  grid-template-columns: repeat(var(--animation-columns), minmax(0, 1fr));
  column-gap: 0;
  row-gap: 16px;
}

.animation {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.animation img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  object-fit: contain;
  padding: 0;
  width: calc(100% + 2 * var(--shot-bleed));
  margin-inline: calc(-1 * var(--shot-bleed));
}

.animation figcaption {
  display: flex;
  align-items: center;
  align-content: flex-start;
  justify-content: space-between;
  flex: 1;
  flex-wrap: wrap;
  gap: 3px 8px;
  /* Aligned to the drawn frame, which the bleed above puts at --frame-inset:
     the label starts under its left edge, the button ends under its right. */
  padding: 5px var(--frame-inset);
  font-size: 13px;
}

.dataset-details {
  flex-basis: 100%;
  color: var(--paper-muted);
}

.animation button {
  color: var(--paper-accent);
  background: transparent;
  border: 0;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.viewer {
  margin-top: 16px;
}

.viewer .top {
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 9px;
  padding: 5px 9px;
}

.viewer .top .field {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}

.viewer .field select { max-width: 100%; min-width: 0; }
.viewer .track { min-width: min(240px, 100%); }

@media (max-width: 800px) {
  .animation-grid { --animation-columns: 2; }

  .paper-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "contents" "paper";
    gap: 25px;
  }

  .contents {
    position: static;
    border-left: 0;
    border-bottom: 1px solid var(--paper-rule);
    padding: 0 0 13px;
  }

  .contents ul {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
  }

  .viewer .top .spacer { display: none; }
  .viewer .top > :first-child { flex-basis: 100%; }
}

@media (max-width: 480px) {
  .animation-grid { --animation-columns: 1; }
  .viewer .field { min-width: 0; }
}
