/* ==========================================================================
   Brown Lab: styles.css
   Palette drawn from the eyebright flower: violet veins, yellow eye,
   set on paper and forest ink.
   ========================================================================== */

:root {
  --paper: #f7f5ef;
  --paper-2: #efebe1;
  --surface: #fffdf8;
  --ink: #16201a;
  --ink-2: #4a554e;
  --ink-3: #78827b;
  --rule: #e0dacb;
  --rule-strong: #cdc5b2;
  --forest: #1d3a2b;
  --forest-ink: #eef3ec;
  --accent: #6a4c9c;
  --accent-soft: #ece6f6;
  --gold: #c9930f;
  --gold-soft: #f6ead0;
  --chart-1: #6a4c9c;
  --chart-2: #a8770a;
  --shadow: 0 1px 2px rgb(22 32 26 / 4%), 0 8px 24px -12px rgb(22 32 26 / 18%);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1512;
    --paper-2: #141c18;
    --surface: #18211c;
    --ink: #ebebe3;
    --ink-2: #b3bbb4;
    --ink-3: #848d86;
    --rule: #26302b;
    --rule-strong: #34403a;
    --forest: #13241b;
    --forest-ink: #e6eee6;
    --accent: #b8a1e8;
    --accent-soft: #2a2438;
    --gold: #e7c15a;
    --gold-soft: #2f2914;
    --chart-1: #9d84d8;
    --chart-2: #b8862a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 28px -14px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0f1512;
  --paper-2: #141c18;
  --surface: #18211c;
  --ink: #ebebe3;
  --ink-2: #b3bbb4;
  --ink-3: #848d86;
  --rule: #26302b;
  --rule-strong: #34403a;
  --forest: #13241b;
  --forest-ink: #e6eee6;
  --accent: #b8a1e8;
  --accent-soft: #2a2438;
  --gold: #e7c15a;
  --gold-soft: #2f2914;
  --chart-1: #9d84d8;
  --chart-2: #b8862a;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 28px -14px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  display: block;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

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

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

h1,
h2,
h3,
h4 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 0.5em;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.5rem, 5.6vw, 4.6rem);
  font-weight: 400;
  letter-spacing: -0.022em;
  word-spacing: 0.04em;
}

h2 {
  font-size: clamp(1.9rem, 3.2vw, 2.6rem);
}

h3 {
  font-size: 1.35rem;
  font-variation-settings: "opsz" 36;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

em,
i {
  font-style: italic;
}

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 12px;
  z-index: 100;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 8px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 1.2rem;
}

.eyebrow::before {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
}

.lede {
  font-size: clamp(1.1rem, 1.6vw, 1.28rem);
  color: var(--ink-2);
  max-width: 40em;
}

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

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

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.site-header.scrolled {
  border-bottom-color: var(--rule);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.32rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand svg {
  width: 30px;
  height: 30px;
  flex: none;
}

.brand small {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-left: 1px solid var(--rule-strong);
  padding-left: 10px;
  margin-left: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.93rem;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover {
  color: var(--ink);
  background: var(--paper-2);
}

.nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--paper-2);
  box-shadow: inset 0 0 0 1px var(--rule);
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin-left: 6px;
  flex: none;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

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

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle .moon {
    display: block;
  }
}

.menu-toggle {
  display: none;
}

