/* Shared by every page of the site. */

:root {
  --text: #494e52;
  --text-light: #7a8288;
  --border: #f2f3f3;
  --bg: #fff;
  --line: #dfe2e4;
  --line-strong: #b9bec2;
  --accent: #2f7f93;
  --accent-soft: #eef6f8;
  --scrim: rgba(29, 31, 33, 0.4);
  --sticky-offset: 0px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #e2e4e6;
    --text-light: #a0a6ab;
    --border: #3a3f44;
    --bg: #1d1f21;
    --line: #34393e;
    --line-strong: #565d63;
    --accent: #52adc8;
    --accent-soft: #1e3138;
    --scrim: rgba(0, 0, 0, 0.6);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  /* short and long pages keep the same width, so the sidebar does not jump between pages */
  scrollbar-gutter: stable;
}

@media (min-width: 768px) {
  html {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", Arial, sans-serif;
  line-height: 1.5;
}

[id] {
  scroll-margin-top: calc(var(--sticky-offset) + 1rem);
}

.standalone-project {
  width: calc(100% - 2rem);
  max-width: 64rem;
  margin: 0 auto;
  padding: 4rem 0;
}

.standalone-project__header,
.media-page__intro,
.media-gallery,
.page-section {
  max-width: 48rem;
  margin-right: auto;
  margin-left: auto;
}

.standalone-project__header {
  margin-bottom: 2rem;
}

.standalone-project__header h1 {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1.15;
}

.media-page__intro {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: var(--text-light);
}

.page-section__kicker {
  margin: 0 0 0.15rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.page-section__title {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  line-height: 1.2;
}

/* a titled group of media inside a page's section (e.g. Sim > Post Wrap) */

.page-subsection {
  margin: 1.5rem 0 1.25rem;
}

.page-subsection__title {
  margin: 0 0 0.9rem;
  padding-bottom: 0.35rem;
  font-size: 1.25rem;
  line-height: 1.3;
  border-bottom: 1px solid var(--line);
}

.page-subsection__lead {
  margin: -0.4rem 0 0.9rem;
  font-size: 0.95rem;
}

/* a short titled list of working notes above a subsection's media (e.g. Sim > Post Wrap > Control) */
.page-notes {
  margin: -0.2rem 0 1.25rem;
  padding-left: 0.9rem;
  font-size: 0.95rem;
  border-left: 3px solid var(--line);
}

.page-notes__title {
  margin: 0 0 0.15rem;
  font-weight: 700;
}

.page-notes ul {
  margin: 0;
  padding-left: 1.3rem;
}

.page-notes li {
  margin: 0.1rem 0;
}

.page-notes li::marker {
  color: var(--text-light);
}

/* longer notes as prose: headings, short paragraphs, lists, code names and figures (e.g. Post Wrap > NN) */
.page-prose {
  font-size: 0.95rem;
  line-height: 1.65;
}

.page-prose h4 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.1rem;
  line-height: 1.3;
}

.page-prose h4:first-child {
  margin-top: 0;
}

.page-prose h5 {
  margin: 1.2rem 0 0.3rem;
  font-size: 0.95rem;
  line-height: 1.4;
}

.page-prose p {
  margin: 0 0 0.75rem;
}

.page-prose ul,
.page-prose ol {
  margin: 0 0 0.85rem;
  padding-left: 1.3rem;
}

.page-prose ol {
  padding-left: 1.5rem;
}

.page-prose li > ul,
.page-prose li > ol {
  margin: 0.1rem 0 0.2rem;
}

.page-prose li {
  margin: 0.15rem 0;
}

.page-prose li::marker {
  color: var(--text-light);
}

.page-prose code {
  padding: 0.05em 0.3em;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
  background: var(--border);
  border-radius: 0.2rem;
}

/* the notes' coloured labels: a section label (训练, 修改 ...) and a term being explained */
.page-prose__label {
  color: var(--accent);
  font-style: italic;
  font-weight: 600;
}

p.page-prose__label {
  margin-bottom: 0.25rem;
}

.page-prose__term {
  font-weight: 700;
}

/* a note or paper the notes refer to by name */
.page-prose__ref {
  color: var(--text-light);
  font-style: italic;
}

.page-prose sub {
  font-size: 0.72em;
  line-height: 0;
}

/* a small table, scrolling sideways on its own if a phone is too narrow */
.page-prose__table {
  margin: 0.25rem 0 1rem;
  overflow-x: auto;
}

.page-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.page-prose th,
.page-prose td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

.page-prose th {
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 700;
  border-bottom-color: var(--line-strong);
}

/* short first and last columns (a time, a keyframe) stay on one line where there is room */
@media (min-width: 600px) {
  .page-prose th,
  .page-prose td:first-child,
  .page-prose td:last-child {
    white-space: nowrap;
  }
}

.page-prose__figure {
  margin: 0.5rem 0 1rem;
}

.page-prose__figure img {
  display: block;
  width: 100%;
  max-width: 38rem;
  height: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.35rem;
}

/* two videos per row; a wide item (a chart, a synced comparison) takes the whole row */
.media-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 1.25rem;
  align-items: start;
}

