:root {
  --bg: #0b0b0c;
  --bg-soft: #141416;
  --ink: #f2f1ef;
  --ink-soft: #c4c3c0;
  --muted: #8a8a90;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.24);
  --tint: rgba(255, 255, 255, 0.05);
  --topbar: rgba(11, 11, 12, 0.72);
  /* Near-white plate so figures authored on white paper sit deliberately. */
  --figure: #edece8;
  --figure-dim: 0.82;
  --lift: 0 14px 30px -18px rgba(0, 0, 0, 0.9);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas,
    monospace;

  --page: min(42rem, calc(100% - 2.5rem));
  --thumb: 12rem;
  --gap: 1.5rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbfbfa;
  --bg-soft: #f2f1ee;
  --ink: #15161a;
  --ink-soft: #3c3e43;
  --muted: #6c6e74;
  --line: rgba(0, 0, 0, 0.12);
  --line-strong: rgba(0, 0, 0, 0.28);
  --tint: rgba(0, 0, 0, 0.035);
  --topbar: rgba(251, 251, 250, 0.76);
  --figure: #ffffff;
  --figure-dim: 1;
  --lift: 0 14px 30px -20px rgba(0, 0, 0, 0.45);

  color-scheme: light;
}

/* Without scripting nothing sets data-theme, so mirror the palette above to
   keep following the OS. Keep the two blocks in sync. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #fbfbfa;
    --bg-soft: #f2f1ee;
    --ink: #15161a;
    --ink-soft: #3c3e43;
    --muted: #6c6e74;
    --line: rgba(0, 0, 0, 0.12);
    --line-strong: rgba(0, 0, 0, 0.28);
    --tint: rgba(0, 0, 0, 0.035);
    --topbar: rgba(251, 251, 250, 0.76);
    --figure: #ffffff;
    --figure-dim: 1;
    --lift: 0 14px 30px -20px rgba(0, 0, 0, 0.45);

    color-scheme: light;
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color 260ms var(--ease), color 260ms var(--ease);
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

a {
  color: inherit;
  text-decoration-color: var(--line-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

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

.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 160ms var(--ease);
  z-index: 10;
}

.skip-link:focus-visible {
  transform: none;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  width: var(--page);
  margin: 0 auto;
  height: 3.5rem;
}

.wordmark {
  margin-right: auto;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.topnav {
  display: flex;
  gap: 1.1rem;
}

.topnav a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
}

.topnav a:hover {
  color: var(--ink);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease),
    background-color 150ms var(--ease);
}

.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--tint);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun,
[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

/* ---------- page shell ---------- */

.page {
  width: var(--page);
  margin: 0 auto;
}

.section {
  padding: 4.25rem 0;
  border-top: 1px solid var(--line);
}

.section-label {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.section-lede {
  margin: -0.5rem 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---------- intro ---------- */

.intro {
  padding: 5rem 0 4.5rem;
}

.eyebrow {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.name {
  margin: 0;
  font-size: clamp(2.5rem, 8.5vw, 3.6rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.tagline {
  margin: 1.5rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(1.1rem, 2.2vw, 1.24rem);
  line-height: 1.55;
  text-wrap: pretty;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 2.25rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.links a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}

.links a:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* Scoped to off-site links, so in-page and mailto links stay unmarked. */
.links a[href^="http"]::after {
  content: " ↗";
  color: var(--muted);
  font-size: 0.9em;
}

/* ---------- prose ---------- */

.prose p {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.prose p:first-child {
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.65;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose a {
  color: var(--ink);
  text-decoration-color: var(--line-strong);
}

/* ---------- publications ---------- */

.biblio,
.also-list,
.patent-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.biblio li {
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

.biblio li:first-child {
  border-top: 0;
  padding-top: 0;
}

.pub-thumb {
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: var(--bg-soft);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 300ms var(--ease), box-shadow 300ms var(--ease);
}

.pub-thumb:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--lift);
}

.pub-thumb img,
.pub-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Plots authored on white: show the whole frame on a paper plate, held back
   so it does not outshine the video thumbnails around it. */
.pub-thumb-figure {
  background: var(--figure);
  filter: brightness(var(--figure-dim));
}

.pub-thumb-figure:hover {
  filter: none;
}

.pub-thumb-figure img {
  object-fit: contain;
  padding: 0.35rem;
}

.pub-body {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.pub-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}

.pub-authors {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.pub-authors strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.pub-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.pub-venue {
  display: inline-block;
  padding: 0.2em 0.5em;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin-top: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.pub-links a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}

.pub-links a:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.pub-links a::after {
  content: " ↗";
  color: var(--muted);
  font-size: 0.9em;
}

/* ---------- open source ---------- */

.also-list li {
  display: grid;
  gap: 0.1rem 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.also-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

/* Each tool is a heading so the document outline lists them, but it carries no
   visual weight of its own; the link inside sets the type. */
.oss-name {
  margin: 0;
  font-size: inherit;
  font-weight: 400;
  line-height: inherit;
}

.also-list a {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration-color: var(--line);
  text-underline-offset: 0.3em;
}

.also-list span {
  color: var(--muted);
  font-size: 0.925rem;
  line-height: 1.5;
}

.also-list code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.also-list .install {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  opacity: 0.85;
}

/* ---------- patents ---------- */

.group-label {
  margin: 2.25rem 0 0.9rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.group-label:first-of-type {
  margin-top: 0;
}

.patent-list li {
  display: grid;
  gap: 0.15rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.patent-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.patent-list a {
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.patent-list a:hover {
  color: var(--ink);
  border-color: var(--line);
}

.patent-meta {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
}

/* ---------- footer ---------- */

.site-footer {
  width: var(--page);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
  border-top: 1px solid var(--line);
}

.footer-note {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.site-footer .links {
  margin-top: 0;
}

.credit {
  margin: 1.5rem 0 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

/* ---------- reveal ---------- */

.reveal {
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 600ms var(--ease), transform 600ms var(--ease);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- responsive ---------- */

@media (min-width: 46rem) {
  .also-list li {
    grid-template-columns: 13rem minmax(0, 1fr);
    align-items: baseline;
  }

  .also-list .install {
    grid-column: 2;
  }

  .patent-list li {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.15rem 1.5rem;
    align-items: baseline;
  }

  .patent-meta {
    text-align: right;
    white-space: nowrap;
  }
}

@media (max-width: 34rem) {
  :root {
    --page: min(42rem, calc(100% - 1.75rem));
    --thumb: 7.5rem;
    --gap: 1rem;
  }

  body {
    font-size: 1rem;
  }

  .topnav {
    display: none;
  }

  .intro {
    padding: 3.5rem 0 3.5rem;
  }

  .section {
    padding: 3.25rem 0;
  }

  .prose p:first-child {
    font-size: 1.08rem;
  }

  .pub-title {
    font-size: 1rem;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
