/* ============================================================
   Anant Gupta — personal site
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;

  --wrap: 68rem;
  --gutter: 1.5rem;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --step: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-theme="light"] {
  --bg: #fcfcfa;
  --bg-elev: #ffffff;
  --bg-sunk: #f4f4f1;
  --text: #16181d;
  --text-soft: #4a4f57;
  --text-mute: #71767f;
  --line: #e2e2dd;
  --line-soft: #ededea;
  --accent: #1f3a68;
  --accent-soft: #eaf0f9;
  --accent-text: #1f3a68;
  --gold: #9a7d2e;
  --gold-soft: #f7f1e1;
  /* Topic hues for research tags; one per tag in the vocabulary. */
  --hue-cl: #1f5fa8;
  --hue-ml: #0f766e;
  --hue-mcl: #6b3fa0;
  --hue-sa: #a0560a;
  --hue-he: #b02a5b;
  --shadow: 0 1px 2px rgba(16, 20, 28, 0.05), 0 6px 20px -8px rgba(16, 20, 28, 0.13);
}

html[data-theme="dark"] {
  --bg: #0e1014;
  --bg-elev: #161a21;
  --bg-sunk: #12151a;
  --text: #e7e8e6;
  --text-soft: #b2b6bd;
  --text-mute: #878d97;
  --line: #262b34;
  --line-soft: #1d222a;
  --accent: #8fb3e6;
  --accent-soft: #1a2436;
  --accent-text: #a9c6f0;
  --gold: #d9c27e;
  --gold-soft: #26210f;
  --hue-cl: #8fb8ee;
  --hue-ml: #5fcfc1;
  --hue-mcl: #c3a5ef;
  --hue-sa: #efb46a;
  --hue-he: #f09ab9;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -10px rgba(0, 0, 0, 0.6);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a {
  color: var(--accent-text);
  text-decoration: none;
  text-underline-offset: 2px;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: -0.012em;
}

p {
  margin: 0 0 1rem;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 200;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus {
  left: 0;
}

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

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

.star {
  color: var(--accent-text);
  font-weight: 600;
}

/* ============================================================
   Nav
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--step), background var(--step);
}

.nav.is-stuck {
  border-bottom-color: var(--line);
}

.nav__inner {
  max-width: var(--wrap);
  margin-inline: auto;
  padding: 0.75rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav__brand {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-right: auto;
}
.nav__brand:hover {
  text-decoration: none;
  color: var(--accent-text);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 1.55rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.nav__links a {
  color: var(--text-soft);
  position: relative;
  padding-block: 0.15rem;
}

.nav__links a:hover {
  color: var(--text);
  text-decoration: none;
}

.nav__links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1.5px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--step);
}

.nav__links a:hover::after,
.nav__links a.is-current::after {
  transform: scaleX(1);
}

.nav__links a.is-current {
  color: var(--text);
}

.nav__cv {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.85rem !important;
  color: var(--text) !important;
}
.nav__cv::after {
  display: none;
}
.nav__cv:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle {
  flex-shrink: 0;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color var(--step), border-color var(--step), background var(--step);
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
}

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

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(2rem, 5vw, 3.25rem);
  border-bottom: 1px solid var(--line-soft);
  background:
    radial-gradient(52rem 30rem at 92% -8%, var(--accent-soft), transparent 70%),
    radial-gradient(36rem 22rem at -6% 0%, var(--gold-soft), transparent 70%);
}

/* The photo floats right and the intro wraps around it. The width cap keeps
   the lines under the photo at a readable length. */
.hero__text {
  max-width: 56rem;
}

.hero__text::after {
  content: "";
  display: block;
  clear: both;
}

.hero__name {
  font-family: var(--font-serif);
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  margin-bottom: 0.4rem;
}

.hero__role {
  font-size: 1.0625rem;
  color: var(--text-soft);
  margin-bottom: 1.35rem;
}

.hero__role a {
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
}
.hero__role a:hover {
  color: var(--accent-text);
  border-color: var(--accent);
  text-decoration: none;
}

.hero__lede {
  font-size: 1.0625rem;
  color: var(--text-soft);
  margin-bottom: 1.85rem;
}

.hero__lede p {
  margin-bottom: 0.8rem;
}

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

.hero__lede strong {
  color: var(--text);
  font-weight: 600;
}

.hero__lede strong.hue-cl {
  color: var(--hue-cl);
}

.hero__lede strong.hue-ml {
  color: var(--hue-ml);
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--text-soft);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--step);
}

