/* Reset, typography and shared layout. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

/* anchors land below the sticky section index */
[id] {
  scroll-margin-top: calc(var(--nav-h) + 16px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
figure,
ol,
ul,
pre,
table {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

img,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

button {
  font: inherit;
  color: inherit;
}

sup {
  font-size: 0.68em;
  line-height: 0;
}

/* ---------- layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--section-gap);
}

/* soft yellow band: sections alternate between white and this */
.section--band {
  background: var(--band);
}

/* every section title starts with the ball, under its number in the index (01-07) */
main {
  counter-reset: section;
}

.section-title {
  /* the number: 60% of the title's size, never under 18px; a yellow pill
     like the count in the narrow-screen section bar */
  --n: max(1.125rem, 0.6em);
  position: relative;
  margin-bottom: var(--space-4);
  padding-top: calc(var(--n) * 1.4 + 0.5rem);
  counter-increment: section;
  font-family: var(--font-head);
  font-size: var(--fs-h2);
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
}

.section-title::after {
  content: counter(section, decimal-leading-zero);
  position: absolute;
  top: 0;
  left: 0;
  padding: 0.05em 0.5em;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--n);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.section-title::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.08em;
}

/* a long title kept on one line: sized so the text always fits the container */
.section-title--line {
  font-size: clamp(1.6rem, 2.9vw, 2.5rem);
}

@media (min-width: 820px) {
  .section-title--line {
    white-space: nowrap;
  }
}

.sub-title {
  margin-bottom: var(--space-2);
  font-family: var(--font-head);
  font-size: var(--fs-h3);
  font-weight: 700;
  line-height: 1.25;
}

.prose {
  max-width: var(--measure);
}

.prose p + p {
  margin-top: var(--space-3);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-7);
  align-items: center;
}

.panel {
  padding: var(--space-5);
  border-radius: var(--radius);
  background: var(--surface);
}

/* numbered ball for steps */
.ball-n {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  flex: none;
  width: 1.1em;
  height: 1.1em;
}

/* a full-colour logo (Hugging Face) is drawn a little larger than a line icon */
.icon--logo {
  width: 1.35em;
  height: auto;
}

/* ---------- figures ---------- */
.figure img {
  width: 100%;
}

.figure figcaption,
.caption {
  margin-top: var(--space-3);
  color: var(--ink-2);
  font-size: var(--fs-small);
  line-height: 1.5;
}

.figure figcaption b,
.caption b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.5em 1.15em;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color var(--dur-ui);
}

.btn:hover {
  background: var(--blue);
  text-decoration: none;
}

.btn--soft {
  background: var(--accent-soft);
  color: var(--ink);
}

.btn--soft:hover {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- model groups ---------- */
/* group marks: shape and color both carry the group */
.mark {
  display: inline-block;
  flex: none;
  width: 13px;
  height: 13px;
  background: var(--g);
}

.mark--ours {
  --g: var(--g-ours);
  border-radius: 50%;
}

.mark--closed {
  --g: var(--g-closed);
  border-radius: 3px;
}

.mark--open {
  --g: var(--g-open);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.mark--motion {
  --g: var(--g-motion);
  transform: rotate(45deg) scale(0.82);
}

/* ---------- fold: content that is there but not in the way ---------- */
.fold > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 1.15em;
  border-radius: 999px;
  background: var(--accent-soft);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  transition: background-color var(--dur-ui);
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::before {
  content: "+";
  font-family: var(--font-head);
  font-weight: 800;
}

.fold[open] > summary::before {
  content: "–";
}

.fold > summary:hover {
  background: var(--accent);
  color: var(--on-accent);
}

.fold__body {
  margin-top: var(--space-4);
}

/* ---------- sideways scrollers ----------
   overflow.js sets data-more to the edge that still hides content; that edge fades out */
[data-more] {
  --fade: 40px;
}

[data-more="end"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--fade)), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - var(--fade)), transparent);
}

[data-more="start"] {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - var(--fade)), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - var(--fade)), transparent);
}

[data-more="both"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade), #000 calc(100% - var(--fade)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--fade), #000 calc(100% - var(--fade)), transparent);
}

/* ---------- tables ---------- */
.table-wrap {
  overflow-x: auto;
}

/* the first column stays put on small screens: never fade it */
.table-wrap[data-more="both"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--fade)), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - var(--fade)), transparent);
}

.table-wrap[data-more="start"] {
  -webkit-mask-image: none;
  mask-image: none;
}

/* separate borders, so a sticky cell keeps its own rule */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.data-table th,
.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table thead th {
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
}

/* ---------- footer ---------- */
.footer {
  padding-block: var(--space-6);
  color: var(--ink-2);
  font-size: var(--fs-small);
}

@media (max-width: 1023px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }
}

@media (max-width: 767px) {
  /* wide paper figures switch to their stacked cut (see the picture sources) */
  .figure--wide img {
    max-width: 560px;
    margin-inline: auto;
  }

  /* tables scroll sideways under a fixed model column */
  .data-table thead tr:first-child > :first-child,
  .data-table tbody tr:not(.is-group) > :first-child {
    position: sticky;
    z-index: 1;
    left: 0;
    width: 10em;
    min-width: 10em;
    background: var(--page);
    box-shadow: 1px 0 0 var(--line);
    white-space: normal;
  }

  .data-table tbody tr.is-ours > td:first-child {
    background: var(--accent-soft);
  }

  .data-table .is-group span {
    position: sticky;
    left: 10px;
  }
}

@media (max-width: 599px) {
  .panel {
    padding: var(--space-4);
  }

  .btn {
    font-size: 0.9375rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .btn,
  .fold > summary {
    transition: none;
  }
}
