/* =====================================================================
   브랜드 팝업 표준 엔진 - 프론트 스킨
   디자인 기준 : DESIGN-coinbase (흰 캔버스 / rounded-xl 24px / pill 버튼 / Inter)
   핵심        : 텍스트 불렛 flex 균등 분배(슬라이드 N개 → 각 1/N)
   ===================================================================== */

.bp-popup { display: none; }
.bp-popup.is-open { display: block; }

/* ----- 디바이스 노출 분기 (반응형: 화면 너비 media query 기준) -----
   서버 user-agent 판별 대신, 화면 너비로 어떤 디바이스용 팝업을 보일지 결정한다.
   슬라이드 이미지 분기(<picture media="(max-width:768px)">)와 동일한 768px 기준.
   data-device : pc / mobile / both (both 은 항상 노출)
   specificity 가 .bp-popup.is-open(2) 보다 높으므로(3) is-open 상태도 확실히 숨긴다. */
@media (max-width: 768px) {
  .bp-popup[data-device="pc"].is-open { display: none; }      /* 모바일 화면 → PC 전용 숨김 */
}
@media (min-width: 769px) {
  .bp-popup[data-device="mobile"].is-open { display: none; }  /* PC 화면 → 모바일 전용 숨김 */
}

/* ----- 오버레이 딤 ----- */
.bp-overlay {
  position: fixed; inset: 0;
  background: var(--bp-overlay, rgba(0,0,0,.5));
  z-index: calc(var(--bp-zindex, 9999) - 1);
}

/* ----- 컨테이너 (Coinbase: rounded-xl 24px, soft drop) -----
   배경은 하단 바(페이지네이션/풋터) 색과 맞춘다.
   텍스트 불렛의 높이는 padding(26px) + font-size×line-height(14×1.2=16.8) = 42.8px 처럼
   소수점이 되기 쉽고, 브라우저가 박스를 반올림해 그리면서 바 위아래에 1px 미만의 틈이 생긴다.
   컨테이너 배경이 흰색이면 그 틈이 흰 라인으로 비친다 → 바 색과 동일하게 두어 보이지 않게 한다.
   슬라이드 영역의 흰 바탕(투명 이미지/HTML 슬라이드용)은 .bp-swiper 가 따로 갖는다. */
