/* {{{ Fonts */
@font-face {
  font-family: "Computer Modern";
  src: url("/fonts/computer-modern/cm-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Computer Modern";
  src: url("/fonts/computer-modern/cm-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: bold;
}

@font-face {
  font-family: "Computer Modern";
  src: url("/fonts/computer-modern/cm-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
}

@font-face {
  font-family: "Computer Modern";
  src: url("/fonts/computer-modern/cm-bolditalic.woff2") format("woff2");
  font-weight: 700;
  font-style: italic;
}

@font-face {
  font-family: "Computer Modern Math";
  src: url("/fonts/computer-modern/cm-math.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "Cascadia Mono";
  src: url("/fonts/cascadia-code/CascadiaMono.woff2") format("woff2");
  font-style: normal;
}

@font-face {
  font-family: "Cascadia Mono";
  src: url("/fonts/cascadia-code/CascadiaMonoItalic.woff2") format("woff2");
  font-style: italic;
}
/* }}} */

/* Base page styling */
/* {{{ <body> */
body {
  max-width: 43rem;
  margin: auto;
  padding: 1rem;

  font:
    16pt/1.6 "Computer Modern",
    sans-serif;

  @media (prefers-color-scheme: light) {
    background: white;
    color: black;
  }

  @media (prefers-color-scheme: dark) {
    background: black;
    color: white;
  }
}
/* }}} */
/* {{{ <pre> & <code> elements */
pre {
  font-family: "Cascadia Mono", monospace;
}

pre > code {
  display: block;
  padding: 1rem;
  overflow-x: scroll;
  text-align: left; /* Otherwise there's issues with code blocks inside figures */
}

@media (prefers-color-scheme: light) {
  code {
    background: #eff1f5;
  }

  .aside code {
    background: #e4e9f5;
  }
}

@media (prefers-color-scheme: dark) {
  code {
    background: #24273a;
    color: #cad3f5;
  }

  .aside code {
    background: #2f2f3a;
  }
}
/* }}} */
/* {{{ Others */
blockquote {
  padding-left: 1.25rem;
  border-left: 3px solid;
  margin-left: 0;
  text-align: left; /* Otherwise there's issues with blockquotes inside figures */
}

ol {
  padding-left: 1.5rem;
}

ul {
  padding-left: 1rem;

  li {
    list-style-type: "⬦";
    padding-left: 0.5rem;
    list-style-position: outside;
  }
}

h1,
h2,
h3,
h4,
h5,
h6 {
  .heading-anchor {
    display: inline-block;
    text-decoration: none;
    transform: translateY(-2px);
  }
}

/* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/Heading_Elements#specifying_a_uniform_font_size_for_h1 */
h1 {
  margin-block: 0.67em;
  font-size: 2em;
}

math[display="block"] {
  margin: 1.5rem 0;
}

/* }}} */
/* {{{ <a> */
a {
  @media (prefers-color-scheme: dark) {
    color: #bac3f5;
  }

  &:visited {
    @media (prefers-color-scheme: dark) {
      /* color: #c586c0; */
      color: #ef87e7;
    }
  }
}
/* }}} */
/* {{{ <hr> */
.article-content hr {
  border: none;
  margin: 2rem 0.5rem;

  @media (prefers-color-scheme: light) {
    border-top: 0.1rem solid #9ca0b040;
  }

  @media (prefers-color-scheme: dark) {
    border-top: 0.1rem solid #6e738d40;
  }
}
/* }}} */

/* Custom elements */
/* {{{ Articles */
.article-content {
  max-width: 40rem;
  margin: auto;
}

.article-list {
  max-width: 36rem;
  margin: auto;
  list-style-type: none;

  ul {
    list-style-type: disc;
  }
}

.change-list {
  max-width: 36rem;
  margin: auto;
}
/* }}} */
/* {{{ Asides */
/* TODO: perhaps remove aside-header altogether? */
.aside-header {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;

  img {
    height: 1.75rem;
    margin-right: 0.75rem;
    transform: translateY(-2px);
  }
}

.aside:not(.aside-long) > .aside-header {
  h3 {
    margin-top: 0;
    margin-bottom: 0;
  }

  /* The default h3 margin feels a bit large here */
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.aside {
  @media (prefers-color-scheme: light) {
    background: hsl(281deg 100% 96%);
    color: black;
    border-color: black;
  }

  @media (prefers-color-scheme: dark) {
    background: hsl(281deg 50% 15%);
    color: #f8e9ff;
    border-color: #f8e9ff88;
  }

  box-sizing: border-box;
  padding-left: 1rem;
  padding-right: 1rem;
  margin: 1.5rem 0;

  /* Prevents margin-collapsing of the children. */
  border-width: 1px;
  border-style: solid;
  border-radius: 3px;

  /* Slightly move things to the left to more nicely align with the marker */
  &.aside-long > :not(summary) {
    margin-left: 1rem;
  }

  /* Remove the top margin of the first paragraph under the header */
  &:has(> .aside-header) > :nth-child(2) {
    margin-top: 0;
  }

  /* Match the margin set by the header */
  &:has(> .aside-header) > :last-child {
    margin-bottom: 1rem;
  }

  &.aside-long:has(> .aside-header) > :last-child {
    margin-bottom: 2rem;
  }
}

/* {{{ Summary & details */
.aside,
.toc {
  summary {
    list-style: none;
  }

  summary::marker,
  summary::webkit-details-marker {
    display: none;
    content: "";
  }

  summary::before {
    display: inline-block;
    content: "▶";
    font-size: 0.75rem;
    margin: 0 0.75rem 0 0.25rem;
    transform-origin: 45% 55%;
    transition: transform 0.1s;
    cursor: pointer;
  }
}

.toc > summary::before {
  transform: translateY(-4px);
}

.toc[open] > summary::before {
  transform: translateY(-4.5px) rotate(90deg);
}

.aside > summary::before {
  transform: translateY(-2px);
}

.aside[open] > summary::before {
  transform: translateY(-2.5px) rotate(90deg);
}
/* }}} */
/* }}} */
/* {{{ Tier lists */
.tier-list {
  background: #444;

  display: flex;
  flex-direction: column;

  padding: calc(3 * var(--spacing));
  box-sizing: border-box;

  --spacing: 0.75px;

  .tier:not(:last-child) {
    border-bottom: 1px solid #000;
  }

  .tier {
    display: flex;
    flex-direction: row;
    justify-items: center;

    .tier-elements {
      display: flex;
      flex-wrap: wrap;

      a > img,
      a {
        height: 3rem;
      }
    }

    .tier-heading,
    a {
      margin: var(--spacing);
    }

    .tier-heading {
      width: 6rem;
      min-width: 6rem;
      min-height: 3rem;
      margin: var(--spacing);
      color: unset;
      text-decoration: none;

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

      .tier-heading-text {
        padding: 0 0.5rem;
        font-size: 1rem;
      }
    }
  }

  /* {{{ Tier colors */
  .tier:nth-child(1) > .tier-heading {
    background: #b39ddb;
  }

  .tier:nth-child(2) > .tier-heading {
    background: #d7bde2;
  }

  .tier:nth-child(3) > .tier-heading {
    background: #e6b0b8;
  }

  .tier:nth-child(4) > .tier-heading {
    background: #f4c2c2;
  }

  .tier:nth-child(5) > .tier-heading {
    background: #dce8a7;
  }

  .tier:nth-child(6) > .tier-heading {
    background: #b5ead7;
  }

  .tier:nth-child(7) > .tier-heading {
    background: #a2d5ab;
  }

  .tier:nth-child(8) > .tier-heading {
    background: linear-gradient(
      45deg,
      #ffb3ba,
      #ffdfba,
      #ffffba,
      #baffc9,
      #bae1ff,
      #b3baff,
      #e2baff
    );
  }
  /* }}} */
}
/* }}} */
/* {{{ Tables of contents */
.toc {
  border-radius: 3px;
  border: 1px solid;

  @media (prefers-color-scheme: light) {
    background: hsl(220deg 23% 95%);
    border-color: black;
  }

  @media (prefers-color-scheme: dark) {
    background: hsl(220deg 30% 15%);
    border-color: #f8e9ff88;
  }

  box-sizing: border-box;
  padding: 1rem;
  margin: 1.5rem 0;

  summary span {
    margin-left: 0.5rem;
  }

  nav {
    margin-left: 1rem;
  }

  li {
    padding: 0.25rem;
  }

  ol {
    margin-bottom: 0;
  }

  ol ol {
    position: relative;

    &::before {
      content: "";
      position: absolute;
      top: 0.5rem;
      bottom: 0.5rem;
      left: -1.4rem;
      width: 2px;

      @media (prefers-color-scheme: light) {
        background: hsl(194deg 100% 16% / 20%);
      }

      @media (prefers-color-scheme: dark) {
        background: hsl(194deg 100% 85% / 20%);
      }
    }
  }
}
/* }}} */
/* {{{ Figures */
figure {
  text-align: center;
  margin: 2rem;
}

figure img {
  max-width: 100%;
  margin: auto;
  height: auto;
}

figure > figcaption {
  text-align: center;
}

figure > figcaption > p {
  margin-top: 0.25rem;
}
/* }}} */
/* {{{ Icons */
span.icon {
  height: 100%;
  text-align: center;
}

img.icon {
  height: 1em;
  width: 1em;
  vertical-align: -0.125em;
}
/* }}} */
/* {{{ Tables */
table {
  display: block;
  max-width: fit-content;
  overflow-x: auto;
  white-space: nowrap;
  border-collapse: collapse;
  margin: 1rem auto 2rem auto;
}

table tr:first-child {
  border-bottom: 1px solid;
  @media (prefers-color-scheme: light) {
    border-right-color: black;
  }

  @media (prefers-color-scheme: dark) {
    border-right-color: white;
  }
}

table td,
table th {
  padding: 0.3rem 0.5rem;
  border-right: 1px solid;

  @media (prefers-color-scheme: light) {
    border-right-color: black;
  }

  @media (prefers-color-scheme: dark) {
    border-right-color: white;
  }

  &:last-child {
    border-right: none;
  }

  &.align-left {
    text-align: left;
  }

  &.align-center {
    text-align: center;
  }

  &.align-right {
    text-align: right;
  }
}
/* }}} */

/* Syntax highlighting */
/* {{{ Light theme */
/* Based on the neovim catppuccin-latte theme. */
@media (prefers-color-scheme: light) {
  span.attribute,
  span.constant {
    color: #fe640b;
  }

  span.comment,
  span.comment-documentation,
  code[data-language="haskell"] span.spell,
  code[data-language="agda"] span.spell {
    color: #9ca0b0;
    font-style: italic;
  }

  span.constant-builtin,
  span.boolean,
  span.number {
    color: #fe640b;
  }

  span.constructor {
    color: #209fb5;
  }

  span.function,
  span.function-method {
    color: #1e66f5;
  }

  span.function-builtin {
    color: #fe640b;
  }

  span.function-macro {
    color: #179299;
  }

  span.keyword,
  span.keyword-repeat {
    color: #8839ef;
  }

  span.label {
    color: #209fb5;
  }

  span.operator {
    color: #04a5e5;
  }

  span.property {
    color: #7287fd;
  }

  span.punctuation,
  span.punctuation-delimiter {
    color: #7c7f93;
  }

  span.punctuation-bracket {
    color: #7c7f93;
  }

  span.string,
  span.markup-link-url {
    color: #40a02b;
  }

  span.string-special {
    color: #ea76cb;
  }

  span.tag,
  span.markup-link,
  span.markup-link-label {
    color: #8839ef;
  }

  span.type,
  span.type-builtin {
    color: #df8e1d;
  }

  span.variable {
    color: #4c4f69;
  }

  span.variable-builtin {
    color: #d20f39;
  }

  span.variable-parameter {
    color: #e64553;
  }
}
/* }}} */
/* {{{ Dark theme */
/* Based on the neovim catppuccin-macchiato theme. */
@media (prefers-color-scheme: dark) {
  span.attribute,
  span.constant {
    color: #f5a97f;
  }

  span.comment,
  span.comment-documentation,
  code[data-language="haskell"] span.spell {
    color: #6e738d;
    font-style: italic;
  }

  span.constant-builtin,
  span.boolean,
  span.number {
    color: #f5a97f;
  }

  span.constructor {
    color: #7dc4e4;
  }

  span.function,
  span.function-method {
    color: #8aadf4;
  }

  span.function-builtin {
    color: #8aadf4;
  }

  span.function-macro {
    color: #8bd5ca;
  }

  span.keyword,
  span.keyword-repeat {
    color: #c6a0f6;
  }

  span.label {
    color: #7dc4e4;
  }

  span.operator {
    color: #91d7e3;
  }

  span.property {
    color: #b7bdf8;
  }

  span.punctuation,
  span.punctuation-delimiter {
    color: #939ab7;
  }

  span.punctuation-bracket {
    color: #939ab7;
  }

  span.string,
  span.markup-link-url {
    color: #a6da95;
  }

  span.string-special {
    color: #f5bde6;
  }

  span.tag,
  span.markup-link,
  span.markup-link-label {
    color: #c6a0f6;
  }

  span.type,
  span.type-builtin {
    color: #f5a97f;
  }

  span.variable {
    color: #cad3f5;
  }

  span.variable-builtin {
    color: #ed8796;
  }

  span.variable-parameter {
    color: #ee99a0;
  }
}
/* }}} */
