/* ---------- Tokens ---------- */
:root {
  --sidebar-w: max(320px, 35vw);           /* About a third of the window, at any screen size */
  --bg: #fbfaf8;
  --text: #2a2622;
  --muted: #6f665e;
  --rule: #e6e1db;
  --accent: #8a5a3c;        /* warm brown, a nod to the old site */
  --accent-soft: #f3ebe4;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* Everything is sized in rem, and 1rem grows with the window: ~18px on a laptop, ~23px on a big monitor */
html { scroll-behavior: smooth; font-size: clamp(17px, 9.5px + 0.375vw, 24px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.7 var(--sans);
}

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: currentColor; }

img, video { max-width: 100%; height: auto; display: block; border-radius: 4px; }

/* ---------- Sidebar (fixed, your background photo) ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4rem 2rem 2rem;
  color: #fff;
  overflow: hidden;
  z-index: 10;
}
.sidebar::before {                       /* blurred background photo */
  content: "";
  position: absolute;
  inset: -20px;
  background: url(media/background.jpg) 25% center / cover;
  filter: blur(4px);
  z-index: -2;
}
.sidebar::after {                        /* darkening so text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(20, 28, 20, .45), rgba(20, 24, 18, .7));
  z-index: -1;
}

.sidebar .portrait {
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 15%;
  border: 4px solid rgba(255, 255, 255, .85);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.sidebar .name {
  font: 600 2rem/1.2 var(--serif);
  margin: 1.2rem 0 .3rem;
  text-align: center;
}
.sidebar .name a { color: #fff; border: 0; }
.sidebar .role {
  font-size: 1rem;
  opacity: .85;
  text-align: center;
  margin: 0 0 2rem;
}
.sidebar nav { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.sidebar nav a {
  color: rgba(255, 255, 255, .88);
  font-size: 1.35rem;
  padding: .1rem .7rem;
  border: 0;
  border-radius: 4px;
}
.sidebar nav a:hover, .sidebar nav a.active { color: #fff; background: rgba(255, 255, 255, .14); }
.sidebar .links {
  margin-top: auto;
  display: flex;
  gap: .8rem;
  font-size: .95rem;
}
.sidebar .links a { color: rgba(255, 255, 255, .8); border: 0; }
.sidebar .links a:hover { color: #fff; }

/* ---------- Main scrollable column ---------- */
main {
  margin-left: var(--sidebar-w);
  max-width: 50rem;
  padding: 4rem 3.5rem 5rem;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.3rem; margin: 0 0 .4em; }
h2 {
  font-size: 1.7rem;
  margin: 2.4em 0 .8em;
  padding-bottom: .3em;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 24px;
}
section:first-child h2 { margin-top: 0; }
h3 { font-size: 1.2rem; margin: 1.6em 0 .3em; }

.lede { font-size: 1.1rem; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .8rem; font-style: italic; margin-top: -.4em; }   /* small side remark */

/* A list of dated entries (experience, education, talks) */
.entries { list-style: none; padding: 0; margin: 0; }
.entries li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .5rem 0; }
.entries .when { color: var(--muted); font-size: .88rem; padding-top: 2px; }
.entries .what strong { display: block; }
.entries .what p { margin: .25em 0 0; font-size: .92rem; color: var(--muted); }

