:root {
  --color-bg: #f8f9fa;
  --color-fg: #2a2a2a;
  --color-fg-muted: #737373;
  --color-active: #0e7a6d;
  --color-inactive: #0d534b;
  --color-highlight: #4f86c6;
  --color-border: #e0e0e0;
  --width-max-content: 45rem;
  --content-padding-x: 1rem;
  --width-main-padding: calc(max(var(--content-padding-x), (100vw - var(--width-max-content)) / 2));
  --text-underline-offset: 0.2rem;
  --border-radius: 0.25rem;
}

html {
  background-color: var(--color-bg);
  color: var(--color-fg);
}

body {
  font-family: "Source Sans 3", sans-serif;
  min-height: 100vh;
  margin: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
}

body > * {
  width: 100%;
}

body > main {
  flex-grow: 1;
}

body > header {
  font-family: "Source Serif 4", serif;

  border-bottom: 1px solid var(--color-border);
  box-sizing: border-box;
  min-height: 4rem;
  padding: 0.5rem var(--width-main-padding);

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

body > header h1 {
  font-weight: 600;
  margin: 0;
}

body > header h1 a {
  text-decoration: none
}

body > header h1 a:hover {
  color: inherit;
  text-decoration: none;
}

nav > ol {
  list-style-type: none;

  display: flex;
  flex-direction: row;
  gap: 2rem;
  margin: auto 0;
}

nav a {
  color: inherit;
  text-decoration: none;
  transition: border-bottom-width ease 0.05s;
}

nav a:visited {
  color: inherit;
}

nav a:hover {
  color: var(--color-highlight);
  border-bottom: 2px solid var(--color-highlight);
}

main {
  box-sizing: border-box;
  padding: 2rem var(--width-main-padding);

  line-height: 1.65;
}

body > footer {
  border-top: 1px solid var(--color-border);
  box-sizing: border-box;
  min-height: 4rem;
  padding: 0.5rem var(--width-main-padding);

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

body > footer > ol {
  list-style-type: none;

  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 1rem;

  margin-bottom: 0;
  padding-left: 0;
}

.footer-item-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
}

.footer-item-link-icon {
  width: 20px;
  height: 20px;

  fill: var(--color-active);
}

a:visited .footer-item-link-icon {
  fill: var(--color-inactive);
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.4;
  margin: 0;
}

h1, h2 {
  font-family: "Source Serif 4", serif;
  font-weight: 400;
}

h3, h4, h5, h6 {
  font-family: "Source Sans 4", sans-serif;
  font-weight: 400;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.72rem;
}

h3 {
  font-size: 1.48rem;
}

h4 {
  font-size: 1.27rem;
}

h5 {
  font-size: 1.10rem;
}

h6 {
  font-size: 1rem;
}

h1, h2, h3, h4, h5, h6 {
  margin-bottom: 0;
}

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
  text-decoration: none;
}

h1:target,
h2:target,
h3:target,
h4:target,
h5:target,
h6:target
{
  text-decoration: underline;
  text-underline-offset: var(--text-underline-offset);
}

h1 a:visited,
h2 a:visited,
h3 a:visited,
h4 a:visited,
h5 a:visited,
h6 a:visited
{
  color: inherit;
}

h1 a:hover,
h2 a:hover,
h3 a:hover,
h4 a:hover,
h5 a:hover,
h6 a:hover
{
  color: var(--color-active);
  text-decoration: underline;
  text-underline-offset: var(--text-underline-offset);
}

h2:has(a):after,
h3:has(a):after,
h4:has(a):after,
h5:has(a):after,
h6:has(a):after
{
  content: '#';
  display: inline-block;
  font-family: "Source Sans 3", sans-serif;
  font-weight: 600;
  margin-left: 0.4rem;
  opacity: 0.4;

  position: relative;
  top: calc(var(--text-underline-offset) / 2);
}

h2:has(a:hover):after,
h3:has(a:hover):after,
h4:has(a:hover):after,
h5:has(a:hover):after,
h6:has(a:hover):after {
  color: var(--color-active);
}

h1:has(a):target:after,
h2:has(a):target:after,
h3:has(a):target:after,
h4:has(a):target:after,
h5:has(a):target:after,
h6:has(a):target:after
{
  text-decoration: none;
}

* + p {
  margin-top: 1rem;
}

blockquote, aside, details.aside {
  border-left: 0.2rem solid var(--color-highlight);
  margin: 0;
  padding: 0 1rem;
}

