/* =========================================================
   Language Popover (Prettykeep) - Full Styles
   - .lang-overlay: 오버레이(열기/닫기 토글)
   - .lang-popover : 팝오버 본체 (JS가 position:fixed로 좌표 지정)
   - 데스크톱/태블릿: 버튼 아래 팝오버 + caret
   - 모바일(≤640px): 전체 화면 모달
   ========================================================= */

/* ===== Overlay ===== */
.lang-overlay {
  position: fixed;
  inset: 0;
  background: transparent;         /* 바깥 클릭 감지용 영역 */
  z-index: 3000;                   /* 헤더/플로팅 요소보다 위 */
  display: none;                   /* 기본은 숨김 */
}
.lang-overlay.is-open {
  display: block;                  /* JS에서 토글 */
}

/* ===== Popover ===== */
.lang-popover {
  position: fixed;                 /* JS가 좌표 배치 (top/left) */
  min-width: 220px;
  max-height: 60vh;
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0,0,0,.15);
  animation: lang-pop-in .16s ease-out;
  will-change: transform, opacity;
}

/* 팝오버 진입 모션 */
@keyframes lang-pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* 데스크톱/태블릿 caret (버튼 아래쪽에서 내려오는 꼬리) */
.lang-popover::after {
  content: "";
  position: absolute;
  top: -6px;
  right: 18px;                               /* 우측에서 18px (JS 좌우 클램프 고려 시 무난한 위치) */
  width: 12px; height: 12px;
  transform: rotate(45deg);
  background: inherit;
  border-left: 1px solid rgba(0,0,0,.08);
  border-top: 1px solid rgba(0,0,0,.08);
  -webkit-backdrop-filter: inherit;
  backdrop-filter: inherit;
}

/* ===== Header (모바일에서만 노출) ===== */
.lang-header {
  display: none; /* 데스크톱/태블릿 기본 비노출 */
}
.lang-header .title {
  font-weight: 700;
  font-size: 16px;
}
.lang-header .close {
  width: 36px; height: 36px; border: 0;
  border-radius: 10px; background: #f4f4f4;
  font-size: 20px; line-height: 36px;
  cursor: pointer;
}

/* ===== List & Items ===== */
.lang-list {
  margin: 6px;
  padding: 6px;
  list-style: none;
}
.lang-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px 14px;
  border: 0; background: transparent;
  border-radius: 10px; cursor: pointer;
  font: inherit; color: #111;
  text-align: left;
}

/* hover 시 회색 */
.lang-item:hover { background: rgba(0,0,0,.06); }

/* 선택된 언어: 굵은 글씨만, 배경 없음 */
.lang-item[aria-checked="true"] {
  background: transparent;
  font-weight: 700;
}

/* 키보드 포커스 접근성 */
.lang-item:focus-visible {
  outline: 2px solid rgba(0, 106, 255, .65);
  outline-offset: 2px;
}

/* 국기(이모지) */
.lang-flag { font-size: 18px; line-height: 1; }

/* ===== Language Button (label only) =====
   - 아이콘 span 제거에 맞춰 min-width 제거 */
#langBtn{
  white-space: nowrap;
  min-width: 0;                    /* 고정폭 제거 */
  max-width: 100%;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;                        /* 아이콘 유무와 무관하게 균형 유지 */
  overflow: hidden;                /* 긴 라벨 보호 */
  text-overflow: ellipsis;
}
.langbtn-label { display: inline-block; }

/* ===== 반응형 ===== */

/* Tablet (641–1023px): 팝오버 최소폭 확대 (헤더 중앙 정렬 시 보기 좋게) */
@media (min-width: 641px) and (max-width: 1023px) {
  .lang-popover { min-width: 320px; }
}

/* Mobile (≤640px): 전체 화면 모달 */
@media (max-width: 640px) {
  /* 배경 dim 처리 */
  .lang-overlay.is-open { background: rgba(0,0,0,.35); }

  /* 팝오버 전체화면 */
  .lang-popover {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    display: flex; flex-direction: column;
    animation: none;
  }

  /* 모바일 전용 헤더 노출 */
  .lang-header {
    position: sticky; top: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    background: #fff; z-index: 1;
  }
  .lang-header .title { font-weight: 700; font-size: 16px; }
  .lang-header .close {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  }

  /* 리스트 */
  .lang-list {
    margin: 0; padding: 10px 12px 20px;
    overflow: auto; flex: 1;
  }

  /* 버튼 여백/폰트 약간 축소 */
  #langBtn{ padding: 6px 10px; gap: 4px; }
  .langbtn-label{ font-size: .72rem; }

  /* 모바일에서는 caret 숨김 */
  .lang-popover::after { display: none; }
}

/* PC/Tablet: lang-header 숨김 유지 */
@media (min-width: 641px) {
  .lang-header { display: none !important; }
}

/* 모션 최소화 환경 배려 */
@media (prefers-reduced-motion: reduce) {
  .lang-popover { animation: none; }
}
