/* 프로모션 팝업 — 모바일·태블릿: 슬라이드 / 데스크톱(1024px+): 펼침 카드 */

#idx-ad-popup {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

#idx-ad-popup.is-open {
  display: flex;
  /* align-items: center 이면 자식이 뷰보다 길 때 위쪽이 스크롤로 복구되지 않고 잘림 */
  align-items: flex-start;
  justify-content: center;
  /* 카드·푸터가 뷰포트보다 길 때 전체 레이어 스크롤 */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #3a3c44 #0f1014;
}

/* WebKit — 오버레이 세로 스크롤 (짙은 그레이) */
#idx-ad-popup.is-open::-webkit-scrollbar {
  width: 6px;
}

#idx-ad-popup.is-open::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#idx-ad-popup.is-open::-webkit-scrollbar-track {
  background: #0f1014;
  border-radius: 6px;
}

#idx-ad-popup.is-open::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: #35373e;
  border: 1px solid #0a0a0c;
  background-clip: padding-box;
}

#idx-ad-popup.is-open::-webkit-scrollbar-thumb:hover {
  background: #42444d;
}

#idx-ad-popup.is-open::-webkit-scrollbar-thumb:active {
  background: #2c2e34;
}

#idx-ad-popup .idx-ad-popup__backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background-color: #000000b2;
  backdrop-filter: blur(5px) brightness(100%);
  -webkit-backdrop-filter: blur(5px) brightness(100%);
  cursor: default;
}

#idx-ad-popup .idx-ad-popup__dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(382px, calc(100vw - 24px));
  max-height: min(92vh, 900px);
  align-items: stretch;
  justify-content: center;
  gap: 5px;
  padding: 15px 20px;
  box-sizing: border-box;
  background-color: #212328;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #1e2939;
  box-shadow: 0px 6px 20px #000000cc;
  flex-shrink: 0;
}

/* 모드 전환 */
#idx-ad-popup .idx-ad-popup__mode-spread {
  display: none;
}

#idx-ad-popup .idx-ad-popup__mode-carousel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 100%;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  /* popup_desk .popup — 바깥 래퍼는 투명, 컬럼·전체닫기만 떠 보이게 */
  #idx-ad-popup .idx-ad-popup__dialog {
    width: min(1720px, calc(100vw - 24px));
    gap: 20px;
    padding: 12px 16px;
    background-color: transparent;
    border: none;
    box-shadow: none;
    /* 세로로 넘치면 다이얼로그만 스크롤 — 스트립·카드가 flex:1에 눌려 잘리지 않게 */
    max-height: calc(100svh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    /* center면 가로로 intrinsic 폭만 차지해 스트립이 다이얼로그 밖으로 잘릴 수 있음 */
    align-items: stretch;
    scrollbar-width: thin;
    scrollbar-color: #3a3c44 #0f1014;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar {
    width: 6px;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar-track {
    background: #0f1014;
    border-radius: 6px;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar-thumb {
    border-radius: 6px;
    background: #35373e;
    border: 1px solid #0a0a0c;
    background-clip: padding-box;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar-thumb:hover {
    background: #42444d;
  }

  #idx-ad-popup .idx-ad-popup__dialog::-webkit-scrollbar-thumb:active {
    background: #2c2e34;
  }

  #idx-ad-popup .idx-ad-popup__mode-carousel {
    display: none;
  }

  #idx-ad-popup .idx-ad-popup__mode-spread {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    min-height: 0;
  }
}

/* ----- 슬라이드(모바일·태블릿) ----- */

#idx-ad-popup .idx-ad-popup__pagination {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

#idx-ad-popup .idx-ad-popup__dot {
  width: 6px;
  height: 6px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background-color: #303338;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__dot.is-active {
  background-color: #e701e2;
}

#idx-ad-popup .idx-ad-popup__carousel {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  position: relative;
  flex: 0 0 auto;
}

#idx-ad-popup .idx-ad-popup__viewport-shell {
  flex: 1;
  min-width: 0;
  position: relative;
}

#idx-ad-popup .idx-ad-popup__viewport {
  overflow: hidden;
  border-radius: 8px;
  position: relative;
  z-index: 0;
  background-color: #1b1d23;
}

#idx-ad-popup .idx-ad-popup__slides {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  margin: 0;
  padding: 0;
  list-style: none;
}