@media (max-width: 920px) {
  .brand small {
    display: none;
  }

  .menu-toggle {
    display: grid;
  }

  .nav {
    position: fixed;
    inset: 68px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px var(--gutter) 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    box-shadow: var(--shadow);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .nav.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .nav a {
    font-size: 1.05rem;
    padding: 12px 14px;
    border-radius: 10px;
  }

  .nav .theme-toggle {
    margin: 8px 0 0;
    align-self: flex-start;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  background: var(--surface);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* ---------- Hero ---------- */

.hero {
  padding: clamp(48px, 8vw, 104px) 0 clamp(40px, 6vw, 72px);
}

.hero .wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: center;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.hero .lede {
  margin: 1.4rem 0 2rem;
}

.figure {
  margin: 0;
  position: relative;
}

.figure .frame {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
}

.figure .frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.figure figcaption {
  font-size: 0.85rem;
  color: var(--ink-3);
  margin-top: 12px;
  line-height: 1.5;
}

.figure figcaption b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-right: 6px;
}

.hero .figure .tag {
  position: absolute;
  left: -18px;
  bottom: 64px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  line-height: 1.35;
}

.hero .figure .tag i {
  font-family: var(--serif);
  font-size: 1rem;
}

.hero .figure .tag span {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

@media (max-width: 860px) {
  .hero .wrap {
    grid-template-columns: 1fr;
  }

  .hero .figure .frame {
    aspect-ratio: 4 / 3;
  }

  .hero .figure .tag {
    left: 12px;
    top: 12px;
    bottom: auto;
  }
}

/* ---------- Telomere ticker ---------- */

.ticker {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-2);
  overflow: hidden;
  position: relative;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.32em;
  color: var(--ink-3);
  white-space: nowrap;
  padding: 11px 0;
  user-select: none;
}

.ticker-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: ticker 70s linear infinite;
}

.ticker-track b {
  color: var(--accent);
  font-weight: 500;
}

.ticker-label {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 var(--gutter) 0 48px;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--ink-2);
  background: linear-gradient(to right, transparent, var(--paper-2) 36px);
}

