@import './variables';

.markdown {
  line-height: 1.5;
  font-size: $font-md;
  word-wrap: break-word;

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

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

  h1,
  h2 {
    font-size: $font-xl;
  }
  h3 {
    font-size: $font-lg;
  }
  h4 {
    font-size: $font-md;
  }
  h5 {
    font-size: $font-sm;
  }
  h6 {
    font-size: $font-xs;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-weight: $bold-weight;
    margin: $space-para 0;
    color: var(--color-primary);

    code,
    tt {
      font-size: 85%;
    }
  }

  & > :first-child {
    margin-top: 0;
  }
  & > :last-child {
    margin-bottom: 0;
  }

  p,
  blockquote,
  ul,
  ol,
  dl,
  table,
  pre,
  details {
    margin-top: 0;
    margin-bottom: $space-para;

    &:last-child {
      margin-bottom: 0;
    }
  }

  ul,
  ol {
    padding-left: 28px;
    line-height: 1.75;
  }

  ul ul,
  ul ol,
  ol ol,
  ol ul {
    margin-top: 0;
    margin-bottom: 0;
    padding-left: 16px;
  }

  li > p {
    margin: 0;
  }

  hr {
    height: $highlight-size;
    padding: 0;
    margin: $space-para 0;
    background-color: var(--color-border);
    border: none;
  }

  pre {
    word-wrap: normal;
    font-size: $font-sm;
    font-family: $font-family-mono;
    background-color: var(--color-wrapper);
    border-radius: $corner-radius-sm;
    padding: 12px 15px;
    overflow-x: auto;
  }

  kbd,
  code,
  tt {
    word-wrap: break-word;
    word-break: break-all;
    font-size: $font-sm;
    display: inline;
    font-family: $font-family-mono;
    padding: 2px 6px;
    color: inherit;
    background-color: var(--color-wrapper);
    border-radius: $corner-radius-sm;
    hyphens: none;

    br {
      display: none;
    }
  }

  pre code {
    word-wrap: inherit;
    word-break: inherit;
    font-size: inherit;
    display: inline;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    hyphens: none;

    br {
      display: unset;
    }
  }

  del code {
    text-decoration: inherit;
  }

  blockquote {
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    margin-bottom: $space-para;
    padding: 0 15px;
    color: inherit;
    font-size: inherit;
    border-left: $highlight-size solid var(--color-border);

    & > :first-child {
      margin-top: 0;
    }

    & > :last-child {
      margin-bottom: 0;
    }
  }

  table {
    display: block;
    width: 100%;
    width: max-content;
    max-width: 100%;
    overflow: auto;
    border-collapse: collapse;
    margin-bottom: $space-para;
    background-color: transparent;

    tr {
      background-color: transparent;
    }

    th {
      font-weight: $bold-weight;
    }

    th,
    td {
      background-color: transparent;
      padding: 4px 12px;
      border: $border-size solid var(--color-border);
    }
  }

  img:not(.emoji) {
    display: block;
    border-radius: $corner-radius-sm;
  }

  .footnotes {
    font-size: $font-sm;
  }
}
