/**
 * Header Styles
 * 헤더, 네비게이션, 모바일 메뉴 스타일
 * CSS Nesting 사용 (Chrome 113+, Firefox 117+, Safari 16.6+)
 */

/* ==========================================================================
   헤더 메인 컨테이너
   ========================================================================== */
.site-header {
  width: var(--full-width);
  margin-bottom: 20px;

  & .user-auth-wrapper {
    width: var(--full-width);
    background-color: #F1F3F6;
    padding: 5px 0;
    height: 32px;
    display: flex;
    align-items: center;

    & .user-auth {
      max-width: var(--container-width);
      width: var(--full-width);
      margin: 0 auto;
      padding-right: 35px;
      text-align: right;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      gap: 8px;

      & .username {
        font-size: 14px;
        font-weight: 700;
      }

      & span {
        color: var(--bg-nav-primary);
      }

      & a {
        font-size: 14px;
        text-decoration: none;
        font-weight: 700;
        transition: all 0.3s ease-in-out;
        color: var(--bg-nav-primary);

        &:hover {
          opacity: 0.7;
        }
      }
    }
  }

  & .header-box {
    position: relative;
    max-width: var(--container-width);
    margin: 0 auto;

    & .container {
      display: flex;
      align-items: center;
      justify-content: space-between;
      max-width: var(--full-width);
      height: 100%;
      padding: 0 10px;
    }
  }
}

/* ==========================================================================
   네비게이션 래퍼 (로고 + 메뉴를 row로 배치)
   ========================================================================== */
.nav_wrapper {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-end;
  width: var(--full-width);
  height: 70px;

  & .site-logo-wrap {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 10;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    padding-left: 20px;

    & .site-main-logo {
      width: auto;
      height: 40px;
      z-index: 2;
    }
  }

  & .site-navigation {
    display: flex;
    align-items: center;
    width: auto;
  }
}

/* ==========================================================================
   메인 콘텐츠 영역
   ========================================================================== */
.site-main {
  margin-top: 0;
}


/* ==========================================================================
   네비게이션 메뉴
   ========================================================================== */
ul.menu {
  display: flex;
  list-style: none;

  & > li {
    display: inline-block;
    position: relative;
    padding: 0 20px;

    /* 버튼 스타일 메뉴 */
    &.button {
      padding: 8px;

      & a {
        font-size: 15px;
        color: var(--bg-white) !important;
        font-weight: normal;

        &:hover {
          color: var(--bg-white) !important;
        }
      }
    }

    &.current-menu-item.button a,
    &.current-menu-item.button a:hover {
      color: var(--bg-white) !important;
      cursor: pointer;
    }

    /* 1depth 링크 */
    & > a {
      font-size: 18px;
      position: relative;
      display: block;
      color: #111;
      cursor: pointer;
      font-weight: 600;
      transition: color 0.3s ease, transform 0.2s ease;
      padding: 8px 4px;

      &:hover {
        color: var(--bg-nav-primary);
        transform: translateY(-2px);
      }

      /* 하단 밑줄 효과 */
      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 2px;
        background: var(--bg-nav-primary);
        transition: width 0.3s ease;
      }

      &:hover::after {
        width: 80%;
      }
    }

    /* 현재 활성화된 메뉴 */
    &.current-post-ancestor > a,
    &.current-menu-item > a,
    &.current-menu-parent > a {
      color: var(--bg-nav-primary);
      font-weight: 700;

      &::after {
        width: 80% !important;
      }
    }

    /* 서브메뉴 링크 */
    &.menu-item-has-children > ul li {
      & a {
        text-align: left;
        display: block;
        padding: 12px 16px;
        color: #333;
        height: auto;
        line-height: 1.4;
        font-size: 14px;
        font-weight: 700;
        transition: background-color 0.2s ease;
      }

      &.menu-item-has-children {
        position: relative;
      }

      &.current-menu-item a,
      &:hover a {
        background-color: #f5f5f5;
        color: var(--bg-nav-primary);
      }
    }

    /* 드롭다운 표시 */
    &.focus > ul,
    &:hover > ul {
      opacity: 1;
      top: 110%;
      visibility: visible;

      & li {
        &.focus > ul,
        &:hover > ul {
          left: 100%;
          opacity: 1;
          top: 40px;
          visibility: visible;
        }
      }
    }

    /* 서브메뉴 공통 */
    & ul {
      background: #ffffff;
      border: 1px solid #e0e0e0;
      position: absolute;
      z-index: 9999;
      visibility: hidden;
      opacity: 0;
      overflow: hidden;
      border-radius: 6px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      transition: 0.3s;
      width: 200px;
    }

    & > ul {
      left: 0;
      top: 105%;

      & ul {
        left: 160px;
      }
    }
  }
}


