@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-base {
  border-radius: 50%;
  background-color: #06c;
  color: #fff;
  width: 20px;
  height: 20px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin-left: 4px;
  margin-right: 4px;
}

@mixin callout {
  counter-increment: callouts;
  content: counter(callouts);
  @include callout-base;
}

.has-callouts {
  counter-reset: callouts;

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

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

  > ol {
    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-callout {
  @include callout-base;
}

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

  .rp-link:hover {
    border-bottom: 0;
    background-color: var(--rp-c-bg-mute);
    border-radius: var(--rp-radius-small);

    &:not(.rp-toc-item--active) .rp-toc-item__text {
      color: var(--rp-c-text-1);
    }
  }

  .rp-toc-item__text {
    padding: 6px 12px;
  }
}

.auto-expandable:has(> div > .rp-codeblock) {
  background-color: var(--rp-code-block-bg);
}

.dark .rp-tabs .auto-expandable:has(> div > .rp-codeblock) {
  // https://github.com/web-infra-dev/rspress/blob/66fe9f837f4cecab859b57f6f10efc6d4d413f1b/packages/core/src/theme/styles/vars/base-vars.css#L26
  --rp-code-block-bg: #{color.adjust($color: #121212, $lightness: 5%)};
}

.rp-tabs .auto-expandable:has(> div > .rp-codeblock) {
  // https://github.com/web-infra-dev/rspress/blob/66fe9f837f4cecab859b57f6f10efc6d4d413f1b/packages/core/src/theme/styles/vars/base-vars.css#L3
  --rp-code-block-bg: #{color.adjust($color: #fff, $lightness: -5%)};
}

.rp {
  &-nav-menu .rp-hover-group__item--active a[target='_blank']:after {
    display: none;
  }

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

  &-doc {
    dl {
      margin: 1rem 0;

      dt {
        font-weight: 600;
        margin: 0.5rem 0;
      }

      dd {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        margin: 0.5rem 0 0.5rem 1rem;

        > p {
          margin: 0.5rem 0;
        }
      }
    }

    code .rp-link[target='_blank'] {
      white-space: nowrap;
    }
  }

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

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

  &-tabs {
    &__content {
      &__item {
        padding: 0 1rem;

        > :first-child,
        > :last-child {
          margin: 1rem 0;
        }
      }
    }
  }

  &-table-scroll-container:has(> table) {
    margin: 1rem 0;
  }
}

@mixin print {
  .rp {
    &-nav,
    &-doc-layout__menu,
    &-doc-footer,
    &-doc-layout__outline,
    &-doc-layout__sidebar {
      display: none;
    }

    &-doc-layout__doc {
      max-width: unset;

      &-container {
        padding: 0;
      }
    }

    &-toc-item--active .rp-toc-item__text {
      color: var(--rp-c-text-2);
    }
  }
}

.print:root {
  @include print;
}

@media print {
  @include print;
}

@import 'intelligence.scss';
@import 'breadcrumb.scss';
