/* ==========================================================================
   Shared stylesheet for hnemati.github.io
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2733;
  --text-muted: #5b6675;
  --heading: #14202e;
  --accent: #1954a6;          /* KTH blue */
  --accent-hover: #123c77;
  --accent-soft: #e8f0fb;
  --border: #e3e7ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 4px 16px rgba(16, 24, 40, .09);
  --award: #b45309;
  --award-soft: #fdf1e2;
  --hire: #0f7b52;
  --hire-soft: #e3f5ec;
  --talk: #6b4ea8;
  --talk-soft: #efe9f9;
  --radius: 12px;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Lora", Georgia, "Times New Roman", serif;

  /* Publication list density — adjust these to loosen or tighten the entries. */
  --pub-pad-y: .72rem;
  --pub-pad-x: 1.05rem;
  --pub-gap: .5rem;
  --pub-title-size: .98rem;
  --pub-title-leading: 1.35;
  --pub-author-size: .86rem;
  --pub-venue-size: .83rem;
  --pub-actions-top: .45rem;
  --pub-actions-gap: .3rem;
  --plink-size: .76rem;
  --plink-pad-y: .16rem;
  --plink-pad-x: .52rem;
  --year-gap-top: 1.5rem;
  --year-gap-bottom: .6rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b23;
    --text: #d7dde6;
    --text-muted: #8b95a5;
    --heading: #eef2f7;
    --accent: #7cabe8;
    --accent-hover: #a7c8f2;
    --accent-soft: #1c2a3f;
    --border: #262d3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, .5);
    --award: #e2a35c;
    --award-soft: #33240f;
    --hire: #5cc79b;
    --hire-soft: #10281f;
    --talk: #b49ce8;
    --talk-soft: #241c38;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--heading); font-family: var(--font-serif); line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 .5rem; }
h2 { font-size: 1.45rem; margin: 0 0 1rem; }
h3 { font-size: 1.15rem; margin: 0 0 .75rem; }

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

/* visible keyboard focus everywhere, without a ring on mouse clicks */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img { max-width: 100%; }

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

.container { max-width: 60rem; margin: 0 auto; padding: 0 1.25rem; }

/* --------------------------------------------------------------------------
   Header / navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .25rem .75rem;
  min-height: 3.6rem;
  padding-top: .4rem;
  padding-bottom: .4rem;
}

.brand {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--heading);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.site-nav { display: flex; flex-wrap: wrap; gap: .15rem; }

.site-nav a {
  padding: .4rem .75rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: .92rem;
  font-weight: 500;
}
.site-nav a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-soft); }

/* --------------------------------------------------------------------------
   Layout blocks
   -------------------------------------------------------------------------- */

main.container { padding-top: 2.25rem; padding-bottom: 3rem; }

/* --------------------------------------------------------------------------
   Single-page sections
   -------------------------------------------------------------------------- */

/* clear the sticky header when jumping to an anchor */
.section { scroll-margin-top: 4.25rem; }
.section + .section { margin-top: 3.25rem; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.section-head h2 { margin: 0; font-size: 1.6rem; }
.section-head .ext-links { display: flex; gap: .5rem; flex-wrap: wrap; }
.section-head .lead { flex-basis: 100%; margin: .1rem 0 0; color: var(--text-muted); font-size: .92rem; }

.to-top {
  display: block;
  text-align: right;
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
}
.to-top:hover { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2rem;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Home page hero
   -------------------------------------------------------------------------- */

.hero { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; }

.hero img.portrait {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}

.hero .intro { flex: 1 1 20rem; }

.hero .role { color: var(--text-muted); margin: .1rem 0 0; font-size: 1.02rem; }

.social-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: 1rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .38rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
}
.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.icon-btn svg { width: 1em; height: 1em; fill: currentColor; }
.icon-btn img.dblp-icon { height: 1em; width: auto; }

.email-chip {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border-radius: 6px;
  padding: 1px 4px;
}

.chips { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: .75rem 0 0; list-style: none; }
.chips li {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: .28rem .8rem;
  font-size: .84rem;
  font-weight: 500;
}

/* the two cards stretch to a common height so the row reads as one block */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.two-col > .card { display: flex; flex-direction: column; margin-bottom: 0; }
@media (max-width: 47rem) { .two-col { grid-template-columns: 1fr; } }

.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li {
  display: flex;
  gap: .65rem;
  align-items: baseline;
  padding: .3rem 0;
}
.contact-list .label { color: var(--text-muted); min-width: 4.5rem; font-size: .88rem; }

/* Latest-news preview at the top of the page: fills its card so the
   "All news" link sits on the bottom edge, level with the contact card. */
#news-preview { display: flex; flex-direction: column; flex: 1; }
#news-preview .more-link { margin-top: auto; padding-top: .5rem; }

.news-preview-item { padding: .65rem 0; border-bottom: 1px dashed var(--border); }
.news-preview-item:last-of-type { border-bottom: 0; }
.news-preview-item .meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .2rem;
}
.news-preview-item .date {
  font-size: .78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.news-preview-item p { margin: 0; font-size: .92rem; }
.more-link { display: inline-block; margin-top: .5rem; font-weight: 500; font-size: .9rem; }

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

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.page-head .ext-links { display: flex; gap: .5rem; flex-wrap: wrap; }

.year-heading {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  color: var(--text-muted);
  margin: var(--year-gap-top) 0 var(--year-gap-bottom);
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.year-heading:first-of-type { margin-top: .25rem; }

.pub {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--pub-pad-y) var(--pub-pad-x);
  margin-bottom: var(--pub-gap);
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pub:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* title left, badges right — a flex row, so a long award label can never overlap */
.pub .pub-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem 1rem;
}

.pub .pub-title {
  font-weight: 600;
  font-size: var(--pub-title-size);
  line-height: var(--pub-title-leading);
}
.pub .pub-title a { color: var(--heading); }
.pub .pub-title a:hover { color: var(--accent); }

.pub .pub-authors {
  font-size: var(--pub-author-size);
  color: var(--text-muted);
  margin-top: .1rem;
  line-height: 1.45;
}
.pub .pub-authors .me { color: var(--text); font-weight: 600; }

.pub .pub-venue {
  font-size: var(--pub-venue-size);
  color: var(--text-muted);
  font-style: italic;
  margin-top: .05rem;
  line-height: 1.45;
}

.pub .badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .3rem;
  flex-shrink: 0;
  max-width: 45%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .16rem .55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
  line-height: 1.5;
}
/* without this the inline trophy SVG expands to its intrinsic size */
.badge svg { width: .78em; height: .78em; fill: currentColor; flex-shrink: 0; }
.badge.award { background: var(--award-soft); color: var(--award); }

