/* Anders Malthe-Sørenssen — personal homepage
   Plain CSS, no build step. Colours are tokens on :root; dark mode follows the system. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1c1f21;
  --muted: #5d666b;
  --rule: #e2dfd8;
  --accent: #156082;
  --accent-strong: #0e4a66;
  --accent-soft: #e6f0f4;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --measure: 68ch;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101315;
    --surface: #171b1e;
    --text: #e8e6e1;
    --muted: #9aa4a9;
    --rule: #2a3035;
    --accent: #5fb4d6;
    --accent-strong: #8ccbe5;
    --accent-soft: #15272f;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 20; background: var(--surface); padding: 8px 12px; }

/* ── Header ── */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 56px; }
.brand { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; color: var(--text); text-decoration: none; white-space: nowrap; }
.site-header nav { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; }
.site-header nav::-webkit-scrollbar { display: none; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 0.9rem; white-space: nowrap; padding: 6px 0; }
.site-header nav a:hover { color: var(--accent); }

/* ── Sections ── */
section { padding: clamp(48px, 7vw, 84px) 0; border-bottom: 1px solid var(--rule); }
section:last-of-type { border-bottom: 0; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); letter-spacing: -0.015em; }
h2 { font-size: clamp(1.5rem, 3vw, 1.9rem); margin-bottom: 20px; }
h2::before {
  content: ""; display: block; width: 36px; height: 3px; background: var(--accent); margin-bottom: 16px;
}
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; max-width: var(--measure); text-wrap: pretty; }
.section-intro { color: var(--muted); margin-bottom: 32px; }

