/* ============================================================
   JONAS HAEG — clean minimal layout, Reading Room design system
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Hanken+Grotesk:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---- Tokens ---- */
:root {
  --paper:       #F5F1E8;
  --paper-2:     #FBF8F1;
  --paper-sunk:  #EFEADD;
  --ink:         #211C16;
  --fg-1:        #211C16;
  --fg-2:        #574F44;
  --fg-3:        #8C8474;
  --rule:        #E3DBCB;
  --rule-strong: #CFC6B2;
  --accent:      #7B2E2E;
  --accent-deep: #5E2121;
  --gold-tint:   #EFE7D4;
  --selection:   #E3D4CE;

  --serif: 'Spectral', Georgia, serif;
  --sans:  'Hanken Grotesk', system-ui, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, monospace;

  --max-w:  800px;
  --nav-h:  56px;
  --ease:   cubic-bezier(0.22, 1, 0.36, 1);
  --dur:    200ms;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--selection); }
img { max-width: 100%; display: block; }

/* Scale the whole site one notch smaller (the header is restored below). */
html { font-size: 15px; }

/* ---- Base ---- */
body {
  background: var(--paper);
  color: var(--fg-2);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
a:hover { border-bottom-color: var(--accent); }

/* ---- Header ---- */
header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-title {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--fg-1);
  letter-spacing: -0.01em;
  border-bottom: none;
  line-height: 1;
  flex-shrink: 0;
}
.site-title:hover { border-bottom: none; color: var(--fg-1); }
.site-title b { color: var(--accent); }

/* ---- Nav ---- */
nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  line-height: 1;
}

nav > a,
.nav-dropdown-trigger {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-3);
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0;
  margin: 0;
  line-height: 1;
  vertical-align: middle;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
nav > a:hover,
.nav-dropdown-trigger:hover { color: var(--fg-1); }

nav > a.active { color: var(--accent); border-bottom-color: var(--accent); }
.nav-dropdown.active .nav-dropdown-trigger { color: var(--accent); }

/* ---- Dropdown ---- */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-dropdown-trigger::after {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.5;
  transition: transform var(--dur) var(--ease);
  position: relative;
  top: 1px;
}
.nav-dropdown.open .nav-dropdown-trigger::after { transform: rotate(180deg); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  min-width: 200px;
  background: var(--paper-2);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(33,28,22,0.08);
  list-style: none;
  padding: 0.35rem 0;
  z-index: 200;
}
.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu li a {
  display: block;
  padding: 0.4rem 1rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--fg-2);
  border-bottom: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-dropdown-menu li a:hover { background: var(--paper-sunk); color: var(--fg-1); }

/* ---- Layout ---- */
.container,
.narrow {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 5rem;
}

/* ---- Page eyebrow ---- */
.page-eyebrow,
.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

h2 {
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--fg-1);
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

/* ---- Subsection labels ---- */
.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  display: block;
  margin: 2.5rem 0 0.25rem;
}
.section-label:first-child,
.section-label--first { margin-top: 0; }

/* ---- Publication list ---- */
.pub-list { list-style: none; }

.pub {
  display: grid;
  grid-template-columns: 4.75rem 1fr;
  gap: 1.5rem;
  padding: 0.55rem 0;
  align-items: baseline;
}

.yr {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--fg-3);
  line-height: 1.35;
}

.pub h3 {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.35;
  margin: 0 0 0.25rem;
}

.venue {
  font-size: 0.9375rem;
  color: var(--fg-2);
  margin: 0 0 0.35rem;
  line-height: 1.5;
}
.venue em { font-style: italic; }

.award-inline {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--fg-3);
  letter-spacing: 0.01em;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1.1rem;
  margin-top: 0.35rem;
}
.pub-links a,
.pub-links button {
  font-family: var(--sans);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
  line-height: 1.6;
}
.pub-links a:hover,
.pub-links button:hover { border-bottom-color: var(--accent); color: var(--accent-deep); }

