@use "sass:map";
@use "global/acms-common" as acms;
@use "global/common" as global;

/* ------------------------------
  モバイルメニュー
------------------------------ */
.global-nav-mobile-menu-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: global.$header-height-fixed;
  height: global.$header-height-fixed;
  background: global.$color-primary;
  border: none;
  cursor: pointer;
  appearance: none;

  @media (hover: hover) {
    &:hover {
      text-decoration: none;
    }
  }

  &:active,
  &:focus {
    outline: 0;
  }
}

.global-nav-mobile-menu-text {
  margin: 0.5rem 0 0;
  color: global.$color-text-inverse;
  font-size: map.get(global.$font-scales, body-s);
  line-height: global.$line-height-ss;
}

/* トグルメニューアイコン */
.global-nav-mobile-icon-toggle-menu {
  position: relative;
  display: inline-block;
  width: 1.25rem;
  height: 2px;
  margin: 0.5rem auto;
  vertical-align: middle;
  background-color: global.$color-text-inverse;
  border-radius: 1px;
  transition: 0.1s all;

  &::before,
  &::after {
    position: absolute;
    display: block;
    width: 100%;
    height: 2px;
    background-color: global.$color-text-inverse;
    border-radius: 1px;
    transition: 0.3s all;
    content: "";
  }

  &::before {
    top: -0.4rem;
  }

  &::after {
    bottom: -0.4rem;
  }

  [aria-expanded="true"] & {
    background: transparent;
  }

  [aria-expanded="true"] &::before {
    width: 1.25rem;
    transform: translate(0, 0.4rem) rotate(45deg);
  }

  [aria-expanded="true"] &::after {
    width: 1.25rem;
    transform: translate(0, -0.4rem) rotate(-45deg);
  }
}

@media (max-width: acms.$breakpoint-lg-max) {
  .is-locked {
    overflow: hidden;
  }
}

.global-nav-mobile {
  position: fixed;
  top: 0;
  left: 0;
  z-index: global.$zindex-mobile-nav;
  display: none;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding-top: global.$header-height + 0.5rem;
  overflow-y: scroll;
  background-color: global.$color-white;
  opacity: 0;
  transition-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transition-duration: 0.3s;
  transition-property: all;

  &.is-active {
    display: block;
  }

  &.is-opened {
    opacity: 1;
  }
}

/* モバイルメニュー開いた時
------------------------------ */
.global-nav-mobile-inner {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0 1.25rem;
}

.global-nav-mobile-menu-btn {
  position: fixed;
  top: 0;
  right: 0;
  z-index: global.$zindex-mobile-nav-btn;
}

.global-nav-mobile-navbar {
  display: grid;
  flex-direction: column;
  row-gap: 16px;
  width: 100%;
  padding: 0 0 50px;
}

.global-nav-mobile-group {
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: global.$border-width-sm solid global.$color-gray30;

  .global-nav-mobile-group {
    border-top: none;
  }
}

.global-nav-mobile-group li {
  font-size: map.get(global.$font-scales, body-m);

  &[data-has="true"] {
    .global-nav-mobile-link {
      position: relative;
    }

    .icon-expand {
      margin-top: 5px;

      &::before,
      &::after {
        position: absolute;
        display: block;
        width: 1.25rem;
        height: 2px;
        background-color: global.$color-text;
        border: 0;
        border-radius: 1px;
        transition: 0.3s all;
        content: "";
      }

      &::before {
        transform: translate(-2px, -0.5rem) rotate(90deg);
      }

      &::after {
        transform: translate(-2px, -0.5rem);
      }
    }

    .icon-expand.is-close {
      &::before,
      &::after {
        width: 1.25rem;
        transform: translate(-2px, -0.5rem);
      }
    }
  }

  .global-nav-mobile-group {
    height: 0;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.5s;
  }

  .global-nav-mobile-group.is-active {
    height: unset;
    visibility: visible;
    opacity: 1;
  }

  .global-nav-mobile-group li {
    font-size: map.get(global.$font-scales, body-s);

    .icon-expand {
      &::before,
      &::after {
        content: none;
      }
    }
  }
}

.global-nav-mobile-group li a,
.global-nav-mobile-group li button {
  position: relative;
  display: block;
  width: 100%;
  padding: 1rem 0;
  color: global.$color-text;
  font-weight: bold;
  text-align: left;
  background-color: transparent;
  border: none;
  border-bottom: global.$border-width-sm solid global.$color-gray30;
  cursor: pointer;
  appearance: none;

  &:link,
  &:visited,
  &:active,
  &:focus {
    color: global.$color-text;
    text-decoration: none;
  }

  @media (hover: hover) {
    &:hover {
      color: global.$color-text;
      text-decoration: none;
    }
  }
}

.global-nav-mobile-group li[data-has="true"] .global-nav-mobile-group li > a::before,
.global-nav-mobile-group li[data-has="true"] .global-nav-mobile-group li > button::before {
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
  border: 0.25rem solid transparent;
  border-left: 0.5rem solid rgb(0 0 0 / 40%);
  content: "";
}

.global-nav-mobile {
  .icon-expand {
    position: absolute;
    top: 50%;
    right: 1.25rem;
    margin-top: -0.25rem;

    &::before {
      position: absolute;
      display: block;
      width: 0.5rem;
      height: 0.5rem;
      border-top: 2px solid global.$color-gray100;
      border-right: 2px solid global.$color-gray100;
      transform: rotate(45deg);
      content: "";
    }
  }
}

.global-nav-mobile-side-group {
  width: 100%;
  margin: 0.5rem 0 0;
  padding: 0;
  font-weight: bold;
  list-style: none;

  .global-nav-mobile-side-group {
    margin: 0 0 1.25rem;
  }
}

.global-nav-mobile-side-group li {
  font-size: map.get(global.$font-scales, body-s);
}

.global-nav-mobile-side-group li a {
  position: relative;
  display: block;
  padding: 0.5rem 0;
  color: currentcolor;
  text-decoration: none;

  @media (hover: hover) {
    &:hover {
      color: inherit;
    }
  }
}

.global-nav-mobile-navbar-btn-group {
  display: grid;
  row-gap: 16px;

  > * {
    display: grid;
  }
}

.global-nav-mobile-navbar-footer {
  display: flex;
  justify-content: center;
}
