/* ==========================================================================
   Personal site stylesheet. No frameworks, no web fonts, no JavaScript.
   Colors/spacing live in the variables below; change them here only.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5d6472;
  --line: #e5e7ec;
  --accent: #2f5bea;
  --chip: #f4f5f8;
  --chip-hover: #e9ecf3;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 52rem;
  --radius: 0.5rem;

  color-scheme: light dark;
}

/* Dark palette. Applied (a) when the visitor picked dark via the toggle, or (b) with no
   JavaScript, when the system prefers dark and nothing was chosen. Keep both in sync. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --fg: #e8eaef;
  --muted: #9ba2b0;
  --line: #262a33;
  --accent: #8db0ff;
  --chip: #171a21;
  --chip-hover: #20242e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1115;
    --fg: #e8eaef;
    --muted: #9ba2b0;
    --line: #262a33;
    --accent: #8db0ff;
    --chip: #171a21;
    --chip-hover: #20242e;
  }
}

/* ---- Base ---------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 650; margin: 2.75rem 0 0.75rem; }
h3 { font-size: 1rem; font-weight: 600; margin: 1.5rem 0 0.4rem; }

p { margin: 0 0 1rem; }

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

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.1em; height: 1.1em; flex: none; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--fg); color: var(--bg); padding: 0.5rem 0.9rem; z-index: 10;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ---- Header / nav -------------------------------------------------------- */

.site-header { border-bottom: 1px solid var(--line); }

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.brand {
  color: var(--fg);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

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

.bar-end { display: flex; align-items: center; gap: 1rem; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--chip); }
.theme-toggle .icon { width: 1.05rem; height: 1.05rem; }
/* Show the icon of the mode you would switch TO */
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
:root:not([data-theme="dark"]) .theme-toggle .i-sun { display: none; }

nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 2px solid transparent;
}
nav a:hover { color: var(--fg); }
nav a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }

/* Phones: name + theme toggle on the first row, navigation on its own row below. */
@media (max-width: 36rem) {
  .bar-end { display: contents; }
  .brand { order: 1; margin-right: auto; }
  .theme-toggle { order: 2; }
  .bar nav { order: 3; flex-basis: 100%; }
}

main.wrap { padding-top: 2.5rem; padding-bottom: 3rem; }

/* ---- Home: hero ---------------------------------------------------------- */

.hero {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  margin-bottom: 2.25rem;
}

.avatar {
  width: 13rem;
  height: 13rem;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 1px solid var(--line);
}

.tagline { color: var(--muted); margin: 0.35rem 0 0.5rem; line-height: 1.5; }
.contact { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin: 0 0 0.75rem; }
.contact .loc { display: block; }
.contact .lbl { display: inline-block; min-width: 4.6rem; color: var(--fg); font-weight: 600; }

.social { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }

.social a {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.social a:hover { color: var(--accent); border-color: var(--accent); background: var(--chip); }
.social .icon { width: 1.15rem; height: 1.15rem; }

@media (max-width: 30rem) {
  .hero { flex-direction: column; align-items: flex-start; gap: 1.1rem; }
  .avatar { width: 9rem; height: 9rem; }
  h1 { font-size: 1.75rem; }
}

/* ---- Lists in content ---------------------------------------------------- */

ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 0.15rem 0; }
.when { color: var(--muted); white-space: nowrap; }
.when::before { content: "\00b7\00a0"; }
@media (max-width: 30rem) {
  .when { display: block; }
  .when::before { content: none; }
}

/* ---- Publications -------------------------------------------------------- */

.lede { color: var(--muted); margin-top: 0.75rem; }

.pubs { list-style: none; margin: 0; padding: 0; }
.pubs > li { padding: 1rem 0; border-top: 1px solid var(--line); }
.pubs > li:first-child { border-top: 0; padding-top: 0.25rem; }

.pub-title { font-weight: 600; line-height: 1.4; margin: 0 0 0.2rem; }
.pub-authors, .pub-venue { margin: 0; font-size: 0.94rem; line-height: 1.55; }
.pub-authors { color: var(--muted); }
.pub-authors strong { color: var(--fg); font-weight: 650; }
.pub-venue { color: var(--muted); }

.pub-kind {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pub-links { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.4rem; margin-top: 0.65rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.12rem 0.65rem;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  font-size: 0.8rem;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}
.pill:hover { background: var(--chip-hover); border-color: var(--muted); text-decoration: none; }
.pill.primary { color: var(--accent); border-color: currentColor; }
.pill .icon { width: 0.95em; height: 0.95em; }

details.bib[open] { flex-basis: 100%; }
details.bib > summary { list-style: none; display: flex; width: fit-content; }
details.bib > summary::-webkit-details-marker { display: none; }
details.bib[open] > summary { background: var(--chip-hover); border-color: var(--muted); }
details.bib pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem 0.9rem;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: 0.78rem/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

/* ---- Projects ------------------------------------------------------------ */

.project-group h2 { margin-top: 2.25rem; }

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1rem;
  align-items: start;           /* expanding one card must not stretch its neighbours */
}
.project-group .projects { margin-top: 0.9rem; }
.lede + .projects { margin-top: 1.75rem; }

.project {
  position: relative;           /* anchor for the stretched link below */
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  transition: border-color 0.15s, background 0.15s;
}
.project:hover { border-color: var(--accent); background: var(--chip); }

.project-kind {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.project-name { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; line-height: 1.3; }
.project-name a { color: var(--fg); text-decoration: none; }
.project-name .icon { width: 0.8em; height: 0.8em; margin-left: 0.4em; color: var(--muted); vertical-align: -0.05em; }
.project:hover .project-name .icon { color: var(--accent); }
.project-role {
  margin-left: 0.55rem;
  padding: 0 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: 0.12em;
  white-space: nowrap;
}

/* The title link covers the whole card, so the entire box is clickable. */
.project-name a.stretch::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.project-name a.stretch:focus-visible { outline: none; }
.project-name a.stretch:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }

.project-summary { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.project code, .project-summary code {
  font: 0.85em var(--mono);
  padding: 0.05em 0.3em;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 0.25rem;
}

/* Expander: sits above the stretched link so it stays independently clickable. */
.project details.more { position: relative; z-index: 1; margin-top: 0.6rem; }
.project details.more > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.project details.more > summary::-webkit-details-marker { display: none; }
.project details.more > summary:hover { color: var(--accent); }
.project details.more > summary::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.15em) rotate(45deg);
  transition: transform 0.15s;
}
.project details.more[open] > summary::after { transform: translateY(0.05em) rotate(-135deg); }
.project details.more p { margin: 0.5rem 0 0; font-size: 0.92rem; line-height: 1.55; }
.project-links { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }

/* ---- Footer -------------------------------------------------------------- */

.site-footer { border-top: 1px solid var(--line); padding: 1.5rem 0 2.5rem; color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0.75rem 0 0; }
.site-footer .social { margin-bottom: 0.25rem; }

@media print {
  .site-header, .site-footer, .social, .skip, .theme-toggle { display: none; }
  a { color: inherit; }
}