/* Palette: change these to retheme the whole site (the moiré reads them too). */
:root {
  --bg: #111827;
  --surface: #1a2232;
  --fg: #e6e9ef;
  --muted: #8b94a5;
  --line: rgba(230, 233, 239, 0.14);
  --accent: #e3a072;
  --link-hover: var(--accent);
  --layer-1: #3d86d8;
  --layer-2: #e3a072;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Full-window backdrops: the moiré canvas (landing) or a looping video (ENFOLD) */

.backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.backdrop-video {
  overflow: hidden;
  background: var(--bg);
}

.backdrop-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

#moire {
  display: block;
  touch-action: none;
  cursor: grab;
}

#moire:active {
  cursor: grabbing;
}

#moire:focus-visible {
  outline: none;
}

.moire-overlay {
  pointer-events: none;
}

.moire-overlay[hidden] {
  display: none;
}

/* Layout: a fixed sidebar box beside the main column. The sidebar's position depends only
   on the window size, never on the page, so it sits in exactly the same place everywhere. */

:root {
  --shell-width: 68rem;
  --shell-pad: 2rem;
  --shell-top: max(2rem, 12vh);
  --sidebar-width: 17.5rem;
  --sidebar-pad: 2rem;
  --column-gap: clamp(2.5rem, 5vw, 4.5rem);
  --sidebar-left: max(var(--shell-pad), calc((100% - var(--shell-width)) / 2 + var(--shell-pad)));
}

html {
  scrollbar-gutter: stable;
}

.panel-box,
.backdrop-page .main > article {
  border: 1px solid var(--line);
  border-radius: 0.875rem;
  background: rgba(17, 24, 39, 0.8);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sidebar {
  position: fixed;
  top: var(--shell-top);
  left: var(--sidebar-left);
  z-index: 10;
  width: var(--sidebar-width);
  max-height: calc(100vh - var(--shell-top) - 1rem);
  overflow-y: auto;
  padding: var(--sidebar-pad);
}

.site-title {
  display: block;
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-decoration: none;
}

.site-tagline {
  margin: 0.5rem 0 2rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--muted);
}

.nav-group {
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}

.nav-group:last-child {
  margin-bottom: 0;
}

.nav-group a {
  display: block;
  margin-left: -1px;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.nav-group a:hover {
  color: var(--fg);
}

.nav-group a[aria-current="page"] {
  color: var(--fg);
  border-left-color: var(--accent);
}

.nav-group a.external::after {
  content: "↗";
  margin-left: 0.2em;
  font-size: 0.8em;
}

.shell {
  position: relative;
  z-index: 1;
  padding: var(--shell-top) var(--shell-pad) 4rem;
}

/* The main column starts right of the sidebar, with its title level with the name. */
.main {
  max-width: 40rem;
  margin-left: calc(var(--sidebar-left) - var(--shell-pad) + var(--sidebar-width) + var(--column-gap));
  padding-top: var(--sidebar-pad);
}

/* Over a video, the text sits on the same kind of box as the sidebar. */
.backdrop-page .main {
  padding-top: 0;
}

.backdrop-page .main > article {
  padding: var(--sidebar-pad) 2.25rem;
}

article > :first-child {
  margin-top: 0;
}

article > :last-child {
  margin-bottom: 0;
}

h1,
h2,
h3 {
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 1.5rem;
}

/* Two-tone rule under page titles, in the moiré's layer colors. */
.main h1::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.65rem;
  background: linear-gradient(to right, var(--layer-1) 0 60%, transparent 60% 68%, var(--layer-2) 68% 100%);
}

h2 {
  font-size: 1.125rem;
  margin: 2.5rem 0 1rem;
}

h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

p {
  margin: 0 0 1rem;
}

.lede {
  font-size: 1.0625rem;
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.funding-note {
  margin-top: 2.5rem;
}

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

/* Lists of projects and papers */

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

.entry {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.entry p {
  margin-bottom: 0.5rem;
}

.entry > :last-child {
  margin-bottom: 0;
}

.entry .meta {
  font-size: 0.9rem;
  color: var(--muted);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.links a::after {
  content: "↗";
  margin-left: 0.15em;
  font-size: 0.85em;
  color: var(--muted);
}

.links .label {
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.5rem;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

/* Landing page: the moiré parameter panel, docked bottom right */

.moire-ui {
  position: fixed;
  inset: var(--shell-top) 1rem 1rem;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

.moire-ui > * {
  pointer-events: auto;
}

.panel-toggle,
.panel button {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
}

.panel-toggle:hover,
.panel button:hover {
  border-color: var(--muted);
}

.panel-dock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 100%;
  max-height: 100%;
}

.panel {
  width: 34rem;
  max-width: 100%;
  min-height: 0;
  overflow: auto;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--bg);
  font-size: 0.8125rem;
}

.panel[hidden] {
  display: none;
}

.panel table {
  width: 100%;
  border-collapse: collapse;
}

.panel th {
  padding: 0 0.25rem 0.4rem;
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.panel td {
  padding: 0.15rem 0.25rem;
  vertical-align: middle;
  white-space: nowrap;
}

.panel input[type="number"] {
  width: 4.25rem;
  padding: 0.2rem 0.35rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
}

.panel input[type="color"] {
  width: 1.9rem;
  height: 1.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  background: none;
  cursor: pointer;
}

.panel input[type="radio"] {
  accent-color: var(--accent);
}

.panel .remove {
  padding: 0.1rem 0.45rem;
  color: var(--muted);
}

.panel-readout {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.panel-actions label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  color: var(--muted);
}

/* Narrow screens */

@media (max-width: 720px) {
  /* One column: the sidebar box becomes a compact header above the content. */
  .shell {
    padding: 1rem 1rem 3rem;
  }

  .sidebar {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    max-height: none;
    margin-bottom: 1.75rem;
    padding: 1.25rem;
  }

  .site-tagline {
    margin-bottom: 0.9rem;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
  }

  .nav-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    margin: 0;
    border-left: none;
  }

  .nav-group a {
    margin-left: 0;
    padding: 0.15rem 0;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .nav-group a[aria-current="page"] {
    border-bottom-color: var(--accent);
  }

  .main {
    margin-left: 0;
    padding-top: 0;
  }

  .backdrop-page .main > article {
    padding: 1.25rem;
  }

  .facts {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .facts dd {
    margin-bottom: 0.5rem;
  }

  .moire-ui {
    inset: auto 0.75rem 0.75rem;
    max-height: 60vh;
  }

  .panel-dock {
    width: 100%;
  }

  .panel {
    width: 100%;
    max-height: 55vh;
    padding: 0.75rem;
  }

  .panel th,
  .panel td {
    padding-inline: 0.15rem;
  }

  .panel input[type="number"] {
    width: 3.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