.bp-container {
  position: fixed;
  z-index: var(--bp-zindex, 9999);
  width: 90%;
  max-width: var(--bp-width, 500px);
  background: var(--bp-pagination-bg, #0a0b0d);
  border-radius: var(--bp-radius, 24px);   /* 관리자 4코너 설정 (TL TR BR BL) */
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(10,11,13,.18);
  font-family: 'Inter', -apple-system, system-ui, 'Segoe UI', 'Malgun Gothic', Roboto, sans-serif;
}

/* ----- HTML / 텍스트 슬라이드 (숏코드·입력폼·자유 코드) ----- */
.bp-html {
  box-sizing: border-box;
  width: 100%;
  padding: 24px;
  color: #0a0b0d;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  font-family: var(--bp-font, inherit);   /* 테마 폰트 지정 시 적용, 미지정이면 컨테이너 기본 */
}
.bp-html img { max-width: 100%; height: auto; }
.bp-html :last-child { margin-bottom: 0; }
.bp-html input, .bp-html textarea, .bp-html select, .bp-html button { max-width: 100%; }

/* ----- 노출 위치 (offset 반영) ----- */
.bp-pos-center .bp-container {
  top: 50%; left: 50%;
  transform: translate(calc(-50% + var(--bp-offset-x, 0px)), calc(-50% + var(--bp-offset-y, 0px)));
}
.bp-pos-topleft .bp-container     { top: var(--bp-offset-y, 0px);  left: var(--bp-offset-x, 0px); }
.bp-pos-topright .bp-container    { top: var(--bp-offset-y, 0px);  right: var(--bp-offset-x, 0px); }
.bp-pos-bottomleft .bp-container  { bottom: var(--bp-offset-y, 0px); left: var(--bp-offset-x, 0px); }
.bp-pos-bottomright .bp-container { bottom: var(--bp-offset-y, 0px); right: var(--bp-offset-x, 0px); }
/* 가운데 상단/하단 : 가로 중앙 + 오프셋 */
.bp-pos-topcenter .bp-container    { top: var(--bp-offset-y, 0px);   left: 50%; transform: translateX(calc(-50% + var(--bp-offset-x, 0px))); }
.bp-pos-bottomcenter .bp-container { bottom: var(--bp-offset-y, 0px); left: 50%; transform: translateX(calc(-50% + var(--bp-offset-x, 0px))); }
/* 좌측/우측 가운데 : 세로 중앙 + 오프셋 */
.bp-pos-centerleft .bp-container   { left: var(--bp-offset-x, 0px);  top: 50%; transform: translateY(calc(-50% + var(--bp-offset-y, 0px))); }
.bp-pos-centerright .bp-container  { right: var(--bp-offset-x, 0px); top: 50%; transform: translateY(calc(-50% + var(--bp-offset-y, 0px))); }

/* ----- 슬라이드 이미지 ----- */
/* 슬라이드 영역의 흰 바탕. 컨테이너가 아니라 여기에 둔다 →
   박스 사이 틈(반올림 오차)에는 컨테이너의 바 색이 비쳐 라인이 보이지 않는다. */
.bp-swiper { display: block; line-height: 0; margin: 0; position: relative; background: #ffffff; } /* 원형 불렛 오버레이 기준 */
.bp-popup .swiper-slide img { width: 100%; height: auto; display: block; }
.bp-popup .bp-slide-link { display: block; line-height: 0; }

/* ----- 동영상 슬라이드 -----
   이미지와 동일 구조 : 컨테이너 폭(--bp-width / 모바일 %)에 맞추고
   높이는 가로:세로 비율(--bp-ratio, 기본 16/9)로 자동 계산 → 모바일 반응형 */
.bp-popup .bp-video {
  position: relative;
  width: 100%;
  aspect-ratio: var(--bp-ratio, 16 / 9);
  background-color: #000;
  background-image: var(--bp-poster, none);   /* 유튜브 썸네일/PC이미지 포스터 (로딩 중 표시) */
  background-size: cover;
  background-position: center;
  line-height: 0;
  overflow: hidden;
}
/* 자체 video / Vimeo iframe / YouTube API 가 생성한 iframe 모두 컨테이너를 꽉 채움 */
.bp-popup .bp-video iframe,
.bp-popup .bp-video video,
.bp-popup .bp-video .bp-video-el {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0; display: block;
}
.bp-popup .bp-video video { object-fit: contain; background: #000; }

/* ----- 페이지네이션 공통 컨테이너 -----
   swiper 밖 컨테이너 직속 → 풋터와 빈틈 없이 맞붙는다.
   Swiper 가 붙이는 .swiper-pagination-horizontal 의 position/bottom/left/transform
   규칙(높은 specificity)을 !important 로 전부 무력화하여 "위로 밀림/여백"을 제거.
   실제 타입(텍스트/원형) 클래스는 script.js 가 화면폭으로 판단해 부여한다. */
.bp-popup .bp-pagination {
  position: static !important;
  top: auto !important; bottom: auto !important;
  left: auto !important; right: auto !important;
  transform: none !important;
  width: 100% !important;
  margin: 0 !important; padding: 0 !important;
  background: var(--bp-pagination-bg, #0a0b0d);   /* 관리자 지정 불렛 영역 배경 */
  line-height: normal;
}

/* ----- 텍스트 페이지네이션 (가변 균등 분배) ----- */
.bp-popup .bp-text-pagination { display: flex !important; }
.bp-popup .bp-text-pagination .swiper-pagination-bullet {
  /* 슬라이드 N개 → 각 1/N 폭 자동 분배 (px 고정 계산 불필요) */
  flex: 1 1 0 !important;
  display: flex; align-items: center; justify-content: center;  /* 텍스트 수직·수평 중앙 */
  width: auto !important; height: auto !important;
  min-height: 0; margin: 0 !important;
  border-radius: 0; opacity: 1;
  background: transparent;
  color: var(--bp-bullet-color, #888);
  font-size: 13px; line-height: 1.2;
  letter-spacing: -0.2px;
  text-align: center; padding: 13px 6px;
  cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .2s ease;
}
.bp-popup .bp-text-pagination .swiper-pagination-bullet-active {
  color: var(--bp-bullet-active-color, #fff);
  font-weight: 700;
}

/* ----- 원형(점) 페이지네이션 -----
   슬라이드가 많아 텍스트 불렛이 겹칠 때의 대안. 가운데 정렬, 점 사이 간격.
   다크 바(.bp-pagination 영역)는 쓰지 않고, script.js 가 이 요소를 .bp-swiper 안으로
   옮겨 이미지 하단(아래에서 10px 위)에 오버레이한다.
   비활성 점 : 지정 크기/색상/불투명도 / 활성 점 : 가로로 확장되는 pill */
.bp-popup .bp-circle-pagination {
  position: absolute !important;
  left: 0 !important; right: 0 !important;
  bottom: 10px !important; top: auto !important;
  width: 100% !important;
  background: transparent !important;   /* 바 영역 숨김 */
  padding: 0 !important;
  z-index: 2;
  display: flex !important;
  justify-content: center; align-items: center;
  gap: 8px;
}
.bp-popup .bp-circle-pagination .swiper-pagination-bullet {
  flex: 0 0 auto;
  width: var(--bp-circle-size, 10px);
  height: var(--bp-circle-size, 10px);
  margin: 0 !important;
  border-radius: 999px;
  background: var(--bp-circle-color, #ffffff);
  opacity: var(--bp-circle-opacity, 1);
  cursor: pointer;
  transition: width .3s ease, opacity .2s ease;
}
.bp-popup .bp-circle-pagination .swiper-pagination-bullet-active {
  width: calc(var(--bp-circle-size, 10px) * 2.6);   /* 확장되는 원형(pill) */
  opacity: 1;
}

/* ----- 배지(카운터) 페이지네이션 : "1 / 3" 둥근 배지, 이미지 우하단 구석 오버레이 -----
   script.js 가 이 요소를 .bp-swiper 안으로 옮기고 --bp-badge-* 변수를 주입한다.
   우하단 앵커 : right/bottom 오프셋(px)이 클수록 구석에서 안쪽/위로 이동. */
.bp-popup .bp-badge-pagination {
  position: absolute !important;
  left: auto !important; top: auto !important;
  right: var(--bp-badge-right, 12px) !important;
  bottom: var(--bp-badge-bottom, 12px) !important;
  width: auto !important;
  z-index: 3;
  display: inline-flex !important; align-items: center; justify-content: center;
  gap: 2px;
  margin: 0 !important; padding: var(--bp-badge-pad-y, 5px) var(--bp-badge-pad-x, 12px) !important;
  background: var(--bp-badge-bg, #0a0b0d);
  color: var(--bp-badge-color, #ffffff);
  font-size: var(--bp-badge-size, 13px);
  font-weight: var(--bp-badge-weight, 600);
  line-height: 1;
  border-radius: var(--bp-badge-radius, 999px);
  transform: none !important;
  pointer-events: none;                 /* 카운터는 클릭 대상 아님 */
}
.bp-popup .bp-badge-pagination .swiper-pagination-current,
.bp-popup .bp-badge-pagination .swiper-pagination-total { color: inherit; }

/* ----- 풋터 (Coinbase: 다크 바 + 체크박스 + pill 닫기 버튼) ----- */
.bp-footer {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bp-footer-bg, #0a0b0d); padding: 14px 20px; margin: 0;
}

/* 오늘 하루 보지 않기 : 명확한 체크박스 + 라벨 */
.bp-footer .bp-today-label {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--bp-today-color, #d7d9dd); font-size: 14px; cursor: pointer; user-select: none;
  transition: color .2s ease;
}
.bp-footer .bp-today-check {
  width: 18px; height: 18px; margin: 0;
  accent-color: #0052ff;            /* 체크 시 브랜드 블루 */
  cursor: pointer; flex: 0 0 auto;
}
.bp-footer .bp-today-label:hover { color: var(--bp-today-hover, #ffffff); }

.bp-footer .bp-btn-close {
  border: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 600;
  background: var(--bp-close-bg, #16181c); color: var(--bp-close-color, #ffffff);
  border-radius: 100px;                 /* pill */
  padding: 10px 18px;
  transition: background .2s ease, color .2s ease;
}
.bp-footer .bp-btn-close:hover { background: var(--bp-close-bg-hover, #2a2d33); }

/* ----- 모바일 반응형 (가로 768px 이하) -----
   PC와 별개로 모바일 전용 위치(상단/중앙/하단)·가로폭(%)을 적용한다.
   .bp-mpos-* 규칙은 .bp-popup 까지 포함해 specificity(3)를 .bp-pos-*(2)보다
   높여 PC 위치 설정을 확실히 덮어쓴다. */
@media (max-width: 768px) {
  /* 가로폭 : 관리자 지정 % (기본 92%, 100% = 좌우 여백 없이 꽉 채움)
     ※ .bp-popup 까지 포함(specificity 2)해 PC 위치(.bp-pos-* = 2)의 left/right/top/bottom 을
       확실히 덮어써 모바일에서는 PC 위치값을 따르지 않고 모바일 위치(.bp-mpos-*)만 적용한다. */
  .bp-popup .bp-container {
    width: var(--bp-mobile-width, 92%);
    max-width: var(--bp-mobile-width, 92%);
    left: 50%; right: auto;            /* 항상 가로 중앙 정렬 */
    top: auto; bottom: auto;           /* PC 세로 위치 무력화 */
    transform: none;
  }

  /* 모바일 위치 : 상단 */
  .bp-popup.bp-mpos-top .bp-container {
    top: 16px; bottom: auto;
    transform: translateX(-50%);
  }
  /* 모바일 위치 : 중앙 */
  .bp-popup.bp-mpos-center .bp-container {
    top: 50%; bottom: auto;
    transform: translate(-50%, -50%);
  }
  /* 모바일 위치 : 하단 */
  .bp-popup.bp-mpos-bottom .bp-container {
    top: auto; bottom: 16px;
    transform: translateX(-50%);
  }

  .bp-text-pagination .swiper-pagination-bullet { font-size: 12px; padding: 12px 3px; }
}
