/* 모든 페이지가 함께 쓰는 기본 규칙 (각 페이지 스타일 뒤에 로드) */

/* 한글은 단어 중간에서 줄바꿈하지 않는다 */
html:lang(ko) body {
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ===== 헤더 내비게이션 ===== */
/* 메뉴 글자가 세로로 쪼개지지 않도록 한 줄을 유지하고,
   들어가지 않는 항목은 js/nav.js가 "더보기" 메뉴로 옮긴다 */
.header .nav-container {
  gap: 16px;
}

.header .logo {
  flex-shrink: 0;
  white-space: nowrap;
}

.header .nav-menu {
  flex: 1 1 0;
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 4px;
}

.header .nav-link {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 8px 12px;
}

/* 모바일 메뉴 패널(☰)이 없는 페이지는 좁은 화면에서도 메뉴를 숨기지 않는다 */
.header:not(:has(.mobile-menu-toggle)) .nav-menu {
  display: flex;
}

/* 그런 페이지는 휴대폰 폭에서 로고 줄 아래에 메뉴 줄을 따로 둔다 */
@media (max-width: 600px) {
  /* 각 페이지는 한 줄짜리 고정 헤더(68px)만큼 본문을 내려 두었다.
     헤더를 문서 흐름에 넣고 그 68px을 빼면, 늘어난 줄만큼만 본문이 더 내려간다.
     (.nav-menu가 있는 헤더만 해당. 결제 완료 페이지의 헤더는 원래 흐름 안에 있다) */
  .header:has(.nav-menu):not(:has(.mobile-menu-toggle)) {
    position: sticky;
    top: 0;
    margin-bottom: -68px;
  }

  /* 로고, 로그인 버튼, 언어 선택이 첫 줄에 함께 들어가도록 간격을 줄인다 */
  .header:not(:has(.mobile-menu-toggle)) .nav-container {
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 0 12px;
  }

  .header:has(.nav-menu):not(:has(.mobile-menu-toggle)) .logo {
    font-size: 1.35rem;
  }

  .header:not(:has(.mobile-menu-toggle)) .nav-menu {
    order: 1;
    flex: 1 0 100%;
  }

  /* 폭 360px 화면에서도 네 항목이 한 줄에 들어가는 크기
     (.nav-links는 결제 완료 페이지의 메뉴) */
  .header:not(:has(.mobile-menu-toggle)) .nav-link {
    padding: 6px 8px;
    font-size: 0.9rem;
  }

  .header .nav-links {
    gap: 4px;
  }
}

.header .nav-right,
.header .auth-buttons,
.header .user-info,
.header .user-menu {
  flex-shrink: 0;
}

.header .google-login-btn,
.header .language-select {
  white-space: nowrap;
}

/* "더보기" 메뉴 */
.nav-more {
  position: relative;
  flex-shrink: 0;
}

.nav-more[hidden] {
  display: none;
}

/* 페이지마다 있는 일반 button 규칙에 덮이지 않도록 선택자를 구체적으로 둔다 */
.header .nav-menu .nav-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  border: 0;
  border-radius: 20px;
  background: none;
  box-shadow: none;
  font: inherit;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transform: none;
}

.header .nav-menu .nav-more-toggle:hover,
.header .nav-menu .nav-more.is-open .nav-more-toggle,
.header .nav-menu .nav-more-toggle.active {
  color: #667eea;
  background: rgba(102, 126, 234, 0.1);
  box-shadow: none;
  transform: none;
}

.nav-more-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.2s ease;
}

.nav-more.is-open .nav-more-toggle::after {
  transform: translateY(1px) rotate(-135deg);
}

.nav-more-toggle:focus-visible {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

.nav-more-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 110;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
  padding: 8px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.nav-more.is-open .nav-more-menu {
  display: flex;
}

.header .nav-more-menu .nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  text-align: left;
}