@keyframes ticker {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

@media (max-width: 600px) {
  .ticker-label {
    display: none;
  }
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(56px, 8vw, 104px) 0;
}

.section + .section {
  border-top: 1px solid var(--rule);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: clamp(28px, 4vw, 48px);
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  max-width: 18em;
}

.section-head .lede {
  margin: 0.8rem 0 0;
}

.link-arrow {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.link-arrow::after {
  content: "→";
  transition: transform 0.15s ease;
}

.link-arrow:hover::after {
  transform: translateX(3px);
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.stat {
  padding: 26px 26px 22px;
  border-right: 1px solid var(--rule);
}

.stat:last-child {
  border-right: 0;
}

.stat .num {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: lining-nums;
  font-variation-settings: "opsz" 144;
}

.stat .label {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.stats-note {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--ink-3);
  font-family: var(--mono);
}

@media (max-width: 760px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat:nth-child(2) {
    border-right: 0;
  }

  .stat:nth-child(-n + 2) {
    border-bottom: 1px solid var(--rule);
  }
}

/* ---------- Theme cards ---------- */

.themes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.theme-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 26px 26px 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

a.theme-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--rule-strong);
}

.theme-card .idx {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 26px;
  display: flex;
  justify-content: space-between;
}

.theme-card .idx span {
  color: var(--ink-3);
}

.theme-card h3 {
  margin-bottom: 0.5em;
}

.theme-card p {
  color: var(--ink-2);
  font-size: 0.95rem;
  margin: 0;
}

@media (max-width: 960px) {
  .themes {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .themes {
    grid-template-columns: 1fr;
  }
}

/* ---------- Publication list ---------- */

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

.pub {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 28px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.pub:first-child {
  border-top: 1px solid var(--rule);
}

.pub-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.32;
  font-variation-settings: "opsz" 30;
  margin: 0 0 6px;
  font-weight: 500;
}

.pub-title a {
  color: var(--ink);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease;
}

.pub-title a:hover {
  background-size: 100% 1px;
}

.pub-authors {
  font-size: 0.9rem;
  color: var(--ink-2);
  margin: 0 0 4px;
}

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

.pub-venue {
  font-size: 0.88rem;
  color: var(--ink-3);
  margin: 0;
}

.pub-venue i {
  color: var(--ink-2);
}

.pub-meta {
  text-align: right;
  min-width: 92px;
}

.cites {
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
  font-variation-settings: "opsz" 144;
}

.cites-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-top: 4px;
}

.cites-bar {
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.cites-bar span {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  min-width: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-pill {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  color: var(--ink-2);
  background: var(--paper);
}

.tag-pill.lead {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.tag-pill.oa {
  background: var(--gold-soft);
  border-color: transparent;
  color: var(--ink);
}

@media (max-width: 620px) {
  .pub {
    grid-template-columns: 1fr;
  }

  .pub-meta {
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 8px;
  }

  .cites {
    font-size: 1.1rem;
  }

  .cites-bar {
    display: none;
  }
}

/* ---------- Software band ---------- */

.band-dark {
  background: var(--forest);
  color: var(--forest-ink);
  --ink: var(--forest-ink);
  --ink-2: color-mix(in srgb, var(--forest-ink) 76%, transparent);
  --ink-3: color-mix(in srgb, var(--forest-ink) 56%, transparent);
  --rule: color-mix(in srgb, var(--forest-ink) 14%, transparent);
  --rule-strong: color-mix(in srgb, var(--forest-ink) 26%, transparent);
  --surface: color-mix(in srgb, var(--forest-ink) 5%, transparent);
  --paper: color-mix(in srgb, var(--forest-ink) 6%, transparent);
  --paper-2: color-mix(in srgb, var(--forest-ink) 9%, transparent);
  --accent: #cdb8f5;
  --accent-soft: color-mix(in srgb, #cdb8f5 18%, transparent);
  --gold: #f0cd6b;
}

.section + .band-dark,
.band-dark + .section {
  border-top: 0;
}

.repos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.repo {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

a.repo:hover {
  border-color: var(--rule-strong);
  transform: translateY(-2px);
}

.repo-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
}

.repo-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 1.12rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.repo-org {
  color: var(--ink-3);
  font-weight: 400;
}

.repo p {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.94rem;
}

.repo-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
}

.repo-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lang-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, #888);
}

.badge {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--gold-soft);
  color: var(--ink);
  white-space: nowrap;
}

.band-dark .badge {
  background: color-mix(in srgb, var(--gold) 22%, transparent);
  color: var(--gold);
}

.terminal {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.7;
  background: #121a16;
  border: 1px solid #26302b;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 1.4em 0 0;
  color: #d8e0d9;
  overflow-x: auto;
  white-space: pre;
}

.terminal .c {
  color: #7f8c84;
}

.terminal .k {
  color: #c9b4f2;
}

.terminal .s {
  color: #e8c46a;
}

.terminal .n {
  color: #8fd1b0;
}

.terminal .p {
  color: #c9b4f2;
  user-select: none;
}

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

/* ---------- Software: under the hood ---------- */

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 1px 5px;
}

.dev {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  padding: clamp(44px, 6vw, 72px) 0;
  border-top: 1px solid var(--rule);
  scroll-margin-top: 80px;
}

.dev:nth-of-type(even) .dev-text {
  order: 2;
}

.dev h3 {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  margin-bottom: 0.4em;
}

.dev h3 a {
  color: var(--accent);
  text-decoration: none;
}

.dev h3 a::after {
  content: " ↗";
  font-size: 0.85em;
}

.dev h2 {
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
}

.dev-text > p {
  color: var(--ink-2);
}

.viz {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(14px, 2.4vw, 24px);
  position: sticky;
  top: 92px;
}

.viz figcaption {
  font-size: 0.84rem;
  color: var(--ink-3);
  margin-top: 14px;
  line-height: 1.5;
}

.viz figcaption b {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-right: 4px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend .sw.s1 {
  background: var(--chart-1);
}

.legend .sw.s2 {
  background: var(--chart-2);
}

.chart {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  font-family: var(--mono);
}

.chart .grid {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart .axis {
  stroke: var(--ink-3);
  stroke-width: 1;
}

.chart .tick {
  fill: var(--ink-3);
  font-size: 10px;
}

.chart .tick.lab {
  font-family: var(--sans);
  font-size: 11px;
  fill: var(--ink-2);
}

.chart .note {
  fill: var(--ink-2);
  font-family: var(--sans);
  font-size: 11px;
}

.chart .note.halo,
.chart .note.strong {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.chart .note.strong {
  fill: var(--ink);
  font-weight: 600;
}

.chart .s1,
.chart .s1-f {
  fill: var(--chart-1);
}

.chart .s2,
.chart .s2-f {
  fill: var(--chart-2);
}

.chart .rep-f {
  fill: var(--ink-2);
}

.chart rect.s1:hover,
.chart rect.s2:hover {
  opacity: 0.7;
}

.chart .seg {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.chart .seg.s1 {
  stroke: var(--chart-1);
}

.chart .seg.s2 {
  stroke: var(--chart-2);
}

.chart .seg.rep {
  stroke: var(--ink-2);
  stroke-width: 16;
}

.chart .seg:hover {
  stroke-width: 13;
}

.chart .seg.rep:hover {
  stroke-width: 19;
}

.chart .walker {
  fill: none;
  stroke: var(--surface);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 3 97;
  animation: walk 7s linear infinite;
  pointer-events: none;
}

@keyframes walk {
  from {
    stroke-dashoffset: 100;
  }

  to {
    stroke-dashoffset: 0;
  }
}

.chart .dot {
  fill: var(--chart-1);
  fill-opacity: 0.38;
}

.chart .dot:hover {
  fill-opacity: 1;
}

.chart .hit {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  pointer-events: none;
}

.chart .median {
  stroke: var(--ink);
  stroke-width: 2.5;
  stroke-linecap: round;
}

.seg-ctrl {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.seg-ctrl button {
  appearance: none;
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}

.seg-ctrl button:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
}

.seg-ctrl button[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.seg-ctrl .reroll {
  margin-left: auto;
}

.tree-plate {
  box-shadow: none;
}

#tree {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #16201a;
}

#tree svg {
  max-width: 100%;
  height: auto;
}

.tree-fallback {
  padding: 24px;
  text-align: center;
  font-size: 0.9rem;
  color: #78827b;
}

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

  .dev:nth-of-type(even) .dev-text {
    order: 0;
  }

  .viz {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chart .walker {
    animation: none;
    display: none;
  }
}

/* ---------- CTA ---------- */

.cta {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: calc(var(--radius) + 6px);
  padding: clamp(28px, 5vw, 56px);
  position: relative;
  overflow: hidden;
}

.cta h2 {
  margin-bottom: 0.4em;
}

.cta p {
  color: var(--ink-2);
  margin: 0;
}

.cta .btn-row {
  justify-content: flex-end;
}

.cta-mark {
  position: absolute;
  right: -40px;
  top: -40px;
  width: 220px;
  opacity: 0.08;
  pointer-events: none;
}

@media (max-width: 760px) {
  .cta {
    grid-template-columns: 1fr;
  }

  .cta .btn-row {
    justify-content: flex-start;
  }
}

/* ---------- Page header (inner pages) ---------- */

.page-head {
  padding: clamp(48px, 7vw, 88px) 0 clamp(28px, 4vw, 44px);
  border-bottom: 1px solid var(--rule);
}

.page-head h1 {
  font-size: clamp(2.4rem, 5vw, 3.9rem);
  margin-bottom: 0.3em;
}

/* ---------- Research page ---------- */

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.toc a {
  font-size: 0.86rem;
  color: var(--ink-2);
  text-decoration: none;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
}

.toc a:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
}

.theme {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  padding: clamp(44px, 6vw, 72px) 0;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 80px;
}

.theme:last-of-type {
  border-bottom: 0;
}

.theme-aside {
  position: sticky;
  top: 96px;
  align-self: start;
}

.theme-num {
  font-family: var(--serif);
  font-size: 4.2rem;
  line-height: 1;
  color: var(--accent);
  font-weight: 300;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.04em;
}

.theme-aside .kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 12px;
}

.theme-body h2 {
  margin-bottom: 0.6em;
}

.theme-body > p {
  font-size: 1.06rem;
  color: var(--ink-2);
  max-width: 40em;
}

.theme-body > p:first-of-type {
  color: var(--ink);
  font-size: 1.18rem;
}

.outputs {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.output {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
  transition: border-color 0.15s ease;
}

a.output:hover {
  border-color: var(--accent);
}

.output small {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
}

.theme-figure {
  margin: 32px 0 0;
  max-width: 640px;
}

.theme-figure .frame {
  aspect-ratio: 16 / 10;
}

@media (max-width: 820px) {
  .theme {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .theme-aside {
    position: static;
    display: flex;
    align-items: baseline;
    gap: 16px;
  }

  .theme-num {
    font-size: 2.6rem;
  }
}

/* ---------- Publications page ---------- */

.pub-controls {
  position: sticky;
  top: 68px;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.pub-controls .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.search {
  flex: 1 1 260px;
  position: relative;
}

.search input {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 10px 16px 10px 40px;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-3);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--rule-strong);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.year-group {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 24px;
  padding-top: 36px;
}

.year-group h2 {
  font-size: 2rem;
  color: var(--ink-3);
  font-weight: 300;
  position: sticky;
  top: 150px;
  align-self: start;
  margin: 18px 0 0;
}

.year-group[hidden],
.pub[hidden] {
  display: none;
}

.empty {
  padding: 48px 0;
  color: var(--ink-3);
  text-align: center;
}

@media (max-width: 760px) {
  .pub-controls {
    position: static;
  }

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

  .year-group h2 {
    position: static;
    margin: 0 0 8px;
  }
}

.talks {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0;
}

.talks li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.talks li:first-child {
  border-top: 1px solid var(--rule);
}

.talks .when {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-3);
  padding-top: 3px;
}

.talks .what {
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.35;
}

.talks .where {
  font-size: 0.9rem;
  color: var(--ink-2);
  margin-top: 2px;
}

@media (max-width: 620px) {
  .talks li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ---------- People page ---------- */

.pi {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
}

.pi .figure .frame {
  aspect-ratio: 4 / 5;
}

.pi-role {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 0 0 18px;
}

.pi-body > p:not([class]) {
  font-size: 1.06rem;
  color: var(--ink-2);
}

.pi-body > p.intro {
  font-size: 1.2rem;
  color: var(--ink);
}

.pi-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 760px) {
  .pi {
    grid-template-columns: 1fr;
  }

  .pi .figure {
    max-width: 320px;
  }
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 129px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--rule-strong);
}

.timeline li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 40px;
  padding: 14px 0;
  position: relative;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 125px;
  top: 23px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}

.timeline li.now::before {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.timeline .when {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-3);
  text-align: right;
  padding-top: 3px;
}

.timeline .role {
  font-weight: 600;
}

.timeline .org {
  color: var(--ink-2);
  font-size: 0.94rem;
}

.timeline .note {
  color: var(--ink-3);
  font-size: 0.88rem;
  margin-top: 2px;
}

@media (max-width: 560px) {
  .timeline::before {
    left: 4px;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-left: 26px;
  }

  .timeline li::before {
    left: 0;
  }

  .timeline .when {
    text-align: left;
  }
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 5vw, 64px);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 26px;
}