.pub .actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pub-actions-gap);
  margin-top: var(--pub-actions-top);
  align-items: center;
}

.plink {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: var(--plink-size);
  font-weight: 500;
  padding: var(--plink-pad-y) var(--plink-pad-x);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  transition: background-color .12s ease, border-color .12s ease;
}
.plink:hover { background: var(--accent-soft); text-decoration: none; }
.plink svg { width: .85em; height: .85em; fill: currentColor; }

.pub .foldout {
  display: none;
  margin-top: .7rem;
  border-top: 1px dashed var(--border);
  padding-top: .7rem;
  font-size: .87rem;
}
.pub .foldout.open { display: block; }
.pub .foldout pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem;
  font-size: .78rem;
  margin: 0;
}
.pub .foldout .abstract-text { color: var(--text-muted); text-align: justify; margin: 0; }

.copy-bib { float: right; margin: 0 0 .4rem .6rem; }

.no-results { color: var(--text-muted); font-style: italic; }

/* --------------------------------------------------------------------------
   News
   -------------------------------------------------------------------------- */

/* News is genuinely chronological, so the rail and year markers carry
   information rather than decorating the page. */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.9rem;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: .32rem;
  top: .6rem;
  bottom: .6rem;
  width: 2px;
  background: var(--border);
}
.timeline > li { position: relative; }

.tl-year {
  margin: 1.6rem 0 .9rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
}
.tl-year:first-child { margin-top: 0; }
.tl-year::before {          /* mask the rail so the year reads as a divider */
  content: "";
  position: absolute;
  left: -1.9rem;
  top: -.35rem;
  width: .75rem;
  height: 2.1rem;
  background: var(--bg);
}

.tl-item { margin-bottom: 1.1rem; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -1.75rem;
  top: 1.35rem;
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.35rem;
}

.news-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}
.news-head .news-date {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.kind {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.kind-hiring { background: var(--hire-soft); color: var(--hire); }
.kind-award  { background: var(--award-soft); color: var(--award); }
.kind-talk   { background: var(--talk-soft); color: var(--talk); }

.news-card h3 { margin: 0 0 .4rem; font-size: 1.08rem; }

/* text left, thumbnail right — collapses to one column on narrow screens */
.news-main { display: grid; gap: 1.1rem; }
.news-main.has-thumb { grid-template-columns: 1fr 190px; }

.news-body p { margin: 0 0 .55rem; }
.news-body p:last-child { margin-bottom: 0; }

.news-thumb {
  display: block;
  align-self: start;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.news-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
}
.news-thumb:hover { border-color: var(--accent); }

.news-card .news-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .8rem;
}

/* inline links inside post text, shortened to a readable label */
.news-body a {
  font-weight: 500;
  word-break: break-word;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 2px;
}

@media (max-width: 47rem) {
  .news-main.has-thumb { grid-template-columns: 1fr; }
  .news-thumb img { aspect-ratio: 16 / 9; }
}

/* --------------------------------------------------------------------------
   Teaching
   -------------------------------------------------------------------------- */

.course-list { list-style: none; padding: 0; margin: 0; }
.course-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .25rem 1rem;
  padding: .8rem .25rem;
  border-bottom: 1px solid var(--border);
}
.course-list li:last-child { border-bottom: 0; }
.course-list .course-name { font-weight: 500; }
.course-list .course-term { color: var(--text-muted); font-size: .9rem; }

.prose p { text-align: justify; }
.prose ul { padding-left: 1.25rem; }
.prose li { margin-bottom: .35rem; }

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 40rem) {
  .hero { justify-content: center; text-align: center; }
  .hero .intro { flex-basis: 100%; }
  .social-row { justify-content: center; }
  .chips { justify-content: center; }
  .pub .pub-head { flex-direction: column-reverse; align-items: flex-start; }
  .pub .badges { justify-content: flex-start; max-width: 100%; }
  .card { padding: 1.15rem 1.25rem; }
}
