/*
  Academic adaptation of The Monospace Web by Oskar Wickström.
  Original: https://github.com/owickstrom/the-monospace-web
  License: MIT. This stylesheet borrows the all-monospace, grid-conscious
  typography, bordered tables, compact lists, and sparse neutral palette.
*/

:root {
  --font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono",
    Menlo, monospace;
  --line-height: 1.45rem;
  --border-thickness: 2px;
  --text-color: #17130f;
  --text-color-alt: #6c6255;
  --background-color: #f4eddf;
  --background-color-alt: #e8dcc9;
  --max-width: 84ch;

  color-scheme: light;
  font-family: var(--font-family);
  font-size: 16px;
  font-style: normal;
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 500;
  line-height: var(--line-height);
}

@media (prefers-color-scheme: dark) {
  :root {
    --text-color: #f5f5f5;
    --text-color-alt: #aaa;
    --background-color: #050505;
    --background-color-alt: #171717;

    color-scheme: dark;
  }
}

:root[data-theme="light"] {
  --text-color: #17130f;
  --text-color-alt: #6c6255;
  --background-color: #f4eddf;
  --background-color-alt: #e8dcc9;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --text-color: #f5f5f5;
  --text-color-alt: #aaa;
  --background-color: #050505;
  --background-color-alt: #171717;

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background-color);
  color: var(--text-color);
}

body {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--line-height) 2ch calc(var(--line-height) * 2);
  overflow-x: hidden;
}

/* Base typography */

h1,
h2,
h3 {
  font-weight: 800;
  line-height: var(--line-height);
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: calc(var(--line-height) * 2);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

h2 {
  margin-top: calc(var(--line-height) * 2);
  font-size: 1rem;
  text-transform: uppercase;
}

h3 {
  margin-top: 0;
  font-size: 1rem;
}

p,
li,
td,
th {
  overflow-wrap: break-word;
  hyphens: auto;
}

p + p,
p + ul,
ul + p,
.project + .project,
.publication-list li + li {
  margin-top: var(--line-height);
}

a {
  color: var(--text-color);
  text-decoration-thickness: var(--border-thickness);
  text-underline-offset: 0.16em;
}

a:visited {
  color: var(--text-color);
}

a:focus-visible {
  outline: var(--border-thickness) solid var(--text-color);
  outline-offset: 2px;
}

code {
  font-family: var(--font-family);
  font-weight: 700;
}

hr {
  position: relative;
  height: var(--line-height);
  margin: calc(var(--line-height) * 1.5) 0;
  border: 0;
}

hr::after {
  position: absolute;
  top: calc(var(--line-height) / 2 - var(--border-thickness));
  left: 0;
  width: 100%;
  border-top: calc(var(--border-thickness) * 3) double var(--text-color);
  content: "";
}

/* Layout */

.skip-link {
  position: absolute;
  top: -100vh;
  left: 2ch;
  z-index: 10;
  padding: calc(var(--line-height) / 2) 1ch;
  border: var(--border-thickness) solid var(--text-color);
  background: var(--background-color);
}

.skip-link:focus {
  top: var(--line-height);
}

.site-header {
  position: relative;
  padding-bottom: var(--line-height);
  border-bottom: calc(var(--border-thickness) * 3) double var(--text-color);
}

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 8ch;
  height: calc(var(--line-height) * 1.5);
  padding: calc(var(--line-height) / 4 - var(--border-thickness)) 1ch;
  border: var(--border-thickness) solid var(--text-color);
  background: var(--background-color);
  color: var(--text-color);
  font: inherit;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--background-color-alt);
}

.theme-toggle:focus-visible {
  outline: var(--border-thickness) solid var(--text-color);
  outline-offset: 2px;
}

.theme-toggle:active {
  transform: translate(1px, 1px);
}

.identity {
  padding-right: 10ch;
}

.identity > * + * {
  margin-top: var(--line-height);
}

.subtitle {
  font-weight: 700;
}

.affiliation,
.meta,
.notice {
  color: var(--text-color-alt);
}

.site-nav {
  margin-top: var(--line-height);
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2ch;
  list-style: none;
}

.site-nav li {
  margin: 0;
}

.site-nav a::before {
  content: "[";
}

.site-nav a::after {
  content: "]";
}

main {
  margin-top: calc(var(--line-height) * 2);
}

section {
  scroll-margin-top: var(--line-height);
}

.site-footer {
  margin-top: calc(var(--line-height) * 2);
  padding-top: var(--line-height);
  border-top: calc(var(--border-thickness) * 3) double var(--text-color);
}

/* Lists and repeated academic entries */

ul {
  padding-left: 2ch;
  list-style: square;
}

li {
  margin: 0;
}

.compact-list li + li,
.contact-list li + li {
  margin-top: calc(var(--line-height) / 2);
}

/* Verschachtelte Abschnitte (Academic / SOEP-RegioHub / Tools) brauchen Luft: h3 hat
   margin-top: 0, damit eine Überschrift direkt unter ihrem h2 sitzt, und ohne diese Regel
   klebt die zweite Untergruppe am letzten Absatz der ersten. */
main section section + section {
  display: block;
  margin-top: calc(var(--line-height) * 2);
}

.project,
.publication-list li {
  padding-top: calc(var(--line-height) - var(--border-thickness));
  border-top: var(--border-thickness) solid var(--text-color);
}

.project p {
  margin-top: calc(var(--line-height) / 2);
}

.publication-list {
  padding-left: 0;
  list-style: none;
}

.notice {
  display: inline-block;
  padding: calc(var(--line-height) / 2 - var(--border-thickness)) 1ch;
  border: var(--border-thickness) solid var(--text-color);
  color: var(--text-color);
}

address {
  font-style: normal;
}

/* Tables */

table {
  width: 100%;
  margin-top: var(--line-height);
  border-collapse: collapse;
}

caption {
  margin-bottom: calc(var(--line-height) / 2);
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  padding: calc(var(--line-height) / 2) 1ch;
  border: var(--border-thickness) solid var(--text-color);
  line-height: var(--line-height);
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 800;
  background: var(--background-color-alt);
}

/* Mobile */

@media (max-width: 640px) {
  body {
    padding-right: 1ch;
    padding-left: 1ch;
  }

  .site-nav ul {
    gap: 0 1ch;
  }

  .theme-toggle {
    position: static;
    float: right;
    margin-bottom: var(--line-height);
  }

  .identity {
    padding-right: 0;
  }

  .cv-table,
  .cv-table caption,
  .cv-table thead,
  .cv-table tbody,
  .cv-table tr,
  .cv-table th,
  .cv-table td {
    display: block;
    width: 100%;
  }

  .cv-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .cv-table tr {
    margin-top: var(--line-height);
    border: var(--border-thickness) solid var(--text-color);
  }

  .cv-table td {
    border: 0;
    border-top: var(--border-thickness) solid var(--text-color);
  }

  .cv-table td:first-child {
    border-top: 0;
  }

  .cv-table td::before {
    display: block;
    margin-bottom: calc(var(--line-height) / 4);
    color: var(--text-color-alt);
    font-weight: 800;
    content: attr(data-label);
    text-transform: uppercase;
  }
}
