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

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

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

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

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

/* トグルメニューアイコン */
.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;
    content: "";
    background-color: global.$color-text-inverse;
    border-radius: 1px;
    transition: 0.3s all;
  }

  &::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);
  }
}

@include acms.media-breakpoint-down(lg) {
  .is-locked {
    overflow: hidden;
  }
}

.global-nav-mobile {
  position: fixed;
  top: 0;
  left: 0;
  z-index: global.$zindex-mobile-nav;
  box-sizing: border-box;
  display: none;
  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 {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  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%;
  padding: 0;
  margin: 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;
        content: "";
        background-color: global.$color-text;
        border: 0;
        border-radius: 1px;
        transition: 0.3s all;
      }

      &::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 {
    visibility: hidden;
    height: 0;
    opacity: 0;
    transition: opacity 0.5s;
  }

  .global-nav-mobile-group.is-active {
    visibility: visible;
    height: unset;
    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;
  font-weight: bold;
  color: global.$color-text;
  text-align: left;
  appearance: none;
  cursor: pointer;
  background-color: transparent;
  border: none;
  border-bottom: global.$border-width-sm solid global.$color-gray30;

  &: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;
  content: "";
  border: 0.25rem solid transparent;
  border-left: 0.5rem solid rgb(0 0 0 / 40%);
}

.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;
      content: "";
      border-top: 2px solid global.$color-gray100;
      border-right: 2px solid global.$color-gray100;
      transform: rotate(45deg);
    }
  }
}

.global-nav-mobile-side-group {
  width: 100%;
  padding: 0;
  margin: 0.5rem 0 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;
}
