:root {
  color-scheme: light;
  --page-background: #fff;
  --page-surface: #f5f5f5;
  --page-card: #fff;
  --page-text: #4a4a4a;
  --page-heading: #363636;
  --page-muted: #555;
  --page-link: #3273dc;
  --page-border: #d8dce3;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-background: #10151e;
  --page-surface: #18212e;
  --page-card: #212c3b;
  --page-text: #e5eaf1;
  --page-heading: #f5f7fb;
  --page-muted: #b4c0d0;
  --page-link: #84bfff;
  --page-border: #35465c;
}

html,
body {
  background-color: var(--page-background);
}

/* Leave room for the toggle above the title on narrow screens. */
body > .hero:first-of-type .hero-body {
  padding-top: 4.5rem;
}

.theme-toggle {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--page-border);
  border-radius: 50%;
  color: var(--page-heading);
  background: var(--page-card);
  box-shadow: 0 3px 12px rgb(0 0 0 / 12%);
  cursor: pointer;
  transition: background-color 150ms ease, box-shadow 150ms ease;
}

.theme-toggle[hidden] {
  display: none;
}

.theme-toggle:hover {
  background-color: var(--page-surface);
  box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
}

.theme-toggle:focus-visible {
  outline: 3px solid var(--page-link);
  outline-offset: 3px;
}

.theme-toggle svg {
  width: 22px;
  height: 22px;
}

.theme-toggle .theme-sun,
:root[data-theme="dark"] .theme-toggle .theme-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .theme-sun {
  display: block;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .hero.is-light {
  color: var(--page-text);
}

:root[data-theme="dark"] .hero.is-light,
:root[data-theme="dark"] .footer {
  background-color: var(--page-surface);
}

:root[data-theme="dark"] :is(h1, h2, h3, h4, h5, h6, strong, .title, .subtitle),
:root[data-theme="dark"] .hero.is-light :is(.title, .subtitle) {
  color: var(--page-heading);
}

:root[data-theme="dark"] a {
  color: var(--page-link);
}

:root[data-theme="dark"] a:hover {
  color: var(--page-heading);
}

:root[data-theme="dark"] .publication-authors a {
  color: var(--page-link) !important;
}

:root[data-theme="dark"] .publication-venue,
:root[data-theme="dark"] .related-project-card p {
  color: var(--page-muted);
}

:root[data-theme="dark"] .related-project-card {
  color: var(--page-text);
  background-color: var(--page-card);
  box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
}

:root[data-theme="dark"] .related-project-card:hover,
:root[data-theme="dark"] .related-project-card:focus {
  box-shadow: 0 12px 30px rgb(0 0 0 / 35%);
}

:root[data-theme="dark"] .button.is-dark,
:root[data-theme="dark"] .copy-btn {
  color: var(--page-heading);
  background: var(--page-card);
  border: 1px solid var(--page-border);
}

:root[data-theme="dark"] .button.is-dark:hover {
  color: var(--page-heading);
  background: #2c3b50;
}

:root[data-theme="dark"] :is(a, button):focus-visible {
  outline: 3px solid var(--page-link);
  outline-offset: 3px;
}

:root[data-theme="dark"] :is(pre, code, .bibtex-card) {
  color: var(--page-text);
  background: var(--page-card);
}

.bibtex-card {
  position: relative;
}

.bibtex-card .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}

.bibtex-card .copy-btn .icon-check,
.bibtex-card .copy-btn[data-copied="true"] .icon-clipboard {
  display: none;
}

.bibtex-card .copy-btn[data-copied="true"] .icon-check {
  display: block;
}

/* Preserve the colors and contrast in figures exported from the papers. */
:root[data-theme="dark"] .image img {
  background-color: #fff;
  border-radius: 8px;
}

:root[data-theme="dark"] figcaption[style*="color:"] {
  color: var(--page-text) !important;
}

:root[data-theme="dark"] .video-item p[style*="color:"] {
  color: var(--page-link) !important;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle {
    transition: none;
  }
}
