:root {
  color-scheme: light dark;
  --fg: #2a2520;
  --bg: #faf6ef;
  --surface: #fffdf8;
  --muted: #74695c;
  --rule: #e6dccb;
  --accent: #1f4e8c;
  --accent-fg: #ffffff;
  --sand: #c58a2b;
  --sand-soft: #f1e4c9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ece5da;
    --bg: #1b1815;
    --surface: #25211c;
    --muted: #a59a8b;
    --rule: #39322a;
    --accent: #8db4f2;
    --accent-fg: #14171c;
    --sand: #deb262;
    --sand-soft: #3a3124;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--fg);
  background: var(--bg);
  font-family: var(--sans);
  line-height: 1.65;
}

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2.1rem;
  margin: 0 0 1rem;
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  font-size: 0.85em;
}

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.site-title img {
  border-radius: 7px;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-header nav a:hover {
  color: var(--accent);
}

.site-main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
}

.site-main.wide {
  max-width: 1080px;
}

.narrow {
  max-width: 632px;
  margin-left: auto;
  margin-right: auto;
}

.site-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.site-footer p {
  margin: 0.25rem 0;
}

.site-footer a {
  margin: 0 0.6rem;
  color: var(--muted);
}

/* ---------- landing page ---------- */

.hero {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 2.5rem;
  align-items: center;
  padding: 1.5rem 0 1rem;
}

.hero h1 {
  font-size: clamp(2rem, 4.2vw, 3rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--sand);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-figure {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  /* Figures are drawn for a light background in either colour scheme. */
  background: #fffdf8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0 0;
}

.button {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  text-decoration: none;
}

.button.ghost {
  background: transparent;
  color: var(--accent);
}

.button:hover {
  filter: brightness(1.1);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--sand);
}

.card img {
  width: 100%;
  height: 170px;
  margin-bottom: 0.6rem;
  border-radius: 8px;
  background: #fffdf8;
  object-fit: contain;
}

.card-kicker {
  color: var(--sand);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.25;
}

.card-text {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* ---------- lists of posts / projects / talks / papers ---------- */

.post-list,
.paper-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  margin-bottom: 1.5rem;
}

.post-list a {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}

.post-list a:hover {
  text-decoration: underline;
}

.post-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: 0.5rem;
}

.post-summary {
  color: var(--muted);
  margin: 0.25rem 0 0;
}

.post-body code {
  background: var(--sand-soft);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

.paper-list li {
  margin: 1.25rem 0;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--sand);
  border-radius: 10px;
  background: var(--surface);
}

.paper-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

.paper-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.paper-links {
  margin: 0.6rem 0 0;
}

.paper-links a {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
}

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

/* ---------- demo ---------- */

.demo {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  max-width: 900px;
  margin: 2rem auto 1rem;
}

.demo-controls,
.demo-main {
  margin: 0;
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--surface);
}

.demo-main figcaption,
.ref figcaption {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.demo-graph,
.ref-graph,
.simplex {
  display: block;
  width: 100%;
  height: auto;
}

.edges line {
  stroke: var(--rule);
  stroke-width: 0.6;
}

.ref-graph .edges line {
  stroke-width: 1.2;
}

.mass {
  fill: var(--sand);
  transition: r 0.18s ease-out, fill-opacity 0.18s ease-out;
}

.simplex {
  touch-action: none;
  cursor: crosshair;
  user-select: none;
}

.simplex-face {
  fill: var(--sand-soft);
  stroke: var(--sand);
  stroke-width: 2;
  stroke-linejoin: round;
}

.simplex-spoke {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
}

.simplex-label {
  fill: var(--fg);
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  text-anchor: middle;
}

.simplex-handle {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 3;
  cursor: grab;
  outline: none;
}

.simplex-handle:focus-visible {
  stroke: var(--sand);
  stroke-width: 4;
}

.weights {
  margin: 0.25rem 0 1rem;
  font-family: var(--serif);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.ref-row {
  display: flex;
  gap: 0.75rem;
}

.ref {
  flex: 1;
  margin: 0;
}

.demo-status {
  color: var(--muted);
  min-height: 1.5em;
  margin: 0.25rem auto;
}

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

@media (prefers-reduced-motion: reduce) {
  .mass,
  .card {
    transition: none;
  }
}