.media-gallery__item {
  margin: 0 0 1.5rem;
}

.media-gallery__item--wide {
  grid-column: 1 / -1;
}

@media (max-width: 599px) {
  .media-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}

.media-gallery__item figcaption {
  margin-top: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

.media-gallery__media img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--border);
}

.media-gallery__media video {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: #000;
}

/* Section nav: a sidebar on wide screens, a drawer opened from the top bar on narrow ones. */

.site-nav__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.site-nav__label {
  color: var(--text-light);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-nav__list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.site-nav__link {
  display: block;
  margin-left: -1px;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  color: var(--text-light);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 0.35rem 0.35rem 0;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.site-nav__link:hover {
  color: var(--text);
  border-left-color: var(--line-strong);
}

.site-nav__link[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

/* a category whose sub-page is open */
.site-nav__link.is-active {
  color: var(--text);
}

.site-nav__sub {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav__link--sub {
  padding: 0.35rem 0.75rem 0.35rem 1.9rem;
  font-size: 0.92rem;
  font-weight: 600;
}

/* a sub-page's own sections (Post Wrap > MPC ...), shown only while that sub-page is open */
.site-nav__sub--deep {
  display: none;
}

.site-nav__link[aria-current="page"] + .site-nav__sub--deep {
  display: block;
}

.site-nav__link--deep {
  padding: 0.25rem 0.5rem 0.25rem 2.6rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* a section's own parts (Post Wrap > Imitation Learning > V0 ... V4-DP), shown with that section's deep list */
.site-nav__link--deeper {
  padding: 0.15rem 0.5rem 0.15rem 3.4rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.site-nav__link:focus-visible,
.site-nav__close:focus-visible,
.site-bar__menu:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-nav__close,
.site-bar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 0.35rem;
  cursor: pointer;
}

.site-nav__close:hover,
.site-bar__menu:hover {
  background: var(--accent-soft);
}

.site-nav__close svg,
.site-bar__menu svg {
  width: 1.25rem;
  height: 1.25rem;
}

.site-bar,
.site-scrim,
.site-nav__close {
  display: none;
}

@media (min-width: 900px) {
  .standalone-project {
    display: grid;
    grid-template-columns: 12rem minmax(0, 48rem);
    align-items: start;
    justify-content: center;
    column-gap: 3rem;
  }

  .site-nav {
    position: sticky;
    top: 4rem;
  }
}

@media (max-width: 899px) {
  :root {
    --sticky-offset: 3rem;
  }

  .site-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 3rem;
    padding: 0 1rem 0 0.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }

  .site-bar__title {
    overflow: hidden;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .standalone-project {
    padding-top: 2rem;
  }

  .site-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(18rem, 82vw);
    padding: 0.375rem 1rem 1.5rem;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--line);
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .site-nav__head {
    margin-bottom: 1rem;
  }

  .site-nav__close {
    display: inline-flex;
  }

  .nav-open {
    overflow: hidden;
  }

  .nav-open .site-nav {
    visibility: visible;
    transform: none;
    transition: transform 0.2s ease;
  }

  .nav-open .site-scrim {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: block;
    background: var(--scrim);
  }
}

@media (prefers-reduced-motion: reduce) {
  .site-nav,
  .nav-open .site-nav {
    transition: none;
  }
}

@media (max-width: 767px) {
  .standalone-project {
    padding-bottom: 2.5rem;
  }

  .standalone-project__header h1 {
    font-size: 1.8rem;
  }
}
