/*
 * 地図左列の切り替えボタン（map-side-control.js）と、それを使う昼／夜モードの意匠。
 *
 * ボタンの見た目は立体視点の 2D/3D ボタン（map-tilt.css の .map-tilt-control）に揃える。
 * 2D/3D 側を変えたらここも揃えること。map-tilt.css の後に読む（styles_last）。
 */

/* ---------- 共通：ボタン ---------- */

.map-side-control {
  margin: 0 0 8px calc(16px * var(--common-zoom-ratio, 1)) !important;
}

.map-side-control a {
  display: block;
  text-align: center;
  text-decoration: none;
  color: #333;
}

/* アイコンは行の高さ（line-height）ではなく flex で上下左右の中央に置く。
   行の高さ任せだと、フォントの上下の余白しだいでアイコンが枠の上寄りに見え、
   テーマ同梱の Leaflet の .leaflet-bar a:hover { display: block } などの状態別の指定とも
   食い違う。2D/3D ボタン（map-tilt.css の .map-tilt-control a）と同じ対処。 */
.map-side-control a,
.map-side-control a:hover,
.map-side-control a:focus,
.map-side-control a:active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-side-control a i {
  display: block;
  line-height: 1;
}

.map-side-control.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

body.is-view-expand .tooltip.tooltip-map-side-control {
  position: fixed !important;
  z-index: 10001;
}

/* PC：縦に積んだときの間隔は、切り替えボタンどうしの 8px に +/- の上もそろえる（3.14.0 実機確認の指摘）。
   +/- は既定で上下左右に 16px × 比率の margin を持つ（jquery.mapping.css） */
@media (min-width: 992px) {
  .leaflet-container:not(.is-side-controls-row):not(.gmap-picker-map)
    .leaflet-bottom.leaflet-left
    > .map-tilt-control
    + .leaflet-control-zoom {
    margin-top: 8px !important;
  }
}

/* PC で地図の高さが低いとき：左列（+/-・3D/2D・追加ボタン）を横一列に並べ替える。
   DOM は上から [追加ボタン…, 3D/2D, +/-] なので、row-reverse で +/- を左端にする。 */
@media (min-width: 992px) {
  .leaflet-container.is-side-controls-row .leaflet-bottom.leaflet-left {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: flex-end;
  }

  /* 底辺は +/- に揃える（gmaps.css で Google の帰属表示を避けて 44px 持ち上げてある） */
  .leaflet-container.is-side-controls-row .leaflet-bottom.leaflet-left > .map-tilt-control,
  .leaflet-container.is-side-controls-row .leaflet-bottom.leaflet-left > .map-side-control {
    margin: 0 0 calc(44px * var(--common-zoom-ratio, 1)) 8px !important;
  }
}

/* ---------- SP：操作行の左端の列で、3D/2D の上に縦積み ---------- */

