@use "@sass-palette/hope-config";
@use "vuepress-shared/styles/arrow";
@use "vuepress-shared/styles/reset";

.dropdown-wrapper {
  cursor: pointer;

  &:not(:hover) {
    .arrow {
      transform: rotate(-180deg);
    }
  }

  .dropdown-title {
    @include reset.button;

    padding: 0 0.25rem;

    color: var(--dark-grey);

    font-weight: 500;
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;

    cursor: inherit;

    &:hover {
      border-color: transparent;
    }

    .icon {
      margin-inline-end: 0.25em;
      font-size: 1em;
    }

    .arrow {
      @include arrow.arrow;
      font-size: 1.2em;
    }
  }

  ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
  }

  .nav-dropdown {
    position: absolute;
    top: 100%;

    // NOTE: Compatible with Android Wechat
    // inset-inline-end: 0;
    right: 0;

    overflow-y: auto;
    box-sizing: border-box;

    min-width: 6rem;
    max-height: calc(100vh - var(--navbar-height));
    margin: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--grey14);
    border-radius: 0.5rem;

    background: var(--bg-color);
    box-shadow: 2px 2px 10px var(--card-shadow);

    text-align: start;
    white-space: nowrap;

    opacity: 0;
    visibility: hidden;

    transition: all 0.18s ease-out;
    transform: scale(0.9);

    #{hope-config.$rtl-selector} & {
      right: unset;
      left: 0;
    }
  }

  &:hover,
  &.open {
    .nav-dropdown {
      z-index: 2;
      opacity: 1;
      visibility: visible;
      transform: none;
    }
  }

  .nav-link {
    position: relative;

    display: block;

    margin-bottom: 0;
    border-bottom: none;

    color: var(--dark-grey);

    font-weight: 400;
    font-size: 0.875rem;
    line-height: 1.7rem;

    transition: color var(--color-transition);

    &:hover {
      color: var(--theme-color);
    }

    &.active {
      color: var(--theme-color);
    }
  }

  .dropdown-subtitle {
    margin: 0;
    padding: 0.5rem 0.25rem 0;

    color: var(--light-grey);

    font-weight: 600;
    font-size: 0.75rem;
    line-height: 2;
    text-transform: uppercase;

    transition: color var(--color-transition);
  }

  .dropdown-subitem-wrapper {
    padding: 0 0 0.25rem;
  }

  .dropdown-item {
    color: inherit;
    line-height: 1.7rem;

    &:last-child {
      .dropdown-subtitle {
        padding-top: 0;
      }

      .dropdown-subitem-wrapper {
        padding-bottom: 0;
      }
    }
  }
}