#idx-ad-popup .idx-ad-popup__slide {
  grid-area: 1 / 1;
  width: 100%;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.55s ease-in-out;
  will-change: opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

#idx-ad-popup .idx-ad-popup__slide.is-active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

#idx-ad-popup .idx-ad-popup__slide img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
}

#idx-ad-popup .idx-ad-popup__hit-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: min(38%, 140px);
  min-width: 48px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__hit-zone--prev {
  left: 0;
}

#idx-ad-popup .idx-ad-popup__hit-zone--next {
  right: 0;
}

#idx-ad-popup .idx-ad-popup__hit-zone:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: -2px;
}

#idx-ad-popup .idx-ad-popup__arrow {
  flex-shrink: 0;
  min-width: 24px;
  min-height: 44px;
  width: 24px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 10px;
  background-color: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__arrow-img {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  object-fit: contain;
  pointer-events: none;
}

#idx-ad-popup .idx-ad-popup__arrow.idx-ad-popup__arrow--placeholder {
  visibility: hidden;
  pointer-events: none;
}

#idx-ad-popup .idx-ad-popup__hit-zone.idx-ad-popup__hit-zone--inactive {
  visibility: hidden;
  pointer-events: none;
}

#idx-ad-popup.idx-ad-popup--single .idx-ad-popup__arrow {
  visibility: hidden;
  pointer-events: none;
}

#idx-ad-popup.idx-ad-popup--single .idx-ad-popup__hit-zone {
  visibility: hidden;
  pointer-events: none;
}

/* ----- 펼침 카드(데스크톱) — popup_desk .frame-5 / .popup-2·popup-3 ----- */

#idx-ad-popup .idx-ad-popup__strip-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  scroll-snap-type: x proximity;
  /* 가로 스크롤 — Firefox (짙은 그레이) */
  scrollbar-width: thin;
  scrollbar-color: #3a3c44 #0f1014;
}

/* WebKit — 스트립 가로 스크롤 (짙은 그레이) */
#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar {
  height: 6px;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-button,
#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-button:start:decrement,
#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-button:end:increment {
  display: none;
  width: 0;
  height: 0;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-track {
  margin: 0 10px;
  background: #0f1014;
  border-radius: 6px;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: #35373e;
  border: 1px solid #0a0a0c;
  background-clip: padding-box;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-thumb:hover {
  background: #42444d;
}

#idx-ad-popup .idx-ad-popup__strip-wrap::-webkit-scrollbar-thumb:active {
  background: #2c2e34;
}

#idx-ad-popup .idx-ad-popup__strip {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 15px;
  padding: 6px 4px 14px;
  box-sizing: border-box;
  min-height: 0;
}

#idx-ad-popup.idx-ad-popup--single .idx-ad-popup__strip {
  justify-content: center;
}

/* popup_desk .popup-2 / .popup-3 */
#idx-ad-popup .idx-ad-popup__card {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(360px, calc(100vw - 80px));
  padding: 15px 20px;
  box-sizing: border-box;
  background-color: #212328;
  border: 1px solid #1e2939;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0px 6px 20px #000000cc;
  scroll-snap-align: start;
}

#idx-ad-popup.idx-ad-popup--single .idx-ad-popup__card {
  width: min(360px, calc(100vw - 48px));
}

/* popup_desk .element — 배너 영역 320×530, radius 10 */
#idx-ad-popup .idx-ad-popup__card-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 10px;
  background-color: #222222;
  width: 320px;
  max-width: 100%;
  height: 530px;
  max-height: min(530px, calc(100dvh - 220px));
  box-sizing: border-box;
}

#idx-ad-popup .idx-ad-popup__card-viewport img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  vertical-align: middle;
}

/* popup_desk .frame-8 — 카드별 스누즈(btn-join) + 닫기(btn-join-3) */
#idx-ad-popup .idx-ad-popup__card-footer {
  display: flex;
  align-items: center;
  gap: 15px;
  align-self: stretch;
  width: 100%;
  flex: 0 0 auto;
}

#idx-ad-popup .idx-ad-popup__card-snooze {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 10px 0;
  border-radius: 24px;
  box-sizing: border-box;
  cursor: pointer;
  font-family: "Inter", Helvetica, sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 20px;
  color: #6a7282;
  user-select: none;
}

#idx-ad-popup .idx-ad-popup__card-snooze-input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  border-radius: 4px;
  border: 1px solid #424242;
  accent-color: #e701e2;
  cursor: pointer;
}

