/* ========== HEADER ========== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 100;
  transition: background 0.3s ease;
  background: transparent;
}
.header:hover {
  background: rgba(255, 255, 255, 0.95);
}
.header.scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo a {
  display: inline-flex;
  align-items: center;
  /* 이미지 없을 때 fallback 텍스트 스타일 유지 */
  font-size: 20px;
  font-weight: 300;
  letter-spacing: var(--letter-spacing-logo);
  color: var(--color-text-heading);
}
.logo a img {
  height: 22px;
  width: auto;
  max-width: 100%;
  display: block;
  /* 기본(transparent header) 상태에선 밝은 톤. scrolled/hover면 원래 브랜드 컬러 복원 */
  filter: brightness(1.6);
  transition: filter 0.25s ease;
}
.header.scrolled .logo a img,
.header:hover .logo a img {
  filter: none;
}
.nav-list {
  display: flex;
  gap: 40px;
}
.nav-list a {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--color-text-heading);
  transition: color var(--transition);
  position: relative;
}
.nav-list a:hover,
.nav-list a.active {
  color: var(--color-brand-beige);
}
/* active 표시는 색상 + bold로 처리 (밑줄 제거) */
.nav-list a.active {
  font-weight: 700;
}

/* Menu EN ↔ KO crossfade (Option A) */
.nav-list a.menu-item {
  display: inline-block;
  position: relative;
}
.nav-list a.menu-item .en,
.nav-list a.menu-item .ko {
  display: block;
  transition: opacity 260ms ease;
}
.nav-list a.menu-item .ko {
  position: absolute;
  inset: 0;
  opacity: 0;
}
.nav-list a.menu-item:hover .en,
.nav-list .nav-item.has-dropdown:hover .menu-item .en {
  opacity: 0;
}
.nav-list a.menu-item:hover .ko,
.nav-list .nav-item.has-dropdown:hover .menu-item .ko {
  opacity: 1;
}

/* Header Dropdown (LNB on hover) */
.nav-list .nav-item {
  position: relative;
}
.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding-top: 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 200ms ease,
    transform 200ms ease;
  z-index: 101;
}
.nav-item.has-dropdown:hover .nav-dropdown,
.nav-item.has-dropdown:focus-within .nav-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.nav-dropdown-inner {
  background: #fff;
  border: 1px solid #e5e1d6;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  padding: 8px 0;
  min-width: 150px;
  border-radius: 2px;
}
.nav-dropdown a {
  display: block;
  padding: 10px 22px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: #8a8376;
  white-space: nowrap;
  text-align: center;
  transition:
    color 160ms ease,
    background 160ms ease;
}
.nav-dropdown a:hover {
  color: var(--color-text-heading);
  background: #fbf9f3;
}
.nav-dropdown a.active {
  color: var(--color-text-heading);
  font-weight: 600;
}

/* Mobile Menu */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text-heading);
  transition: var(--transition);
}
.mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 99;
}
.mobile-nav.open {
  display: block;
}
.mobile-nav a {
  display: block;
  padding: 16px 40px;
  font-size: 14px;
  letter-spacing: 1px;
  border-bottom: 1px solid #f0f0f0;
}

