/* =========================================
   NAV.CSS — 네비게이션 전용 스타일
   ========================================= */

/* =========================================
   HEADER
   ========================================= */
.site-header {
  --nav-bg-color: rgba(14, 34, 68, 0.92);
  --nav-bg-filter: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--height-header);
  background-color: var(--nav-bg-color);
}

/* 전 페이지 공통 헤더 배경 */
.site-header {
  --nav-bg-color: #2a5298;
  background-color: var(--nav-bg-color);
}

/* index.php 전용: 히어로 위 투명 오버레이 */
.site-header.site-header--home {
  --nav-bg-color: rgba(0, 0, 0, 0.3);
  background-color: var(--nav-bg-color);
}

/* ── 3단 그리드: [로고] [메뉴] [전화] ── */
.header-inner {
  max-width: var(--width-header);
  margin: 0 auto;
  padding: 0 var(--sp-5);
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

/* 왼쪽 영역 */
.header-left {
  display: flex;
  align-items: center;
}

/* 오른쪽 영역 */
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-4);
}

/* 전화번호 */
.nav_phone {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-sans);
  font-size: calc(var(--fs-lg) * 1.5);
  font-weight: 600;
  white-space: nowrap;
}

.nav_phone:hover {
  color: #c30028;
}

/* 로고 */
.logo {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.logo-image {
  display: block;
  height: var(--fs-lg);
  width: auto;
  aspect-ratio: 12.63480911486181 / 1;
}

@media (min-width: 901px) {
  .logo-image {
    height: calc(var(--fs-lg) * 1.5);
  }
}

.logo-text {
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: #fff;
  letter-spacing: -0.5px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
}

/* =========================================
   MEGA NAV
   ========================================= */
.mega-nav {
  position: static;
}

.nav-list {
  display: flex;
  justify-content: center;
  gap: 0;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  height: var(--height-header);
  padding: 0 22px;
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  transition:
    color var(--transition-fast),
    text-shadow 0.25s ease;
}

.nav-item:hover .nav-link {
  color: #ffd700;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.9),
    0 0 20px rgba(255, 255, 255, 0.6),
    0 0 40px rgba(255, 255, 255, 0.3);
}

.nav-item.active .nav-link {
  color: #fff;
}

.nav-item.active .nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent); /* 골드 액센트 언더라인 */
  border-radius: 2px 2px 0 0;
  transition: opacity 0.15s;
}

/* 메가패널 오픈 시 active 언더라인 숨김 → hover 항목만 강조 */
.site-header.mega-open .nav-item.active .nav-link::after {
  opacity: 0;
}

/* 모바일 토글용 개별 패널 기본값 */
.mega-panel {
  display: none;
}

/* PC 통합 메가메뉴 패널 */
.mega-all-panel {
  display: block;
  position: fixed;
  top: var(--height-header);
  left: 0;
  right: 0;
  transform: translateY(-6px);
  width: 100%;
  background-color: var(--nav-bg-color);
  border-top: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  border-radius: 0;
  min-height: 210px;
  padding: 18px 0 44px;
  z-index: 1005;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0.22s;
}

.site-header.mega-open .mega-all-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s;
}

.mega-all-grid {
  display: none;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  max-width: var(--width-header);
  margin: 0 auto;
  padding: 0 20px;
  gap: 14px 24px;
}

/* --- 서브네비(PC) 스타일: 메인 nav와 통일 --- */
.mega-col-sub li a {
  display: block;
  padding: 5px 0;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.95); /* 메인 nav와 동일 */
  font-family: var(--font-sans);
  font-weight: 500;
  background: transparent;
  white-space: nowrap;
  transition:
    color 0.18s,
    background 0.18s,
    text-shadow 0.18s;
}
.mega-col-sub li a:hover {
  color: #ffd700;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.9),
    0 0 20px rgba(255, 255, 255, 0.6),
    0 0 40px rgba(255, 255, 255, 0.3);
  background: transparent;
}
.mega-col-sub li.active > a,
.mega-col-sub li a.active {
  color: #fff;
  background: var(--color-accent);
  border-radius: 2px;
}

/* 기존 개별 서브메뉴 텍스트 스타일 (모바일에서 사용) */

/* --- 서브네비(모바일/PC) 스타일: 메인 nav와 통일 --- */
.mega-sub li a {
  display: block;
  padding: 13px 22px;
  font-size: calc(0.875rem + 2px);
  color: rgba(255, 255, 255, 0.95); /* 메인 nav와 동일 */
  font-family: var(--font-sans);
  font-weight: 500;
  background: transparent;
  white-space: nowrap;
  transition:
    background 0.18s,
    color 0.18s,
    text-shadow 0.18s;
}
.mega-sub li a:hover {
  color: #ffd700;
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.9),
    0 0 20px rgba(255, 255, 255, 0.6),
    0 0 40px rgba(255, 255, 255, 0.3);
  background: transparent;
}
.mega-sub li.active > a,
.mega-sub li a.active {
  color: #fff;
  background: var(--color-accent);
  border-radius: 2px;
}