.card h3 {
  margin-bottom: 0.4em;
}

.card p {
  color: var(--ink-2);
  font-size: 0.96rem;
}

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

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card .kicker {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.card.open {
  border-style: dashed;
  border-color: var(--rule-strong);
  background: transparent;
}

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

.list-clean li {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.96rem;
}

.list-clean li:first-child {
  border-top: 1px solid var(--rule);
}

.list-clean .when {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.collab {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0;
  border-top: 1px solid var(--rule);
}

.collab div {
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}

.collab b {
  display: block;
  font-weight: 500;
}

.collab span {
  font-size: 0.86rem;
  color: var(--ink-3);
}

/* ---------- Prose (opportunities, contact) ---------- */

.prose {
  max-width: 44em;
}

.prose h2 {
  margin-top: 1.6em;
}

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

.prose p,
.prose li {
  color: var(--ink-2);
  font-size: 1.05rem;
}

.prose ul {
  padding-left: 1.2em;
}

.prose li {
  margin-bottom: 0.4em;
}

.prose li::marker {
  color: var(--accent);
}

.side-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

.side-grid aside {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 16px;
}

@media (max-width: 900px) {
  .side-grid {
    grid-template-columns: 1fr;
  }

  .side-grid aside {
    position: static;
  }
}

.contact-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.contact-row:first-child {
  border-top: 1px solid var(--rule);
}

.contact-row svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex: none;
  margin-top: 3px;
}

.contact-row .k {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.contact-row .v {
  font-size: 1.05rem;
}

.contact-row .v a {
  color: var(--ink);
}

/* ---------- Figures ---------- */

/* Charts are drawn on white, so they sit on a white plate in both themes */
.plate {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.plate img {
  width: 100%;
  height: auto;
}

.fig-feature {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 6vw, 72px);
  align-items: center;
}

.fig-feature .plate img {
  padding: clamp(8px, 2vw, 20px);
}

.embed-slot iframe {
  display: block;
  width: 100%;
  height: 860px;
  border: 0;
}

.embed-slot.live {
  grid-column: 1 / -1;
}

.fig-feature.live {
  grid-template-columns: 1fr;
}

@media (max-width: 860px) {
  .fig-feature {
    grid-template-columns: 1fr;
  }
}

.fig-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.fig-grid.two {
  grid-template-columns: repeat(2, 1fr);
}

.fig-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.fig-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.fig-card .plate {
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  box-shadow: none;
  aspect-ratio: 16 / 10;
}

.fig-card .plate img {
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.fig-card-body {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.fig-card-body .kicker {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.fig-card-body p {
  color: var(--ink-2);
  font-size: 0.94rem;
}

.fig-card-body .link-arrow {
  margin-top: auto;
}

@media (max-width: 960px) {
  .fig-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .fig-grid,
  .fig-grid.two {
    grid-template-columns: 1fr;
  }
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 56px 0 40px;
  margin-top: 0;
  font-size: 0.9rem;
  color: var(--ink-2);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
}

.site-footer h4 {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.site-footer a {
  color: var(--ink-2);
  text-decoration: none;
}

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

.site-footer address {
  font-style: normal;
  line-height: 1.6;
}

.footer-base {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--ink-3);
}

.footer-base .mono {
  letter-spacing: 0.06em;
}

@media (max-width: 760px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }

  .footer-grid > :first-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Motion ---------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

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

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

  .ticker-track {
    animation: none;
  }

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

@media print {
  .site-header,
  .ticker,
  .pub-controls,
  .site-footer,
  .theme-toggle {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ---------- DNA halo (cursor) ---------- */

.dna-halo {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  user-select: none;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 22px;
  letter-spacing: 0.35em;
  white-space: pre;
  color: var(--accent);
  --dna-mut: #1f9d55;
  opacity: 0;
  transition: opacity 0.6s ease;
  /* mask-image is drawn by site.js as the cursor moves */
  -webkit-mask-image: linear-gradient(transparent, transparent);
  mask-image: linear-gradient(transparent, transparent);
}

.dna-halo.on {
  opacity: 1;
}

.dna-halo .mut {
  animation: dna-mut 0.8s ease-out forwards;
}

@keyframes dna-mut {
  from {
    color: var(--dna-mut);
  }
  to {
    color: var(--accent);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dna-halo {
    --dna-mut: #5fd68a;
  }
}

:root[data-theme="dark"] .dna-halo {
  --dna-mut: #5fd68a;
}

/* ---------- News ---------- */

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

.news-item {
  display: grid;
  grid-template-columns: 9em minmax(0, 1fr);
  gap: 8px 32px;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.news-item time {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 0.35em;
}

.news-item h2,
.news-item h3 {
  font-size: 1.3rem;
  margin: 0 0 0.3em;
}

.news-item h2 a,
.news-item h3 a {
  color: inherit;
  text-decoration: none;
}

.news-item h2 a:hover,
.news-item h3 a:hover {
  color: var(--accent);
}

.news-item p {
  margin: 0;
  color: var(--ink-2);
}

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

.page-head .eyebrow a {
  color: inherit;
}

.post-body img {
  max-width: 100%;
  height: auto;
  margin: 1.4em 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #fff;
}

.post-back {
  margin-top: 40px;
}