.btn svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:hover {
  text-decoration: none;
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .btn--primary {
  color: #0e1014;
}

.btn--primary:hover {
  color: #fff;
  filter: brightness(1.12);
}

html[data-theme="dark"] .btn--primary:hover {
  color: #0e1014;
}

.hero__photo {
  float: right;
  /* Shrinks on mid-width screens so the text beside it keeps room. */
  width: clamp(11rem, 28vw, 16rem);
  margin: 0.4rem 0 1.25rem clamp(1.5rem, 4vw, 2.75rem);
}

.hero__photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: center 22%;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* ============================================================
   Sections
   ============================================================ */
.section {
  padding: clamp(2.75rem, 7vw, 4.5rem) 0;
  border-bottom: 1px solid var(--line-soft);
}

.section--tight {
  padding-block: clamp(2rem, 4vw, 2.75rem);
  background: var(--bg-sunk);
}

.section__title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.4vw, 2.05rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
}

.section__title::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
  margin-top: 0.6rem;
}

.section--tight .section__title::after {
  display: none;
}

.section--tight .section__title {
  font-size: 1.1rem;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 1rem;
}

.section__lede {
  font-size: 1.0125rem;
  color: var(--text-soft);
  max-width: 46rem;
  margin-bottom: 2rem;
}

.subhead {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-mute);
  margin: 2.25rem 0 1rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line-soft);
}

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

/* The question each research thread answers, set under its subhead. */
.thread__q {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-soft);
  margin-bottom: 1.1rem;
}

/* ---------- News ---------- */
.news {
  list-style: none;
  display: grid;
  gap: 0.6rem;
}

.news li {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr);
  gap: 1rem;
  font-size: 0.9375rem;
  color: var(--text-soft);
}

.news time {
  color: var(--accent-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  padding-top: 0.06rem;
}

.news strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Research cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1rem;
}

/* A thread with a single card: keep it card-sized instead of spanning the row. */
.cards > .card:only-child {
  max-width: 34rem;
}

.card {
  --c1: var(--accent);
  position: relative;
  overflow: hidden;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.4rem 1.5rem;
  transition: border-color var(--step), box-shadow var(--step), transform var(--step);
}

/* A thin stripe in the card's topic color(s), taken from its tags. */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--c1), var(--c2, var(--c1)));
}

.card:has(.card__tags span:first-child.tag-cl) { --c1: var(--hue-cl); }
.card:has(.card__tags span:first-child.tag-mcl) { --c1: var(--hue-mcl); }
.card:has(.card__tags span:first-child.tag-sa) { --c1: var(--hue-sa); }
.card:has(.card__tags span:first-child.tag-he) { --c1: var(--hue-he); }
.card:has(.card__tags span:nth-child(2).tag-ml) { --c2: var(--hue-ml); }

.card:hover {
  border-color: color-mix(in srgb, var(--c1) 45%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.card h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.card__meta {
  font-size: 0.8125rem;
  color: var(--text-mute);
  margin-bottom: 0.8rem;
}

.card p:not(.card__meta) {
  font-size: 0.9375rem;
  color: var(--text-soft);
}

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

/* The "why this matters to me" note — set apart from the idea above it.
   Deliberately not pinned to the card foot: the notes vary in length, so
   bottom-aligning them opens a gap mid-card without lining the rules up. */
.card__why {
  margin-top: 0.9rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line-soft);
  color: var(--text-mute) !important;
}

.card__why em {
  color: var(--text-soft);
  font-style: italic;
}

.card strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Publication filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.chip {
  padding: 0.38rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--step);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .chip.is-active {
  color: #0e1014;
}

/* ---------- Publication list ---------- */
.pubs {
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.pub {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.15rem 0;
  border-top: 1px solid var(--line-soft);
}

.pub:first-child {
  border-top: none;
}

.pub[hidden] {
  display: none;
}

.pub__venue {
  padding-top: 0.15rem;
}

.badge {
  display: inline-block;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--bg-sunk);
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge--hl {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-text);
}

.badge--muted {
  background: transparent;
  color: var(--text-mute);
  font-weight: 500;
  font-style: italic;
}

/* Home-page selected publications: the venue column is a tile, navy for
   published papers and gold for preprints. */
.pubs--selected .pub {
  grid-template-columns: 9.5rem minmax(0, 1fr);
  padding: 1.1rem 0;
}

.pub__tile {
  --t1: var(--accent);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-self: start;
  padding: 0.7rem 1rem 0.7rem 1.15rem;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--t1) 7%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--t1) 20%, transparent);
}

