/* =============================================================
   sven-karbach.de
   A document, not an interface. One typeface for reading, the
   original monospace kept for metadata, and no JavaScript.
   ============================================================= */

/* ------------------------------------------------------ tokens */
:root {
  --paper:   #fbfaf6;   /* warm near-white  */
  --ink:     #1c1e1b;   /* green-black      */
  --ink-2:   #4c4f47;
  --ink-3:   #7d8077;
  --rule:    #ddd9cd;
  --rule-2:  #ebe8de;
  --accent:  #7c6a2c;   /* muted olive; only ever on hover */

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --pad:  clamp(1.4rem, 5vw, 3rem);
  --inset: clamp(0rem, 9vw - var(--pad), 12rem);
  --rail: 7rem;
  --gap:  2.25rem;
  --page: 51.25rem;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #141613;
    --ink:    #eceadf;
    --ink-2:  #b3b5a9;
    --ink-3:  #83867b;
    --rule:   #2e312b;
    --rule-2: #232620;
    --accent: #c3ae67;
    color-scheme: dark;
  }
}

/* -------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1rem, 0.955rem + 0.2vw, 1.125rem);
  font-weight: 400;
  line-height: 1.62;
  font-optical-sizing: auto;
  font-variant-numeric: oldstyle-num;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p { text-wrap: pretty; }
:where(h1, h2, h3) { font-weight: 400; text-wrap: balance; }
ul { list-style: none; padding: 0; }
img, svg, video, iframe { display: block; max-width: 100%; }
em, i, cite { font-style: italic; }

::selection { background: var(--rule); color: var(--ink); }

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* Links keep the original's hairline, corrected: it now skips
   descenders and darkens to the accent instead of to grey. */
a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule);
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: auto;
  transition: text-decoration-color .18s ease;
}
a:hover { text-decoration-color: var(--accent); }

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--paper);
  padding: .6rem 1rem;
}
.skip:focus { left: 0; top: 0; z-index: 9; }

/* ------------------------------------------------------ layout */
/* An asymmetric composition with a responsive inset on wider screens. */
.page {
  max-width: var(--page);
  margin-inline: var(--inset) 0;
  padding-inline: var(--pad);
}

.row {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0 var(--gap);
  padding-block: clamp(1.9rem, 1.3rem + 1.8vw, 2.9rem);
  border-top: 1px solid var(--rule-2);
}

/* A second, narrower rail for dated entries inside a row. */
.dl { display: grid; grid-template-columns: 5.6rem minmax(0, 1fr); gap: 1.45em 1.25rem; }
.dl > dt {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em;
  font-variant-numeric: lining-nums; color: var(--ink-3);
  padding-top: 0.5em; line-height: 1.5;
}
.dl > dd { margin: 0; }
.dl > dd > p { color: var(--ink-2); }
@media (max-width: 34rem) {
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl > dt { padding-top: 0; margin-bottom: 0.35rem; }
  .dl > dd + dt { margin-top: 1.45em; }
}

/* The rail: every label, year and marker lives here and nowhere else. */
.rail {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
  color: var(--ink-3);
  line-height: 1.7;
  padding-top: 0.42em;
}

@media (max-width: 46rem) {
  :root { --inset: 0rem; }
  .row { grid-template-columns: 1fr; }
  .rail { padding-top: 0; margin-bottom: 0.8rem; }
}

.measure { max-width: 36rem; }
.flow > * + * { margin-top: 1.05em; }
.flow > * + .sub { margin-top: 1.9em; }

/* ---------------------------------------------------- masthead */
.masthead { padding-block: clamp(3.5rem, 2rem + 6vw, 7rem) 0; }
.masthead-video {
  display: block;
  max-width: 17.5rem;
  margin-top: 1.5rem;
}

.name {
  font-size: clamp(2.35rem, 1.6rem + 3.2vw, 3.6rem);
  line-height: 1.02;
  letter-spacing: -0.017em;
  margin-bottom: 0.5rem;
}
.name a { text-decoration: none; }

.role {
  color: var(--ink-2);
  font-size: 0.95em;
  margin-block: 0.75rem 1rem;
}

.standfirst {
  font-size: clamp(1.05rem, 1rem + 0.35vw, 1.3rem);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 30rem;
  text-wrap: balance;
}
.standfirst em { color: var(--ink); }

