@import (reference) './variables.less';

.markdown {
  color: @c-text;
  font-size: 15px;
  line-height: 1.60625;

  &:not(:first-child):empty {
    min-height: 32px;
  }

  // titles
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 42px 0 18px;
    color: @c-heading;
    font-weight: 500;
    line-height: 1.40625;

    // anchor link
    &:hover > a[aria-hidden] {
      float: left;
      margin-top: 0.06em;
      margin-left: -20px;
      width: 20px;
      padding-right: 4px;
      line-height: 1;
      box-sizing: border-box;

      @media @mobile {
        width: 14px;
        margin-left: -14px;
      }

      &::after {
        content: '#';
        display: inline-block;
        vertical-align: middle;
        font-size: 20px;
      }

      span {
        display: none;
      }
    }

    + h1,
    + h2,
    + h3,
    + h4,
    + h5,
    + h6 {
      margin-top: 16px;
    }
  }

  h1 {
    margin-top: 48px;
    margin-bottom: 32px;
    font-size: 32px;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 20px;
  }

  h4 {
    font-size: 18px;
  }

  h5 {
    font-size: 16px;
  }

  h6 {
    font-size: 14px;
  }

  // paragraph
  p {
    margin: 16px 0;
  }

  // inline code
  *:not(pre) code {
    padding: 2px 5px;
    color: #d56161;
    background: darken(@c-light-bg, 1%);
  }

  code {
    font-family: Lucida Console, Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace;
  }

  // code block
  pre {
    font-size: 14px;
    background: darken(@c-light-bg, 1%);

    &:not([class^='language-']) {
      padding: 1em;
    }
  }

  // horizontal line
  hr {
    margin: 16px 0;
    border: 0;
    border-top: 1px solid @c-border;
  }

  // blockquote
  blockquote {
    margin: 16px 0;
    padding: 0 24px;
    color: fadeout(@c-text, 30%);
    border-left: 4px solid @c-border;
    overflow: hidden;
  }

  // list
  ul,
  ol {
    margin: 8px 0 8px 32px;
    padding: 0;

    li {
      margin-bottom: 4px;
    }
  }

  // table
  table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid @c-border;

    th,
    td {
      padding: 10px 24px;
      border-style: solid;
      border-color: #f0f0f0;
      border-width: 1px 0;
      font-size: 13px;
      vertical-align: middle;
      padding: 12px;
      line-height: 1.5715;
    }

    th {
      font-weight: 600;
      background: #fafafa;
      white-space: nowrap;
      text-align: left;
      color: #555;
    }

    td:first-child {
      font-weight: 600;
      font-size: 14px;
      width: 18%;
    }

    td:nth-child(2) {
      width: 55%;
    }

    td:nth-child(3) {
      width: 30%;
    }

    td:nth-child(4) {
      width: 15%;
    }
  }

  // links
  a {
    color: @c-link;
    text-decoration: none;
    transition: opacity 0.2s;
    outline: none;

    &:hover {
      color: @c-link;
      opacity: 0.7;
      text-decoration: underline;
    }

    &:active {
      color: @c-link;
      opacity: 0.9;
    }
  }

  // images
  img {
    max-width: 100%;
  }
}

.@{prefix} {
  &-external-link-icon {
    vertical-align: -0.155em;
    margin-left: 2px;
  }
}