.pub__tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--t1);
}

.tile-pub { --t1: var(--accent-text); }
.tile-pre { --t1: var(--gold); }

.pub__tile-venue {
  font-family: var(--font-serif);
  /* Same size as the paper title beside it. */
  font-size: 1.0125rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--t1);
}

.pub__tile-venue.is-preprint {
  font-style: italic;
}

.pub__tile-year {
  font-size: 0.8rem;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

.pub__title {
  font-size: 1.0125rem;
  font-weight: 600;
  margin-bottom: 0.28rem;
  letter-spacing: -0.008em;
}

.pub__authors {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-bottom: 0.18rem;
}

.pub__authors b {
  color: var(--text);
  font-weight: 600;
}

.pub__meta {
  font-size: 0.85rem;
  color: var(--text-mute);
  margin-bottom: 0.4rem;
}

.pub__meta b {
  color: var(--text-soft);
}

.pub__links {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0;
}

.pub__links a {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.16rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-sm);
  transition: all var(--step);
}

.pub__links a:hover {
  text-decoration: none;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .pub__links a:hover {
  color: #0e1014;
}

/* Topic tags at the top of a research card. A project can carry several. */
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.7rem;
}

.card__tags span {
  --tag: var(--accent);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tag);
  background: color-mix(in srgb, var(--tag) 11%, transparent);
  padding: 0.14rem 0.5rem;
  border-radius: var(--r-sm);
}

.card__tags .tag-cl { --tag: var(--hue-cl); }
.card__tags .tag-ml { --tag: var(--hue-ml); }
.card__tags .tag-mcl { --tag: var(--hue-mcl); }
.card__tags .tag-sa { --tag: var(--hue-sa); }
.card__tags .tag-he { --tag: var(--hue-he); }

/* Paper links at the foot of a research card — same chips as the pub list. */
.card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.card__links a,
.card__links span {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.14rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--r-sm);
  transition: all var(--step);
}

.card__links span {
  color: var(--text-mute);
  border-color: var(--line);
}

.card__links a:hover {
  text-decoration: none;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html[data-theme="dark"] .card__links a:hover {
  color: #0e1014;
}

/* ---------- Timeline ---------- */
.timeline {
  list-style: none;
  display: grid;
  gap: 1.5rem;
}

.timeline li {
  display: grid;
  grid-template-columns: 10.5rem minmax(0, 1fr);
  gap: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line-soft);
}

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

.timeline__when {
  font-size: 0.85rem;
  color: var(--accent-text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}

.timeline__what h3 {
  font-size: 1.0125rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.timeline__where {
  font-size: 0.875rem;
  color: var(--text-mute);
  margin-bottom: 0.45rem;
}

.timeline__where b {
  color: var(--accent-text);
}

.timeline__what p:last-child {
  font-size: 0.9375rem;
  color: var(--text-soft);
  margin-bottom: 0;
}

/* ---------- Two column + plain lists ---------- */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: clamp(2rem, 5vw, 3.5rem);
}

.plain {
  list-style: none;
  display: grid;
  gap: 0.85rem;
  font-size: 0.9375rem;
  color: var(--text-soft);
}

.plain li {
  padding-left: 1rem;
  border-left: 2px solid var(--line);
}

.plain b {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Contact ---------- */
.section--contact {
  background: var(--bg-sunk);
  border-bottom: none;
}

.contact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: start;
}

.contact__primary {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.35rem;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all var(--step);
}

html[data-theme="dark"] .contact__primary {
  color: #0e1014;
}

.contact__primary:hover {
  text-decoration: none;
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.contact__primary svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.contact__list {
  list-style: none;
  display: grid;
  gap: 0.75rem;
  font-size: 0.9375rem;
  color: var(--text-soft);
}

.contact__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 0.1rem;
}

/* ---------- "All publications →" link ---------- */
.more {
  margin: 1.75rem 0 0;
  font-size: 0.9375rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.more__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

.more__link svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--step);
}

.more__link:hover svg {
  transform: translateX(3px);
}

/* ============================================================
   Sub-pages: publications, writing, posts
   ============================================================ */
.wrap--narrow {
  max-width: 44rem;
}

.page-head {
  padding-top: clamp(2.25rem, 5vw, 3.25rem);
  border-bottom: none;
}

.page-title {
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 5vw, 2.9rem);
  font-weight: 500;
  letter-spacing: -0.022em;
  margin-bottom: 0.6rem;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-mute);
  margin-bottom: 1.75rem;
}