/* ========== FOOTER ========== */
.footer {
  background: var(--color-brand-grey);
  color: #fff;
  padding: 60px 40px 40px;
}
.footer-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
}
.footer-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 40px;
}
.footer-logo {
  font-size: 20px;
  font-weight: 300;
  letter-spacing: var(--letter-spacing-logo);
  display: flex;
  align-items: center;
}
.footer-logo img {
  height: 24px;
  width: auto;
  max-width: 100%;
  display: block;
  /* 푸터 배경(#5a5448)과 로고 컬러(동일)가 겹쳐 안 보이는 문제 해결 */
  filter: brightness(0) invert(1);
}
.footer-nav {
  display: flex;
  gap: 40px;
}
.footer-nav a {
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0.9;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.footer-nav a:hover {
  opacity: 1;
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.footer-social {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}
.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  opacity: 0.9;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.footer-social a:hover {
  opacity: 1;
}
.footer-social img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  /* 네이버 블로그 등 비정사각 아이콘도 비율 유지 */
  flex-shrink: 0;
}
.footer-info {
  font-size: 12px;
  line-height: 2;
  opacity: 0.7;
}
.footer-info p {
  margin-bottom: 4px;
}
.footer-credit {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 11px;
  opacity: 0.5;
}

/* ========== POPUP ========== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 60px;
}
.popup-overlay.hidden {
  display: none;
}
.popup {
  background: #fff;
  max-width: 520px;
  width: 90%;
  position: relative;
}
.popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  z-index: 1;
}
.popup-content {
  padding: 40px 36px 24px;
}
.popup-content h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-heading);
  margin-bottom: 4px;
}
.popup-content .popup-subtitle {
  font-size: 14px;
  color: var(--color-brand-beige);
  font-weight: 600;
  margin-bottom: 16px;
}
.popup-content .popup-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.7;
  margin-bottom: 20px;
}
.popup-branches {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}
.popup-branch {
  flex: 1;
}
.popup-branch h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.popup-branch h3 .new-badge {
  color: #c5371a;
  font-size: 12px;
  font-weight: 700;
  margin-right: 4px;
}
.popup-branch .branch-map {
  width: 100%;
  aspect-ratio: 4/3;
  background: #f5f5f5;
  margin-bottom: 8px;
  border: 1px solid #eee;
}
.popup-branch .branch-map img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.popup-branch .branch-addr {
  font-size: 11px;
  color: #666;
  line-height: 1.6;
}
.popup-hours {
  text-align: center;
  font-size: 13px;
  color: #555;
  margin-bottom: 16px;
}
.popup-hours p {
  margin-bottom: 2px;
}
.popup-consult {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-heading);
  margin-bottom: 8px;
}
.popup-consult-note {
  text-align: center;
  font-size: 11px;
  color: #999;
}
.popup-footer {
  display: flex;
  border-top: 1px solid #eee;
}
.popup-footer button {
  flex: 1;
  padding: 14px;
  font-size: 13px;
  color: #fff;
  background: var(--color-brand-beige);
  transition: var(--transition);
}
.popup-footer button:hover {
  opacity: 0.9;
}
.popup-footer button:first-child {
  background: var(--color-brand-grey);
}

/* ========== UTILITY ========== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 40px;
}
.section {
  padding: var(--section-padding) 0;
}
.section-title {
  font-size: var(--font-size-xl);
  font-weight: 300;
  letter-spacing: var(--letter-spacing-heading);
  text-align: center;
  color: var(--color-brand-beige);
  margin-bottom: 12px;
}
.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
  text-align: center;
  letter-spacing: 1px;
}
.divider {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  height: 1px;
  background: var(--color-divider);
}
.btn-primary {
  display: inline-block;
  padding: 14px 40px;
  background: var(--color-brand-beige);
  color: #fff;
  font-size: 14px;
  letter-spacing: 1px;
  border-radius: 2px;
  transition: var(--transition);
}
.btn-primary:hover {
  opacity: 0.85;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 991px) {
  .nav-list {
    display: none;
  }
  .hamburger {
    display: flex;
  }
  .header-inner {
    padding: 0 20px;
    position: relative;
  }
  /* 모바일: 로고를 헤더 가운데 고정 (햄버거는 우측 유지) */
  .logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
  }
  .container {
    padding: 0 20px;
  }
  .footer {
    padding: 40px 20px 30px;
  }
  :root {
    --section-padding: 60px;
    --font-size-hero: 32px;
    --font-size-2xl: 26px;
    --font-size-xl: 20px;
  }
}
@media (max-width: 767px) {
  .logo a {
    letter-spacing: 3px;
    font-size: 17px;
  }
  .logo a img {
    height: 16px;
  }
  .footer-logo img {
    height: 20px;
  }
  .popup-branches {
    flex-direction: column;
  }
  :root {
    --section-padding: 48px;
    --font-size-hero: 26px;
  }
}

/* 모바일 가로 스크롤 절대 금지: 어떤 요소가 오버플로해도 body가 스크롤 생성하지 않도록 고정 안전장치.
   (가로 스크롤은 모바일 UX 최악 요소 — 원인 요소 발견 시 별도 수정하되 이 안전장치는 항상 유지) */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ========== 한글 타이포 기본 방어 ==========
 * 한글은 어절 단위 줄바꿈(keep-all), 긴 영문/URL은 break-word.
 * 세로 텍스트(break-all) 방지 기본 정책. */
