/* One stylesheet for the whole site. The two blocks of variables below
   (light, then dark) are the only things you should need to change. */

:root {
  --text: #1f2328;
  --muted: #5f6670;
  --rule: #e2e4e8;
  --accent: #1f4e8c;      /* links — the only colour on the site */
  --bg: #ffffff;
  --surface: #f6f7f9;     /* cards, code blocks, placeholders */
  --code-bg: #f6f8fa;
  --measure: 59rem;       /* width of the page column, about 1000px */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --toggle-bg: #1f2328;   /* the toggle shows the other mode: dark here */
  --toggle-fg: #f6f7f9;
  color-scheme: light;
}

[data-theme="dark"] {
  --text: #e3e6ea;
  --muted: #9aa3ad;
  --rule: #2c333c;
  --accent: #82aef0;
  --bg: #12161b;          /* deep blue-grey rather than pure black */
  --surface: #1a2027;
  --code-bg: #161b22;
  --toggle-bg: #f6f7f9;   /* ...and light here */
  --toggle-fg: #1f2328;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

body {
  margin: 0 auto;
  max-width: var(--measure);
  padding: 2rem 1.25rem 3rem;
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

html { background: var(--bg); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 2.5rem 0 1rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
h3 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }

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

/* Header and footer */

.site-header {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 0.5rem 1.5rem;
  margin-bottom: 2.5rem;
}
.site-title { font-weight: 600; font-size: 1.1rem; color: var(--text); }
/* On the home page the big name right below already says it: no name in the header, menu stays on the right */
.home .site-title { display: none; }
.home .site-header { justify-content: flex-end; }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.25rem; }
.site-header nav a { position: relative; padding: 0.2rem 0; font-weight: 500; color: var(--muted); }
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
/* A short bar under the menu item for the page you're on (faint on hover), in
   the item's own colour (`colour` in the nav list in _config.yml) */
.site-header nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -0.2rem; height: 3px; border-radius: 2px;
  background: var(--nav-colour, var(--accent)); opacity: 0;
}
.site-header nav a:hover::after { opacity: 0.35; }
.site-header nav a[aria-current="page"]::after { opacity: 1; }

.site-footer {
  margin-top: 4rem; padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem; color: var(--muted);
}

/* Light/dark toggle */

.theme-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font: inherit; font-size: 0.85rem; font-weight: 500; color: var(--toggle-fg);
  background: var(--toggle-bg); border: 1px solid var(--toggle-bg); border-radius: 999px;
  padding: 0.25rem 0.75rem; cursor: pointer;
}
.theme-toggle:hover { opacity: 0.85; }
.theme-toggle svg { width: 0.95rem; height: 0.95rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
.icon-sun, .label-light { display: none; }
[data-theme="dark"] .icon-sun, [data-theme="dark"] .label-light { display: inline; }
[data-theme="dark"] .icon-moon, [data-theme="dark"] .label-dark { display: none; }

/* Placeholders: shown only in the local preview, for media not yet added */

.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  aspect-ratio: 16 / 9; padding: 1rem;
  background: var(--surface); border: 1px dashed var(--rule); border-radius: 6px;
  color: var(--muted); font-size: 0.85rem;
}
.placeholder code { background: none; word-break: break-all; }
.placeholder-note { color: var(--muted); font-size: 0.9rem; }

/* Unpublished pages: only built in the local preview, so this never shows publicly */
.unpublished-note {
  padding: 0.6rem 0.8rem; margin: 0 0 1.5rem;
  background: var(--surface); border: 1px dashed var(--rule); border-radius: 6px;
  color: var(--muted); font-size: 0.9rem;
}
.unpublished-tag {
  display: inline-block; padding: 0.05rem 0.45rem; margin-right: 0.3rem;
  border: 1px solid var(--muted); border-radius: 999px;
  color: var(--muted); font-size: 0.75rem; font-weight: 600; vertical-align: middle;
}

/* Home page */

