@import url("/fonts/source-serif/source-serif-text.css");
@import url("/fonts/source-serif/source-serif-display.css");
@import url("/fonts/source-code-pro/source-code-pro.css");

* {
  box-sizing: border-box;
}
html {
  font-size: 16px;
  scrollbar-gutter: stable;
}

:root {
  --color-main: black;
  --color-alternate: #38f;
  --color-alternate-2: #f38;

  --font-body: "Source Serif", serif;
  --font-alternate: "Source Serif Display", serif;
  --font-mono: "Source Code Pro", monospace;

  --size-font-extra-small: 0.8rem;
  --size-font-small: 1rem;
  --size-font-base: 1.2rem;
  --size-font-large: 1.5rem;
  --size-font-extra-large: 2rem;
  --size-font-huge: 2.75rem;
  --size-line-base: 1.94rem;

  --size-line-thickness: 0.078125em; /* approx. 1.5px at base line size */

  --size-width-text: calc(27 * var(--size-font-base));

  --space-small: calc(var(--size-line-base) / 2);
  --space-medium: calc(var(--space-small) * 2); /* yes, I see it. */
  --space-large: calc(var(--space-small) * 3);
  --space-extra-large: calc(var(--space-small) * 4);
}

body {
  font-family: var(--font-body);
  font-size: var(--size-font-base);

  display: grid;
  grid-template-rows: auto 1fr auto;

  height: auto;
  min-height: 100dvh;

  margin: 0;
  padding: 0 var(--space-small);
}

h1#site-link {
  margin-top: 0;
  padding-top: var(--space-large);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-alternate);
}
h1 {
  font-size: var(--size-font-huge);
  font-weight: 600;
  line-height: calc(1.4 * var(--size-line-base));
}
h2 {
  font-size: var(--size-font-extra-large);
  font-weight: 600;
  line-height: var(--size-line-base);
  margin-top: calc(3.5 * var(--size-line-base));
  margin-bottom: calc(1.5 * var(--size-line-base));
}
h3, #index .post-title {
  font-size: var(--size-font-large);
  font-weight: 700;
  line-height: var(--size-line-base);
}
h3 {
  margin-top: calc(2 * var(--size-line-base));
}
h4 {
  font-size: var(--size-font-base);
  font-weight: 900;
  line-height: var(--size-line-base);
  margin-top: var(--size-line-base);
  position: relative;
  top: calc(0.75 * var(--size-line-base));
}
h2, h3, h4 {
  &:first-child {
    margin-top: 0;
  }
}

header {
  display: flex;
  flex-direction: column;
  align-items: middle;
  margin-bottom: var(--space-large);

  h1, h2, h3, h4, h5, h6 {
    text-align: center;
    margin-bottom: 0;
    max-width: calc(var(--size-width-text) * 4 / 3);
  }
  h1 {
    margin-bottom: calc(-0.25 * var(--size-line-base));
  }
  p, time {
    text-align: center;
  }
  p {
    font-family: var(--font-alternate);
    margin: 0;
    margin-top: calc(1 / 3 * var(--size-line-base));
  }
}

a:link, a:visited {
  color: var(--color-main);
  text-decoration-color: var(--color-alternate);
  text-decoration-thickness: var(--size-line-thickness);
}

p, li {
  font-weight: 400;
  line-height: var(--size-line-base);
  max-width: var(--size-width-text);
  /* text-align: justify; */
  /* hyphens: auto; */

  sup {
    /* no extra space for you! */
    line-height: 0;
  }
}
p {
  margin: var(--size-line-base) 0;
}

pre, code, kbd, samp {
  font-family: var(--font-mono);
}

strong, b {
  font-weight: 600;
}

time {
  font-size: var(--size-font-extra-small);
  font-style: normal;
  line-height: calc(0.75 * var(--size-line-base));
}

blockquote {
  border-left: var(--size-line-thickness) solid var(--color-alternate-2);
  font-size: var(--size-font-small);
  margin-left: calc(var(--space-small) - var(--size-line-thickness));
  margin-right: calc(2 * var(--space-small));
  padding-left: var(--space-small);
}

a[id^="fnref"], a.footnoteBackLink, li[id^="fn"]::marker {
  color: var(--color-alternate);
  font-family: var(--font-alternate);
  text-decoration: none;
}

ol.notes {
  font-size: var(--size-font-small);
  max-width: var(--size-width-text);
  line-height: var(--size-line-base);
  li:first-child {
    margin-top: var(--size-line-base);
  }
  p {
    text-align: left;
    hyphens: none;
    margin: calc(0.5 * var(--size-line-base)) 0;
  }
}

hr {
  border: 0;
  border-top: var(--size-line-thickness);
  border-style: solid;
  color: var(--color-alternate-2);
  max-width: calc(var(--size-width-text) * 2 / 5);
  margin: 0 auto;
}

article {
  align-content: start;
  margin: calc(2 * var(--size-line-base)) auto;
  max-width: var(--size-width-text);

  & > p {
    hyphens: auto;
    text-align: justify;
  }
}

h1#site-link {
  font-weight: 900;
  text-align: center;
}

#index {
  nav {
    align-content: start;
    display: grid;
    grid-template-columns: max-content fit-content(max-content);
    margin-top: var(--space-extra-large);
  }

  h2 {
    grid-column: 2;
    margin-top: var(--space-medium);
    margin-bottom: var(--space-medium);
  }

  ol {
    display: grid;
    grid-column: 1 / span 2;
    grid-template-columns: subgrid;

    list-style-type: none;
    margin: 0 auto;
    margin-bottom: var(--space-small);
    padding-left: 0;
  }

  li {
    grid-column: 1 / span 2;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-rows: auto auto;
    align-items: first baseline;
    margin-bottom: var(--space-small);
  }

  time {
    grid-column: 1;
    grid-row: 1;
    text-align: right;

    margin-right: var(--space-small);
  }

  p, .post-title {
    grid-column: 2;
    max-width: 100%;
    margin: 0;
  }
  p {
    grid-row: 2;
    font-family: var(--font-alternate);
  }
  .post-title {
    grid-row: 1;
  }
}

footer {
  display: flex;
  flex-direction: row;
  gap: var(--space-small);
  font-size: var(--size-font-extra-small);
  padding-bottom: var(--space-small);
  justify-content: center;
  text-align: center;
}

@media screen and (width < 27rem) {
  article {
    margin-top: var(--space-small);
    header {
      align-items: flex-start;

      h1, p {
        text-align: left;
      }
      h1 {
        margin-bottom: calc(0.001 * var(--size-line-base));
      }
      p {
        max-width: 75%;
      }
      time {
        line-height: var(--size-line-base);
      }
    }

    & > p {
      text-align: left;
      hyphens: none;
    }
  }

  #index {
    nav {
      grid-template-columns: 1fr;
    }
    li {
      margin-bottom: var(--space-medium);
    }
    h2, h3, a, p {
      grid-column: 1;
    }
    a {
      grid-row: 2;
    }
    time {
      grid-row: 1;
      text-align: left;
    }
    p {
      grid-row: 3;
    }
  }
}