.pub-abstract {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease, margin-top 0.25s ease, padding-top 0.25s ease;
  overflow: hidden;
  margin-top: 0;
  padding-top: 0;
}
.pub-abstract.open {
  grid-template-rows: 1fr;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rule);
}
.pub-abstract-inner {
  overflow: hidden;
  min-height: 0;
  font-size: 0.9375rem;
  color: var(--fg-2);
  line-height: 1.75;
  text-align: justify;
}

.research-bio {
  margin-bottom: 2rem;
}
.research-bio p {
  color: var(--fg-1);
  line-height: 1.75;
  padding-bottom: 1.5rem;
}

/* ---- WIP ---- */
/* .pub--wip keeps the .pub grid so titles align with article titles,
   but is lighter and more compact since it's less prominent. */
.pub--wip {
  padding: 0.8rem 0;
}

.wip-group-label {
  margin-top: 2rem;
}
/* Ensure the WIP block always gets breathing room after publications */
#wip { margin-top: 2.5rem; }

.pub h3.wip-title {
  font-family: var(--serif);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg-2);
  line-height: 1.45;
  margin: 0;
}
.pub--wip .pub-links a,
.pub--wip .pub-links button { font-size: 0.78rem; }

/* ---- Page description ---- */
.page-description {
  color: var(--fg-2);
  margin-top: -1rem;
  margin-bottom: 1.75rem;
  font-size: 1rem;
  line-height: 1.7;
}

/* ---- Talks ---- */
.talks-legend {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--fg-3);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.talk-item {
  list-style: none;
  padding: 0.55rem 0;
}

.talk-item h3 {
  font-family: var(--serif);
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.35;
  margin: 0 0 0.35rem;
}

.talk-pres-list { display: flex; flex-direction: column; gap: 0.15rem; }
/* Indent venue text only — keep year column in place */
.talk-pres-list .talk-row-detail { padding-left: 1.25rem; }

.talk-row {
  display: grid;
  grid-template-columns: 4.75rem 1fr;
  gap: 1.5rem;
  align-items: baseline;
}

.talk-yr {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--fg-3);
  line-height: 1.5;
}

.talk-row-detail {
  font-size: 0.9375rem;
  color: var(--fg-2);
  line-height: 1.5;
}
.talk-tag {
  color: var(--fg-3);
  font-size: 0.7em;
  margin-left: 0.05em;
}
.talk-comment {
  color: var(--fg-3);
  font-size: 0.875rem;
}

/* ---- Workshop / Teaching sections ---- */
.page-section {
  padding-top: 2.5rem;
  margin-top: 2.5rem;
  border-top: 1px solid var(--rule);
}
.page-section.page-section--first {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}
/* Teaching: no divider between institutions, smaller gap */
#teaching .page-section {
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: none;
}
#teaching .page-section.page-section--first { padding-top: 0; margin-top: 0; }

.section-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--fg-1);
  margin-bottom: 0;
}
.page-section > .section-label:first-of-type { margin-top: 0.5rem; }
.section-subtitle {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0;
  margin-bottom: 1rem;
}
.workshop-description {
  color: var(--fg-2);
  line-height: 1.75;
}
.workshop-description p { margin-bottom: 1.25rem; }
.workshop-description a { color: var(--accent); }
.ws-speaker-list {
  list-style: none;
  margin: 0.25rem 0 0;
}
.ws-speaker-item {
  padding: 0.55rem 0;
}
.ws-speaker {
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.35;
  margin: 0;
}
.ws-affiliation { font-weight: 400; color: var(--fg-3); }
.ws-paper-title {
  font-style: italic;
  margin: 0.15rem 0 0;
}
.ws-registration {
  font-size: 0.9rem;
  color: var(--fg-3);
  margin-top: 1.25rem;
  line-height: 1.65;
}