.intro { display: flow-root; margin-bottom: 1rem; }   /* the bio wraps around the photo */
.intro h1 { margin-top: 0.25rem; }
.role { margin: 0 0 1.25rem; color: var(--muted); }
.bio > p:first-of-type { margin-top: 0; }   /* so the photo's top lines up with the bio's first line */
.photo {
  float: right; width: min(18rem, 42%); margin: 0.3rem 0 1rem 2rem;
  aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px;   /* landscape; 4 / 5 for a portrait */
}
@media (max-width: 34rem) {
  .photo { float: none; display: block; width: 100%; max-width: 20rem; margin: 0 0 1.25rem; }
}

/* Interests and education, under the bio */

.about { display: grid; grid-template-columns: 1fr 1fr; gap: 0 3rem; margin: 1.5rem 0 1rem; }
.about h3 { margin: 0 0 0.5rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.about ul { list-style: none; padding: 0; margin: 0; font-size: 0.95rem; }
.interests li { margin-bottom: 0.2rem; }
.education li { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 0.5rem; }
.education .icon { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; fill: var(--muted); }
.education small { display: block; color: var(--muted); font-size: 0.85rem; }
.education .thesis { margin-top: 0.15rem; }
@media (max-width: 34rem) {
  .about { grid-template-columns: 1fr; gap: 1.25rem; }
}

/* News */

.news { list-style: none; padding: 0; margin: 0; }
.news li { margin-bottom: 0.6rem; }
.news time { font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 0.3rem; }
.news li.has-pic {
  display: grid; grid-template-columns: 1fr 10rem; gap: 0 2rem; align-items: start;
  margin: 1.25rem 0;
}
.news-pic { display: block; width: 100%; height: auto; border-radius: 6px; }
.news-pic.placeholder { aspect-ratio: 4 / 3; }
/* The News page as a timeline: a line down the left, a dot and the date above each item */
.news.timeline { border-left: 2px solid var(--rule); margin-left: 0.4rem; }
.news.timeline li, .news.timeline li.has-pic { position: relative; margin: 0; padding: 0 0 1.4rem 1.4rem; }
.news.timeline li:last-child { padding-bottom: 0.2rem; }
.news.timeline li::before {
  content: ""; position: absolute; left: -0.42rem; top: 0.35rem; width: 0.7rem; height: 0.7rem;
  border-radius: 50%; background: var(--dot, var(--accent)); border: 2px solid var(--bg);
}
.news.timeline time { display: block; font-size: 0.85rem; margin-bottom: 0.15rem; }
@media (max-width: 34rem) {
  .news li.has-pic { grid-template-columns: 1fr; gap: 0.6rem; }
  .news-pic { max-width: 16rem; }
}

/* Publications */

.bibliography { list-style: none; padding: 0; margin: 0; }
.bibliography li { margin-bottom: 1.5rem; }
.pub > span { display: block; }
.pub-title { font-weight: 600; }
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-status { font-style: italic; }
.pub-authors, .pub-venue { color: var(--muted); }
.pub-authors strong { color: var(--text); font-weight: 600; }
.pub-links { display: flex !important; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.pub[hidden] { display: none; }

/* The Publications page, grouped by year: the year large in a left column */
.pub-year { display: grid; grid-template-columns: 5.5rem 1fr; gap: 0 1.5rem; padding: 1.25rem 0; border-top: 1px solid var(--rule); }
.pub-year[hidden] { display: none; }
.pub-year-label { margin: 0; padding: 0; border: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: var(--pop-3); }
.pub-year .bibliography li:last-child { margin-bottom: 0; }
@media (max-width: 34rem) {
  .pub-year { grid-template-columns: 1fr; }
  .pub-year-label { margin-bottom: 0.6rem; }
}

/* Small outlined link buttons (paper links) and the publication filter */

.btn {
  display: inline-block; font-size: 0.78rem; line-height: 1; padding: 0.3rem 0.65rem;
  border: 1px solid var(--accent); border-radius: 999px; color: var(--accent);
}
.btn:hover { text-decoration: none; background: var(--accent); color: var(--bg); }

.pub-filter { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0 1.75rem; }
.pub-filter[hidden] { display: none; }
.pub-filter button {
  font: inherit; font-size: 0.85rem; padding: 0.35rem 0.9rem; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--rule); border-radius: 999px;
}
.pub-filter button:hover { color: var(--text); background: var(--surface); }
.pub-filter button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

/* Blog */

.meta { color: var(--muted); margin-top: 0; }
.post-list { list-style: none; padding: 0; }
.post-list li { margin-bottom: 1.25rem; }
.post-list time { display: block; color: var(--muted); font-size: 0.9rem; }
.post-list p { margin: 0.2rem 0 0; color: var(--muted); }
.back { margin-top: 3rem; }

figure { margin: 2rem 0; }
figcaption { font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; }
.media img { display: block; width: 100%; border-radius: 4px; }

/* Research */

/* The Research page: one large row per thread, figure and text side by side,
   the figure swapping sides from row to row (stacked on a phone) */
.cards { display: grid; gap: 3rem; margin-top: 1.75rem; }
.card {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2.25rem; align-items: center;
  color: var(--text);
}
.card:hover { text-decoration: none; }
.card + .card { padding-top: 3rem; border-top: 1px solid var(--rule); }   /* a thin line between rows */
.card:nth-child(even) .media { order: 2; }
.card .media { margin: 0; }
.card .media img, .card .placeholder { aspect-ratio: 4 / 3; }
.card h2 { font-size: 1.35rem; margin: 0 0 0.6rem; padding: 0; border: 0; }
.card:hover h2 { color: var(--accent); }
.card:hover .media img { border-color: var(--pop-4); }
.card p { margin: 0 0 0.6rem; color: var(--muted); }
.card .more { color: var(--accent); font-size: 0.9rem; }
@media (max-width: 34rem) {
  .card { grid-template-columns: 1fr; gap: 1rem; }
  .card:nth-child(even) .media { order: 0; }
}

/* Research figures sit in a white frame, so paper figures (mostly on white)
   look clean in both light and dark mode */
.card .media img, .research .media img {
  object-fit: contain; background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 0.5rem;
}

/* A short blue bar under headings: Research card titles and research page sections */
.card h2::after, .research h2::after {
  content: ""; display: block; width: 2.5rem; height: 3px; margin-top: 0.5rem; border-radius: 2px; background: var(--pop-4);
}

/* One research page */
.research h1 { font-size: 2rem; }
.research .lead { font-size: 1.15rem; max-width: 44rem; }
.research h2 { border-bottom: 0; padding-bottom: 0; margin-top: 3rem; }
.research .media img { width: auto; max-width: min(100%, 44rem); max-height: 34rem; margin: 0 auto; }
.research .media .placeholder, .research figcaption { max-width: 44rem; margin-left: auto; margin-right: auto; }

/* "← All research" / "← All posts" as a button */
.back a { display: inline-block; border: 1px solid var(--accent); border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.back a:hover { text-decoration: none; background: var(--accent); color: var(--bg); }

.lead { font-size: 1.1rem; color: var(--muted); margin-top: 0; }
.code-list { padding-left: 1.2rem; }

.code-entries { list-style: none; padding: 0; margin: 0; }
.code-entries li { margin-bottom: 1.5rem; }
.code-entries li > span { display: block; }
.code-name { font-weight: 600; font-family: var(--mono); }
.code-role { font-family: var(--font); font-weight: 400; font-size: 0.85rem; color: var(--muted); margin-left: 0.4rem; }
.code-desc { color: var(--muted); }

code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 0.1em 0.3em; border-radius: 3px; }
pre { background: var(--code-bg); padding: 1rem; overflow-x: auto; border-radius: 4px; line-height: 1.45; }
pre code { background: none; padding: 0; }

blockquote { margin: 1.5rem 0; padding-left: 1rem; border-left: 3px solid var(--rule); color: var(--muted); }

mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; }

