/* ═══════════════════════════════════════════════════════════════════════════
   mliuschi.github.io
   Plain CSS on purpose: no Sass, no preprocessor, no build step. Colours and
   the few tunable values live in :root below.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Self-hosted variable font, latin subset. No external requests. */
@font-face {
  font-family: 'Schibsted Grotesk';
  src: url('/assets/fonts/schibsted-grotesk.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* palette — warm ground, moss accent */
  --bg: #faf8f2;
  --surface: #ffffff;
  --ink: #1b1a15;
  --soft: #403d34;
  --muted: #726d60;
  --rule: #e5e0d3;
  --rule-2: #cfc8b6;
  --accent: #3e6136;
  --accent-ink: #ffffff;
  --wash: rgba(62, 97, 54, 0.075);
  --glow: rgba(62, 97, 54, 0.16);

  --sans: 'Schibsted Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --tt: -0.014em;              /* display tracking */

  /* equal-contribution mark; change this one value to swap the glyph */
  --eq: "\2733";               /* ✳ */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.66;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Wide shell. Body text runs the full width; to pull it back in, add a
   max-width to .prose (and .ledger .what for news). */
.wrap { max-width: 58rem; margin: 0 auto; padding: 2.5rem 1.75rem 5rem; }

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

/* ── the one link idiom ──────────────────────────────────────────────────────
   A hairline underline that thickens into a highlight on hover. Defined once
   here for every body-size text link on the site, so the treatment can't drift.
   Deliberately NOT applied to headings or publication titles: the bar grows to
   0.38em, which reads as an underline at body size but as a highlighter stripe
   on large or wrapped text.
   ─────────────────────────────────────────────────────────────────────────── */
.prose a,
.ledger .what a,
.topnav a,
.tagline a,
.more .more-t,
.lnk,
.u-link {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 0.075em;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 0.05em;
  transition: background-size 0.22s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease;
}
.prose a:hover,
.ledger .what a:hover,
.topnav a:hover,
.tagline a:hover,
.more:hover .more-t,
.lnk:hover,
.u-link:hover { background-size: 100% 0.38em; color: var(--ink); }

/* ── top bar ─────────────────────────────────────────────────────────────── */
/* Nav sits alone on the left now that the CV button is gone. */
.topbar { display: flex; align-items: center; gap: 1rem; padding-bottom: 2.5rem; }
.topnav { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.topnav a {
  font-size: 0.8rem; font-weight: 500; letter-spacing: 0.02em;
  color: var(--muted); padding-bottom: 0.15rem;
}
.topnav a { background-size: 100% 0; }
/* The current page is marked by weight and colour, NOT by an underline —
   hover already owns the underline, so an underlined active state would make a
   hovered inactive item look momentarily current. */
.topnav a[aria-current] { color: var(--ink); font-weight: 600; }

/* ── masthead ────────────────────────────────────────────────────────────── */
.masthead {
  display: flex; align-items: center; gap: 2.5rem;
  padding-bottom: 1.9rem; border-bottom: 1px solid var(--rule-2);
}
.portrait { flex: 0 0 auto; width: 8.25rem; }
.portrait img {
  display: block; width: 100%; height: auto; aspect-ratio: 1;
  border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 1px var(--rule-2), 0 2px 10px -4px rgba(0, 0, 0, 0.18);
}
.mast-text { flex: 1 1 auto; min-width: 0; }
h1.name {
  margin: 0; font-size: clamp(2rem, 5.2vw, 2.7rem); font-weight: 600;
  line-height: 1.08; letter-spacing: var(--tt);
}
/* Links home, but must still read as a heading: no underline, inherits colour,
   only a quiet accent shift on hover so it's discoverable. */
h1.name a { color: inherit; transition: color 0.18s ease; }
h1.name a:hover { color: var(--accent); }
.portrait a { display: block; border-radius: 50%; }
.tagline { margin: 0.65rem 0 0; font-size: 0.97rem; color: var(--soft); }
.tagline .sep { color: var(--rule-2); padding: 0 0.5em; }
.mast-email { margin: 0.3rem 0 0; font-size: 0.88rem; color: var(--muted); }

/* ── social icons ────────────────────────────────────────────────────────── */
.icons { display: flex; align-items: center; gap: 0.45rem;
         margin: 1.15rem 0 0 -0.5rem; padding: 0; }
.ico {
  display: grid; place-items: center; width: 2.2rem; height: 2.2rem;
  border-radius: 50%; color: var(--muted); border: 1px solid transparent;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease,
              transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ico svg { width: 1.06rem; height: 1.06rem; fill: currentColor; }
.ico:hover {
  color: var(--accent); background: var(--wash); border-color: var(--rule);
  transform: translateY(-2.5px);
}
.ico:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* divider between the icon set and the CV text link */
.ico-sep {
  width: 1px; height: 1.1rem; background: var(--rule-2);
  margin: 0 0.7rem 0 0.5rem; align-self: center; flex: 0 0 auto;
}
.cv-link {
  align-self: center; font-size: 0.83rem; font-weight: 600;
  letter-spacing: 0.01em; color: var(--accent);
}

/* ── section headings ────────────────────────────────────────────────────── */
h2.sec {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  margin: 3.5rem 0 0; padding-bottom: 0.6rem; border-bottom: 1px solid var(--rule);
  font-size: 1.45rem; font-weight: 600; line-height: 1.2;
  letter-spacing: var(--tt); color: var(--ink);
}
.more {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.775rem; font-weight: 500; color: var(--muted);
  white-space: nowrap; transition: color 0.18s ease;
}
.more .ar { display: inline-block; transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1); }
.more:hover .ar { transform: translateX(3px); }

.prose { margin-top: 1.5rem; color: var(--soft); }
.prose p { margin: 0 0 1.05rem; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); font-weight: 600; }

/* ── year groups (news + publications pages) ─────────────────────────────────
   The year sits in its own margin gutter rather than stacked above the item
   dates. Without this the year, the per-item date, and a horizontal rule all
   compete for the same left edge. A single vertical hairline carries the group
   instead, and the year sticks while you scroll through its year.
   ───────────────────────────────────────────────────────────────────────────── */
.yr { display: grid; grid-template-columns: 4.5rem 1fr; margin-top: 2.4rem; }
.yr:first-of-type { margin-top: 1.5rem; }
.yr-head {
  margin: 0; padding-right: 1.75rem; text-align: right;
  font-size: 1rem; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
  position: sticky; top: 1.25rem; align-self: start;
}
.yr > .ledger,
.yr > .pubs { border-left: 1px solid var(--rule); padding-left: 1.75rem; margin-top: 0; }
/* rows bleed their hover tint to the right edge only, so it can't cross the rule */
.yr > .ledger li,
.yr > .pubs .pub { margin-left: 0; }
/* the year already labels the group, so items need only month + day */
.yr > .ledger li { grid-template-columns: 4.2rem 1fr; }

/* ── news ───────────────────────────────────────────────────────────────── */
.ledger { list-style: none; margin: 0.4rem 0 0; padding: 0; }
.ledger li {
  display: grid; grid-template-columns: 5.4rem 1fr; gap: 1.35rem;
  padding: 1rem 1rem; margin: 0 -1rem;
  border-radius: 4px; border-bottom: 1px solid var(--rule);
  transition: background 0.2s ease;
}
.ledger li:last-child { border-bottom: 0; }
.ledger li:hover { background: var(--wash); }
.ledger .when {
  font-size: 0.75rem; font-weight: 500; color: var(--muted);
  font-variant-numeric: tabular-nums; padding-top: 0.35em; white-space: nowrap;
}
.ledger .what { font-size: 0.97rem; line-height: 1.62; color: var(--soft); }
/* markdownify wraps each item in <p>; strip its margins rather than the tag */
.ledger .what p { margin: 0; }

/* awarding body, after an award title — reuses the .ledger row markup */
.dim { color: var(--muted); }
.dim::before { content: " — "; }

/* ── publications ───────────────────────────────────────────────────────── */
.pubs { margin-top: 0.45rem; }
.pub {
  display: grid; grid-template-columns: 12rem 1fr; gap: 1.75rem;
  padding: 1.5rem 1rem; margin: 0 -1rem;
  border-radius: 5px; border-bottom: 1px solid var(--rule);
  align-items: start; transition: background 0.22s ease;
}
.pub:last-child { border-bottom: 0; }
.pub:hover { background: var(--wash); }
/* an entry with no thumbnail gives its text the full width */
.pub.no-thumb { grid-template-columns: 1fr; }

.thumb {
  display: block; aspect-ratio: 4 / 3; background: var(--surface);
  border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--rule);
  transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.thumb img { display: block; width: 100%; height: 100%; }
/* Paper previews are rendered at exactly 4:3 and fill the box. Figures vary in
   aspect ratio, so they are letterboxed rather than cropped — losing part of a
   scientific figure is worse than a little whitespace. */
.thumb.is-paper img { object-fit: cover; }
.thumb.is-figure img { object-fit: contain; padding: 0.3rem; }

/* hover: a tinted ring blooms outward plus a soft accent halo. Pure box-shadow,
   so there is no stacking-context fight with the row's hover tint. */
.pub:hover .thumb {
  transform: translateY(-3px) scale(1.025);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 38%, transparent),
              0 0 0 4px var(--wash),
              0 12px 32px -10px var(--glow);
}

.pub h3 {
  margin: 0; font-size: 1.05rem; font-weight: 600; line-height: 1.34;
  letter-spacing: var(--tt);
}
.pub h3 a { color: var(--ink); transition: color 0.18s ease; }
.pub:hover h3 a { color: var(--accent); }

.authors { margin: 0.45rem 0 0; font-size: 0.825rem; line-height: 1.58; color: var(--muted); }
.authors strong { color: var(--soft); font-weight: 600; }

.tags { margin: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tag {
  font-size: 0.69rem; font-weight: 500; color: var(--soft);
  border: 1px solid var(--rule-2); border-radius: 2rem; padding: 0.16em 0.6em;
}
.tag.yr-t { color: var(--muted); border-color: var(--rule); }
.tag.aw {
  color: var(--accent); background: var(--wash);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.pub .row { margin: 0.65rem 0 0; display: flex; flex-wrap: wrap; gap: 0.3rem 0.95rem; }
.lnk { font-size: 0.74rem; font-weight: 600; color: var(--accent); }

/* ── equal-contribution mark ─────────────────────────────────────────────── */
/* The glyph comes from --eq so it is set in exactly one place. Some candidate
   glyphs are not in the body font, hence the explicit symbol fallbacks. */
.eq {
  font-family: var(--sans), 'Apple Symbols', 'Segoe UI Symbol', sans-serif;
  font-size: 0.6em; line-height: 0; color: var(--accent);
  padding-left: 0.06em; font-weight: 600; position: relative; top: -0.25em;
}
.eq::after { content: var(--eq); }

.eq-note { margin: 0.9rem 0 0; font-size: 0.8rem; color: var(--muted); }
/* In the legend it reads as normal inline text, not a superscript. */
.eq-note .eq { font-size: 1em; top: 0; line-height: inherit; padding: 0; }

/* ── footer ─────────────────────────────────────────────────────────────── */
footer {
  margin-top: 4rem; padding-top: 1.4rem; border-top: 1px solid var(--rule-2);
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 1rem;
}
.foot-note { margin: 0; font-size: 0.72rem; color: var(--muted); opacity: 0.85; }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pub { grid-template-columns: 9.5rem 1fr; gap: 1.5rem; }
}

@media (max-width: 640px) {
  body { font-size: 1.01rem; }
  .wrap { padding: 1.5rem 1.15rem 3.5rem; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 1rem; padding-bottom: 1.75rem; }
  .topnav { gap: 1.15rem; flex-wrap: wrap; }
  .masthead { flex-direction: column; align-items: flex-start; gap: 1.35rem; }
  .portrait { width: 6.5rem; }
  h2.sec { font-size: 1.28rem; }
  .ledger li { grid-template-columns: 1fr; gap: 0.2rem; }
  .ledger .when { padding-top: 0; }
  .pub { grid-template-columns: 6rem 1fr; gap: 1.05rem; }

  /* no room for a margin gutter: year becomes a plain header above its group */
  .yr { display: block; margin-top: 2rem; }
  .yr-head {
    position: static; text-align: left; padding: 0 0 0.5rem;
    font-size: 0.95rem; border-bottom: 1px solid var(--rule);
  }
  .yr > .ledger,
  .yr > .pubs { border-left: 0; padding-left: 0; }
  .yr > .ledger li { grid-template-columns: 1fr; }
}

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