:root {
  --height: 100vh;
  /* Fallback for older browsers */
  --height: calc(var(--vh, 1vh) * 100);
  --black: #292929;
  --accent: #c94f2a;
  --min-content-width: 450;
  --max-content-width: 780;
  --padding: 20px;

  /* Dynamic font-size while going between min and max content width */
  --h1-font-size: clamp(22px,
      calc(22px + (30 - 22) * ((100vw - calc(1px * var(--min-content-width))) / (var(--max-content-width) - var(--min-content-width)))),
      30px);
  --h2-font-size: clamp(18px,
      calc(18px + (24 - 18) * ((100vw - calc(1px * var(--min-content-width))) / (var(--max-content-width) - var(--min-content-width)))),
      24px);
  --h3-font-size: clamp(16px,
      calc(16px + (20 - 16) * ((100vw - calc(1px * var(--min-content-width))) / (var(--max-content-width) - var(--min-content-width)))),
      20px);
  --h4-font-size: var(--p-font-size);
  --small-font-size: clamp(12px,
      calc(12px + (14 - 12) * ((100vw - calc(1px * var(--min-content-width))) / (var(--max-content-width) - var(--min-content-width)))),
      14px);
  --p-font-size: clamp(14px,
      calc(14px + (17 - 14) * ((100vw - calc(1px * var(--min-content-width))) / (var(--max-content-width) - var(--min-content-width)))),
      17px);
}

html,
body {
  font-family: sans-serif;
  margin: 0;
  color: var(--black);
}

h1,
h2,
h3 {
  font-family: "Geneva", sans-serif;
  font-weight: bold;
}

h1 {
  font-size: var(--h1-font-size);
  margin: calc(var(--h1-font-size) / 2) 0;
}

h2 {
  font-size: var(--h2-font-size);
  margin: calc(var(--h2-font-size) / 2) 0;
}

h3 {
  font-style: italic;
}

nav {
  font-family: "Architects Daughter", "Bradley Hand", sans-serif;
  /* https://meowni.ca/font-style-matcher/ */
}

h3,
nav {
  font-size: var(--h3-font-size);
}

p {
  font-family: sans-serif;
  font-size: var(--p-font-size);
  font-weight: 300;
  line-height: 1.6;
}

main {
  display: flex;
  min-height: var(--height);
  flex-direction: column;
  margin: auto;
  min-width: 320px;
  max-width: calc(1px * var(--max-content-width));
  padding: 0 var(--padding);
}

a {
  text-decoration: none;
  color: var(--accent);
}

nav {
  align-items: center;
  display: flex;
  flex: 0 0 calc(2 * var(--padding));
  margin: calc(var(--h3-font-size) / 2) 0;
}

nav ul {
  display: inline-grid;
  grid-auto-flow: column;
  grid-gap: 15px;
  list-style: none;
  margin-left: auto;
}

nav a {
  color: var(--black);
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: text-decoration-color 0.15s ease;
}

/* Only enable on desktop */
@media (hover: hover) and (pointer: fine) {
  nav a:hover {
    text-decoration-color: var(--accent);
  }
}

#portrait {
  align-self: center;
  margin-top: auto;
  min-height: 250px;
  padding-top: var(--padding);
}

#portrait path {
  fill: var(--black);
}

/* ---------- Writing ---------- */

article header p {
  color: #6b6b6b;
  font-size: var(--small-font-size);
  margin: 0 0 calc(var(--h1-font-size) / 2);
}

article h4,
article h5 {
  font-family: "Geneva", sans-serif;
  font-size: var(--h4-font-size);
  font-weight: bold;
  margin: calc(var(--h4-font-size) / 2) 0;
}

article ul,
article ol {
  font-family: sans-serif;
  font-size: var(--p-font-size);
  font-weight: 300;
  line-height: 1.6;
  padding-left: 1.25em;
}

article li {
  margin: calc(var(--p-font-size) / 2.5) 0;
}

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

figure {
  margin: calc(var(--h2-font-size)) 0;
}

figure img {
  margin: 0 auto;
  max-width: 512px;
}

figcaption {
  color: #6b6b6b;
  font-family: sans-serif;
  font-size: var(--small-font-size);
  font-weight: 300;
  line-height: 1.5;
  margin-top: calc(var(--padding) / 2);
}

blockquote {
  border-left: 3px solid var(--accent);
  margin: calc(var(--h2-font-size)) 0;
  padding-left: var(--padding);
}

blockquote p {
  font-style: italic;
}

blockquote cite {
  color: #6b6b6b;
  font-size: var(--small-font-size);
  font-style: normal;
}

code {
  background: rgba(41, 41, 41, 0.06);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  border-radius: 3px;
  font-size: 0.9em;
  padding: 0.15em 0.35em;
}

pre,
pre.z-code {
  /* pre.z-code is needed to outrank giallo.css's own .z-code background */
  background: rgba(41, 41, 41, 0.04);
  border-radius: 4px;
  font-size: var(--small-font-size);
  line-height: 1.5;
  overflow-x: auto;
  padding: var(--padding);
}

pre code {
  background: none;
  font-size: inherit;
  padding: 0;
}

hr {
  border: 0;
  border-top: 1px solid rgba(41, 41, 41, 0.15);
  margin: calc(var(--h1-font-size)) 0;
}

table {
  border-collapse: collapse;
  display: block;
  font-family: sans-serif;
  font-size: var(--small-font-size);
  font-weight: 300;
  overflow-x: auto;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid rgba(41, 41, 41, 0.15);
  padding: 0.5em 0.75em 0.5em 0;
  text-align: left;
}

article a:hover {
  text-decoration: underline;
}
