/* スマートフォン向けの見た目（2026年8月26日、ユーザー判断）
 *
 * ⚠️⚠️ **このファイルの規則はすべて `body.mobile` の下に書くこと。**
 *   PC ではこのクラスが付かないので、どの規則も当たらない＝PC版は絶対に壊れない。
 *   判定は Source/modules/mobile.js の isPhone() 1箇所だけ。
 *
 * ⚠️ 要素はHTMLから消さず、ここで隠す。消すと getElementById が null を返し、
 *   ハンドラが無言で落ちる（初期化が黙って止まる型の事故）。
 */

/* ---- 隠すもの（PCのUIはスマホ幅に収まらない） ---- */
body.mobile #menu,                      /* 左メニュー（min-width 172px） */
body.mobile #quakeListPanel,            /* 右の地震一覧（277px） */
body.mobile #minimapContainer,          /* ミニマップ（2つ目のViewer。JS側でも起動を止めている） */
body.mobile #menuLegend,                /* 右下の凡例（3D都市モデル用） */
body.mobile #perfPanel,                 /* 描画設定のパネル */
body.mobile #perfToggle,                /* 同・歯車 */
body.mobile .cesium-viewer-timelineContainer,
body.mobile .cesium-viewer-animationContainer,
body.mobile .cesium-viewer-fullscreenContainer,
body.mobile .cesium-navigationHelpButton-wrapper,
body.mobile .cesium-viewer-vrContainer,
body.mobile .cesium-navigation-help,
body.mobile #compass,
body.mobile #cursorInfo {
  display: none !important;
}

/* ---- 右上は home と住所検索だけ残す（ユーザー判断） ----
 * ⚠️ Cesium 標準のボタンだけでなく、アプリが自前で足したボタン（地球全体・回転・2D・
 *   時間・キャプチャ・描画設定・Layers）も並んでいる。**まず全部隠してから2つだけ戻す**。
 *   個別に列挙すると、あとでボタンが増えたときに漏れる。 */
body.mobile .cesium-viewer-toolbar > * {
  display: none !important;
}
body.mobile .cesium-viewer-toolbar > .cesium-viewer-geocoderContainer,
body.mobile .cesium-viewer-toolbar > .cesium-home-button {
  display: block !important;
}
body.mobile .cesium-performanceDisplay-defaultContainer {
  display: none !important;   /* FPS表示 */
}

body.mobile .cesium-viewer-toolbar {
  top: 8px;
  right: 8px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
body.mobile .cesium-viewer-toolbar .cesium-button {
  width: 40px;
  height: 40px;
}
body.mobile .cesium-viewer-geocoder-searchButton {
  width: 36px;
  height: 36px;
}
/* 検索欄は画面幅に合わせて広げる（自宅を探すのがスマホの主用途） */
body.mobile .cesium-geocoder-input {
  width: 58vw;
  min-width: 180px;
  height: 40px;
  font-size: 16px; /* ⚠️ 16px未満だと iOS が入力時に勝手に拡大する */
}

/* ---- 凡例は左下に小さく（コンターの色を読むのに要る） ---- */
body.mobile #leftLegendStack {
  left: 8px;
  bottom: 104px;
  max-width: 44vw;
  max-height: 34vh;
  overflow-y: auto;
  font-size: 11px;
}
body.mobile #topLegend {
  font-size: 12px;
  padding: 4px 8px;
}

/* ---- InfoBox は画面幅に合わせる（既定は width:40% で読めない） ---- */
body.mobile .cesium-infoBox {
  width: calc(100vw - 24px) !important;
  max-height: 46vh;
  left: 12px;
  right: auto;
  top: 56px;
}
body.mobile .cesium-infoBox-title {
  font-size: 14px;
}

/* ---- 画面下のバー: 「現在地」の大ボタン ＋ シートの取っ手 ---- */
body.mobile #mobileBar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1200;
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(20, 20, 20, 0.92), rgba(20, 20, 20, 0));
  pointer-events: none;
}
body.mobile #mobileBar > button {
  pointer-events: auto;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  min-height: 52px; /* 指で押せる大きさ */
}
body.mobile #mobileBar .m-locate {
  flex: 2;
  background: #2f7fd6;
  color: #fff;
}
body.mobile #mobileBar .m-locate.is-busy {
  opacity: 0.6;
}
body.mobile #mobileBar .m-handle {
  flex: 1;
  background: rgba(255, 255, 255, 0.92);
  color: #222;
}

/* ---- 下から引き出すシート ---- */
body.mobile #mobileSheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1300;
  max-height: 72vh;
  background: #2b2b2b;
  color: #ededed;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
body.mobile #mobileSheet.is-open {
  transform: translateY(0);
}
body.mobile .m-sheet-head {
  padding: 8px 16px 4px;
  flex: none;
}
body.mobile .m-sheet-grip {
  width: 44px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 2px;
  background: #777;
}
body.mobile .m-sheet-title {
  font-size: 15px;
  font-weight: 600;
}
body.mobile .m-sheet-body {
  padding: 4px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
body.mobile .m-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #3d3d3d;
  min-height: 52px;
}
body.mobile .m-row-text {
  flex: 1;
  min-width: 0;
}
body.mobile .m-row-title {
  font-size: 15px;
}
body.mobile .m-row-sub {
  font-size: 11.5px;
  color: #b5b5b5;
  margin-top: 2px;
}
body.mobile .m-switch {
  width: 24px;
  height: 24px;
  flex: none;
}
body.mobile .m-select {
  font-size: 16px; /* ⚠️ iOS の自動拡大よけ */
  max-width: 46vw;
  padding: 6px;
  background: #3d3d3d;
  color: #ededed;
  border: 1px solid #555;
  border-radius: 6px;
}
body.mobile .m-note {
  font-size: 10.5px;
  color: #9a9a9a;
  padding-top: 12px;
  line-height: 1.5;
}

/* シートを開いている間は下のバーを隠す（取っ手が二重になるため）。
 * ⚠️ `:has()` は環境によって効かないので、JS が body に付けるクラスで確実に切る */
body.mobile.sheet-open #mobileBar {
  opacity: 0;
  pointer-events: none;
}
