/* Niklas Schumann, personal site. One stylesheet, no JavaScript, no external requests. */

/* ---------- Fonts (self-hosted, OFL; licences in fonts/) ---------- */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/manrope-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("fonts/manrope-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;

  /* Colour, light: warm paper, ink, one brick red. */
  --paper: #f8f6f1;
  --paper-sunk: #efece4;
  --ink: #1d1b18;
  --ink-soft: #57524a;
  --rule: #d9d4c8;
  --accent: #8f2f12;
  --mark: #f3dfa2;

  --code-comment: #625c53;
  --code-keyword: #8f2f12;
  --code-string: #2f5d1e;
  --code-constant: #1f4f86;
  --code-name: #1d1b18;

  /* Type */
  --font-text: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --text-small: 0.8125rem;
  --text-meta: 0.875rem;
  --text-body: 1.0625rem;
  --text-lede: 1.25rem;
  --text-h3: 1.1875rem;
  --text-h2: 1.5rem;
  --text-h1: 2rem;
  --text-code: 0.875em;

  --leading-body: 1.7;
  --leading-tight: 1.2;

  --weight-body: 450;
  --weight-strong: 700;
  --weight-heading: 700;

  /* Space */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  /* Measure: the text column, and the margin that labels hang in on wide screens. */
  --measure: 37rem;
  --gutter: 11rem;
  --page-pad: 1.25rem;
}

@media (min-width: 40rem) {
  :root {
    --text-body: 1.125rem;
    --text-lede: 1.375rem;
    --text-h3: 1.25rem;
    --text-h2: 1.625rem;
    --text-h1: 2.5rem;
    --measure: 39rem;
    --page-pad: 2rem;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171614;
    --paper-sunk: #201e1b;
    --ink: #e9e5dc;
    --ink-soft: #b0aa9e;
    --rule: #3a3731;
    --accent: #f0a583;
    --mark: #5c4a12;

    --code-comment: #a39d91;
    --code-keyword: #f0a583;
    --code-string: #a9cf93;
    --code-constant: #9cc3ee;
    --code-name: #e9e5dc;

    /* Light text on dark reads heavier; take a little weight back. */
    --weight-body: 400;
  }
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-5);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-body);
  font-weight: var(--weight-body);
  line-height: var(--leading-body);
  font-synthesis-weight: none;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

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

/* The frame: header, main and footer share one centred text column. */
.site-header,
main,
.site-footer {
  width: min(100% - 2 * var(--page-pad), var(--measure));
  margin-inline: auto;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: var(--weight-heading);
  line-height: var(--leading-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-h1);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

h2 {
  font-size: var(--text-h2);
}

h3,
h4 {
  font-size: var(--text-h3);
  line-height: 1.3;
}

p,
ul,
ol,
dl,
figure,
blockquote,
pre,
table {
  margin: 0;
}

p {
  text-wrap: pretty;
}

/* German compounds need hyphenation to fit a phone; set on the element that carries `lang`, so it inherits. */
[lang="de"] {
  hyphens: auto;
}

[lang="en"] {
  hyphens: manual;
}

strong,
b {
  font-weight: var(--weight-strong);
}

small {
  font-size: var(--text-meta);
}

mark {
  background: var(--mark);
  color: inherit;
  padding: 0 0.15em;
}

abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

/* ---------- Links and focus ---------- */

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 0.06em;
  text-underline-offset: 0.22em;
}

a:hover {
  text-decoration-thickness: 0.14em;
}

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

.skip-link {
  position: absolute;
  left: var(--page-pad);
  top: 0;
  transform: translateY(-120%);
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--paper);
  font-size: var(--text-meta);
  font-weight: var(--weight-strong);
  z-index: 1;
}

.skip-link:focus {
  transform: translateY(var(--space-2));
  outline-color: var(--paper);
  outline-offset: -5px;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-5);
  padding-block: var(--space-5) var(--space-4);
  font-size: var(--text-meta);
  line-height: 1.5;
}