body {
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 제목·리드 텍스트 고아(orphan) 방지 — 브라우저 지원 시 자동 균형 줄바꿈 */
h1,
h2,
h3,
.section-title,
.section-subtitle,
.brandfilm-lead,
.brandfilm-desc,
.about-lead {
  text-wrap: pretty;
}
h1,
.section-title {
  text-wrap: balance;
}

/* 유틸: PC 전용 <br>을 모바일에서 제거 → 모바일에서 어색한 강제 줄바꿈 방지 */
@media (max-width: 767px) {
  br.pc-br,
  .pc-br {
    display: none;
  }
}

/* ========== BOTTOM NAV (모바일 하단 탭바) ========== */
.bottom-nav {
  display: none;
}
@media (max-width: 991px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.04);
    z-index: 99;
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.2px;
    color: var(--color-text-primary);
    transition: color 0.2s ease;
  }
  .bottom-nav a {
    position: relative;
    padding-top: 10px; /* active indicator용 여유 */
  }
  .bottom-nav a.active {
    color: var(--color-brand-beige);
    font-weight: 700;
  }
  /* active indicator: 상단 중앙 막대 + 은은한 배경 → 계층 구분 강화 */
  .bottom-nav a.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--color-brand-beige);
    border-radius: 0 0 3px 3px;
  }
  .bottom-nav a.active::after {
    content: "";
    position: absolute;
    inset: 4px 4px 4px 4px;
    background: rgba(90, 84, 72, 0.06);
    border-radius: 8px;
    z-index: -1;
  }
  .bottom-nav a + a {
    border-left: 1px solid rgba(0, 0, 0, 0.05);
  }
  /* 햄버거/드롭다운 대체: 하단바로 통일 */
  .hamburger {
    display: none !important;
  }
  .mobile-nav {
    display: none !important;
  }
  /* 하단바에 콘텐츠가 가려지지 않도록 body에 여백 */
  body {
    padding-bottom: 58px;
  }
  /* 모바일 푸터: 메뉴(PC 전용) 숨김 + SNS/텍스트 레이아웃 재정리 */
  .footer-nav {
    display: none;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
  }
  .footer-social,
  .footer-social a,
  .footer-social img {
    width: 32px;
    height: 32px;
  }
  /* 헤더 fixed와 본문 사이 여백 확보 — 히어로 없는 페이지의 첫 섹션에 상단 여유.
     히어로가 있는 페이지(index, about)는 hero 자체가 공간 차지해 영향 없음. */
  .community-header,
  .project-section,
  .estimate-header {
    padding-top: calc(var(--header-height) + 20px);
  }
}
@media (max-width: 767px) {
  .footer-info {
    font-size: 11px;
    line-height: 1.75;
  }
  .footer-info p {
    margin-bottom: 2px;
  }
  .footer-credit {
    font-size: 10px;
  }
}

/* ========== BOTTOM NAV · Popover LNB ========== */
/* ABOUT/PORTFOLIO 탭 클릭 시 탭 바로 위에 뜨는 서브메뉴 팝오버 */
.bn-popover {
  position: fixed;
  bottom: 72px; /* 탭바 58 + 간격 14 */
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px;
  z-index: 200;
  min-width: 180px;
  max-width: 220px;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  display: none;
}
.bn-popover.open {
  display: block;
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}
.bn-popover a {
  display: block;
  padding: 10px 16px;
  font-size: 13px;
  letter-spacing: 0.5px;
  color: var(--color-text-primary);
  border-radius: 8px;
  transition: background 0.15s ease;
}
.bn-popover a:hover,
.bn-popover a.active {
  background: rgba(90, 84, 72, 0.08);
  color: var(--color-brand-beige);
  font-weight: 600;
}
.bn-popover .bn-pop-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.06);
  margin: 4px 2px;
}
/* 화살표 (탭 방향 가리킴) — popover가 뷰포트 경계로 밀려도 화살표는 탭 중앙 고정 */
.bn-popover::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: calc(50% + var(--bn-arrow-x, 0px));
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
/* popover 열린 상태에서 해당 트리거 탭 강조 */
.bottom-nav a.submenu-open {
  color: var(--color-brand-beige);
  font-weight: 700;
}
/* PC(992+)에선 popover 숨김 (하단탭바 자체가 안 보임) */
@media (min-width: 992px) {
  .bn-popover {
    display: none !important;
  }
}
