/* Layout: a slim sticky header; Home is a left profile column plus a reading column;
   Research, Teaching and CV are one calm reading column (~760px). Light by default,
   dark only when the visitor picks it with the header switch. */

/* Calluna: once the font files are in assets/fonts/calluna/, uncomment this block.
@font-face { font-family: "Calluna"; src: url("../fonts/calluna/Calluna-Regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
*/

:root {
  color-scheme: light;
  --bg: #F7F8F7;
  --surface: #FFFFFF;
  --ink: #141B1A;
  --muted: #59655F;
  --rule: #DAE0DD;
  --accent: #1D5C58;
  --accent-soft: #E2EEEC;
  --serif: "Calluna", "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Calluna Sans", "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1.125rem;
  --step-1: 1.35rem;
  --step-2: 1.75rem;
  --step-3: 2.4rem;
}
:root[data-site-theme="dark"] {
  color-scheme: dark;
  --bg: #121517;
  --surface: #1A1E21;
  --ink: #E4E8EA;
  --muted: #9AA4A9;
  --rule: #2B3135;
  --accent: #74B9B0;
  --accent-soft: #1E2A2A;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: var(--step-0); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { text-wrap: balance; font-weight: 500; line-height: 1.2; margin: 0; }

.wrap {
  max-width: 1000px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-head {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-head .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-block: 18px; flex-wrap: wrap; }
.wordmark { font-family: var(--serif); font-size: var(--step-1); font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: 0.005em; }
.nav { display: flex; align-items: baseline; gap: 24px; font-family: var(--sans); font-size: 1rem; }
.nav a { color: var(--muted); text-decoration: none; padding-bottom: 4px; border-bottom: 2px solid transparent; transition: color .15s, border-color .15s; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.theme-toggle { align-self: center; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s; }
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .moon { display: none; }
:root[data-site-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-site-theme="dark"] .theme-toggle .moon { display: block; }

main .wrap { padding-block: 56px 72px; }
.page { max-width: 760px; display: grid; gap: 48px; }
.page-title { font-size: var(--step-3); }
.page > p { margin: 0; }

.eyebrow {
  font-family: var(--sans); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  margin: 0 0 18px;
}

/* Buttons */
.btn {
  font-family: var(--sans); font-size: var(--step--1); font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 4px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { color: var(--bg); filter: brightness(1.08); }
.btn.small { padding: 2px 9px; font-size: 0.8rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Home: profile column on the left, reading column on the right */
.home { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 56px; align-items: stretch; }
.profile { align-self: start; position: sticky; top: calc(var(--head-h, 68px) + 28px); display: grid; gap: 18px; justify-items: start; text-align: left; }
.portrait { width: 100%; max-width: 220px; aspect-ratio: 1; border-radius: 6px; object-fit: cover; filter: grayscale(0.15); background: var(--accent-soft); }
.role { font-family: var(--sans); font-size: 0.98rem; line-height: 1.45; margin: 0; display: grid; gap: 2px; }
.role b { font-weight: 700; color: var(--ink); }
.role span { color: var(--muted); }
.contact { list-style: none; margin: 0; padding: 16px 0 0; border-top: 1px solid var(--rule); width: 100%; display: grid; gap: 9px; font-family: var(--sans); font-size: 0.95rem; }
.contact .lbl { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.email { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.email a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.email a:hover { color: var(--accent); }
.icons { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.icon-link { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--rule); border-radius: 50%; background: var(--surface); color: var(--muted); transition: color .15s, border-color .15s, transform .15s; }
.icon-link:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.icon-link svg { width: 18px; height: 18px; display: block; }

/* The bio column stretches to the profile's height so the skyline sits level with the contact links */
.home-main { display: flex; flex-direction: column; gap: 56px; min-width: 0; }
.bio { flex: 1; display: flex; flex-direction: column; }
.bio p { margin: 0 0 14px; max-width: 62ch; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.bio a { text-decoration: none; }
.bio a:hover, .bio a:focus-visible { text-decoration: underline; text-decoration-thickness: 1px; }

/* Nyhavn skyline under the bio: gabled houses cut from collage fabrics, sitting on the canal */
.skyline { flex: none; width: 100%; height: 34px; max-width: 62ch; margin-top: auto; overflow: hidden; }
.skyline svg { display: block; width: 100%; height: 100%; }

/* Featured paper (switched on in _data/featured.yml) */
.featured {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  display: grid; grid-template-columns: 1.25fr 1fr; overflow: hidden;
}
.featured--text { grid-template-columns: 1fr; }
.featured__text { padding: 28px 28px 26px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.featured__text h2 { font-size: var(--step-2); }
.featured__text h2 a { color: var(--ink); text-decoration: none; }
.featured__text h2 a:hover { color: var(--accent); }
.byline { font-family: var(--sans); color: var(--muted); font-size: 0.98rem; margin: 0; }
.takeaway { margin: 0; font-size: 1.08rem; }
.featured__fig { margin: 0; background: var(--accent-soft); padding: 18px; display: grid; place-items: center; border-left: 1px solid var(--rule); min-width: 0; }

/* Research */
.jump {
  position: sticky; top: var(--head-h, 68px); z-index: 4;
  display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0;
  background: var(--bg); border-bottom: 1px solid var(--rule);
  margin-bottom: -20px;
}
.jump a { font-family: var(--sans); font-size: var(--step--1); color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; }
.jump a:hover { color: var(--ink); background: var(--accent-soft); }
.jump a.is-on { color: var(--accent); background: var(--accent-soft); }
.jump .count { font-variant-numeric: tabular-nums; opacity: .7; margin-left: 3px; }
.r-body { display: grid; gap: 48px; }

.r-section { scroll-margin-top: calc(var(--head-h, 68px) + 72px); display: grid; }
.r-section > h2 { font-size: var(--step-1); font-weight: 700; margin-bottom: 6px; display: flex; align-items: baseline; gap: 10px; }
.r-section > h2 small { font-family: var(--sans); font-size: var(--step--1); font-weight: 400; color: var(--muted); }

.paper { padding: 22px 0; border-top: 1px solid var(--rule); display: grid; gap: 8px; }
.r-section > h2 + .paper { border-top: 0; }
.paper__top { display: flex; gap: 14px; justify-content: space-between; align-items: baseline; }
.paper h3 { font-size: 1.28rem; min-width: 0; }
.paper h3 a { color: var(--ink); text-decoration: none; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0 1px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size .25s, color .15s; }
.paper h3 a:hover { color: var(--accent); background-size: 100% 1px; }
.pill { flex: none; font-family: var(--sans); font-size: 0.75rem; font-weight: 500; padding: 2px 9px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--rule); color: var(--muted); }
.pill.pub { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.pill.sub { border-color: var(--accent); color: var(--accent); }
.paper .meta { font-family: var(--sans); font-size: 0.95rem; color: var(--muted); margin: 0; }
.paper .meta i { font-family: var(--serif); color: var(--ink); }
.paper .takeaway { font-size: 1.02rem; }
.paper .btn-row { margin-top: 4px; }
.abs-toggle { justify-self: start; }
.abstract { overflow: hidden; display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.abstract.open { grid-template-rows: 1fr; }
.abstract > div { min-height: 0; }
.abstract p { margin: 4px 0; padding-left: 16px; border-left: 2px solid var(--accent-soft); color: var(--muted); font-size: 1rem; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.talks { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin: 2px 0 0; }

/* CV and Teaching */
.cv-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.cv-body { display: grid; gap: 44px; }
.cv-block h2 { font-size: var(--step-1); font-weight: 700; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--ink); }
.cv-row { display: grid; grid-template-columns: 112px 1fr; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.cv-row .yr { font-family: var(--sans); font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 3px; }
.cv-row .what { min-width: 0; }
.cv-row .what b { font-weight: 500; }
.cv-row .what .sub { display: block; font-family: var(--sans); font-size: 0.92rem; color: var(--muted); }

/* Footer and toast */
.site-foot { border-top: 1px solid var(--rule); }
.site-foot .wrap { padding-block: 24px 40px; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: var(--bg); font-family: var(--sans); font-size: 0.9rem; padding: 8px 16px; border-radius: 6px; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 820px) {
  .home { grid-template-columns: 1fr; gap: 36px; }
  .profile { position: static; grid-template-columns: 120px minmax(0, 1fr); column-gap: 20px; align-items: start; }
  .portrait { grid-row: span 2; }
  .contact { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  :root { --step-3: 1.95rem; --step-2: 1.45rem; }
  .nav { gap: 16px; font-size: 0.95rem; }
  main .wrap { padding-block: 36px 56px; }
  .page { gap: 36px; }
  .featured { grid-template-columns: 1fr; }
  .featured__fig { border-left: 0; border-top: 1px solid var(--rule); }
  .featured__text { padding: 22px 20px; }
  .cv-row { grid-template-columns: 1fr; gap: 2px; }
  .paper__top { flex-direction: column; gap: 6px; }
  .skyline { height: 30px; }
}