details.aside summary {
  font-weight: 600;
}

blockquote {
  font-style: italic;
}

blockquote em {
  font-style: normal;
}

blockquote > *:last-child {
  margin-bottom: 0;
}

kbd {
  word-break: break-all;
}

code, pre, samp, samp > kbd {
  font-family: "Source Code Pro", monospace;
  font-size: 1em;
}

code, pre, samp {
  border-radius: var(--border-radius);
  border: 1px solid var(--color-border);
  padding: 0 0.15rem;
  background: linear-gradient(135deg, #f7f8f9, #f1f7ff);
}

pre {
  line-height: 1.25;
  overflow-x: auto;
}

pre code, pre samp {
  border: none;
  background: none;
  padding: 0;
}

a {
  color: var(--color-active);
  text-decoration: underline;
  text-underline-offset: var(--text-underline-offset);
}

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

h1:has(+ .post-metadata),
.post-metadata:has(+ .post-metadata),
.note-metadata:has(+ .note-metadata-reference)
{
  margin-bottom: 0;
}

.post-metadata, .note-metadata, .note-metadata-reference {
  color: var(--color-fg-muted);
  font-size: 0.9rem;
}

.post-metadata a, .note-metadata a {
  color: inherit;
}

.post-metadata {
  margin-top: 0;
  margin-bottom: 1rem;
}

.note-metadata {
  display: flex;
}

.note-metadata-permalink {
  margin-left: auto;
}

p sup {
  vertical-align: top;
  position: relative;
  top: -0.4rem;
}

a:has(sup:only-child) {
  text-underline-offset: unset;
}

img {
  width: 100%;
}

.post-navigation {
  width: 100%;

  margin-top: 2rem;
  margin-bottom: 1rem;

  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

ul {
  list-style-type: disc;
}

ul, ol {
  margin-top: 0;
  padding-left: 1rem;
}

#toc {
  background: linear-gradient(135deg, #f7f8f9, #f1f7ff);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  float: right;
  margin-top: 0;
  margin-bottom: 1rem;
  margin-left: 1rem;
  margin-right: 1rem;
  padding-top: 0.3rem;
  padding-bottom: 0.5rem;
  padding-left: 1rem;
  padding-right: 1rem;

  box-sizing: border-box;
  min-width: 10rem;
  max-width: 33%;
}

#toc ul {
  margin: 0;
}

hr {
  height: 1px;
  border: none;
  border-top: 1px solid #a1a2a3;
  margin: 1rem auto;
  width: 40%;
}

.post-list-item + .post-list-item {
  border-top: 1px solid var(--color-border);
  margin-top: 2rem;
}

.post-list-item + .post-list-item > *:first-child {
  margin-top: 2rem;
}

figure {
  margin: 0 0 1rem 0;
}

figcaption {
  font-size: 0.9rem;
}

.text-with-figure {
  display: flex;
  column-gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.text-with-figure__text {
  flex: 1 0 min-content;
  min-width: 60%;
}

.text-with-figure__figure {
  max-width: 100%;
}

th {
  text-align: left;
}

th + th, td + td {
  padding-left: 0.5rem;
}

th:has(+ th), td:has(+ td) {
  padding-right: 0.5rem;
}


.contains-snippet {
  position: relative;
}

.snippet {
  outline: none;
}

a.snippet {
  color: inherit;
  text-decoration: none;
}

a.snippet:visited {
  color: inherit;
}

.snippet:target, .snippet:hover, .snippet:has(+ .snippet-anchor:hover) {
  background-color: #c1f0e6;
}

.snippet:hover + .snippet-anchor,
.snippet-anchor:hover,
.snippet:hover + .snippet-anchor:visited,
.snippet-anchor:visited:hover
{
  color: var(--color-active);
}

a.snippet-anchor:visited {
  color: inherit;
}

.snippet-anchor {
  font-size: 1.25rem;
  font-weight: 600;
  padding: 0 0.25rem;
  position: absolute;
  opacity: 0.4;
  left: calc(100% - 0.25rem);
  text-decoration: none;
}

@media (width < 28rem) {
  body > header {
    flex-direction: column;
    gap: 0.5rem;
  }

  body > footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-item {
    margin-right: 0;
  }

  #toc {
    float: none;
    margin-left: 0;
    margin-right: 0;
    max-width: none;
  }
}
