/* stylelint-disable no-duplicate-selectors */
/* stylelint-disable no-descending-specificity */
/* stylelint-disable declaration-block-no-duplicate-properties */
/* stylelint-disable custom-property-pattern */
/* stylelint-disable scss/selector-no-redundant-nesting-selector */
@mixin gfm {
  @include markdown-defaults;
  @include markdown-overrides;
}

@mixin markdown-defaults {
  @include clearfix;

  color: var(--markdown-text);
  font-family: var(--markdown-font);
  line-height: var(--markdown-line-height);
  position: relative;
  text-size-adjust: 100%;
  word-wrap: break-word;

  ul {
    list-style: initial;
  }

  .anchor {
    float: left;
    line-height: 1;
    margin-left: -20px;
    padding-right: 4px;
  }

  .anchor:focus {
    outline: 0;
  }

  h1:hover .anchor,
  h2:hover .anchor,
  h3:hover .anchor,
  h4:hover .anchor,
  h5:hover .anchor,
  h6:hover .anchor {
    text-decoration: none;
  }

  details {
    display: block;
  }

  summary {
    display: list-item;
  }

  a {
    transition: 0.15s ease;

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

  a:active,
  a:hover {
    outline-width: 0;
  }

  a:not([href]) {
    color: inherit;
    text-decoration: none;
  }

  strong {
    font-weight: inherit;
    font-weight: bolder;
  }

  h1 {
    font-size: 2em;
    margin: 0.67em 0;
  }

  hr {
    @include clearfix;

    background: transparent;
    border-bottom: 1px solid var(--markdown-edge, #dfe2e5);
    border-width: 0 0 1px;
    box-sizing: content-box;
    height: 0;
    margin: 15px 0;
    overflow: hidden;
  }

  input {
    font: inherit;
    margin: 0;
  }

  input {
    overflow: visible;
  }

  [type='checkbox'] {
    box-sizing: border-box;
    padding: 0;
  }

  * {
    box-sizing: border-box;
  }

  input {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
  }

  strong {
    font-weight: 600;
  }

  details summary {
    cursor: pointer;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    color: var(--markdown-title);
    font-family: var(--markdown-title-font);
    font-size: var(--markdown-title-size);
    font-weight: var(--markdown-title-weight, 600);
    line-height: 1.25;
    margin-bottom: var(--markdown-title-marginBottom, 1rem);
    margin-top: var(--markdown-title-marginTop, 1em);
  }

  h1 {
    font-size: 1.75em;
    font-size: var(--markdown-title-size, 1.75em);
  }

  h2 {
    font-size: 1.5em;
    font-size: var(--markdown-title-size, 1.5em);
  }

  h1 {
    font-weight: 700;
    font-weight: var(--markdown-title-weight, 700);
  }

  h2 {
    font-weight: 600;
    font-weight: var(--markdown-title-weight, 600);
  }

  h3,
  h4 {
    font-weight: 600;
    font-weight: var(--markdown-title-weight, 600);
  }

  h3 {
    font-size: 1.25em;
    font-size: var(--markdown-title-size, 1.25em);
  }

  h4 {
    font-size: 1em;
    font-size: var(--markdown-title-size, 1em);
  }

  h5,
  h6 {
    font-weight: 600;
    font-weight: var(--markdown-title-weight, 600);
  }

  h5 {
    font-size: 0.875em;
    font-size: var(--markdown-title-size, 0.875em);
  }

  h6 {
    color: var(--markdown-title, #6a737d);
    font-size: 0.85em;
    font-size: var(--markdown-title-size, 0.85em);
  }

  p,
  .p {
    margin-bottom: 10px;
    margin-top: 0;
  }

  blockquote {
    margin: 0;
  }

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

  ol ol,
  ul ol {
    list-style-type: lower-alpha;
  }

  ol ol ol,
  ol ul ol,
  ul ol ol,
  ul ul ol {
    list-style-type: lower-roman;
  }

  dd {
    margin-left: 0;
  }

  input::-webkit-inner-spin-button,
  input::-webkit-outer-spin-button {
    appearance: none;
    appearance: none;
    margin: 0;
  }

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

  // for mdx pages, select the first markdown element after the style tags
  & > :nth-child(1 of :not(style)) {
    margin-top: 0 !important;
  }

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

  blockquote,
  dl,
  ol,
  p,
  pre,
  table,
  ul {
    margin-bottom: 15px;
    margin-top: 0;
  }

  blockquote {
    border-left: 0.225em solid #dfe2e5;
    color: #6a737d;
    display: block;
    padding: 0 1em;

    &:has(img, figure, .Image) {
      display: flow-root;
    }
  }

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

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

  ol,
  ul {
    padding-left: 2em;
  }

  ol ol,
  ol ul,
  ul ol,
  ul ul {
    margin-bottom: 0;
    margin-top: 0;
  }

  li {
    clear: both;
    word-wrap: break-all;
  }

  li > p {
    margin-top: 1em;
  }

  li + li {
    margin-top: 0.25em;
  }

  dl {
    padding: 0;
  }

  dl dt {
    font-size: 1em;
    font-style: italic;
    font-weight: 600;
    margin-top: 1em;
    padding: 0;
  }

  dl dd {
    margin-bottom: 1em;
    padding: 0 1em;
  }

  :checked + .radio-label {
    border-color: var(--project-color-primary);
    position: relative;
    z-index: 1;
  }

  .task-list-item {
    list-style-type: none;
  }

  .task-list-item + .task-list-item {
    margin-top: 3px;
  }

  .task-list-item input {
    margin: 0 0.2em 0.25em -1.6em;
    vertical-align: middle;
  }

  p.blank-line {
    height: 1.5em;
  }
}

@mixin markdown-overrides {
  h5,
  h6 {
    font-size: 0.9em;
  }

  blockquote h1:last-child,
  blockquote h2:last-child {
    border-bottom: 0;
  }

  > * {
    margin-bottom: 15px !important;
    margin-top: 15px;
  }

  .task-list-item input {
    margin: 0 0.5em 0.25em -1.25em;
  }

  a[href],
  a:not([href='']) {
    text-decoration: underline;
  }
}

@mixin clearfix() {
  &::before,
  &::after {
    content: '';
    display: table;
  }

  &::after {
    clear: both;
  }
}
