:root {
  --bg: #ffffff;
  --text: #1d1f23;
  --muted: #5d636e;
  --faint: #a3a8b1;
  --rule: #e6e8ec;
  --link: #1f5fa8;
  --link-hover: #0d3d73;
  --accent: #2a7f86;          /* teal, shared with the landscape palette */

  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --measure: 720px;
  --rail: 0px;                /* width reserved for the landscape scrollbar */
}

@media (min-width: 1100px) {
  :root { --rail: 260px; }
}
@media (min-width: 1400px) {
  :root { --rail: 340px; }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* The landscape replaces the native scrollbar only when JS has turned it on. */
html.has-landscape { scrollbar-width: none; }
html.has-landscape::-webkit-scrollbar { display: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
}
html.has-landscape body { padding-right: var(--rail); }

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}
.topbar.is-scrolled .topbar__inner { box-shadow: 0 1px 0 var(--rule); }
.topbar__inner {
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: baseline;
  transition: box-shadow 0.2s;
}
.topbar__nav {
  display: flex;
  gap: 28px;
  font-size: 0.92rem;
  font-weight: 500;
}
.topbar__nav a { color: var(--muted); }
.topbar__nav a:hover { color: var(--text); text-decoration: none; }
.topbar__nav a.is-active { color: var(--text); }

.page {
  max-width: calc(var(--measure) + 48px);
  margin: 0 auto;
  padding: 32px 24px 48px;
}

section { margin-top: 64px; scroll-margin-top: 72px; }

h2 {
  font-size: 1.45rem;
  margin: 0 0 24px;
}

/* ---------- Intro ---------- */
.intro {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 40px;
  align-items: start;
}
.intro h1 {
  font-size: 2.1rem;
  margin: 0 0 20px;
}
.intro p { margin: 0 0 14px; }
.intro__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  margin-top: 20px;
  font-weight: 500;
}
.links a + a::before {
  content: "/";
  color: var(--faint);
  margin: 0 10px;
  display: inline-block;
}

/* ---------- Publications ---------- */
.pub {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
}
.pub:last-child { border-bottom: 1px solid var(--rule); }
.pub__media img,
.pub__media video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 6px;
}
.pub h3 {
  font-size: 1.08rem;
  margin: 0 0 6px;
}
.pub h3 a { color: var(--text); }
.pub h3 a:hover { color: var(--link); }
.pub p { margin: 0 0 4px; font-size: 0.94rem; }
.pub__authors { color: var(--muted); }
.pub__authors strong { color: var(--text); font-weight: 600; }
.pub__venue { font-style: italic; color: var(--muted); }
.pub__links { margin-top: 8px !important; }
.pub__links a + a::before {
  content: "·";
  color: var(--faint);
  margin: 0 8px;
  display: inline-block;
}

/* ---------- Learning trail ---------- */
.lede { margin: 0 0 16px; }
.lede:last-of-type { margin-bottom: 32px; }

.trail {
  --node: 14px;
  --gutter: 40px;              /* space left of each card for the trail */
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Fallback trail (no JS / narrow screens): a straight dotted line. */
.trail::before {
  content: "";
  position: absolute;
  left: calc(var(--node) / 2 - 1px);
  top: 12px;
  bottom: 12px;
  border-left: 2px dotted var(--faint);
}
.trail.is-drawn::before { display: none; }

.trail__path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.trail__path path {
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 0.1 7;
}
.trail__path path.is-upcoming { stroke: var(--rule); }

.stop {
  position: relative;
  padding-left: var(--gutter);
  margin-bottom: 40px;
}
.stop:last-child { margin-bottom: 0; }

/* Alternate stops drift right so the trail meanders (wide screens only). */
@media (min-width: 700px) {
  .stop:nth-of-type(even) { margin-left: 56px; }
}

.stop__node {
  position: absolute;
  left: 0;
  top: 6px;
  width: var(--node);
  height: var(--node);
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  z-index: 1;
}
.stop__node::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
}

.stop__meta {
  margin: 0 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.stop__kind {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.stop h3 {
  font-size: 1.12rem;
  margin: 0 0 8px;
}
.stop p { margin: 0 0 10px; font-size: 0.96rem; }

.stop__files {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.stop__files a {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
}
.stop__files a:hover {
  border-color: var(--link);
  text-decoration: none;
}

/* Optional embedded media inside a stop (video, image, iframe). */
.stop__media { margin: 12px 0 0; }
.stop__media > * {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 8px;
}
.stop__media iframe { aspect-ratio: 16 / 9; height: auto; }

.stop--upcoming { color: var(--faint); }
.stop--upcoming .stop__kind { color: var(--faint); }
.stop--upcoming h3 { color: var(--faint); font-weight: 400; }
.stop--upcoming .stop__node { border-color: var(--rule); border-style: dashed; }
.stop--upcoming .stop__node::after { display: none; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 96px;
  font-size: 0.82rem;
  color: var(--faint);
}

/* ---------- Landscape scrollbar ---------- */
.landscape { display: none; }

html.has-landscape .landscape {
  display: block;
  position: fixed;
  top: 0;
  right: 0;
  width: var(--rail);
  height: 100vh;
  height: 100dvh;
  z-index: 10;
  cursor: ns-resize;
  touch-action: none;
}
.hero-landscape { display: none; }

.landscape canvas,
.hero-landscape canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
/* Fade the contours into the page on the side nearest the content. */
.landscape__field {
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 60%);
          mask-image: linear-gradient(to right, transparent 0%, #000 60%);
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .page { padding: 20px 18px 32px; }
  section { margin-top: 48px; }

  .intro {
    grid-template-columns: 128px 1fr;
    grid-template-areas: "photo land" "text text";
    gap: 20px 0;
  }
  .intro__text { grid-area: text; }
  .intro__photo { grid-area: photo; }
  .hero-landscape {
    grid-area: land;
    display: block;
    position: relative;
    height: 128px;
  }
  /* Contours fade out toward the photo; the ball stays crisp. */
  .hero-landscape .landscape__field {
    -webkit-mask-image:
      linear-gradient(to right, transparent 0%, #000 45%, #000 85%, transparent 100%),
      linear-gradient(to bottom, transparent 0%, #000 15%, #000 85%, transparent 100%);
    -webkit-mask-composite: source-in;
            mask-image:
      linear-gradient(to right, transparent 0%, #000 45%, #000 85%, transparent 100%),
      linear-gradient(to bottom, transparent 0%, #000 15%, #000 85%, transparent 100%);
            mask-composite: intersect;
  }
  .intro__photo img { aspect-ratio: 1; border-radius: 50%; object-position: 50% 30%; }
  .intro h1 { font-size: 1.75rem; }

  .pub { grid-template-columns: 1fr; gap: 14px; }
  .pub__media img,
  .pub__media video { aspect-ratio: auto; }

  .topbar__inner { padding: 12px 18px; }
  .topbar__nav { gap: 20px; }

  .trail { --gutter: 30px; }
}