/* ── Hero ── */
.hero { padding-top: clamp(40px, 7vw, 88px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: clamp(28px, 5vw, 64px); align-items: start; }
.eyebrow { font-size: 0.8rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 14px; }
.lede { font-family: var(--serif); font-size: clamp(1.15rem, 2.2vw, 1.35rem); line-height: 1.5; margin-top: 22px; }

.links { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 10px; }
.links a {
  display: inline-block; padding: 8px 16px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.92rem; font-weight: 500;
}
.links a:hover { border-color: var(--accent); color: var(--accent); }
.links li:first-child a { background: var(--accent); border-color: var(--accent); color: #fff; }
.links li:first-child a:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
@media (prefers-color-scheme: dark) {
  .links li:first-child a, .links li:first-child a:hover { color: #0b1114; }
}

.portrait {
  margin: 0; position: relative; aspect-ratio: 4 / 5; border-radius: 6px; overflow: hidden;
  background: var(--accent-soft); border: 1px solid var(--rule);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait .initials {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 3rem; color: var(--accent); letter-spacing: 0.04em;
}
.portrait.no-photo img { display: none; }
.portrait.no-photo .initials { display: flex; }

/* ── Research themes ── */
.themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(28px, 5vw, 64px); }
.themes article { padding: 22px 0; border-top: 1px solid var(--rule); }
.themes h3 { margin-bottom: 8px; }
.themes p { color: var(--muted); margin: 0; font-size: 0.98rem; }

/* ── Publications ── */
.pub-group {
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--accent); margin: 36px 0 4px;
}
.pubs { list-style: none; margin: 0; padding: 0; }
.pubs li { padding: 16px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 2px; max-width: 80ch; }
.pubs .title { font-family: var(--serif); font-size: 1.08rem; line-height: 1.35; font-weight: 600; color: var(--text); text-decoration: none; order: -1; }
.pubs .title:hover { color: var(--accent); text-decoration: underline; }
.pubs .authors { font-size: 0.92rem; color: var(--muted); }
.pubs .authors b { color: var(--text); font-weight: 600; }
.pubs .venue { font-size: 0.92rem; color: var(--muted); }

/* ── Books ── */
.books { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 20px; }
.books article {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 24px 26px;
}
.book-meta { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.02em; margin-bottom: 8px; }
.books h3 { font-size: 1.3rem; margin-bottom: 10px; }
.books h3 a { color: var(--text); text-decoration: none; }
.books h3 a:hover { color: var(--accent); text-decoration: underline; }
.books article { display: flex; flex-direction: column; }
.books article > p:not(.book-meta):not(.card-links) { color: var(--muted); font-size: 0.98rem; }
.books article > p:last-child { margin-bottom: 0; }
.card-links { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.92rem; font-weight: 600; }
.card-links a { text-decoration: none; }
.card-links a:hover { text-decoration: underline; }
.plain .sub { display: block; font-size: 0.9rem; color: var(--muted); margin-top: 2px; }
.plain .sub a { font-weight: 500; margin-right: 0; }

.more { margin: 24px 0 0; font-weight: 600; }
.more a { text-decoration: none; }
.more a:hover { text-decoration: underline; }

/* ── Media page ── */
.page-head { padding-top: clamp(40px, 6vw, 72px); padding-bottom: clamp(28px, 4vw, 44px); }
.page-head h1 { font-size: clamp(2rem, 5vw, 3rem); }
.page-head p { color: var(--muted); margin: 18px 0 0; }
.back { display: inline-block; margin-bottom: 18px; font-size: 0.9rem; text-decoration: none; }
.back:hover { text-decoration: underline; }
.site-header nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.mentions { list-style: none; margin: 0; padding: 0; }
.mentions li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 20px; padding: 14px 0; border-top: 1px solid var(--rule); }
.mentions time, .mentions .when { color: var(--accent); font-weight: 600; font-size: 0.9rem; font-variant-numeric: tabular-nums; padding-top: 3px; white-space: nowrap; }
.mentions .item { display: grid; gap: 2px; max-width: 78ch; }
.mentions .title { font-family: var(--serif); font-size: 1.08rem; line-height: 1.35; font-weight: 600; color: var(--text); text-decoration: none; }
.mentions .title:hover { color: var(--accent); text-decoration: underline; }
.mentions .outlet { font-size: 0.8rem; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mentions .note { font-size: 0.93rem; color: var(--muted); }

/* ── Book and exam pages ── */
.page-head .eyebrow { margin: 0 0 14px; }
.page-head .subtitle { font-family: var(--serif); font-size: clamp(1.1rem, 2.2vw, 1.3rem); color: var(--muted); margin: 12px 0 0; }
.page-head .links { margin-top: 26px; }
section .links { margin: 20px 0 0; }
.fine { font-size: 0.92rem; color: var(--muted); margin: 22px 0 0; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-block; padding: 3px 12px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); font-size: 0.86rem; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.pill:hover { border-color: var(--accent); }
.week-topic { font-family: var(--serif); font-size: 1.08rem; font-weight: 600; line-height: 1.35; }
.week-topic .note { font-family: var(--sans); font-weight: 400; }
.weeks .item, .exam-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; max-width: none; }
.exams .item { display: grid; gap: 12px; max-width: none; }
.books + .pub-group { margin-top: 44px; }
.books.pairs { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
@media (max-width: 760px) { .books.pairs { grid-template-columns: 1fr; } }

.filelist { list-style: none; margin: 24px 0 0; padding: 0; columns: 4 170px; column-gap: 28px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; }
.filelist li { padding: 4px 0; break-inside: avoid; }
.filelist a { text-decoration: none; }
.filelist a:hover { text-decoration: underline; }

/* ── Timeline ── */
.timeline { margin: 0; }
.timeline > div { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-top: 1px solid var(--rule); }
.timeline dt { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: 0.95rem; padding-top: 2px; }
.timeline dd { margin: 0; max-width: var(--measure); color: var(--muted); }
.timeline dd b { color: var(--text); display: block; font-weight: 600; margin-bottom: 2px; }

/* ── Two-column blocks ── */
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(32px, 6vw, 72px); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 10px 0; border-top: 1px solid var(--rule); }
.plain a { font-variant-numeric: tabular-nums; font-weight: 600; margin-right: 8px; text-decoration: none; }
.plain a:hover { text-decoration: underline; }

.awards { list-style: none; padding: 0; margin: 0; }
.awards li { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.awards span { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

address { font-style: normal; color: var(--muted); align-self: end; }

/* ── Footer ── */
.site-footer { padding: 28px 0 40px; border-top: 1px solid var(--rule); }
.site-footer p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.site-footer .credit { margin-top: 6px; }

/* ── Small screens ── */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .brand { display: none; }
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { width: 160px; order: -1; }
  .themes, .two-col { grid-template-columns: 1fr; }
  .timeline > div { grid-template-columns: 1fr; gap: 4px; }
  .mentions li { grid-template-columns: 1fr; gap: 2px; }
  address { align-self: start; }
}

@media print {
  .site-header { display: none; }
  section { padding: 20px 0; }
  a { color: inherit; }
}