/* Tangents: coloured link tiles, the one colourful page. The five tile
   colours repeat in order; the dark-mode versions are deeper shades. */

:root {
  --fav-1: #fde2e4; --fav-2: #fff1c1; --fav-3: #d8f3dc; --fav-4: #dbeafe; --fav-5: #ede4ff;
  /* stronger shades of the same five, for small marks (menu bars, home page); 0 is neutral */
  --pop-0: var(--text);
  --pop-1: #e0727f; --pop-2: #d9a93a; --pop-3: #5aa36b; --pop-4: #5b8fd9; --pop-5: #9a7fd6;
  --dot-old: #b4bac2;   /* the grey the News page's timeline dots fade to */
}
[data-theme="dark"] {
  --fav-1: #3d2329; --fav-2: #3a321d; --fav-3: #1d3626; --fav-4: #1c2c45; --fav-5: #2d2544;
  --pop-1: #f08a96; --pop-2: #e8bf5a; --pop-3: #6fbf80; --pop-4: #7aa8ec; --pop-5: #b39cf0;
  --dot-old: #5d6670;
}
.favs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.75rem; }
.fav {
  display: flex; flex-direction: column; gap: 0.5rem; min-height: 8.5rem;
  padding: 1rem 1.1rem; border: 1px solid transparent; border-radius: 10px;
  color: var(--text); background: var(--fav-1);
}
.fav:nth-child(5n+2) { background: var(--fav-2); }
.fav:nth-child(5n+3) { background: var(--fav-3); }
.fav:nth-child(5n+4) { background: var(--fav-4); }
.fav:nth-child(5n+5) { background: var(--fav-5); }
.fav:hover { text-decoration: none; border-color: var(--text); }
.fav-title { font-weight: 600; font-size: 1.05rem; line-height: 1.3; }
.fav-comment { font-size: 0.9rem; line-height: 1.45; }
.fav-label { margin-top: auto; font-size: 0.8rem; color: var(--muted); }
/* Below the tiles: one xkcd comic, picked at random on each visit */
.comic { margin-top: 3rem; padding-top: 2.5rem; border-top: 1px solid var(--rule); }
.xkcd { margin: 0; text-align: center; }
.xkcd[hidden] { display: none; }
.xkcd img { max-width: 100%; height: auto; background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 0.75rem; }
.xkcd figcaption { max-width: 36rem; margin: 0.75rem auto 0; }
.xkcd-alt { display: block; font-style: italic; }
.xkcd-credit { display: block; margin-top: 0.4rem; font-size: 0.8rem; }
@media (max-width: 40rem) {
  .favs { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .fav { padding: 0.85rem; min-height: 7.5rem; }
  .fav-title { font-size: 0.98rem; }
}

/* Home page touches: a bigger name, a short coloured bar under each section
   heading (colours from the Tangents tile palette), interests as soft tags,
   contact links as buttons, and pink timeline dots for the news */

.home .intro h1 { font-size: 2.2rem; letter-spacing: -0.01em; }
/* The intro (name, title, bio, photo) in a soft tinted panel. On trial: delete these two lines to remove it. */
.home .intro { background: color-mix(in srgb, var(--accent) 6%, var(--bg)); border-radius: 14px; padding: 1.75rem 1.75rem 0.75rem; }
@media (max-width: 34rem) { .home .intro { padding: 1.25rem 1.1rem 0.5rem; } }
.home h2 { border-bottom: 0; padding-bottom: 0; margin-top: 3rem; }
.home h2::after { content: ""; display: block; width: 2.5rem; height: 3px; margin-top: 0.45rem; border-radius: 2px; background: var(--accent); }
.home h2#news::after { background: var(--pop-1); }
.home h2#research::after { background: var(--pop-4); }
.home h2#recent-publications::after { background: var(--pop-3); }
.home .news.timeline li::before { background: var(--pop-1); }
.home .interests { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.home .interests li { margin: 0; padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.88rem;
  background: color-mix(in srgb, var(--accent) 10%, transparent); }
.contact { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.5rem 0; }
.btn.pill { border-radius: 999px; padding: 0.45rem 0.9rem; font-size: 0.85rem; }

/* Home page: one tile per research thread */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.tile { display: flex; flex-direction: column; gap: 0.3rem; color: var(--text); }
.tile:hover { text-decoration: none; }
.tile:hover .tile-title { color: var(--accent); }
.tile .media { margin: 0 0 0.3rem; }
.tile .media img, .tile .placeholder { aspect-ratio: 1 / 1; object-fit: cover; border-radius: 6px; }
.tile-title { font-weight: 600; line-height: 1.3; }
.tile-caption { font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
@media (max-width: 34rem) {
  .tiles { grid-template-columns: 1fr; }
  .tile .media img, .tile .placeholder { aspect-ratio: 16 / 10; }
}