.teaching-levels {
  font-size: 0.8rem;
  color: var(--fg-3);
  margin-left: 0.4em;
  font-style: italic;
}
/* ---- Teaching resources ---- */
.resource-intro { margin-bottom: 2rem; color: var(--fg-2); }
.resource-note { color: var(--fg-3); font-style: italic; font-size: 0.85rem; }
.resource-author { font-family: var(--sans); font-size: 0.875rem; color: var(--fg-2); }
/* Resource group heading: like section-label (mono uppercase accent) */
.resource-group-heading {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin: 2.5rem 0 0.25rem;
}
.resource-group-heading:first-child { margin-top: 0; }
/* Resource item title: like pub h3 (serif) */
.resource-item-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--fg-1);
  line-height: 1.35;
  margin: 0;
}
.resource-item-title a { font-weight: 500; color: var(--fg-1); }
.resource-item-title a:hover { color: var(--fg-1); border-bottom-color: var(--fg-3); }

/* ---- About ---- */
.about-body {
  line-height: 1.8;
}
.about-body p {
  color: var(--fg-1);
  margin-bottom: 1rem;
}
.about-body p:last-child { margin-bottom: 0; }

.about-portrait {
  float: right;
  width: 280px;
  margin: 0.2rem 0 1.25rem 2.5rem;
  shape-outside: margin-box;
}
.about-portrait img {
  width: 100%;
  display: block;
  border-radius: 6px;
  filter: grayscale(1) contrast(1.03);
  transition: filter 0.4s ease;
}
.about-portrait img:hover { filter: grayscale(0) contrast(1); }

.about-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 1.25rem;
  margin-top: 0.85rem;
}
.about-links a {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  border-bottom: none;
}
.about-links a:hover { color: var(--accent); border-bottom: none; }
.about-portrait .photo-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--paper-sunk);
}

/* ---- CV ---- */
.cv-section { margin-bottom: 2.5rem; }
.cv-section > .eyebrow,
.cv-section .cv-eyebrow-row {
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.6rem;
}
.cv-eyebrow-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.cv-eyebrow-row .eyebrow { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.cv-item {
  display: grid;
  grid-template-columns: 4.75rem 1fr;
  gap: 1.5rem;
  padding: 0.4rem 0;
  align-items: baseline;
}
.cv-year { font-family: var(--mono); font-size: 0.8125rem; color: var(--fg-3); line-height: 1.5; }
.cv-area-label { color: var(--fg-2); font-size: 0.75rem; letter-spacing: 0.04em; }
.cv-detail { font-family: var(--serif); font-size: 1rem; font-weight: 500; color: var(--fg-1); line-height: 1.4; }
.cv-detail-sub { display: block; font-family: var(--sans); font-size: 0.875rem; font-weight: 400; color: var(--fg-2); margin-top: 3px; line-height: 1.5; }
/* cv-pub-title: normal weight */
.cv-pub-title { font-weight: 400; }
/* journal name: same size as title, bold */
.cv-detail-inline { font-family: var(--serif); font-size: 1rem; font-weight: 500; color: var(--fg-1); }
/* vol/issue/pages: smaller, sans, muted */
.cv-detail-vol { font-family: var(--sans); font-size: 0.875rem; font-weight: 400; color: var(--fg-2); }
.cv-contact-addr { display: block; margin-top: 0.15rem; }
.cv-prize { display: block; font-family: var(--mono); font-size: 0.75rem; color: var(--fg-3); margin-top: 2px; }
/* CV talks should match the size of other CV sections, not the larger Talks page */
#cv-talks .talk-item h3 { font-size: 1rem; }
#cv-talks .talk-item { padding: 0.3rem 0; }
/* Keep presentation dates aligned with section years; indent only the venue text */
#cv-talks .talk-pres-list { padding-left: 0; }
#cv-talks .talk-pres-list .talk-row-detail { padding-left: 1.25rem; }
.cv-subsection-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  margin: 1.25rem 0 0;
  padding-bottom: 0;
  border-bottom: none;
}
.cv-subsection-label:first-child { margin-top: 0; }
.cv-references-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
  margin-top: 0.5rem;
  padding-left: 6.25rem;
}
.cv-ref-name { font-family: var(--serif); font-size: 1rem; font-weight: 500; color: var(--fg-1); margin-bottom: 0.2rem; }
.cv-ref-detail { font-size: 0.9rem; color: var(--fg-2); line-height: 1.5; }
.cv-download {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--sans); font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--rule-strong); border-radius: 3px;
  padding: 0.4rem 0.9rem; color: var(--fg-1); text-decoration: none;
  background: none; cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.cv-download:hover { background: var(--paper-2); border-color: var(--fg-3); }