/* ==========================================================================
   모바일 메뉴 컨테이너
   ========================================================================== */
.menu-container {
  display: none;
  position: fixed;
  width: var(--full-width);
  height: 100%;
  top: 0;
  left: 0;
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s 0.3s;

  &.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s 0s;

    & .more-navigation {
      transform: translateX(0);
    }

    & .overlay {
      visibility: visible;
      opacity: 1;
      transition: 0.2s;
    }
  }

  & .overlay {
    position: absolute;
    width: var(--full-width);
    height: 100%;
    opacity: 0;
    visibility: hidden;
    background: rgba(0, 0, 0, 0.5);
    z-index: 0;
    backdrop-filter: blur(4px);
  }

  & .more-navigation {
    position: absolute;
    top: 0;
    right: 0;
    width: 50vw;
    max-width: 80vw;
    height: 100vh;
    overflow-y: auto;
    padding: 12px;
    z-index: 10;
    background: #ffffff;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;

    & .container {
      width: 100%;
      display: flex;
      align-items: flex-start;
    }

    & #menu-main-menu-1 {
      width: 100%;
      padding: 0;
      margin: 0;
    }

    & .toggle-btn {
      display: none;
    }

    & .button.menu-item {
      margin-left: 0;
    }

    & li {
      position: relative;
      margin-bottom: 4px;
      width: var(--full-width);
      list-style: none;

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

      & > a {
        position: relative;
        display: block;
        text-align: left;
        font-size: 16px;
        font-weight: 600;
        line-height: 1.4;
        padding: 12px 16px;
        border-radius: 8px;
        color: #333;
        text-decoration: none;
        transition: all 0.2s ease;

        &:hover {
          background-color: #f5f5f5;
          color: var(--bg-nav-primary);
        }
      }

      &.button {
        height: auto;
        line-height: auto;
        margin-top: 80px;
        margin-bottom: 40px;
        padding: 0;
        display: block;
        border: none;
        border-radius: var(--radius-medium);

        & a {
          font-size: 20px;
          padding: 12px;
          color: var(--bg-white);
          text-align: center;
          font-weight: normal;
        }
      }

      &.current-post-ancestor > a,
      &.current-menu-parent > a,
      &.current-menu-item > a {
        background-color: var(--bg-nav-primary);
        color: #ffffff;
      }

      & .sub-menu {
        display: block !important;
        margin: 4px 0 0 0;
        padding: 0;
        background-color: #f8f8f8;
        border-radius: 8px;
        overflow: hidden;

        & li {
          border-bottom: none;
          margin-bottom: 0;

          &.current-menu-item > a {
            background-color: #e8e8e8;
            color: var(--bg-nav-primary);
          }

          & a {
            font-size: 14px;
            font-weight: 500;
            padding: 10px 16px 10px 32px;
            color: #555;

            &:hover {
              background-color: #e8e8e8;
              color: var(--bg-nav-primary);
            }
          }
        }
      }

      &.show .sub-menu {
        display: block !important;
      }
    }
  }

  &.active .more-navigation .current-page-item a {
    opacity: 1;
  }
}


/* ==========================================================================
   모바일 메뉴 버튼
   ========================================================================== */
.menu-btn {
  display: none;
}


/* ==========================================================================
   반응형 - 모바일 (1100px 이하)
   ========================================================================== */
@media screen and (max-width: 1100px) {
  .nav_wrapper {
    height: 56px;
    align-items: end;

    & .site-navigation {
      display: none;
    }

    & .site-logo-wrap {
      padding-left: 20px;

      & .site-main-logo {
        height: 35px;
      }
    }
  }

  .menu-container {
    display: block;
  }

  .menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    cursor: pointer;
    padding-right: 20px;
    background-color: transparent;
    z-index: 40;

    & .menu-icon {
      position: relative;
      height: 100%;
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 4px;

      &::before,
      &::after {
        content: '';
        width: 24px;
        height: 3px;
        background-color: #000;
        border-radius: 2px;
        transition: all 0.3s ease;
      }

      & span {
        width: 24px;
        height: 3px;
        background-color: #000;
        border-radius: 2px;
        transition: all 0.3s ease;
      }
    }

    &.active .menu-icon {
      display: none;
    }
  }
}

/* ==========================================================================
   반응형 - 모바일 (768px 이하)
   ========================================================================== */
@media screen and (max-width: 768px) {
  .site-header {
    & .user-auth-wrapper {
      & .user-auth {
        padding-right: 15px;

        & .username {
          font-size: 12px;
        }

        & a {
          font-size: 12px;
        }

        & .admin-btn {
          display: none;
        }

        & .admin-btn + span {
          display: none;
        }
      }
    }
  }
}
