/*
 * ツアー機能（map-tour.js）
 * カードの「ツアー」ボタン、スポット名の吹き出し、コントローラ。
 */

/* ---------- 14-3 カード見出しのボタン ---------- */

.map-tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 30px;
  margin: 0 6px;
  padding: 0 12px 0 4px;
  border: none;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.map-tour-btn i {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-size: 10px;
}

/* 表示領域が狭いときは再生アイコンの丸ボタンだけにする */
@container (max-width: 260px) {
  .map-tour-btn {
    width: 30px;
    padding: 0;
    justify-content: center;
  }
  .map-tour-btn-label {
    display: none;
  }
}

.map-topic-box-info .inner-fixed-contents {
  container-type: inline-size;
}

/* ---------- 14-4 スポットの吹き出し（v3 モック isometric-map.html の .stop-card の実装値） ----------
   画像（添付のサムネイル。4:3 に切り抜き）とタイトルを白いカードに載せる。
   画像が無ければタイトルだけ、タイトルが無ければ画像だけ（どちらも同じ白いカード）。
   SP は幅 132px・タイトル中央寄せ、PC は幅 232px・タイトル左寄せ（モックの tbar-bottom＝PC の値） */

.leaflet-marker-icon .pin-balloon.pin-balloon-tour {
  --tour-card-width: 132px;
  --tour-card-padding: 5px 5px 7px;
  --tour-card-radius: 10px;
  --tour-thumb-radius: 6px;
  --tour-title-size: 11.5px;
  --tour-title-gap: 6px;
  /* ふわっと出し入れする（v3 モックの .here-chip[data-stop]：opacity と 6px の浮き上がりを 0.4s） */
  display: block;
  visibility: hidden;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s linear 0.4s;
  pointer-events: none;
  top: auto;
  bottom: calc(100% + 8px);
  left: 50%;
  /* 通常の吹き出し（.leaflet-marker-icon .pin-balloon:not(.card)）の margin-left: 50% を打ち消す。
     left と二重に効いて、ピンの幅の半分だけ右へずれていた */
  margin-left: 0;
  width: max-content;
  max-width: var(--tour-card-width);
  padding: 6px 10px;
  border-radius: var(--tour-card-radius);
  background-color: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
  color: #1a1a1a;
  line-height: 1.35;
  white-space: normal;
}

.leaflet-marker-icon .pin-balloon.pin-balloon-tour.has-image {
  width: var(--tour-card-width);
  padding: var(--tour-card-padding);
}

.leaflet-marker-icon .pin-balloon.pin-balloon-tour .pin-balloon-arrow::before {
  border-top-color: #fff;
}

/* 地図のピン（.aspect-ratio）の中に置くので、custom.css の .aspect-ratio img（全面に広げる）を
   is-not-aspect-ratio-target で外したうえで大きさを決める */
.pin-balloon-tour .pin-balloon-tour-image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--tour-thumb-radius);
}

.pin-balloon-tour .pin-balloon-tour-title {
  display: -webkit-box;
  overflow: hidden;
  padding: 0 3px;
  font-size: var(--tour-title-size);
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pin-balloon-tour .pin-balloon-tour-image + .pin-balloon-tour-title {
  margin-top: var(--tour-title-gap);
}

@media (min-width: 992px) {
  .leaflet-marker-icon .pin-balloon.pin-balloon-tour {
    --tour-card-width: 232px;
    --tour-card-padding: 9px 9px 13px;
    --tour-card-radius: 14px;
    --tour-thumb-radius: 9px;
    --tour-title-size: 15px;
    --tour-title-gap: 11px;
    padding: 9px 13px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  }

  .pin-balloon-tour .pin-balloon-tour-title {
    text-align: left;
  }
}

/* 吹き出しを出しているスポットは、ほかのピンや現在地の印（zIndexOffset 2000。gmaps-view-features.js）より前に出す。
   Leaflet がマーカーごとに付ける z-index（緯度で決まる）を上書きする（実機確認の指摘） */
.leaflet-marker-icon.map_pin.is-tour-stop {
  z-index: 100000 !important;
}

.leaflet-marker-icon.map_pin.is-tour-stop .pin-balloon.pin-balloon-tour {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s;
}

@media (prefers-reduced-motion: reduce) {
  .leaflet-marker-icon .pin-balloon.pin-balloon-tour {
    transition: none;
  }
}

/* 再生中は通常の Here・View 吹き出しを重ねない */
body.is-map-tour-playing .leaflet-marker-icon.map_pin.is-tour-stop .pin-balloon.pin-balloon-here {
  display: none;
}

/* ---------- 14-5 コントローラ ---------- */

/* PC：地図の下部中央に、文字数によらず同じ大きさで出す（見積16-5。v3 モックの実装値 540×60px）。
   左下・右下のボタン列（約 64px）と重ならないよう、狭い地図では幅を詰める */
.map-tour-controller {
  position: absolute;
  bottom: 14px;
  left: 50%;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(540px, calc(100% - 160px));
  height: 60px;
  transform: translateX(-50%);
  padding: 6px 12px 6px 10px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  color: #212529;
  white-space: nowrap;
}

.map-tour-controller button {
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: none;
  background: transparent;
  color: #1a1a1a;
}

.map-tour-controller .map-tour-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
}

.map-tour-controller .map-tour-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.map-tour-controller .map-tour-title {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-tour-controller .map-tour-step {
  font-size: 11.5px;
  color: #3a3a3a;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-tour-controller .map-tour-nav {
  display: flex;
  gap: 6px;
}

.map-tour-controller .map-tour-nav button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
  font-size: 12px;
}

.map-tour-controller .map-tour-nav button:disabled {
  opacity: 0.35;
}

.map-tour-controller .map-tour-close {
  width: 26px;
  height: 26px;
  font-size: 16px;
}

/* SP：画面上部。ヘッダのおばけくんが話しているような吹き出し（gmaps-top-bubble.css と同じ寸法） */
.map-tour-controller.is-sp {
  position: fixed;
  top: 62px;
  bottom: auto;
  left: 14px;
  right: 14px;
  z-index: 10050;
  width: auto;
  height: auto;
  max-width: none;
  transform: none;
  border-radius: 999px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
}

.map-tour-controller.is-sp .map-tour-text {
  flex: 1;
}

.map-tour-controller.is-sp::before {
  content: "";
  position: absolute;
  top: -9px;
  /* おばけくんの中心（右端から 40px）から、尾の幅の半分（9px）だけ左に置く（実機確認でユーザー指定）。
     gmaps-top-bubble.css の --gmap-top-bubble-tail-right と同値 */
  right: calc(40px - 14px - 9px + 9px);
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 10px solid #fff;
  filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.08));
}

/* SP のマップ拡大表示：ヘッダが隠れるので、ヘッダの位置（左右と同じ余白）へ上げ、
   おばけくんも隠れるので尾を外す（ルートの吹き出しも同じ。gmaps-top-bubble.css） */
body.is-view-expand .map-tour-controller.is-sp {
  top: 14px;
}

body.is-view-expand .map-tour-controller.is-sp::before {
  display: none;
}

