@use "../base/color";
@use "../base/var";
@use "code";

// user generated content, e.g. comments, messages etc.
[part~="wy-content"] {
  @include code.themes;

  text-align: initial;
  font-size: var.default(--wy-font-size);
  
  overflow-wrap: break-word;
  min-width: 0;

  &:empty {
    display: none;
  }

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

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

  a {
    text-decoration: var.default(--wy-link-decoration);
    color: color.token(--wy-link);

    &:hover {
      text-decoration: var.default(--wy-link-hover-decoration);
    }

    &:where(:not([href]):not([class])) {
      &,
      &:hover {
        text-decoration: none;
      }
    }
  }

  // P
  p {
    margin-top: 0;
    margin-bottom: var.wy-rem(1);
  }

  b,
  strong {
    font-weight: var.default(--wy-font-weight-bold);
  }

  blockquote {
    border-left: calc(2 * var.default(--wy-border)) solid color.token(--wy-outline-variant);
    margin: var.default(--wy-gap) 0;
    padding-left: var.default(--wy-padding);

    > p {
      margin: 0;
    }
  }

  hr {
    border-color: color.token(--wy-outline-variant);
    border-width: var.default(--wy-border) 0 0 0;
    border-style: solid;
  }

  // code
  pre,
  code {
    font-family: var.default(--wy-font-monospace);
    font-size: var.default(--wy-font-size-sm);
  }

  // code (inline)
  :not(pre) > code {
    overflow-wrap: inherit;
  }

  // code (block)
  pre > code {
    font-size: var.default(--wy-font-size);
    white-space: pre-wrap;
  }

  // headings
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    font-family: var.default(--wy-headings-font-family);
    line-height: var.default(--wy-headings-line-height);
  }

  h1 {
    font-size: var.default(--wy-h1-font-size);
    font-weight: var.default(--wy-h1-font-weight);
    margin: var.default(--wy-h1-margin);
  }

  h2 {
    font-size: var.default(--wy-h2-font-size);
    font-weight: var.default(--wy-h2-font-weight);
    margin: var.default(--wy-h2-margin);
  }

  h3 {
    font-size: var.default(--wy-h3-font-size);
    font-weight: var.default(--wy-h3-font-weight);
    margin: var.default(--wy-h3-margin);
  }

  h4 {
    font-size: var.default(--wy-h4-font-size);
    font-weight: var.default(--wy-h4-font-weight);
    margin: var.default(--wy-h4-margin);
  }

  h5 {
    font-size: var.default(--wy-h5-font-size);
    font-weight: var.default(--wy-h5-font-weight);
    margin: var.default(--wy-h5-margin);
  }

  h6 {
    font-size: var.default(--wy-h6-font-size);
    font-weight: var.default(--wy-h6-font-weight);
    margin: var.default(--wy-h6-margin);
  }

  // tables
  table {
    /* For scrolling */
    display: block; /* This is needed for scrollbar */
    width: 100%;
    max-width: -moz-max-content;
    max-width: max-content;
    overflow-x: auto; /* This is needed for scrollbar */
    white-space: nowrap; /* Keeps each cell on one line */

    /* Other table styles */
    border-collapse: separate;
    border-spacing: 0 0;
    margin-bottom: var.default(--wy-size);

    th,
    td {
      padding: var.default(--wy-padding-sm) var.default(--wy-padding);
      border-color: inherit;
      border-style: solid;
    }

    th {
      text-align: inherit;
      text-align: match-parent;
      text-align: -webkit-match-parent;
      border-width: var.default(--wy-border) 0 var.default(--wy-border) var.default(--wy-border);
      font-weight: var.default(--wy-headings-font-weight);

      &:first-child {
        border-top-left-radius: var.default(--wy-border-radius-sm);
      }

      &:last-child {
        border-top-right-radius: var.default(--wy-border-radius-sm);
        border-right-width: var.default(--wy-border);
      }
    }

    td {
      border-width: 0 0 var.default(--wy-border) var.default(--wy-border);

      &:last-child {
        border-right-width: var.default(--wy-border);
      }
    }

    tr:last-child td:first-child {
      border-bottom-left-radius: var.default(--wy-border-radius-sm);
    }

    tr:last-child td:last-child {
      border-bottom-right-radius: var.default(--wy-border-radius-sm);
    }

    > tbody {
      vertical-align: inherit;
    }

    > thead {
      vertical-align: bottom;
    }
  }

  img {
    max-width: 100%;
    border-radius: var.default(--wy-border-radius-sm);
    margin-block: var.default(--wy-padding-sm);
  }

  // lists
  ol {
    list-style-type: decimal;
  }

  ul {
    list-style-type: disc;
  }

  li {
    margin: var.default(--wy-gap-sm) 0;
  }

  ol,
  ul {
    margin: var.default(--wy-size) 0;
    padding: 0 0 0 1.625em;

    > li {
      padding-left: var.default(--wy-gap-sm);

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

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

  // hashtags
  .wy-hashtag {
    color: #{color.token(--wy-link)};
  }

  // mentions
  .wy-mention {
    font-weight: var.default(--wy-font-weight-bold);
    cursor: pointer;
    color: #{color.token(--wy-link)};
    text-decoration: var.default(--wy-link-decoration);

    &::before {
      content: "@";
    }

    &:hover, &:focus {
      text-decoration: var.default(--wy-link-hover-decoration);
    }
  }
}

[part~="wy-content-emoji"] {
  .wy-emoji {
    font-size: 3em;
  }
}
