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

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

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

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

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

.global-nav-item {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
}

/* 親階層 */
.global-nav-list:not(.global-nav-list *) {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--container);
  padding: 1rem var(--gutter-lg) 0;
  margin: 0 auto;

  & > .global-nav-item {
    padding-bottom: 1rem;

    &:first-child::before,
    &::after {
      position: absolute;
      bottom: 1rem;
      display: block;
      width: 1px;
      height: calc(100% - 1rem);
      content: "";
      background: var(--color-gray30);
    }

    &:first-child::before {
      left: 0;
    }

    &::after {
      right: 0;
    }
  }
}

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

  &,
  &:link,
  &:visited {
    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 {
  width: 100%;
  padding: 0 1rem;
  margin: 0;
  margin-inline: 1.5rem;
  color: var(--color-white);
  background: var(--color-primary);
  border-radius: var(--border-radius-md);
  transition: background-color 0.2s ease;

  &::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;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow);

  .global-nav-item {
    width: 100%;
    padding-bottom: 0;
    margin: 0;
    background-color: #fff;
  }

  .global-nav-item + .global-nav-item {
    border-top: var(--border-width-sm) solid var(--color-gray20);
  }

  .global-nav-link {
    position: relative;
    box-sizing: border-box;
    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;
}


.js-sticky-nav {
  position: absolute;
  inset: auto 0 0;
  width: 100%;

  &.is-sticky {
    position: fixed;
    inset: 0 0 auto;
    z-index: var(--zindex-global-nav);
    box-sizing: border-box;
    max-width: unset;
    height: unset;
    background: var(--color-white);
  }
}
