@use '../../../styles/links' as links;
@use '../../../styles/anchor' as anchor;

:host {
  --translate-y: clamp(5px, 0.25em, 7px);
}

.docs-viewer {
  display: flex;
  flex-direction: column;
  padding: var(--layout-padding);
  max-width: var(--page-width);
  width: 100%;
  box-sizing: border-box;

  @media only screen and (max-width: 1430px) {
    container: docs-content / inline-size;
  }

  // If rendered on the docs page, accommodate width for TOC
  docs-docs & {
    @media only screen and (min-width: 1430px) and (max-width: 1550px) {
      width: calc(100% - 195px - var(--layout-padding));
      max-width: var(--page-width);
    }
  }

  pre {
    margin-block: 0;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    .docs-anchor {
      margin-block-start: 2.5rem;
      display: inline-block;
      color: inherit;

      @include anchor.docs-anchor();
    }
  }

  h1 {
    font-size: 2.5rem;
    margin-block-end: 0;
  }

  h2 {
    font-size: 2rem;
    margin-block-end: 0.5rem;
  }

  h3 {
    font-size: 1.5rem;
    margin-block-end: 0.5rem;
  }

  h4 {
    font-size: 1.25rem;
    margin-block-end: 0.5rem;
  }

  h5 {
    font-size: 1rem;
    margin-block-end: 0;
  }

  h6 {
    font-size: 0.875rem;
    margin-block-end: 0;
  }

  > :last-child {
    margin-block-end: 0;
  }

  a:not(.docs-github-links):not(.docs-card):not(.docs-pill):not(.docs-example-github-link) {
    &[href^='http:'],
    &[href^='https:'] {
      @include links.external-link-with-icon();
    }
  }

  &-scroll-margin-large {
    h2,
    h3 {
      scroll-margin: 5em;
    }
  }
}

.docs-header {
  margin-block-end: 1rem;
  & > p:first-child {
    color: var(--quaternary-contrast);
    font-weight: 500;
    margin: 0;
  }
}

.docs-page-title {
  display: flex;
  justify-content: space-between;

  h1 {
    margin-block: 0;
    font-size: 2.25rem;
  }

  a {
    color: var(--primary-contrast);
    height: fit-content;

    docs-icon {
      color: var(--gray-400);
      transition: color 0.3s ease;
    }

    &:hover {
      docs-icon {
        color: var(--primary-contrast);
      }
    }
  }
}
