@charset "UTF-8";

/*
 * 立体視点モード（地図の傾け表示）
 *
 * 対になる JS は public/js/map-tilt.js（本体）と public/js/map-tilt-gesture.js（操作）。
 * このファイルは「地図面を傾けるための変換」「3D 文脈の外へ出したピンの置き場」
 * 「3D/2D トグルボタンの意匠」の3つを受け持つ。
 *
 * ★読み込み順★
 * blade では jquery.mapping.css / gmaps.css より「後」に読み込むこと。
 * ここには Leaflet 既定と jquery.mapping.css の両方を打ち消すルールが含まれており、
 * 先に読み込むと同詳細度の勝負で負ける。
 *
 * ★アニメーション時間は map-tilt.js の ANIM_MS と同値にすること★
 * JS 側は off() の後片付け（marker pane の復帰・maxBounds の復元）を
 * ANIM_MS + 40 のタイマーで行うため、ここの 450ms とずれると
 * 補間が終わる前に後片付けが走る／終わってから待たされる、のどちらかになる。
 */

/* --------------------------------------------------------------------------
 * 角度のカスタムプロパティ
 * -------------------------------------------------------------------------- */

/* --map-tilt-angle を <angle> として登録する。
   登録して初めて transition で補間できる（未対応ブラウザでは無視され瞬時切替に劣化）。 */