@media (max-width: 991px) {
  .leaflet-control-container .map-side-control {
    display: none !important;
  }

  .tooltip.tooltip-map-side-control {
    display: none !important;
  }

  /* 列（map-tilt.css の .sp-leaflet-control-zoom-wrapper）は column-reverse なので、
     末尾のこの束は 3D/2D の上に来る。束の中も column-reverse（order が大きいほど上） */
  .sp-leaflet-control-zoom-wrapper .map-side-control-sp-stack {
    display: flex;
    flex-direction: column-reverse;
    gap: 16px;
    pointer-events: auto;
  }

  .sp-leaflet-control-zoom-wrapper .map-side-control {
    display: block !important;
    margin: 0 !important;
  }

  .sp-leaflet-control-zoom-wrapper .map-side-control a {
    width: 30px;
    height: 30px;
    line-height: 30px;
  }

  /* 拡大表示中は操作行ごと消えるので、地図内（左下）のボタンを PC と同じ縦積みで出す
     （+/- と 3D/2D は map-tilt.css で同様に復活させている） */
  body.is-view-expand .leaflet-control-container .map-side-control {
    display: block !important;
    /* 間隔は +/- の上（16px）と同じ */
    margin: 0 0 calc(16px * var(--common-zoom-ratio, 1)) calc(16px * var(--common-zoom-ratio, 1)) !important;
  }

  body.is-view-expand .leaflet-control-container .map-side-control a {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  /* 地図内はタッチ端末で Leaflet の .leaflet-touch の枠線の意匠になるので、
     操作行・3D/2D（map-tilt.css の同じ対処）と同じ影の意匠へ戻す */
  body.is-view-expand .leaflet-touch .map-side-control {
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
    border: none;
    background-clip: border-box;
    border-radius: 4px;
  }

  body.is-view-expand .leaflet-touch .map-side-control a {
    border-radius: 4px;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  /* 一覧を開いている間は、上の地図の帯が狭く、縦に積むと左上のメニューに重なるので、
     +/- の右隣に横一列で並べる（実機確認後のユーザー決定。以前は +/- 以外を隠していた）。
     検索で 1 件も無いときの表示は、開いた扱いのまま一覧が下まで縮むので縦積みのまま */
  .topic-list-content:not(.not-have-all-search-target) .topic-list-content-header.active .sp-leaflet-control-zoom-wrapper {
    flex-direction: row;
    align-items: flex-end !important;
  }

  .topic-list-content:not(.not-have-all-search-target)
    .topic-list-content-header.active
    .sp-leaflet-control-zoom-wrapper
    .map-side-control-sp-stack {
    flex-direction: row;
  }

  /* GoogleMaps モードは +/- を Google のロゴの上へ 22px 逃がしている（gmaps.css）ので、横に並べたボタンも揃える */
  body:has(.leaflet-container.gmap-mode)
    .topic-list-content:not(.not-have-all-search-target)
    .topic-list-content-header.active
    .sp-leaflet-control-zoom-wrapper
    :is(.map-tilt-control, .map-side-control-sp-stack) {
    margin-bottom: 22px !important;
  }

  /* 上へ積んだボタンが .topic-list-content（overflow:hidden）の上端で切れないよう、
     切り取りの境界（padding-box の上端）を持ち上げ、同じ量だけ top を引き上げて
     白いカードの見た目の位置は変えない。gmaps.css の 24px の持ち上げと同じ手法で、
     値はそちらに足し込む（GoogleMaps モードでは +/- 自体が 22px 上がっているため）。
     3D/2D と切り替えボタン 2 つ＝30px × 3 ＋ 間隔 16px × 3（+/- と 3D/2D・3D/2D と束・束の中）。
     ボタンを増やしたら値も増やすこと。 */
  :root {
    --sp-map-controls-overflow: calc(30px * 3 + 16px * 3);
  }

  main.project-main.main-fill.main-fill-sp .main-fill-top-contents.topic-list-content {
    box-sizing: content-box;
    padding-top: var(--sp-map-controls-overflow) !important;
    top: calc(var(--topic-list-content-top) - var(--sp-map-controls-overflow)) !important;
  }
}

/* ---------- 昼／夜モード（gmaps-day-night.js） ---------- */

/* 地図タイルが描かれるまでの下地も暗くしておく（白く光らないように） */
.leaflet-container.gmap-mode.is-gmap-night {
  background: #141a22;
}

/* Google の帰属表示は消さずに、暗い地図でも読めるようにする */
.leaflet-container.is-gmap-night .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.8);
}

/* 夜：ピン・吹き出しが暗い地図に沈まないよう、白い縁と濃い影を付ける（v3 モックの夜の値。見積18） */
.leaflet-container.is-gmap-night .leaflet-marker-pane .map_pin .pin-icon-svg-wrapper {
  filter: drop-shadow(0 0 1.5px rgba(252, 253, 250, 0.9)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

/* 吹き出しの白い縁は、四角と尻尾（.pin-balloon-arrow::before の三角形）をひとつの形としてなぞる。
   box-shadow は四角い枠にしか付かず、尻尾だけ縁が無かった（実機確認の指摘）。
   drop-shadow は見えている形に沿うので、上下左右へ 1.5px ずらした白い影を重ねて縁にし、最後に濃い影を落とす */
.leaflet-container.is-gmap-night .leaflet-marker-pane .pin-balloon:not(.pin-balloon-detail):not(.pin-balloon-tour) {
  --night-balloon-outline: rgba(252, 253, 250, 0.85);
  box-shadow: none;
  filter: drop-shadow(1.5px 0 0 var(--night-balloon-outline)) drop-shadow(-1.5px 0 0 var(--night-balloon-outline))
    drop-shadow(0 1.5px 0 var(--night-balloon-outline)) drop-shadow(0 -1.5px 0 var(--night-balloon-outline))
    drop-shadow(0 3px 6px rgba(0, 0, 0, 0.5));
}