#idx-ad-popup .idx-ad-popup__card-dismiss {
  flex-shrink: 0;
  width: 80px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background-color: #303338;
  font-family: "Inter", Helvetica, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: #d1d5dc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__card-dismiss:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

@media (min-width: 1024px) {
  /* popup_desk 고정 크기 유지(카드 360 / 배너 320×530) — 넘치면 가로 스크롤만 */
  /*
   * strip-wrap 에 flex + justify-content:center 를 쓰면 overflow-x:auto 일 때
   * 스크롤로도 양끝(특히 왼쪽) 카드가 잘린 것처럼 보인다. 스크롤 영역은 block + flex-start.
   */
  #idx-ad-popup .idx-ad-popup__strip-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scroll-snap-type: none;
  }

  /* 카드 한 장일 때만 가운데 — 넘침 없어 center 안전 */
  #idx-ad-popup.idx-ad-popup--single .idx-ad-popup__strip-wrap {
    display: flex;
    justify-content: center;
    overflow-x: hidden;
  }

  #idx-ad-popup .idx-ad-popup__strip {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: stretch;
    flex-shrink: 0;
    width: max-content;
    max-width: none;
    box-sizing: border-box;
  }

  #idx-ad-popup.idx-ad-popup--single .idx-ad-popup__strip {
    justify-content: center;
  }

  #idx-ad-popup .idx-ad-popup__card {
    flex: 0 0 auto;
    width: 360px;
    max-width: none;
    min-width: 360px;
    scroll-snap-align: none;
  }

  #idx-ad-popup.idx-ad-popup--single .idx-ad-popup__card {
    width: 360px;
    min-width: 360px;
  }

  #idx-ad-popup .idx-ad-popup__card-viewport {
    width: 320px;
    max-width: none;
    min-height: 0;
    height: min(530px, calc(100vh - 220px));
    height: min(530px, calc(100dvh - 220px));
    aspect-ratio: auto;
    box-sizing: border-box;
  }
}

/* ----- 하단 ----- */

#idx-ad-popup .idx-ad-popup__footer {
  display: flex;
  align-items: center;
  gap: 15px;
  align-self: stretch;
  width: 100%;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

#idx-ad-popup .idx-ad-popup__snooze {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: "Inter", Helvetica, sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 20px;
  color: #6a7282;
  user-select: none;
}

#idx-ad-popup .idx-ad-popup__snooze input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #e701e2;
  cursor: pointer;
}

#idx-ad-popup .idx-ad-popup__footer-dismiss--desktop {
  display: none;
}

#idx-ad-popup .idx-ad-popup__close {
  flex-shrink: 0;
  width: 80px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background-color: #303338;
  font-family: "Inter", Helvetica, sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 20px;
  color: #d1d5dc;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__close:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

#idx-ad-popup .idx-ad-popup__close-all {
  flex-shrink: 0;
  height: 45px;
  margin: 0;
  padding: 0 24px;
  border: none;
  border-radius: 10px;
  background-color: #00bc7d;
  box-shadow: 0px 0px 15px #10b9814c;
  font-family: "Inter", Helvetica, sans-serif;
  font-weight: 900;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: -0.07px;
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
  align-items: center;
  justify-content: center;
  display: none;
  -webkit-tap-highlight-color: transparent;
}

#idx-ad-popup .idx-ad-popup__close-all:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

@media (min-width: 1024px) {
  /* 스트립 아래: 팝업 전체 닫기(btn-join-4)만 — 스누즈는 각 카드 안 */
  #idx-ad-popup .idx-ad-popup__footer-snooze--mobile {
    display: none;
  }

  #idx-ad-popup .idx-ad-popup__footer {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
  }

  #idx-ad-popup .idx-ad-popup__footer-dismiss--mobile {
    display: none;
  }

  #idx-ad-popup .idx-ad-popup__footer-dismiss--desktop {
    display: inline-flex;
  }

  #idx-ad-popup .idx-ad-popup__close-all {
    display: inline-flex;
  }
}

@media (max-width: 480px) {
  #idx-ad-popup .idx-ad-popup__footer {
    flex-direction: column;
    align-items: stretch;
  }

  #idx-ad-popup .idx-ad-popup__close {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  #idx-ad-popup .idx-ad-popup__slide {
    transition-duration: 0.01ms;
    transition-property: none;
  }
}