.site-name {
  flex: 1 0 100%;
  color: var(--ink);
  font-size: 1rem;
  font-weight: var(--weight-heading);
  letter-spacing: -0.01em;
  text-decoration-line: none;
}

.site-name:hover {
  text-decoration-line: underline;
}

.site-nav {
  flex: 1;
}

.site-nav ul,
.lang-switch ul {
  display: flex;
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header nav a {
  display: inline-block;
  padding-block: var(--space-2);
  color: var(--ink);
  font-weight: 550;
  text-decoration-color: var(--rule);
}

.site-header nav a:hover {
  text-decoration-color: currentColor;
}

/* The page you are on, and the language you read: heavier and marked with the accent, not colour alone. */
.site-header nav a[aria-current] {
  font-weight: var(--weight-strong);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.14em;
}

.lang-switch ul {
  gap: 0;
}

.lang-switch li + li::before {
  content: "|";
  margin-inline: var(--space-2);
  color: var(--ink-soft);
  font-weight: 400;
}

.lang-switch a {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  letter-spacing: 0.04em;
}

/* ---------- Main ---------- */

main {
  padding-block: var(--space-6) var(--space-7);
}

main:focus {
  outline: none;
}

/* A section is a label and a body. On narrow screens the label sits above; on wide ones it hangs in the margin. */
.section + .section {
  margin-top: var(--space-7);
}

.label {
  margin-bottom: var(--space-3);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-wrap: wrap;
}

h2.label,
h3.label {
  letter-spacing: 0.02em;
}

.label > span,
.label > time,
.label > a {
  display: inline-block;
  margin-right: var(--space-4);
}

.body > * + * {
  margin-top: var(--space-4);
}

.lede {
  font-size: var(--text-lede);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.page-head h1 + .lede {
  margin-top: var(--space-5);
}

/* ---------- Post lists ---------- */

.posts {
  padding: 0;
  list-style: none;
}

.posts > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-5);
}

.posts > li + li {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
}

.posts h2,
.posts h3 {
  flex: 1 0 100%;
  font-size: var(--text-h3);
  line-height: 1.35;
  letter-spacing: -0.01em;
  text-wrap: wrap;
}

/* On a phone the date stands above the title; from tablet width on it sits at the end of the title's line. */
.posts time {
  order: -1;
}

@media (min-width: 40rem) {
  .posts h2,
  .posts h3 {
    flex: 1 1 14rem;
  }

  .posts time {
    order: 0;
  }
}

.posts h2 a,
.posts h3 a {
  color: var(--ink);
  text-decoration-color: var(--accent);
}