.cv-contact {
  font-size: 0.9rem;
  color: var(--fg-2);
  margin: -0.5rem 0 2rem;
}
.cv-contact a { color: var(--fg-2); }
.cv-contact a:hover { color: var(--accent); }
.cv-contact-sep { color: var(--fg-3); margin: 0 0.6rem; }
.cv-award-amount {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--fg-3);
}

/* ---- Print: clean CV as PDF ---- */
@page { margin: 2cm 1.9cm; }
@media print {
  header, footer, .cv-download, .nav-dropdown-menu { display: none !important; }
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
  .narrow { max-width: 100%; padding: 0; }
  a { color: #000 !important; border: none !important; }
  .cv-item, .talk-item, .pub { break-inside: avoid; }
  .cv-section { margin-bottom: 1.2rem; }
  .eyebrow { color: #000 !important; }
}

/* ---- Footer ---- */
footer {
  clear: both;
  border-top: 1px solid var(--rule);
  padding: 1.5rem 0;
}
.foot-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.foot-fine { font-family: var(--mono); font-size: 0.7rem; color: var(--fg-3); letter-spacing: 0.05em; }

/* Courses page: course name styled like pub/talk title */
#teaching .talk-row-detail {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--fg-1);
}
#teaching .teaching-levels,
#teaching .talk-comment {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg-2);
}
@media (max-width: 580px) {
  /* Layout */
  .header-inner { padding: 0 0.75rem; gap: 0.75rem; }
  .container, .narrow { padding: 2rem 1rem 3.5rem; }

  /* Site title: smaller so nav items all fit on one line */
  .site-title { font-size: 0.9rem; }

  /* Nav: tighter gaps and smaller font to fit all items */
  nav { gap: 0.6rem; }
  nav > a, .nav-dropdown-trigger { font-size: 0.9rem; }

  /* Typography */
  h2 { font-size: 1.35rem; }
  .pub h3, .talk-item h3 { font-size: 1rem; }

  /* Portrait: stop floating, centre above text */
  .about-portrait {
    float: none;
    width: 100%;
    max-width: 240px;
    margin: 0 auto 1.5rem;
    display: block;
  }

  /* Publications & CV: collapse to single column (year above content) */
  .pub, .cv-item { grid-template-columns: 1fr; gap: 0.15rem; align-items: start; }
  .yr, .cv-year { font-size: 0.75rem; opacity: 0.75; }

  /* More breathing room between publications on mobile */
  .pub { padding: 0.85rem 0; }

  /* Talks: narrower year column, more gap between items, wrap comment */
  .talk-row { grid-template-columns: 3.5rem 1fr; gap: 0.75rem; align-items: start; }
  .talk-item { padding: 0.75rem 0; }
  .talk-pres-list .talk-row-detail { padding-left: 1rem; }
  #cv-talks .talk-pres-list .talk-row-detail { padding-left: 1rem; }
  .talk-comment { white-space: normal; display: inline; }

  /* CV h2 name+button: stack vertically */
  h2[style*="justify-content"] { flex-direction: column; align-items: flex-start; gap: 0.5rem; }

  /* CV contact: prevent overflow */
  #cv-contact { overflow-wrap: break-word; word-break: break-word; }

  /* CV download button: hide on mobile (print doesn't work well on mobile) */
  .cv-download { display: none; }

  /* CV references: single column, no indent */
  .cv-references-grid { grid-template-columns: 1fr; padding-left: 0; }

  /* Teaching courses: full-width, not crammed under year */
  #teaching .talk-row { grid-template-columns: 1fr; gap: 0.15rem; }
  #cv-teaching .cv-item { grid-template-columns: 1fr; gap: 0.15rem; }
}