@property --map-tilt-angle {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

/* 方位角（面内の回転）。傾き角と同じく <angle> として登録することで
   トグル時の補間対象になり、ラッパの rotateZ が滑らかに補間される。 */
@property --map-tilt-bearing {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

/* --------------------------------------------------------------------------
 * 地図面の傾け
 * -------------------------------------------------------------------------- */

/* 視点。perspective は overflow:hidden があっても子に効く */
.leaflet-container.map-tilt-active {
  perspective: var(--map-tilt-perspective);
  /* 消失点（デザインFB No.9・10）。値は map-tilt.js の syncOrigin() が VANISH_X_RATIO /
     VANISH_Y_RATIO から px で入れる（既定値は JS が動く前の保険）。
     回転・傾けの軸（.map-tilt-pane の transform-origin）はコンテナ中心のまま */
  perspective-origin: var(--map-tilt-vanish-x, 50%) var(--map-tilt-vanish-y, 38%);
  transition: --map-tilt-angle 450ms ease, --map-tilt-bearing 450ms ease;
}

/* 「初期表示に戻す」で方位を 0° へ戻すときだけ、地図の移動と同じ 0.5 秒・同じ緩急で回す
   （デザインFB 2026-10-29 操作性3・6）。緩急は map-reset-view.js の easeInOut と同じ曲線。
   ★map-tilt.js の RECENTER_MS と同値にすること★ */
.leaflet-container.map-tilt-active.map-tilt-recentering {
  transition: --map-tilt-angle 450ms ease,
    --map-tilt-bearing 500ms cubic-bezier(0.37, 0, 0.63, 1);
}

/* 「初期表示に戻す」は傾きも方位・移動と同じ 0.5 秒の ease-in-out で戻す */
.leaflet-container.map-tilt-active.map-tilt-recentering.map-tilt-resetting {
  transition: --map-tilt-angle 500ms cubic-bezier(0.37, 0, 0.63, 1),
    --map-tilt-bearing 500ms cubic-bezier(0.37, 0, 0.63, 1);
}

/* ★ドラッグ／ピンチ操作中は補間を切る★
   ON/OFF のトグルだけをアニメーションさせたい。操作中も補間したままだと
   指の動きに対して角度が 450ms 遅れて追いかける「ゴムのような」感触になり、
   さらに毎フレーム getComputedStyle が読む実効角が目標角とずれ続けるため、
   逆射影（ズームアンカー・パン補正）まで操作中ずっと過去の角度で計算される。 */
.leaflet-container.map-tilt-active.map-tilt-dragging {
  transition: none;
}

/* ★ 0×0 必須（getSizedParentNode に拾われないため） */
.map-tilt-pane {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

/* ★順序が意味を持つ★ 単一 transform 内は「右の関数ほど先に点へ効く」ので
   rotateX(θ) rotateZ(φ) ＝「面の上で φ 回してから θ 倒す」。
   逆順にすると倒した後の画面法線まわりに回ってしまい、地図が画面内で
   ぐるぐる回るだけの見え方になる。JS 側の射影も R(φ) → 傾き射影 の順で合わせてある。 */
.leaflet-container.map-tilt-active .map-tilt-pane {
  transform: rotateX(var(--map-tilt-angle)) rotateZ(var(--map-tilt-bearing));
}

/* --------------------------------------------------------------------------
 * ピンの置き場（3D 文脈の外）
 * -------------------------------------------------------------------------- */

/* 3D 文脈の「外」なので transform も preserve-3d も持たない。
   marker pane の元の z-index(600) を引き継いで地図面より前面に出す。 */
.map-tilt-markers {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 600;
}

/* 画面から大きく外れたピン（map-tilt.js の OFFSCREEN_CLASS）。描かない */
.map-tilt-markers .leaflet-marker-pane > .map-tilt-offscreen {
  visibility: hidden !important;
}

/* ★marker pane を .leaflet-map-pane の外へ出すと、
   jquery.mapping.css の「.map-contents .leaflet-map-pane ...」にスコープされた
   非表示ルールが効かなくなる。
   DB のステータス由来(is-hide)と表示/非表示チェックボックス由来
   (is-hide-by-layer-control)の2つを同じ内容で張り直す。
   これが無いと、非表示のはずのピンが傾け中だけ現れる／
   チェックボックスで消せなくなる。 */
.map-tilt-markers .map_pin.is-hide,
.map-tilt-markers .map_pin_edit.is-hide,
.map-tilt-markers .map_pin.is-hide-by-layer-control,
.map-tilt-markers .map_pin_edit.is-hide-by-layer-control {
  display: none !important;
}

/* marker pane の要素は自前射影で毎フレーム transform を書くので、
   Leaflet のズームアニメーション用 transition を無効化する。
   transform-origin はその要素の iconAnchor に合わせること。射影で掛ける
   スケール（透視の k と貼り付きの cosθ）が「地図上で指している点」を中心に
   掛かるようにするため、ここがずれると拡大時にピンの足元が動いてしまう。
     既定  … 50% 50%   （現在地ドット＝ iconAnchor が中心の要素）
     ピン  … 50% 100%  （iconAnchor が先端） */
.map-tilt-markers .leaflet-marker-pane > * {
  transform-origin: 50% 50%;
  transition: none !important;
}

.map-tilt-markers .leaflet-marker-pane > .map_pin,
.map-tilt-markers .leaflet-marker-pane > .map_pin_edit {
  transform-origin: 50% 100%;
}

/* ★ラベル（.pin-name / .pin-custom-text）は地図面と一緒に回す★
   一度「文字だけ逆回転させて常に正立させる」実装を入れたが撤去した（2026-09-01）。
   逆回転が直せるのは★文字の向きだけ★で、★ラベルの位置★は
   「地図面の座標系でピンの上」に貼り付いたまま＝回転するとラベルはピンの周りを
   公転し、φ=180° 付近ではピンの下に来る。文字だけ正立していると
   かえってちぐはぐに見えるため、向きが変わることを許容する方針になった。
   ＝ここでは何もしない（面の変換をそのまま受けさせる）。 */

/* --------------------------------------------------------------------------
 * 3D/2D トグルボタン（PC）
 * -------------------------------------------------------------------------- */

/* +/- ズーム（.leaflet-control-zoom）と左端を揃える。
   Leaflet 既定の .leaflet-left .leaflet-control{margin-left:10px} のままだと
   16px * ratio を持つ +/- に対して左へずれる。 */
.map-tilt-control {
  margin: 0 0 0 calc(16px * var(--common-zoom-ratio)) !important;
}

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

/* アイコンは «いまの状態»（平面＝正方形の枠／傾け＝台形の枠）。
   大きさ・形・アイコンの絵柄は地図ボタン共通の css/map-buttons.css が決める（デザインFB 2026-10-24）。 */
.map-tilt-control a,
.map-tilt-control a:hover,
.map-tilt-control a:focus {
  /* テーマ同梱の Leaflet の .leaflet-bar a:hover { display: block } の方が詳細度が高く、
     マウスを重ねたとき・押したあとだけ中央寄せが外れてアイコンが左上へずれていた */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 編集中は傾け不可（閲覧目的のモードなので） */
.map-tilt-control.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* 拡大表示中は地図が position:fixed のオーバーレイになる。ツールチップは
   data-bs-container="body" で body 直下へ出るので absolute のままだと
   スクロール量ぶんずれる。既存の
   `.is-view-expand .tooltip.tooltip-view-expand-or-compress`（jquery.mapping.css）
   と同じ対処を当てる。z-index は現在地ボタン等のスタック(10000)より前へ。 */
body.is-view-expand .tooltip.tooltip-map-tilt {
  position: fixed !important;
  z-index: 10001;
}

/* --------------------------------------------------------------------------
 * SP（max-width は Obake.config.project.sp_max_window_width と同値）
 *
 * +/- と同じくヘッダ行のラッパへクローンして出す。
 * 元の control は .leaflet-control-zoom と同じ扱いで隠す。
 * -------------------------------------------------------------------------- */

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

  /* ★SP ではツールチップを一切出さない（タップで出て残る不具合の再発防止）。
     クローン側は属性ごと剥がしてあるので本来ここへは到達しないが、
     PC 幅 → SP 幅へのリサイズ中に PC 側のものが残るケースまで潰す。
     jquery.mapping.css の .tooltip-pc-only と同値だが、その CSS を
     読まない画面でも効くようこちらにも持たせる。 */
  .tooltip.tooltip-map-tilt {
    display: none !important;
  }

  /* 操作行の左端の列に、+/- ズームを一番下にして 3D/2D・切り替えボタン（map-side-control.js）を
     縦に積む（PC の左下と同じ並び。3.14.0 実機確認の指摘）。

     列は column-reverse：DOM 順 [+/-, 3D/2D, 切り替えボタンの列] の先頭（+/-）が一番下に来る。
     ラッパの高さは操作行の固定値のまま変えず、上へ積んだ分は箱の外（上）へはみ出させる。
     操作行（＝ヘッダ）の高さを変えると、一覧の開閉位置の計算（jquery.view-mode.js）や
     Google の帰属表示を持ち上げる量（gmaps.css の --gmap-sp-card-header-h）がすべてずれるため。
     はみ出した分は .topic-list-content（overflow:hidden）に切られるので、
     その上端を --sp-map-controls-overflow だけ持ち上げてある（下の .topic-list-content のルール）。

     ヘッダ操作行は justify-content:space-between の3アイテム
     （[この列] / [開くボタン] / [閉じるボタン]）。この並びでは
     中央アイテムの中心 = 行の中心 + (左アイテム幅 - 右アイテム幅) / 2
     となり、中央ボタンの位置が左アイテムの幅に引きずられる。
     縦に積んだので左アイテムの幅はボタン1個分（30px）。
     負の右マージンで「場所取りの幅」だけを右アイテムと同じ 50px に見せ、
     中央ボタンを厳密な中央（＝行の中心）へ揃える。
     なお「初期表示に戻す」(map-reset-view.js) は SP ではこの列ではなく
     閉じるボタンのスロットへ重ねる方式なので、ここには数えない。 */
  .sp-leaflet-control-zoom-wrapper {
    width: auto !important;
    flex-direction: column-reverse;
    justify-content: flex-start !important;
    align-items: flex-start !important;
    /* ボタンの間隔は +/- の上も含めてすべて 16px（3.14.0 実機確認の指摘で統一） */
    gap: 16px;
    margin-right: calc(50px - 30px) !important;
  }

  .sp-leaflet-control-zoom-wrapper .map-tilt-control {
    pointer-events: auto;
    display: block !important;
    margin: 0 !important;
    opacity: 1;
  }

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

  .sp-leaflet-control-zoom-wrapper .map-tilt-control.is-disabled {
    opacity: 0.45;
  }

  /* ★SP の拡大表示中は、ヘッダ操作行（.topic-list-content-header-controller）ごと
     潰れるため、そこへクローンした +/- と 3D/2D がどこにも出なくなる。
     jquery.mapping.css が SP 幅で地図内の .leaflet-control-zoom を
     display:none にし、代わりに操作行のクローンを出す設計のため、行が消えると
     受け皿も無くなるのが理由（+/- が消えるのは立体視点の実装以前からの既存挙動）。
     拡大表示中だけ地図内の Leaflet コントロールを復活させ、PC と同じ左下へ出す。 */
  body.is-view-expand .leaflet-control-container .leaflet-control-zoom,
  body.is-view-expand .leaflet-control-container .map-tilt-control {
    display: block !important;
  }

  /* 配置は通常表示の操作行・PC と同じく「+/- の上に 3D/2D（その上に切り替えボタン）」の縦積み。
     左下コーナーは Leaflet 既定で縦積み、DOM 順も上から [切り替えボタン…, 3D/2D, +/-] なので
     並びはそのままでよい。左端は +/- に揃える。
     +/- の下マージンはテーマ＝既定 16px、gmaps＝Google ロゴ回避で 44px
     （gmaps.css の .leaflet-container.gmap-mode .leaflet-control-zoom と同値）。 */
  body.is-view-expand .leaflet-control-container .map-tilt-control {
    /* +/- の上マージン（16px）がそのまま間隔になる（浮動要素どうしなので相殺されない） */
    margin: 0 0 0 calc(16px * var(--common-zoom-ratio, 1)) !important;
  }

  body.is-view-expand
    .leaflet-control-container
    .leaflet-bottom.leaflet-left
    > .leaflet-control-zoom {
    margin-bottom: calc(16px * var(--common-zoom-ratio, 1)) !important;
  }

  body.is-view-expand:has(.leaflet-container.gmap-mode)
    .leaflet-control-container
    .leaflet-bottom.leaflet-left
    > .leaflet-control-zoom {
    margin-bottom: calc(44px * var(--common-zoom-ratio, 1)) !important;
  }

  /* ★意匠差の本体＝Leaflet の .leaflet-touch ルール（leaflet.css）。
     タッチ端末では .leaflet-container に .leaflet-touch が付き、
       .leaflet-touch .leaflet-bar { box-shadow: none; border: 2px solid rgba(0,0,0,.2); }
       .leaflet-touch .leaflet-bar a:first/last-child { border-radius: 2px; }
       .leaflet-touch .leaflet-control-zoom-in/out { font-size: 22px; }
     が効く。通常表示のクローンは .leaflet-container の「外」にあるため
     これらが一切当たらず、「影あり・枠なし・角丸4px・+/- 18px」のままになる。
     ＝拡大表示（地図内）だけ枠が出て影が消えていた。実機（iOS/Android）でのみ
     再現し、タッチ非対応のデスクトップ Chrome では差が出ない。
     拡大表示側を通常表示の見た目へ戻す。 */
  body.is-view-expand .leaflet-touch .leaflet-control-zoom,
  body.is-view-expand .leaflet-touch .map-tilt-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 .leaflet-control-zoom a:first-child,
  body.is-view-expand .leaflet-touch .map-tilt-control a:first-child {
    border-radius: 4px 4px 0 0;
  }

  body.is-view-expand .leaflet-touch .leaflet-control-zoom a:last-child,
  body.is-view-expand .leaflet-touch .map-tilt-control a:last-child {
    border-radius: 0 0 4px 4px;
  }

  /* 3D/2D は a が1つ＝first と last の両方に当たるので4隅を戻す */
  body.is-view-expand .leaflet-touch .map-tilt-control a:only-child {
    border-radius: 4px;
  }

  body.is-view-expand .leaflet-touch .leaflet-control-zoom-in,
  body.is-view-expand .leaflet-touch .leaflet-control-zoom-out {
    /* .leaflet-touch の 22px → 通常表示と同じ Leaflet 既定へ */
    font-size: 18px;
  }

  /* タップ時のハイライト。地図内は Leaflet 既定の青フラッシュが出るが、
     操作行のクローンは透明。押した瞬間の見え方も揃える。 */
  body.is-view-expand .leaflet-control-container .leaflet-control-zoom a,
  body.is-view-expand .leaflet-control-container .map-tilt-control a {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  }

  /* 意匠を通常表示の操作行と揃える。地図内の Leaflet コントロールは
     .leaflet-container が font-size:12px を敷くため、同じ 30px 径でも
     アイコンだけ 12px に縮む（操作行は地図の外なので body の 16px を継承）。
     径・行送り・アイコンサイズの3点を明示して一致させる。 */
  body.is-view-expand .leaflet-control-container .leaflet-control-zoom a,
  body.is-view-expand .leaflet-control-container .map-tilt-control a {
    width: 30px;
    height: 30px;
    /* 操作行の +/- と同値（Leaflet 既定のまま） */
    line-height: 26px;
  }

  body.is-view-expand .leaflet-control-container .map-tilt-control a {
    /* 操作行と同値。既定は .leaflet-container の 12px */
    font-size: 16px;
    /* jquery.mapping.css の
       `.leaflet-touch .leaflet-bar a{line-height:calc(26px*ratio)!important}` を打ち消す。
       26px だとアイコンが 30px 角の中で 2px 上に寄り、通常表示（30px＝中央）とズレる。
       +/- 側は 26px のままで通常表示と一致するのでそちらは触らない。 */
    line-height: 30px !important;
  }
}

/* --------------------------------------------------------------------------
 * 地平線の白いぼかし（GoogleMaps モードの 3D 中。map-tilt.js が要素を作り is-visible を付け外しする）
 * --------------------------------------------------------------------------
 * デザインFB No.4：画面上端から 80px の幅で固定し、傾きに関わらず広げない。
 * 深く倒したときに見える地図の奥の切れ目は隠さない（ユーザー判断 2026-10-24）。
 * 地平線より上の「空」はコンテナの背景（白）がそのまま見える。
 * -------------------------------------------------------------------------- */
.map-tilt-fog {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 80px;
  /* 地図面（tile/overlay pane）より前、ピン（600）より後ろ */
  z-index: 450;
  pointer-events: none;
  background: linear-gradient(
    #fff 0%,
    rgba(255, 255, 255, 0.85) 45%,
    rgba(255, 255, 255, 0) 100%
  );
  opacity: 0;
  transition: opacity 450ms ease;
}

.map-tilt-fog.is-visible {
  opacity: 1;
}