.posts time,
.history .when {
  flex: none;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.posts p {
  flex: 1 0 100%;
  margin-top: var(--space-1);
  color: var(--ink-soft);
}

.more {
  font-weight: 550;
}

/* ---------- Work history ---------- */

.history {
  padding: 0;
  list-style: none;
}

.history > li + li {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
}

.history .when {
  display: block;
  margin-bottom: var(--space-1);
}

.history h3 + p {
  margin-top: var(--space-2);
}

.plain-list {
  padding: 0;
  list-style: none;
}

/* ---------- Prose: everything Markdown can produce ---------- */

.prose {
  margin-top: var(--space-6);
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2 {
  margin-top: 2.25em;
}

.prose h3,
.prose h4 {
  margin-top: 1.9em;
}

.prose h2 + *,
.prose h3 + *,
.prose h4 + * {
  margin-top: 0.7em;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li + li,
.prose li > ul,
.prose li > ol {
  margin-top: 0.4em;
}

.prose li::marker {
  color: var(--ink-soft);
}

.prose ol > li::marker {
  font-family: var(--font-mono);
  font-size: var(--text-code);
}

.prose ul > li::marker {
  content: "–  ";
}

.prose blockquote {
  padding-left: var(--space-5);
  border-left: 2px solid var(--accent);
  font-size: var(--text-lede);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.prose blockquote > * + * {
  margin-top: var(--space-3);
}

.prose blockquote footer,
.prose blockquote cite {
  color: var(--ink-soft);
  font-size: var(--text-meta);
  font-style: normal;
  font-weight: var(--weight-body);
  letter-spacing: 0;
}

.prose hr {
  width: 4rem;
  height: 1px;
  margin: var(--space-7) 0;
  border: 0;
  background: var(--ink-soft);
}

/* Code */

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: var(--text-code);
  font-variant-ligatures: none;
}

:not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--paper-sunk);
  overflow-wrap: anywhere;
}

a > code {
  color: inherit;
}

kbd {
  padding: 0.1em 0.4em;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
}

pre {
  padding: var(--space-4) var(--space-5);
  border-radius: 3px;
  background: var(--paper-sunk);
  color: var(--code-name);
  font-size: 0.8125rem;
  line-height: 1.65;
  overflow-x: auto;
  tab-size: 4;
  hyphens: none;
  overflow-wrap: normal;
}

pre code {
  font-size: inherit;
}

/* Zola 0.23 highlights with giallo: every token gets a numbered class, `z-N`, per colour of the chosen theme
   (`github-light` in config.toml, whose palette only numbers the classes; giallo.css is not linked).
   The numbers are therefore tied to that theme: 1 constant, 2 string, 3 tag, 4 and 5 comment, 6 function,
   7 and 8 keyword, 9 variable. Re-check them when the theme changes. */
.z-4,
.z-5 {
  color: var(--code-comment);
}

.z-7,
.z-8 {
  color: var(--code-keyword);
  font-weight: 600;
}

.z-2,
.z-3 {
  color: var(--code-string);
}

.z-1,
.z-9 {
  color: var(--code-constant);
}

.z-6 {
  color: var(--code-name);
  font-weight: 700;
}

/* Tables scroll inside themselves, with no wrapper element, since Markdown emits a bare <table>. */
.prose table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--text-meta);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  hyphens: manual;
}

.prose th,
.prose td {
  padding: var(--space-2) var(--space-5) var(--space-2) 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

/* Keep text columns readable: on a phone the table scrolls sideways before its cells get too narrow. */
.prose th:not([align="right"]),
.prose td:not([align="right"]) {
  min-width: 7.5rem;
}

.prose th:last-child,
.prose td:last-child {
  padding-right: 0;
}

.prose thead th {
  border-bottom-color: var(--ink-soft);
  font-weight: var(--weight-strong);
  white-space: nowrap;
}

.prose td[align="right"],
.prose th[align="right"] {
  text-align: right;
}

.prose caption {
  caption-side: bottom;
  padding-top: var(--space-2);
  color: var(--ink-soft);
  text-align: left;
}

/* Figures */

.prose figure {
  margin-block: var(--space-6);
}

.prose figure > svg,
.prose figure > img {
  display: block;
  width: 100%;
}

/* A drawing with lettering stops growing where its letters reach text size. */
.prose figure > svg {
  max-width: 30rem;
}

figcaption {
  margin-top: var(--space-3);
  color: var(--ink-soft);
  font-size: var(--text-meta);
  line-height: 1.5;
}

/* Inline SVG figures draw with the page's own tokens, so they follow light and dark. */
.fig-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
}