/* 오버레이 */
.mega-overlay {
  display: none;
  position: fixed;
  inset: var(--height-header) 0 0 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 990;
}

/* =========================================
   MOBILE MENU TOGGLE
   ========================================= */
.nav_toggleBtn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav_toggleBtn span {
  display: block;
  width: 25px;
  height: 2px;
  background: #fff;
  transition: all 0.3s;
}

/* 열린 상태 */
.nav_toggleBtn.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.nav_toggleBtn.open span:nth-child(2) {
  opacity: 0;
}
.nav_toggleBtn.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

@media (min-width: 901px) {
  .header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: var(--sp-6);
    max-width: none;
    width: 100%;
    padding: 0 clamp(8px, 2vw, 24px);
  }

  .header-left {
    justify-self: start;
  }

  .mega-nav {
    margin: 0;
    width: 100%;
  }

  .header-right {
    justify-self: end;
  }

  /* 데스크톱: 풀폭 배경 + 각 메인메뉴 아래 세로 서브메뉴 */
  .mega-panel {
    display: none;
    position: absolute;
    top: var(--height-header);
    left: 50%;
    transform: translateX(-50%);
    min-width: max-content;
    z-index: 1006;
    background: transparent;
    border: none;
    border-top: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    padding-top: 10px;
  }

  .site-header.mega-open .mega-panel {
    display: block;
  }

  .mega-sub li {
    text-align: center;
  }

  .mega-sub li a {
    display: inline-block;
    padding: 6px 0 5px;
    position: relative;
    background: transparent;
    text-decoration: none;
  }

  .mega-sub li a::after {
    content: '';
    position: absolute;
    left: -3px;
    bottom: 0;
    width: calc(100% + 6px);
    height: 1px;
    background: var(--ipark-red);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.24s ease;
  }

  .mega-sub li a:hover {
    background: transparent;
    color: #fff;
  }

  .mega-sub li a:hover::after,
  .mega-sub li a:focus-visible::after {
    transform: scaleX(1);
  }
}

@media (max-width: 900px) {
  /* 모바일: 3단 그리드 → 로고 + 오른쪽(전화+햄버거) */
  .nav_phone {
    display: none;
  }

  .logo-image {
    height: 1rem;
    width: auto;
  }

  /* 모바일 헤더 좌측 로고만 확대 */
  .header-left .logo-image {
    height: 1.35rem;
  }

  .header-inner {
    grid-template-columns: 1fr auto;
  }

  /* 중앙 메뉴는 fixed 패널로 전환되므로 grid에서 제외 */
  .mega-nav {
    grid-column: unset;
  }

  .nav_toggleBtn {
    display: flex;
  }

  .mega-all-panel {
    display: none !important;
  }

  .mega-nav {
    position: fixed;
    top: var(--height-header);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 34, 68, 0.92);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 998;
  }

  .mega-nav.open {
    transform: translateX(0);
  }

  .nav-list {
    flex-direction: column;
  }

  .nav-link {
    height: auto;
    padding: 16px 20px;
    color: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 1rem;
  }

  .nav-item.active .nav-link::after {
    display: none;
  }

  /* 모바일: .active 일 때만 열기 (PC와 동일한 클래스 제어) */
  .mega-panel {
    display: none;
  }

  .mega-panel.active {
    display: block;
    position: static;
    transform: none;
    border: none;
    border-top: none;
    border-radius: 0;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .mega-sub li a {
    padding: 11px 36px;
    color: rgba(255, 255, 255, 0.95); /* 메인 nav와 동일 */
    font-family: var(--font-sans);
    font-weight: 500;
    background: transparent;
    transition:
      background 0.18s,
      color 0.18s,
      text-shadow 0.18s;
  }
  .mega-sub li a:hover {
    color: #ffd700;
    text-shadow:
      0 0 8px rgba(255, 255, 255, 0.9),
      0 0 20px rgba(255, 255, 255, 0.6),
      0 0 40px rgba(255, 255, 255, 0.3);
    background: transparent;
  }
  .mega-sub li.active > a,
  .mega-sub li a.active {
    color: #fff;
    background: var(--color-accent);
    border-radius: 2px;
  }
}

/* =========================================
   서브페이지: 메가패널 오픈 시 page-hero 아래로 밀기
   (index.php --home 제외)
   ========================================= */
.page-hero {
  transition: padding-top 0.22s ease;
}
.site-header:not(.site-header--home).mega-open ~ .page-hero {
  padding-top: calc(var(--height-header) + 220px);
}