.backlink:hover {
  color: var(--accent-text);
  text-decoration: none;
}

.backlink svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--step);
}

.backlink:hover svg {
  transform: translateX(-3px);
}

/* ---------- Post list ---------- */
.postlist {
  list-style: none;
  display: grid;
  gap: 0;
  margin-top: 0.5rem;
}

.postlist__item {
  border-top: 1px solid var(--line-soft);
}

.postlist__item:first-child {
  border-top: none;
}

.postlist__link {
  display: grid;
  grid-template-columns: 6rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.15rem 0.75rem 1.15rem 0;
  border-radius: var(--r-md);
  color: inherit;
  transition: background var(--step), padding-left var(--step);
}

.postlist__link:hover {
  text-decoration: none;
  background: var(--bg-sunk);
  padding-left: 0.75rem;
}

.postlist__link time {
  font-size: 0.85rem;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  padding-top: 0.15rem;
}

.postlist__title {
  display: block;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.2rem;
}

.postlist__link:hover .postlist__title {
  color: var(--accent-text);
}

.postlist__summary {
  display: block;
  font-size: 0.9125rem;
  color: var(--text-soft);
}

/* ---------- Post body ---------- */
.post {
  border-bottom: none;
}

.post__title {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4.6vw, 2.65rem);
  font-weight: 500;
  letter-spacing: -0.022em;
  margin-bottom: 0.45rem;
}

.post__date {
  font-size: 0.875rem;
  color: var(--text-mute);
  margin-bottom: 2.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}

.prose {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text-soft);
}

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

.prose h2 {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 500;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.016em;
}

.prose h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.6rem;
}

.prose p {
  margin: 0 0 1.25rem;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose ul,
.prose ol {
  margin: 0 0 1.25rem;
  padding-left: 1.35rem;
}

.prose li {
  margin-bottom: 0.55rem;
}

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

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--text-mute);
  font-style: italic;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--bg-sunk);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 0.1em 0.36em;
}

.prose pre {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow-x: auto;
  line-height: 1.6;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.prose img {
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  margin: 1.5rem 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  margin: 0 0 1.5rem;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}

.prose th {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--line);
}

.prose .footnote {
  font-size: 0.9rem;
  color: var(--text-mute);
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding-top: 0.5rem;
}

/* KaTeX should inherit our body colour and scroll rather than overflow. */
.prose .katex {
  color: var(--text);
  font-size: 1.02em;
}

.prose .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.35rem 0;
}

/* ---------- Footer ---------- */
.footer {
  padding: 2.5rem 0 3rem;
  font-size: 0.875rem;
  color: var(--text-soft);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: flex-end;
}

.footer p {
  margin: 0;
}

.footer__meta {
  font-size: 0.8125rem;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 860px) {
  .nav__links {
    gap: 1.1rem;
    font-size: 0.8125rem;
  }
}

@media (max-width: 640px) {
  /* Phones: the photo sits above the name instead of floating. */
  .hero__photo {
    float: none;
    width: 8.5rem;
    margin: 0 0 1.5rem;
  }

  .nav__brand {
    display: none;
  }

  /* Let the links scroll sideways rather than dropping them entirely. */
  .nav__links {
    margin-right: auto;
    gap: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-block: 0.2rem;
  }

  .nav__links::-webkit-scrollbar {
    display: none;
  }

  .nav__links a {
    white-space: nowrap;
  }

  .pub,
  .timeline li,
  .news li,
  .postlist__link,
  .contact {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.5rem;
  }

  .contact {
    gap: 1.5rem;
  }

  .contact__primary {
    justify-content: center;
  }

  .pub__venue {
    padding-top: 0;
  }

  /* On phones the tile becomes a compact strip above the title. */
  .pubs--selected .pub {
    grid-template-columns: minmax(0, 1fr);
  }

  .pub__tile {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.5rem;
    padding: 0.45rem 0.8rem 0.45rem 0.95rem;
  }

  .pub__tile-venue {
    font-size: 1.1rem;
  }

  .timeline__when {
    padding-top: 0;
    order: 2;
  }
}

/* ---------- Motion / print ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .nav,
  .filters,
  .theme-toggle,
  .hero__links,
  .skip-link {
    display: none !important;
  }
  .section,
  .hero {
    border: none;
    padding-block: 1rem;
  }
  body {
    background: #fff;
    color: #000;
  }
}
