/* WEB_POPUP: 右下常駐型（オーバーレイなし。裏のページ操作を妨げない） */

.p-web-popup {
  /* JSがwindow.popupSettingsの値で上書きする。未設定時は従来と同じ16px */
  --popup-offset-x: 16px;
  --popup-offset-y: 16px;
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
}

/* 表示位置（JSが -pos-right / -pos-left / -pos-center のいずれかを付与する） */
.p-web-popup.-pos-right {
  justify-content: flex-end;
}

.p-web-popup.-pos-left {
  justify-content: flex-start;
}

.p-web-popup.-pos-center {
  justify-content: center;
}

.p-web-popup.-closing {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.p-web-popup.-open {
  visibility: visible;
  opacity: 1;
}

.p-web-popup__wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 360px;
  max-height: calc(100vh - var(--popup-offset-y) - 16px);
  max-height: calc(100dvh - var(--popup-offset-y) - 16px);
  pointer-events: auto;
}

/* 画面端からの距離。中央下だけは中央からのずれなのでtransformで動かす */
.p-web-popup__wrap,
.p-web-popup__icon-wrap {
  margin-bottom: var(--popup-offset-y);
  margin-top: 16px;
}

.p-web-popup.-pos-right .p-web-popup__wrap,
.p-web-popup.-pos-right .p-web-popup__icon-wrap {
  margin-right: var(--popup-offset-x);
}

.p-web-popup.-pos-left .p-web-popup__wrap,
.p-web-popup.-pos-left .p-web-popup__icon-wrap {
  margin-left: var(--popup-offset-x);
}

.p-web-popup.-pos-center .p-web-popup__wrap,
.p-web-popup.-pos-center .p-web-popup__icon-wrap {
  transform: translateX(var(--popup-offset-x));
}

.p-web-popup__inner {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  padding: 0 0 20px;
  position: relative;
  cursor: pointer;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.p-web-popup__inner .p-web-popup__text {
  padding: 16px 20px 0;
}

.p-web-popup__inner:not(.-has-image) .p-web-popup__text {
  padding-top: 24px;
}

.p-web-popup__close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  color: #555;
  z-index: 2;
}

.p-web-popup__close .c-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.p-web-popup__title {
  font-size: 16px;
  font-weight: 700;
  color: #222;
  margin: 0 0 10px;
  line-height: 1.4;
}

.p-web-popup__body {
  font-size: 13px;
  color: #555;
  margin: 0 0 16px;
  line-height: 1.6;
}

.p-web-popup__property {
  margin-bottom: 12px;
}

.p-web-popup__property-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f8f8f8;
  border-radius: 8px 8px 0 0;
}

.p-web-popup__property-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.p-web-popup__property-name {
  font-size: 13px;
  font-weight: 700;
  color: #333;
  margin: 0 0 8px;
}

.p-web-popup__action {
  text-align: center;
}

.p-web-popup__btn {
  display: block;
  width: 100%;
  background: #e05a2b;
  color: #fff;
  text-align: center;
  padding: 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s;
}

.p-web-popup__btn:hover {
  background: #c44d22;
  color: #fff;
}

/* ---- アイコン型 ---- */

.p-web-popup__icon-wrap {
  position: relative;
  width: 100px;
  pointer-events: auto;
  background: transparent;
}

/* アイコン型表示中はカード型コンテナを非表示 */
.p-web-popup:has(.p-web-popup__icon-wrap:not([hidden])) .p-web-popup__wrap {
  display: none;
}

.p-web-popup__icon-close {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-radius: 50%;
  padding: 3px;
  line-height: 1;
  color: #fff;
  cursor: pointer;
}

.p-web-popup__icon-close .c-icon {
  width: 14px;
  height: 14px;
  display: block;
}

.p-web-popup__icon-link {
  display: block;
  cursor: pointer;
}

.p-web-popup__icon-img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 640px) {
  .p-web-popup {
    align-items: flex-end;
  }

  /* カード型（icon-wrapがhidden＝表示されていない）は全幅のボトムシートなので
     横位置とXオフセットを無効化して中央に固定する。
     アイコン型表示中はこのセレクタが不成立になり、位置クラスのjustify-contentがそのまま効く */
  .p-web-popup:not(:has(.p-web-popup__icon-wrap:not([hidden]))) {
    justify-content: center;
  }

  .p-web-popup__wrap {
    max-width: 100%;
    max-height: calc(100vh - var(--popup-offset-y) - 16px);
    max-height: calc(100dvh - var(--popup-offset-y) - 16px);
    border-radius: 12px 12px 0 0;
  }

  /* margin-left/rightとtransformは.-pos-*側と同じ詳細度（3クラス）で書き、
     source order（このブロックの方が後）で確実に上書きする */
  .p-web-popup.-pos-right .p-web-popup__wrap,
  .p-web-popup.-pos-left .p-web-popup__wrap,
  .p-web-popup.-pos-center .p-web-popup__wrap {
    margin-left: 0;
    margin-right: 0;
    transform: none;
  }

  .p-web-popup__inner {
    border-radius: 12px 12px 0 0;
  }

  .p-web-popup__property-img {
    aspect-ratio: 16 / 7;
    border-radius: 12px 12px 0 0;
  }
}
