@use 'sass:math';

@mixin markdown() {
  font-family: var(--llm-font-primary);
  background: var(--llm-assistant-background);
  color: var(--llm-assistant-foreground);
  border: var(--llm-assistant-border);

  /*
  &,
  p {
    font-weight: 300;
  }
  */

  h1 {
    @include text(display3);
  }

  h2 {
    @include text(display4);
  }

  h3 {
    @include text(display5);
  }

  h4,
  h5,
  h6 {
    @include text(display6);
  }

  ol,
  ul {
    display: flex;
    flex-direction: column;
    gap: 0.75em;
    margin-left: var(--llm-markdown-margin-left);
  }

  ol {
    margin-left: 1.1em;
  }

  ul {
    margin-left: 0.8em;
    list-style: disc;
  }

  code,
  pre {
    font-size: inherit;
    line-height: inherit;
    font-style: normal;
    font-family: inherit;
    background-color: transparent;
    color: inherit;
  }

  pre,
  code {
    font-family: monospace;
    font-size: 0.9em;
  }

  i,
  em {
    font-style: italic;
  }

  b,
  strong {
    font-weight: var(--llm-typography-cta2-font-weight);
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin-top: var(--llm-markdown-margin-top);
  }

  p,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6,
  ul,
  ol,
  pre,
  blockquote {
    margin-bottom: var(--llm-markdown-margin-bottom);

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

  blockquote {

    &,
    &:before,
    &:after {
      margin: 0;
      padding: 0;
      border: none;
      outline: none;
      font-family: inherit;
      font-size: inherit;
      background: none;
      color: inherit;
    }

    & {
      margin-bottom: var(--llm-markdown-margin-bottom);
      padding-left: 0.5em;
      border-left: var(--llm-markdown-border);
    }
  }

  hr {
    border: none;
    border-top: var(--llm-markdown-border);
    margin-top: var(--llm-markdown-margin-top);
    margin-bottom: var(--llm-markdown-margin-bottom);
  }

  a {
    text-decoration: underline;

    &:link,
    &:active,
    &:visited,
    &:hover {
      color: var(--llm-markdown-accent);
    }
  }

  img {
    max-width: 320px;
    padding: 8px;
    border-radius: 8px;
    border: var(--llm-markdown-border);
  }

  .llm__text-img {
    display: block;
    margin-top: var(--llm-markdown-margin-top);
    margin-bottom: var(--llm-markdown-margin-bottom);
    font-size: 0;
    text-decoration: none;

    &>img {
      display: inline-flex;
      justify-content: center;
      align-items: center;
      width: 320px;
      height: 320px;
      object-fit: cover;
    }
  }

  .llm__pill {
    max-width: Max(375px, u(30));
    margin-bottom: 1em;

    &:first-of-type {
      margin-top: 2em;
    }

    &:last-of-type {
      margin-bottom: 2em;
    }
  }
}