nav.top {
  margin-top: clamp(1.8rem, 1.2rem + 2vw, 2.8rem);
  padding-bottom: 0.9rem;
  display: flex; flex-wrap: wrap; gap: 0.35rem 1.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
nav.top a { text-decoration-color: transparent; color: var(--ink-3); transition: color .18s ease, text-decoration-color .18s ease; }
nav.top a:hover { color: var(--ink); text-decoration-color: var(--rule); }
nav.top a[aria-current] { color: var(--ink); text-decoration-color: var(--rule); }

/* --------------------------------------------------- headings */
h3, .entry__title {
  font-size: 1em;
  font-weight: 500;
  line-height: 1.4;
}
.course-title {
  font-size: clamp(1.5rem, 1.3rem + 0.5vw, 1.75rem);
  font-weight: 400;
  line-height: 1.2;
  scroll-margin-top: 2rem;
}
.flow > .course-title + p { margin-top: 0.65em; }
.sub {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.7rem;
}

/* ------------------------------------------------------ items */
.items > li + li { margin-top: 1.15em; }
.items p { color: var(--ink-2); }
.items .who { color: var(--ink-2); }

.inline { color: var(--ink-2); }
.inline li { display: inline; }
.inline li + li::before { content: " · "; color: var(--ink-3); }

/* ------------------------------------------------ bibliography */
.bib > li + li { margin-top: 1.5em; }
.bib .t { display: block; font-weight: 500; }
.bib .t a { text-decoration-color: var(--ink-3); }
.bib .t a:hover { text-decoration-color: var(--accent); }
.bib .meta {
  display: block;
  margin-top: 0.3em;
  font-size: 0.9em;
  line-height: 1.55;
  color: var(--ink-2);
}
.bib .a, .bib .v { color: var(--ink-2); }
.bib .me { color: var(--ink); font-weight: 500; }
.bib .id {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  font-variant-numeric: lining-nums;
  color: var(--ink-3);
  display: inline-block;
  margin-top: 0.15em;
}

/* --------------------------------------------------- syllabus */
.course-index { padding-block: 1.2rem; }
.course-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
}
details { border-top: 1px solid var(--rule-2); }
details:last-of-type { border-bottom: 1px solid var(--rule-2); }
summary {
  list-style: none;
  cursor: pointer;
  padding-block: 0.62em;
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr) 1rem;
  align-items: baseline;
  color: var(--ink-2);
  transition: color .18s ease;
}
summary::-webkit-details-marker { display: none; }
summary:hover { color: var(--ink); }
summary .n {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-variant-numeric: lining-nums;
  color: var(--ink-3);
}
summary .mark {
  justify-self: end;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1;
}
summary .mark::after { content: "+"; }
details[open] summary { color: var(--ink); }
details[open] summary .mark::after { content: "–"; }
.detail {
  padding: 0.1rem 0 1.1rem 2.1rem;
  color: var(--ink-2);
  font-size: 0.94em;
}
.detail > * + * { margin-top: 0.75em; }
.detail li { padding-left: 1.05em; text-indent: -1.05em; }
.detail li + li { margin-top: 0.25em; }
.detail li::before { content: "— "; color: var(--ink-3); }

/* ----------------------------------------------------- figure */
.figure { margin-block: 1.9em; }
.portrait { max-width: 17.5rem; }

/* The masthead video and research visual use the open right margin on wide screens. */
@media screen and (min-width: 76rem) {
  .masthead {
    max-width: calc(var(--page) + 19rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    column-gap: 4rem;
    align-items: start;
  }
  .masthead > :not(.masthead-video) { grid-column: 1; }
  .masthead-video {
    display: block;
    grid-column: 2;
    grid-row: 1 / span 4;
    max-width: 17rem;
    margin-top: 0.15rem;
  }
  .home {
    max-width: calc(var(--page) + 19rem);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    column-gap: 4rem;
    align-items: start;
  }
  .home > .row { grid-column: 1; }
  .home > .research-row {
    grid-column: 1 / -1;
  }
  .research-row .measure {
    max-width: none;
  }
  .research-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 17rem;
    gap: 4rem;
  }
  .research-visual .figure {
    margin-block: 0 1.5rem;
  }
  .research-interest {
    color: var(--ink-2);
    margin-top: 1.5em;
  }
}

.figure__art { width: 100%; height: auto; color: var(--ink); }
figcaption {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin-top: 0.9rem;
  max-width: 30rem;
  line-height: 1.6;
}

video {
  width: 100%;
  height: auto;            /* the width/height attributes carry the aspect ratio */
  border: 1px solid var(--rule-2);
  background: var(--rule-2);
}

/* ----------------------------------------------------- footer */
footer.page {
  border-top: 1px solid var(--rule-2);
  margin-top: clamp(3rem, 2rem + 4vw, 5rem);
  padding-block: 1.6rem clamp(3rem, 2rem + 4vw, 5rem);
  display: flex; flex-wrap: wrap; gap: 0.5rem 2rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
footer.page a { text-decoration-color: transparent; }
footer.page a:hover { text-decoration-color: var(--rule); }
footer .end { margin-left: auto; }

/* ------------------------------------------------------ print */
@media print {
  :root {
    --paper: #fff; --ink: #000; --ink-2: #333; --ink-3: #555;
    --rule: #bbb; --rule-2: #ddd; --accent: #000;
    --inset: 0rem; --page: 47rem;
  }
  body { font-size: 10.5pt; line-height: 1.45; }
  nav.top, video, .no-print { display: none; }
  .row { break-inside: avoid; padding-block: 0.9rem; }
  .masthead { padding-block: 0 0; }
  a { text-decoration: none; }
  .print-urls .items a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-family: var(--mono); font-size: 7.5pt; color: #555;
    word-break: break-all;
  }
  footer.page { border-top: 1px solid #ddd; }
  @page { margin: 16mm 14mm; }
}

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