@use 'sass:color';

th,
td {
  img {
    display: inline-block;
  }
}

.doom-btn {
  position: relative;
  padding: 0 !important;

  > span {
    display: block;
    padding: 0 20px;
  }
}

.doom-collapse-group {
  .rspress-directive {
    margin-bottom: 0;
    padding-top: 10px;
    padding-bottom: 10px;
    border-radius: 0;

    &:first-child {
      border-top-left-radius: var(--rp-radius-small);
      border-top-right-radius: var(--rp-radius-small);
    }

    &:last-child {
      border-bottom-left-radius: var(--rp-radius-small);
      border-bottom-right-radius: var(--rp-radius-small);
    }

    + .rspress-directive {
      margin-top: -1px;
    }
  }
}

@mixin callout {
  counter-increment: callouts;
  content: counter(callouts);
  border-radius: 50%;
  background-color: #06c;
  color: #fff;
  width: 20px;
  height: 20px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-left: 4px;
}

.has-callouts {
  counter-reset: callouts;

  .line.callout {
    &:after {
      @include callout;
    }
  }
}

.doom-callouts {
  margin-top: 1rem;
  margin-bottom: 1rem;
  line-height: 1.75rem;

  > .rp-list-decimal {
    counter-reset: callouts;
    list-style-type: none;

    > li {
      margin-left: -1.25rem;

      &:not(:has(> p)),
      > p {
        &:before {
          @include callout;
          margin-right: 0.75rem;
        }
      }

      > {
        ul,
        ol {
          margin-left: 1.25rem;
        }
      }
    }
  }
}

.doom-tabs {
  div.language-mdx {
    margin: 24px 0;
  }

  .language-mdx {
    // https://github.com/web-infra-dev/rspress/blob/bbe6476c8394f9c95a98fd791f0614481f89d878/packages/theme-default/src/styles/code.css#L6
    --rp-code-block-bg: #{color.adjust($color: #f6f8fa, $lightness: -5%)};
  }
}

.doom-auto-toc {
  @media (min-width: 1280px) {
    display: none;
  }
}

.dark .doom-tabs .language-mdx {
  // https://github.com/web-infra-dev/rspress/blob/bbe6476c8394f9c95a98fd791f0614481f89d878/packages/theme-default/src/styles/code.css#L17
  --rp-code-block-bg: #{color.adjust($color: #242424, $lightness: 5%)};
}

.rspress {
  &-sidebar-item {
    word-break: break-word;
  }
}

@mixin print {
  .rspress {
    &-nav,
    &-sidebar-menu,
    &-doc-footer {
      display: none;
    }

    &-doc-container {
      padding: 0;
    }

    &-directive-title::marker {
      content: none;
    }
  }

  [class^='scroll-to-top_'] {
    display: none;
  }
}

.print:root {
  @include print;
}

@media print {
  @include print;
}

.rp-list-decimal:not(:has(p)) {
  list-style: none;
  counter-reset: section;
  padding-left: 20px;

  > li:before {
    counter-increment: section;
    content: counters(section, '.') '. ';
  }
}
