/* ==========================================================================
   Sergey Norin, personal website
   Colours and type follow the 2026 CV: petrol-blue accent,
   Libertinus Serif for text, Source Sans (served as "SN Sans") for labels.
   ========================================================================== */

/* ---------- fonts --------------------------------------------------------- */
@font-face { font-family: "Libertinus Serif"; src: url("../fonts/libertinus-serif-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Libertinus Serif"; src: url("../fonts/libertinus-serif-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Libertinus Serif"; src: url("../fonts/libertinus-serif-semibold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "SN Sans"; src: url("../fonts/sn-sans-light.woff2") format("woff2");
  font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "SN Sans"; src: url("../fonts/sn-sans-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "SN Sans"; src: url("../fonts/sn-sans-semibold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap; }

/* ---------- colour tokens ------------------------------------------------- */
:root {
  --bg: #ffffff;
  --ink: #1f2328;
  --accent: #1d5a7a;
  --accent-soft: #e8f0f5;
  --muted: #6a7178;
  --hair: #c9d4dc;
  --serif: "Libertinus Serif", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "SN Sans", "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, sans-serif;
  --datecol: 7.6rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181b;
    --ink: #e3e6e8;
    --accent: #84bedb;
    --accent-soft: #1d2b33;
    --muted: #9aa3aa;
    --hair: #2f3d46;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181b; --ink: #e3e6e8; --accent: #84bedb; --accent-soft: #1d2b33;
  --muted: #9aa3aa; --hair: #2f3d46; color-scheme: dark;
}

/* ---------- base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.1875rem;          /* 19px: Libertinus runs small */
  line-height: 1.5;
  font-variant-numeric: lining-nums;
  font-kerning: normal;
}
.page { max-width: 52rem; margin: 0 auto; padding: 2.75rem 1.5rem 3rem; }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; text-underline-offset: 0.15em; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
p { margin: 0 0 0.75em; }
i, em { font-style: italic; }
b, strong { font-weight: 600; }
sub, sup { font-size: 0.72em; line-height: 0; }
.muted { color: var(--muted); }
.sans { font-family: var(--sans); }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: 0.4rem 0.7rem; z-index: 10; }

/* ---------- masthead ------------------------------------------------------ */
.masthead {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 1rem 2rem;
  padding-bottom: 0.9rem;
  border-bottom: 1.5px solid var(--accent);
}
.masthead h1 {
  margin: 0 0 0.35rem;
  font-family: var(--sans); font-weight: 300;
  font-size: clamp(2.3rem, 6vw, 2.9rem); line-height: 1.05; letter-spacing: -0.01em;
}
.masthead h1 a { color: inherit; }
.masthead h1 a:hover { text-decoration: none; }
.masthead h1 .last { font-weight: 600; color: var(--accent); }
.masthead .role { margin: 0; font-family: var(--sans); font-size: 1.1rem; line-height: 1.35; }
.masthead .dept { margin: 0.1rem 0 0; font-family: var(--sans); font-size: 1rem; color: var(--muted); }
.masthead .dept a { color: var(--muted); }
.masthead .dept a:hover { color: var(--accent); }

.nav { font-family: var(--sans); font-size: 1rem; }
.nav ul { list-style: none; display: flex; gap: 0.25rem; margin: 0; padding: 0; }
.nav a {
  display: block; padding: 0.3rem 0.7rem; border-radius: 3px;
  color: var(--ink);
}
.nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }

/* ---------- sections (CV-style headings) ---------------------------------- */
.section { margin-top: 2.1rem; }
.section > h2 {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0 0 0.9rem;
  font-family: var(--sans); font-weight: 600; font-size: 1.22rem; line-height: 1.2;
  color: var(--accent);
}
.section > h2::before {
  content: ""; flex: none; width: 4px; height: 1.15em; background: var(--accent);
}
.section > h2::after {
  content: ""; flex: 1; height: 1px; background: var(--hair); margin-left: 0.4rem;
}
.lead p { max-width: 40rem; }

/* ---------- two-column lists (date | content), as in the CV -------------- */
.cvlist { list-style: none; margin: 0; padding: 0; }
.cvlist > li {
  display: grid; grid-template-columns: var(--datecol) minmax(0, 1fr);
  column-gap: 1rem;
  padding: 0.18rem 0;
}
.cvlist .when {
  font-family: var(--sans); font-size: 0.95rem; line-height: 1.85;
  color: var(--accent); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.cvlist .what { min-width: 0; }
.cvlist .note { display: block; color: var(--muted); font-size: 0.95em; }
.cvlist .note::before { content: "\2192\00a0"; }
.cvlist .sub {
  grid-column: 2; padding-top: 0.6rem;
  font-family: var(--sans); font-weight: 600; font-size: 0.8rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.cvlist > li.sub-row { display: block; padding: 0.8rem 0 0.1rem calc(var(--datecol) + 1rem); }
.cvlist > li.sub-row:first-child { padding-top: 0; }
.cvlist > li.sub-row span {
  font-family: var(--sans); font-weight: 600; font-size: 0.8rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}

/* contact rows: label column */
.contact .when { color: var(--muted); }
.contact address { font-style: normal; }

/* compact inline link lists (workshops, quick links) */
.inline-list { list-style: none; margin: 0.4rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.inline-list a {
  display: inline-block; padding: 0.12rem 0.6rem;
  font-family: var(--sans); font-size: 0.98rem;
  border: 1px solid var(--hair); border-radius: 3px; color: var(--accent);
}
.inline-list a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.quicklinks { font-family: var(--sans); font-size: 1rem; margin-top: 1rem; }
.quicklinks a { font-weight: 600; white-space: nowrap; }
.quicklinks .sep { color: var(--hair); margin: 0 0.5rem; }

/* ---------- publications -------------------------------------------------- */
.pub-tools {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.8rem 1.5rem; margin: 1.6rem 0 0.4rem;
  font-family: var(--sans); font-size: 1rem;
}
.pub-count { color: var(--muted); }
.pub-note { margin: 0 0 0.2rem; font-family: var(--sans); font-size: 1rem; color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--accent); border-radius: 4px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 0.95rem; padding: 0.3rem 0.85rem; margin: 0;
  border: 0; background: transparent; color: var(--accent); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--accent); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.no-js .seg { display: none; }

.topic-index { margin: 0.6rem 0 0; }
.topic-index a .n { color: var(--muted); font-size: 0.85em; margin-left: 0.3em; }

.pubs { list-style: none; margin: 0; padding: 0; font-size: 1.06rem; }
.pubs > li {
  display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); column-gap: 1rem;
  padding: 0.28rem 0;
}
.pubs .y {
  font-family: var(--sans); font-size: 0.9rem; line-height: 1.95;
  color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.pubs li[data-y="preprint"] .y, .pubs li[data-y="manuscript"] .y { color: var(--muted); }
.pubs .t { font-weight: 400; }
.pubs .co { color: var(--muted); }
.pubs .extra { display: block; color: var(--muted); font-size: 0.93em; }
#by-year .pubs .y { font-weight: 600; }
#by-year .pubs .y:empty::before { content: ""; }
#by-year .yeargroup + .yeargroup { margin-top: 0.5rem; }
[hidden] { display: none !important; }

/* ---------- coauthors ----------------------------------------------------- */
/* Rows of names grouped by number of joint papers; --k (set on each row)
   is that number and drives the font size and weight. */
.co-head, .coauthors > li {
  display: grid; grid-template-columns: 3rem minmax(0, 1fr); column-gap: 1.1rem;
  align-items: baseline;
}
.co-head {
  margin: 1.4rem 0 0.2rem;
  font-family: var(--sans); font-weight: 600; font-size: 0.8rem;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.co-head span:first-child { text-align: right; }
.coauthors { list-style: none; margin: 0; padding: 0; }
.coauthors > li {
  padding: 0.55rem 0 0.6rem;
  border-top: 1px solid var(--hair);
}
.coauthors .n {
  font-family: var(--sans); font-weight: 600; color: var(--accent);
  font-size: calc(0.95rem + (var(--k) - 1) * 0.07rem);
  text-align: right; font-variant-numeric: tabular-nums; line-height: 1.2;
}
.coauthors .names {
  list-style: none; margin: 0; padding: 0;
  font-size: calc(1rem + (var(--k) - 1) * 0.085rem);
  /* semibold from 5 joint papers up */
  font-weight: clamp(400, calc(400 + (var(--k) - 4) * 200), 600);
  line-height: 1.45;
}
.coauthors .names li { display: inline; white-space: nowrap; }
.coauthors .names li:not(:last-child)::after {
  content: "\00a0\00b7"; color: var(--muted); font-weight: 400;
}
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- footer -------------------------------------------------------- */
.foot {
  margin-top: 3rem; padding-top: 0.9rem; border-top: 1px solid var(--hair);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  font-family: var(--sans); font-size: 0.9rem; color: var(--muted);
}
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }

/* ---------- small screens ------------------------------------------------- */
@media (max-width: 40rem) {
  body { font-size: 1.125rem; }
  .page { padding: 1.6rem 1rem 2.4rem; }
  .masthead { align-items: flex-start; }
  .nav { width: 100%; }
  .nav ul { margin-left: -0.7rem; }
  .cvlist > li, .pubs > li { grid-template-columns: minmax(0, 1fr); }
  .cvlist .when, .pubs .y { line-height: 1.4; }
  .cvlist > li.sub-row { padding-left: 0; }
  .pubs .y:empty { display: none; }
  .pubs > li { padding: 0.45rem 0; }
  .cvlist > li { padding: 0.35rem 0; }
  .coauthors > li { grid-template-columns: 2.1rem minmax(0, 1fr); column-gap: 0.75rem; }
  .co-head { display: none; }
  /* five tabs: one spread-out row from 375px up, wrapping (not overflowing) below that */
  .nav { font-size: 0.93rem; }
  .nav ul { margin: 0 -0.25rem; flex-wrap: wrap; justify-content: space-between; gap: 0; }
  .nav a { padding: 0.3rem 0.25rem; }
  .coauthors { margin-top: 1rem; }
  .coauthors .names { font-size: calc(0.98rem + (var(--k) - 1) * 0.06rem); }
  .coauthors .n { font-size: calc(0.9rem + (var(--k) - 1) * 0.05rem); }
}
@media (max-width: 22rem) {
  .nav ul { justify-content: flex-start; column-gap: 0.6rem; }
}

/* ---------- print --------------------------------------------------------- */
@media print {
  .nav, .pub-tools .seg, .topic-index, .skip { display: none !important; }
  .page { max-width: none; padding: 0; }
  a { color: inherit; }
}
