/*
 * SP の画面上部の吹き出し枠（.gmap-sp-top-bubble）
 *
 * ルート表示モードの距離/所要時間（3.14.0 追加仕様 15-1）とツアーのコントローラ（14-5）を、
 * ヘッダ右上のおばけくんが話しているように見せる。地図の左下・右下のボタン類と重ならないよう
 * 上に置く。PC は現行の意匠・配置のまま（この枠は SP だけで使う）。
 *
 * 尾の位置はヘッダのおばけくんの中心に合わせる。おばけくん（.avatar-obake・幅 48px）は
 * 右上の枠（.navbar-right-side-area・幅 64px・右端密着）の左寄せなので、中心は画面の右端から 40px。
 */

.gmap-sp-top-bubble {
  display: none;
}

@media (max-width: 991px) {
  .gmap-sp-top-bubble {
    --gmap-top-bubble-gutter: 14px;
    /* おばけくんの中心（右端から 64px - 48px / 2 = 40px）から、枠の右端までの距離と尾の半幅を引いた位置 */
    /* おばけくんの中心から尾の幅の半分（9px）だけ左（実機確認でユーザー指定。map-tour.css と同値） */
    --gmap-top-bubble-tail-right: calc(40px - var(--gmap-top-bubble-gutter) - 9px + 9px);
    position: fixed;
    top: 62px;
    left: var(--gmap-top-bubble-gutter);
    right: var(--gmap-top-bubble-gutter);
    /* 地図上のボタン類（〜10000）より前、ピン詳細カード（20000）・通知より後ろ */
    z-index: 10050;
    /* 親（SP のトピックス一覧）は地図を操作させるため pointer-events: none の場面がある。
       継承したままだと、見えている × ボタンを押しても下の地図へ抜けてしまう */
    pointer-events: auto;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
  }

  .gmap-sp-top-bubble::before {
    content: "";
    position: absolute;
    top: -9px;
    right: var(--gmap-top-bubble-tail-right);
    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));
  }

  body.gmap-route-mode-active .gmap-sp-top-bubble:has(.gmap-route-info),
  .gmap-sp-top-bubble.is-active {
    display: flex;
  }

  /* 枠そのものが白い吹き出しなので、ウィジェット自身の白ピル装飾は打ち消す */
  .gmap-sp-top-bubble .gmap-route-info {
    display: flex;
    flex: 1 1 auto;
    justify-content: space-between;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
  }

  .gmap-sp-top-bubble .gmap-route-exit {
    margin-left: auto;
  }

  /* マップ拡大表示ではヘッダが隠れるので、ヘッダの位置（左右と同じ余白）へ上げる。
     おばけくんも隠れるので尾は外す（ツアーの帯も同じ。map-tour.css） */
  body.is-view-expand .gmap-sp-top-bubble {
    top: var(--gmap-top-bubble-gutter);
  }

  body.is-view-expand .gmap-sp-top-bubble::before {
    display: none;
  }
}

/* 右上のおばけくんを出さない設定（見積20）では、話しかける相手がいないので尾を外す */
body.is-obake-hidden .gmap-sp-top-bubble::before,
body.is-obake-hidden .map-tour-controller.is-sp::before {
  display: none;
}