/* A research project: text on the left, a picture on the right */
.project { display: grid; grid-template-columns: 1fr 34%; gap: 2rem; align-items: start; margin: 1.5rem 0 2rem; }
.project > div > p:first-child { margin-top: 0; }
.project-area { font-weight: 600; margin-bottom: .1em; }                                        /* the general area: bold */
.project-name { font: italic 1.08rem/1.4 var(--serif); color: var(--accent); margin-top: 0; }  /* the specific project: brown serif italic */
.project figure { margin: 2rem 0 0; }
/* "PDEs: Einstein <=> Euler" with underbraces, above the project picture */
.coupling { display: flex; justify-content: center; align-items: flex-start; gap: .45rem; margin-bottom: .9rem; font: 1.05rem/1.2 var(--serif); }
.coupling .pdes { color: var(--muted); font-size: .85em; padding-top: .1em; }
.coupling .term { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.coupling .brace { width: 100%; min-width: 3.5rem; height: .45rem; margin-top: .15rem; overflow: visible; }
.coupling .brace path { fill: none; stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.coupling small { font: .7rem/1.2 var(--sans); color: var(--muted); margin-top: .2rem; }
.coupling .arrow { color: var(--accent); }
.project figcaption { font-size: .75rem; color: var(--muted); margin-top: .4rem; line-height: 1.4; }

/* Publications */
.pubs { list-style: none; padding: 0; }
.pubs li { margin-bottom: 1em; }
.pubs .title { font-weight: 600; }
.pubs .authors { display: block; color: var(--muted); }   /* author line under the title; yours is <strong> */

/* Recent blog posts on the home page + blog index */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { display: grid; grid-template-columns: 7rem 1fr; gap: 1.1rem; padding: .9rem 0; border-bottom: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: 0; }
.post-list .thumb { width: 7rem; height: 5rem; object-fit: cover; background: var(--accent-soft); border-radius: 4px; }
.post-list .thumb.empty { display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: .75rem; }
.post-list h3 { margin: 0 0 2px; font-size: 1.08rem; }
.post-list h3 a { color: var(--text); }
.post-list p { margin: 4px 0 0; font-size: .93rem; color: var(--muted); }
.meta { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tag { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 6px; margin-left: 6px; text-transform: none; letter-spacing: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.filters button {
  font: inherit; font-size: .85rem;
  background: none; border: 1px solid var(--rule); border-radius: 20px;
  padding: 3px 12px; cursor: pointer; color: var(--muted);
}
.filters button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* A single post */
article.post { font-size: 1rem; }
article.post img, article.post video { margin: 1.4em auto .4em; }
article.post figure { margin: 1.6em 0; }
article.post figure img, article.post figure video { max-height: 70vh; width: auto; }   /* single photos/videos: at most 70% of screen height */
article.post figcaption { font-size: .88rem; color: var(--muted); text-align: center; }
article.post .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 10px; }
article.post .gallery img { margin: 0; aspect-ratio: 4/3; object-fit: cover; width: 100%; }
article.post .gallery.tall img { aspect-ratio: 3/4; }
article.post blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
article.post pre { background: #f1eee9; padding: 12px 16px; border-radius: 4px; overflow-x: auto; font-size: .88rem; }
article.post code { font-size: .9em; }
.back { display: inline-block; margin-bottom: 24px; font-size: .9rem; }

footer { margin-top: 64px; font-size: .8rem; color: var(--muted); }

/* ---------- Phones / narrow screens: same two columns, just slimmer ---------- */
@media (max-width: 860px) {
  html { font-size: 15px; }
  :root { --sidebar-w: 30vw; }
  .sidebar { padding: 1.6rem .5rem 1rem; overflow-y: auto; }   /* scrolls on its own if the phone is held sideways */
  .sidebar::before { background-position: 30% center; }
  .sidebar .portrait { width: min(20vw, 7rem); height: min(20vw, 7rem); border-width: 2px; }
  .sidebar .name { font-size: 1.05rem; margin: .7rem 0 .2rem; }
  .sidebar .role { font-size: .68rem; margin-bottom: 1.1rem; }
  .sidebar nav a { font-size: .9rem; padding: .05rem .4rem; }
  .sidebar .links { flex-direction: column; align-items: center; gap: .15rem; font-size: .75rem; }
  main { padding: 1.5rem .9rem 3rem; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .entries li { grid-template-columns: 1fr; gap: 2px; }
  .project { grid-template-columns: 1fr; gap: 1rem; }
  .project figure { max-width: 22rem; margin-top: 0; }
  .post-list li { grid-template-columns: 1fr; gap: .4rem; }
  .post-list .thumb { width: 100%; height: 7rem; }
  article.post .gallery { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
}