.fig-soft {
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.fig-accent {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.fig-fill {
  fill: var(--paper-sunk);
  stroke: var(--ink);
  stroke-width: 1.25;
}

.fig-dot {
  fill: var(--accent);
}

.fig-text {
  fill: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
}

.fig-text-soft {
  fill: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Footnotes, in both shapes Zola can emit. */
.footnote-reference {
  font-family: var(--font-mono);
  font-size: 0.7em;
  line-height: 0;
  vertical-align: super;
}

.footnote-reference a {
  padding: 0.3em 0.2em;
  font-weight: 600;
}

.footnotes,
.footnote-definition {
  color: var(--ink-soft);
  font-size: var(--text-meta);
  line-height: 1.6;
}

.prose > .footnotes {
  margin-top: var(--space-7);
  padding-top: var(--space-4);
  border-top: 1px solid var(--rule);
}

.prose > hr:has(+ .footnotes) {
  display: none;
}

.footnotes ol {
  padding-left: 1.6em;
}

.footnote-definition {
  display: flex;
  gap: var(--space-2);
}

.footnote-definition-label {
  font-family: var(--font-mono);
}

:target {
  background: var(--mark);
  color: var(--ink);
  box-shadow: 0 0 0 0.3em var(--mark);
}

/* ---------- Post frame ---------- */

.post-head h1 + .lede {
  margin-top: var(--space-4);
}

.post-foot {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--rule);
}

.post-foot > * + * {
  margin-top: var(--space-2);
}

/* ---------- Footer ---------- */

.site-footer {
  padding-block: var(--space-5) var(--space-7);
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: var(--text-meta);
  line-height: 1.5;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  display: inline-block;
  padding-block: var(--space-2);
  color: var(--ink-soft);
  text-decoration-color: var(--rule);
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

/* ---------- Wide screens: labels hang in the left margin, the text column stays centred ---------- */

@media (min-width: 64rem) {
  .site-header,
  .section {
    display: grid;
    grid-template-columns: var(--gutter) minmax(0, 1fr);
    margin-left: calc(-1 * var(--gutter));
  }

  .site-header {
    grid-template-columns: var(--gutter) minmax(0, 1fr) auto;
    width: calc(var(--measure) + var(--gutter));
    margin-left: calc(50% - var(--measure) / 2 - var(--gutter));
    gap: 0;
    padding-block: var(--space-6) var(--space-5);
  }

  main {
    padding-block: var(--space-7) var(--space-8);
  }

  .label {
    margin-bottom: 0;
    padding-right: var(--space-5);
    /* Sit on the first baseline of the body text beside it. */
    padding-top: calc((var(--text-body) * var(--leading-body) - var(--text-small) * 1.5) / 2 + 0.08rem);
  }

  .label > span,
  .label > time,
  .label > a {
    display: block;
    margin-right: 0;
  }

  .page-head .label {
    padding-top: calc(var(--text-h1) * 1.12 - var(--text-small) * 1.5 - 0.42rem);
  }

  .section + .section {
    margin-top: var(--space-8);
  }
}

/* ---------- Print ---------- */

@media print {
  :root {
    --paper: #fff;
    --paper-sunk: #fff;
    --ink: #000;
    --ink-soft: #333;
    --rule: #999;
    --accent: #000;
    --mark: #fff;
    --code-comment: #444;
    --code-keyword: #000;
    --code-string: #000;
    --code-constant: #000;
    --code-name: #000;
    --weight-body: 450;
    --text-body: 11pt;
    --text-lede: 13pt;
    --text-h1: 22pt;
    --text-h2: 15pt;
    --text-h3: 12pt;
    --text-meta: 9pt;
    --text-small: 8.5pt;
  }

  @page {
    margin: 22mm 24mm;
  }

  .skip-link,
  .site-nav,
  .lang-switch,
  .site-footer,
  .post-foot {
    display: none;
  }

  .site-header,
  main {
    display: block;
    width: auto;
    max-width: 38rem;
    margin-inline: 0;
    padding-block: 0 var(--space-5);
  }

  .section {
    display: block;
    margin-left: 0;
  }

  .label {
    padding-top: 0;
    margin-bottom: var(--space-2);
  }

  .label > span,
  .label > time {
    display: inline-block;
    margin-right: var(--space-4);
  }

  h1,
  h2,
  h3,
  h4 {
    break-after: avoid;
  }

  pre,
  figure,
  blockquote,
  tr,
  .posts > li,
  .history > li {
    break-inside: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  pre {
    border: 1px solid var(--rule);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .prose table {
    display: table;
    width: 100%;
  }

  .prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: var(--text-meta);
    overflow-wrap: anywhere;
  }
}
