:root {
  color-scheme: light dark;

  --width: 34.5;
  --rounding: 4px;
  --color-accent: #268bd2;
  --color-background: light-dark(#ffffff, #0e0e0e);
  --color-background-off1: light-dark(#f9f9f9, #202020);
  --color-background-off2: light-dark(#e5e5e5, #333333);
  --color-background-off3: light-dark(#9a9a9a, #aaaaaa);
  --color-background-notice: light-dark(#fffbb4, #2e2e01);
  --color-text-title: light-dark(#000000, #ffffff);
  --color-text-main: light-dark(#111111, #eeeeee);
  --color-text-strong: light-dark(#000000, #ffffff);
  --color-text-weak: light-dark(#555555, #aaaaaa);
  --color-text-code: #bf616a;
}

/* General */

html,
body {
  margin: 0;
}

html {
  text-rendering: auto;
  overflow-wrap: break-word;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  background: var(--color-background);
  color: var(--color-text-main);
}

body {
  padding: 2vmax 0;
  display: grid;
  grid-template-columns:
    minmax(1rem, 1fr) [text-start]
    minmax(auto, 50rem) [text-end]
    minmax(1rem, 1fr);
  row-gap: 1rem;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    sans-serif,
    Apple Color Emoji,
    Segoe UI Emoji;
  font-weight: 350;
  font-size: clamp(1em, 4vmin, 1.2em);
  line-height: 1.5;

  > * {
    margin: 0;
    grid-column: text-start / text-end;
  }

  > header {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;

    > * {
      flex-grow: 1;
      margin: 0;
    }
  }

  > footer {
    display: flex;
    padding-top: 5rem;

    > * {
      flex: auto;
      margin: 0;
      text-align: center;
    }
  }
}

nav a {
  text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin-top: 1em;
  font-weight: inherit;

  a[href^="#"] {
    padding: 0 0.25em;
    text-decoration: none;

    @media print {
      display: none;
    }
  }
}

header + h2 {
  margin-top: 0;
}

/* table of contents */
#contents + ol {
  a {
    text-decoration: none;
  }
  ol {
    list-style-type: circle;
  }
}

ul,
ol {
  padding-left: 2rem;

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

ol {
  ol {
    list-style-type: circle;
  }
}

li {
  margin: .5rem 0;

  p {
    margin: 0;
  }
}

blockquote {
  display: flex;
  flex-direction: column;
  row-gap: 1rem;
  margin: 0.8rem 0;
  padding: 0.5rem 1rem;
  color: var(--color-text-weak);
  border-left: 0.25rem solid var(--color-background-off2);

  @media (min-width: 30em) {
    padding-right: 5rem;
    padding-left: 1.25rem;
  }

  > * {
    flex-grow: 1;
    margin: 0;
  }
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: .15em;
  text-decoration-thickness: 1px;

  &:hover {
    text-decoration: none;
  }
}

/* Components */

.post-index {
  list-style: none; /** reset ul */
  padding: 0; /** reset ul */
  display: grid;
  grid-template-columns: min-content auto;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.5rem;

  > li {
    margin: 0; /** reset li */
    display: contents;

    > :first-child {
      min-width: fit-content;
      white-space: nowrap;
      text-align: right;
      font-size: 80%;
    }
  }

  a {
    text-decoration: none;
  }
}

.post-details {
  display: flex;
  flex-flow: row wrap;
  align-content: center;
  column-gap: .5em;
  color: var(--color-text-weak);
  font-size: 80%;

  > p {
    margin: 0;

    &::before {
      content: "•";
      padding-right: .5em;
    }
  }
}

/* Reusable */

.print-hide {
  @media print {
    display: none;
  }
}

.text-weak {
  color: var(--color-text-weak);
}

/* Code */

code,
pre {
  font-family: Menlo, Monaco, "Courier New", monospace;
}
code {
  white-space: nowrap;
  padding: 0.25em 0.5em;
  font-size: 75%;
  color: var(--color-text-code);
  background-color: var(--color-background-off1);
  border: 1px solid var(--color-background-off2);
  border-radius: var(--rounding);
}
pre {
  display: block;
  overflow: auto;
  padding: 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
  background-color: var(--color-background-off1);
  border: 1px solid var(--color-background-off2);
  border-radius: var(--rounding);

  &:has(> code.hljs) {
    padding: 0;
    background-color: transparent;
  }

  code {
    white-space: pre;
    padding: 0;
    font-size: 100%;
    color: inherit;
    background-color: transparent;
    border: 0;

    @media print {
      font-size: 80%;
    }
  }
}

/* Footnotes */

.footnotes {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-background-off2);
  color: var(--color-text-weak);
  font-size: 0.8rem;
}
.footnote {
  width: fit-content;
  padding: 0 0.25rem;
  border-radius: var(--rounding);
  border: 1px solid transparent;
}
.footnote::marker {
  content: attr(title) ".";
}
.footnote:has(a:target) {
  background-color: var(--color-background-notice);
  border: 1px solid var(--color-background-off3);
}
.footnote-ref {
  padding: 0.1rem;
  border-radius: var(--rounding);
  border: 1px solid transparent;
}
.footnote-ref:target {
  background-color: var(--color-background-notice);
  border: 1px solid var(--color-background-off3);
}
.footnote-ref::before {
  content: "[";
}
.footnote-ref::after {
  content: "]";
}
.data-footnote-backref {
  margin-left: 0.5rem;
  font-variant-emoji: text;
}
