/* Palette drawn from the portrait: autumn ochre against evergreen. */
:root {
  --paper: #f5f6f2;
  --ink: #1d2620;
  --muted: #5b685f;
  --rule: #d6dbd2;
  --link: #2c5a4b;
  --ochre: #a1660f;
  --field: #ffffff;

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;

  --measure: 38rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151a17;
    --ink: #e4e8e1;
    --muted: #9ca79f;
    --rule: #2e3631;
    --link: #93c7b3;
    --ochre: #dba648;
    --field: #1c221e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151a17;
  --ink: #e4e8e1;
  --muted: #9ca79f;
  --rule: #2e3631;
  --link: #93c7b3;
  --ochre: #dba648;
  --field: #1c221e;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--link) 40%, transparent);
}
a:hover { text-decoration-color: var(--ochre); }
:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: -999px; top: 0.5rem;
  background: var(--ink); color: var(--paper); padding: 0.4rem 0.8rem;
  font-family: var(--sans); font-size: 0.9rem;
}
.skip:focus { left: 0.5rem; }

/* Header and footer ------------------------------------------------------- */
.site-header,
.site-footer,
main {
  max-width: 68rem;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-top: 1.75rem;
  padding-bottom: 1.75rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.site-name {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.2rem 0;
  border-bottom: 1px solid transparent;
}
.site-header nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
.site-header nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ochre); }

.site-footer {
  width: min(calc(68rem - 2 * var(--gutter)), calc(100% - 2 * var(--gutter)));
  padding-left: 0;
  padding-right: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  margin: 5rem auto 0;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); margin-left: 1.25rem; }
.site-footer a:first-child { margin-left: 0; }

/* Type ------------------------------------------------------------------- */
h1, h2, h3 { font-weight: 400; line-height: 1.2; margin: 0; }
h1 { font-size: clamp(2rem, 3.6vw, 2.75rem); letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-family: var(--sans); font-size: 1rem; font-weight: 500; color: var(--muted); }
p { margin: 0 0 1em; }
.prose { max-width: var(--measure); }
.prose p:last-child { margin-bottom: 0; }
.lede { font-size: 1.3rem; line-height: 1.5; color: var(--muted); max-width: var(--measure); margin-top: 1rem; }

/* Home ------------------------------------------------------------------- */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: start;
  padding-top: clamp(0.5rem, 3vw, 2.5rem);
}
.portrait { margin: 0; }
.portrait img { width: 100%; border-radius: 3px; }
.intro h1 { max-width: 20ch; margin-bottom: 1.5rem; }
.intro .prose p { color: var(--ink); }

.actions {
  list-style: none;
  margin: 2rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.button {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.6rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  border-radius: 3px;
}
.button:hover { background: var(--link); color: var(--paper); }

/* Inner pages ------------------------------------------------------------ */
.page { padding-top: clamp(0.5rem, 3vw, 2.5rem); }
.page > h1 { max-width: var(--measure); }

.themes { margin-top: 3.5rem; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.75rem 4rem; }
.theme h2 { font-size: 1.35rem; margin-bottom: 0.6rem; }
.theme p { margin: 0; }

.pubs { margin-top: 5rem; padding-top: 2.5rem; border-top: 1px solid var(--rule); }
.pubs > h2 { margin-bottom: 0.5rem; }
.pubs h3 { margin: 2.25rem 0 0.75rem; }
.refs { list-style: none; margin: 0; padding: 0; max-width: 52rem; }
.refs li {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.55rem 0;
  font-size: 1rem;
  line-height: 1.5;
}
.refs .year { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); padding-top: 0.15em; }
.refs b { font-weight: 600; }
.refs a { overflow-wrap: anywhere; }

.company { margin-top: 3.5rem; display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 8fr); gap: 1rem 4rem; }
.company + .company { padding-top: 3.5rem; border-top: 1px solid var(--rule); }
.company h2 a { color: var(--ink); text-decoration-color: var(--rule); }
.company h2 a:hover { text-decoration-color: var(--ochre); }
.role-dates { white-space: nowrap; }
.role { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Contact form ----------------------------------------------------------- */
.narrow { max-width: var(--measure); }
.contact { margin-top: 2.5rem; display: grid; gap: 0.35rem; }
.contact label { font-family: var(--sans); font-size: 0.9rem; font-weight: 500; margin-top: 1rem; }
.contact label:first-of-type { margin-top: 0; }
.contact input,
.contact textarea {
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.6rem 0.75rem;
  width: 100%;
}
.contact input:focus,
.contact textarea:focus { border-color: var(--link); outline: 2px solid color-mix(in srgb, var(--link) 25%, transparent); outline-offset: 0; }
.contact textarea { resize: vertical; min-height: 9rem; }
.contact button {
  justify-self: start;
  margin-top: 1.25rem;
  font-family: var(--sans);
  font-size: 0.95rem;
  padding: 0.65rem 1.25rem;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
}
.contact button:hover { background: var(--link); }
.contact button:disabled { opacity: 0.6; cursor: progress; }
.hp { position: absolute; left: -9999px; }
.form-status { font-family: var(--sans); font-size: 0.95rem; margin: 0.75rem 0 0; min-height: 1.5em; }
.form-status.is-sent { color: var(--link); }
.form-status.is-error { color: #b3261e; }

/* Blog ------------------------------------------------------------------- */
.post-list { list-style: none; margin: 2.5rem 0 0; padding: 0; max-width: 46rem; }
.post-list li { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); }
.post-list time { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); padding-top: 0.2em; }
.post-list a { font-size: 1.25rem; }
.post-list p { margin: 0.25rem 0 0; color: var(--muted); }
.post-list .ext { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.post .meta { font-family: var(--sans); font-size: 0.9rem; color: var(--muted); margin-top: 0.75rem; }
.post .prose { margin-top: 2.5rem; }
.post .prose h2 { margin: 2rem 0 0.75rem; }

/* Thesis ----------------------------------------------------------------- */
.thesis { margin-top: 3rem; display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: 2rem 4rem; align-items: start; }
.thesis-details dl { margin: 1.75rem 0 0; font-size: 1rem; line-height: 1.5; }
.thesis-details dt { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); margin-top: 1.25rem; }
.thesis-details dd { margin: 0.25rem 0 0; }

/* Small screens ---------------------------------------------------------- */
@media (max-width: 760px) {
  body { font-size: 1.0625rem; }
  .intro { grid-template-columns: 1fr; }
  .portrait { max-width: 18rem; }
  .themes { grid-template-columns: 1fr; gap: 2.25rem; }
  .company { grid-template-columns: 1fr; }
  .thesis { grid-template-columns: 1fr; }
  .refs li { grid-template-columns: 1fr; gap: 0.1rem; }
  .post-list li { grid-template-columns: 1fr; gap: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
