@use "global/acms-common" as acms;
@use "global/common" as global;

/* ------------------------------
　　グローバルナビゲーション
------------------------------ */
.global-nav {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: 100%;

  @include acms.media-breakpoint-down(lg) {
    display: none;
  }
}

.global-nav-list {
  display: flex;
  padding: 0;
  margin: 0;
  font-weight: bold;
  list-style: none;

}

.global-nav-item {
  position: relative;
  display: flex;
}

.global-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--header-height);
  margin: 0 1.5rem;
  color: var(--color-text);
  text-decoration: none;

  &:visited,
  &:active,
  &:hover,
  &:focus {
    color: var(--color-text);
  }

  &:has(+ul) {
    padding: 0 1.75rem 0 0;

    &::before {
      position: absolute;
      right: 0;
      display: block;
      width: 0.5rem;
      height: 0.5rem;
      margin-top: -0.25rem;
      content: "";
      border-top: 2px solid var(--color-gray100);
      border-right: 2px solid var(--color-gray100);
      transform: rotate(135deg);
    }
  }

  &::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 2px;
    content: "";
    background: var(--color-primary);
    transform: scaleX(0);
    transition: transform 0.2s;
  }

  &:hover {
    text-decoration: none;

    &::after {
      transform: scaleX(1);
    }
  }


  // 現在位置
  .global-nav-item.stay>&::after {
    transform: scaleX(1);
  }
}

// CTA用のスタイル
.global-nav-link.is-cta {
  height: var(--header-height);
  padding: 0 2rem;
  margin-right: 0;
  margin-left: 0;
  color: var(--color-white);
  background: var(--color-primary);
  transition: background-color 0.2s;

  &::after {
    content: none;
  }

  &:hover {
    background: var(--color-primary-hover);
  }
}

.global-nav-item > .global-nav-list {
  position: absolute;
  top: 100%;
  right: 0;
  display: none;
  flex-direction: column;
  min-width: 14rem;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow);

  .global-nav-item {
    width: 100%;
    margin: 0;
    background-color: #fff;
    border-top: var(--border-width-sm) solid var(--color-gray20);
  }

  .global-nav-link {
    position: relative;
    justify-content: flex-start;
    width: 100%;
    height: auto;
    padding: 1rem 1.5rem;
    margin: 0;
    color: var(--color-text-2nd);
    background: #fff;

    &:visited {
    color: var(--color-text-2nd);
    }

    &:focus-visible::before {
      position: absolute;
      inset: 0;
      content: "";
      border: 2px solid var(--color-focus);
    }

    &:hover,
    &:active,
    &:focus {
      color: var(--color-text);
      background-color: var(--color-hover-bg);
    }

    &:hover::after {
      content: none;
    }

    &:focus-visible {
      outline: 0;
    }
  }
}

.global-nav-item:hover > .global-nav-list,
.global-nav-item:focus-within > .global-nav-list {
  display: flex;
}

.global-nav-item:last-child .global-nav-link.is-cta+.global-nav-list {
  right: 0;
  left: inherit;
}

/* ロゴ中央・グローバルナビが下
------------------------------ */
.nav-bottom,
.logo-center {
  .global-nav {
    max-width: var(--container);
    margin-right: auto;
    margin-left: auto;

    @include acms.media-breakpoint-up(lg) {
      padding: 1.5rem var(--col-gutter);
    }
  }

  .global-nav-list {
    width: 100%;
    border-left: 1px solid var(--color-gray30);

  }

  .global-nav-item {
    justify-content: center;
    width: 100%;
    border-right: var(--border-width-sm) solid var(--color-gray30);

    >.global-nav-list {
      left: 0;
      min-width: initial;

    }
  }

  .global-nav-link {
    height: 3rem;
  }

  .global-nav-link.is-cta {
    width: 100%;
    height: 3rem;
    margin: 0 1.5rem;
  }

  .global-nav-item:last-child .global-nav-link.is-cta {
    margin-right: 0;
  }
}

@include acms.media-breakpoint-up(lg) {
  .nav-bottom,
  .logo-center {
    .global-nav {
      padding-right: var(--gutter-lg);
      padding-left: var(--gutter-lg);

      > .global-nav-list {
        .global-nav-item {
          border-right: var(--border-width-sm) solid var(--color-gray30);

        }
      }
    }

  }

  .logo-center {
    .global-nav-item:hover {
      &:has(ul) {
        position: static;

        .global-nav-list {
          box-sizing: border-box;
          display: grid;
          grid-template-rows: repeat(2, 1fr);
          grid-template-columns: repeat(3, 1fr);
          grid-gap: 0.5rem;
          max-width: var(--container);
          padding: 3rem;
          margin: auto;
          overflow: initial;
          border: 0;
          box-shadow: none;


          &::after {
            position: absolute;
            top: 0;
            left: 0;
            z-index: -1;
            display: inline-block;
            width: 200vw;
            height: 100%;
            margin: 0 -50vw;
            content: '';
            background-color: var(--color-gray30);
          }

          .global-nav-item {
            box-sizing: border-box;
            border: 0;
          }
        }
      }
    }
  }
}
