@import "@/styles/variables.scss";
@import "@/styles/mixins.scss";

.menu {
  .submenuContainer {
    position: absolute;
    top: 5.5rem;
    left: 0;
    background: $blue-dark;
    color: $white;
    cursor: default;
  }

  &:hover {
    & > a {
      color: rgba($white, 0.6);
      position: relative;

      .triangle {
        position: absolute;
        top: 2.6rem;
        left: calc(50% - 9px);
        display: inline-block;
        width: 0;
        height: 0;
        border-top: 0.5rem solid transparent;
        border-left: 0.5rem solid transparent;
        border-right: 0.5rem solid transparent;
        border-bottom: 0.5rem solid $blue-dark;
      }
    }
  }

  .submenu {
    display: flex;

    & > div:not(:first-child) {
      border-left: 1px solid rgba($white, 0.12);
    }
  }
}

.standard,
.twoColumnSubmenu,
.contactUsMenu,
.logoMenu {
  padding: 1.875rem 2rem;
  min-width: 13.25rem;
  color: $white;

  h5 {
    @include h5();
    padding-bottom: 1.875rem;
    color: $white;

    img {
      width: 4rem;
    }

    i {
      font-size: $font-h5;
    }
  }

  li {
    padding: 0.5rem 0;
    color: $white;
    opacity: 0.8;

    &:first-child {
      padding-top: 0;
    }

    &:last-child {
      padding-bottom: 0;
    }
  }
}

.logoMenu {
  .line {
    margin: 0 -2rem;
    height: 0;
    border-bottom: 1px solid rgba($white, 0.12);
  }

  .chao {
    //height: max-content;
    padding-top: 2rem;
    font-size: 1.25rem;
    font-weight: $medium;
    .tips {
      font-size: $font-small;
      color: rgba($white, 0.4);
    }
  }
}

.twoColumnSubmenu {
  & > ul {
    display: flex;
  }
}

.miniMenu {
  &:last-child {
    padding-right: 0;
  }

  .subtitle {
    display: inline-block;
    font-size: $font-small;
    color: $white;
    opacity: 0.4;
    padding-bottom: 1.188rem;
  }

  .twoCItem {
    padding: 0.5rem 0;
    font-size: $font-normal;
    color: $white;
    opacity: 0.8;

    &:first-child {
      padding-top: 0;
    }
    &:last-child {
      padding-bottom: 0;
    }
  }

  & > div {
    min-width: 8.75rem;
    color: $white;
  }

  h5 {
    @include h5();
    padding-bottom: 1.5rem;
    color: $white;
  }

  li {
    padding: 0.5rem 0;
    color: $white;
  }
}

.mobileMenu {
  display: none;
}

@media screen and (max-width: $wide) {
  .mobileMenu {
    position: fixed;
    left: 0;
    top: 4rem;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: $blue-dark;
    overflow: hidden;
    @include flex(flex-start, stretch, column);
    .header {
      padding: 8px 16px 16px;
      .search {
        width: 100%;
        height: 2.375rem;
        line-height: 2.375rem;
        border-radius: 4px;
        background: rgba($white, 0.1);
        border: none;
        padding: 0 0.5rem;
        color: rgba($white, 0.4);
        @include p2;
      }
      .search:focus {
        border: none;
      }
      .search::placeholder {
        content: "\ue63c";
        text-align: center;
        color: rgba($white, 0.4);
      }
    }
    .section {
      padding-left: 16px;
      .menus {
        .menu {
          color: $white;
          @include flex(flex-start, flex-start, column);
          .menuName {
            width: 100%;
            height: 3.143rem;
            line-height: 3.143rem;
            padding-right: 16px;
            border-bottom: 1px solid rgba($white, 0.1);
            @include flex(space-between, center);
            .icon {
              transition: transform 0.2s linear;
            }
          }
          .singleLine {
            width: 100%;
          }
          .subMenus {
            width: 100%;
            height: 0;
            // max-height: 0;
            overflow: hidden;
            padding-left: 16px;
            transition: all 0.4s linear;
            @include flex(flex-start, flex-start, column);
          }
          .subMenu {
            width: 100%;
          }
          &.isOpen {
            .icon {
              transform: rotate(90deg);
            }
            .subMenus {
              height: auto;
              // max-height: 100rem;
            }
          }
        }
      }
    }
  }
}

.mobileMenuItem {
  width: 100%;
  .link {
    width: 100%;
    height: 3.143rem;
    line-height: 3.143rem;
    border-bottom: 1px solid rgba($white, 0.1);
    @include flex(space-between, center);
    &:active,
    &:hover {
      color: $white;
    }
  }
  .tidbLogo {
    max-width: 3.375rem;
  }
  .chaosMatrix {
    width: 100%;
    height: 3.143rem;
    line-height: 3.143rem;
    padding-right: 16px;
    border-bottom: 1px solid rgba($white, 0.1);
    @include flex(space-between, center);
    .tips {
      font-size: $font-small;
      color: rgba($white, 0.4);
    }
  }
}
