/* ========================================
   公開型GIS スタイル : モバイル・レスポンシブ（ハンバーガー・ボトムシート・画面幅対応・Drawツールバー・スクロールバー）
   （読み込み順が適用順です。index.html / survey/index.html の
     link 順を入れ替えると見た目が変わります）
   ======================================== */
/* ========================================
   Mobile menu button (hamburger)
   ======================================== */
#mobile-menu-btn {
  display: none;
}

@media (max-width: 640px) {
  #mobile-menu-btn {
    display: flex;
    position: fixed;
    top: calc(var(--content-top) + 10px);
    left: 10px;
    z-index: 700;
    width: 40px;
    height: 40px;
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    align-items: center;
    justify-content: center;
    font-size: var(--icon-lg);
    color: var(--primary);
    cursor: pointer;
  }
  #mobile-menu-btn:hover { background: var(--gray-50); }

  /* パネルを開いている間はボタンをパネルの右外側へ寄せ、中身と重ならないようにする */
  #mobile-menu-btn.sidebar-open {
    left: auto;
    right: 10px;
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-lg);
  }
  #mobile-menu-btn.sidebar-open:hover { background: var(--primary-dark); }
}

/* Sidebar overlay – lives inside #map-wrapper so it only covers the map area,
   not the sidebar itself. Tapping it closes the sidebar on mobile. */
/* ルートの地点を選んでいる間、地図の上に出す案内 */
/* 検索バーと同じ位置に出す（選んでいる間は検索バーを隠す）。
   地図上部の他の操作と重ならず、視線の動きも小さくて済む。 */
#route-pick-hint {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1150;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 20px);
  padding: 8px 8px 8px 14px;
  border-radius: 999px;
  background: rgba(26, 32, 44, 0.92);
  color: #fff;
  font-size: var(--fs-body);
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
#route-pick-hint.visible { display: flex; }
body.route-picking #map-search { display: none; }
#route-pick-hint .pick-hint-cancel {
  flex: none;
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--gray-800, #222);
  font-size: var(--fs-caption);
  font-weight: 600;
  cursor: pointer;
}
#route-pick-hint .pick-hint-cancel:hover { background: #fff; }

/* 通信エラーの表示。原因と次の操作（再試行）を必ず出す */
.load-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  padding: 0 20px;
  text-align: center;
}
.load-error > i { font-size: var(--icon-2xl); color: #dd6b20; }
.load-error-title { margin: 0; font-size: var(--fs-subhead); font-weight: 700; color: var(--gray-800, #222); }
.load-error-hint  { margin: 0; font-size: var(--fs-body); color: var(--gray-500); line-height: 1.7; }

.search-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-size: var(--fs-caption);
  color: #c53030;
}

/* ========================================
   属性表示のボトムシート（スマホ表示のみ）
   ========================================
   画面中央のモーダルは地図を隠してしまい、「どの場所の情報か」が
   見えなくなる。下から出るシートにして、地図と情報を同時に見せる。
   半分（既定）→ つまんで上へ／ヘッダーを押すと全画面 → 下へで閉じる。 */
.sheet-handle { display: none; }

@media (max-width: 640px) {
  #attribute-modal.modal-overlay {
    align-items: flex-end;
    padding: 0;
    background: none;          /* 地図を隠さない（暗幕を出さない） */
    backdrop-filter: none;
    pointer-events: none;      /* シート以外は地図の操作を通す */
  }
  #attribute-modal .modal {
    pointer-events: auto;
    width: 100%;
    max-width: none !important;
    height: 48vh;              /* 既定は半分。地図が上半分に残る */
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -3px 16px rgba(0, 0, 0, 0.28);
    transition: height 0.25s ease, transform 0.25s ease;
    touch-action: none;        /* つまんだときにページが動かないようにする */
  }
  #attribute-modal.sheet-full .modal { height: 92vh; }
  #attribute-modal.sheet-dragging .modal { transition: none; }

  #attribute-modal .sheet-handle {
    display: block;
    width: 40px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--gray-300);
    flex-shrink: 0;
  }
  #attribute-modal .modal-header {
    padding: 10px 16px 12px;
    cursor: pointer;           /* 押すと半分／全画面が切り替わる */
  }
  #attribute-modal .modal-body { padding: 14px 16px; }
  /* 下部の「閉じる」はシートでは冗長（右上の×と下スワイプで閉じられる） */
  #attribute-modal .modal-footer { display: none; }
}

/* XYZタイル（重ね地図）の記号 */
.layer-color-tile {
  flex: none;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: var(--gray-200, #e2e8f0);
  color: var(--gray-600, #4a5568);
  /* 14px の枠に収める記号。文字サイズ切替には連動させない */
  font-size: 9px;
}

/* ポイントのまとめて表示（クラスタリング）。色はレイヤの色に合わせる */
.gis-cluster { background: none; border: none; }
.gis-cluster > div {
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: var(--fs-caption);
  font-weight: 700;
  text-align: center;
}

/* 検索結果を上限で打ち切ったときの案内（「これで全部」と誤解させないため） */
.search-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  font-size: var(--fs-caption);
  color: var(--gray-500);
}
.search-more-btn {
  flex: none;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 4px 10px;
  background: #fff;
  color: var(--primary);
  font-size: var(--fs-body);
  font-weight: 600;
  cursor: pointer;
}
.search-more-btn:hover { background: var(--gray-50); }

#sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
}
#sidebar-overlay.visible { display: block; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  :root { --sidebar-width: 88vw; }

  /* Sidebar hidden by default on mobile; shown with .open */
  #sidebar {
    position: fixed;
    top: var(--content-top);
    bottom: 0;
    left: calc(-1 * var(--sidebar-width));
    z-index: 600;
    transition: left 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  #sidebar.open { left: 0; }

  /* Hide the desktop toggle tab on mobile */
  #sidebar-toggle { display: none; }

  /* スマホでは少し小さくする（並び方はPCと同じ縦） */
  #toolbar { top: 8px; right: 8px; max-height: calc(100% - 16px); }
  .tool-btn { min-width: 56px; padding: 6px 6px 4px; font-size: var(--icon-md); }

  /* スマホ: メニューボタン（左上）と縦並びツールバー（右上）の間に検索バーを収める */
  #map-search {
    top: 8px;
    left: 56px;
    right: 74px;
    width: auto;
    max-width: none;
  }
  #map-search-bar { height: 40px; padding: 0 6px 0 12px; }
  /* 案内も検索バーと同じ幅に収める（☰ボタン・ツールバーと重ねない） */
  #route-pick-hint {
    top: 8px;
    left: 56px;
    right: 74px;
    max-width: none;
    font-size: var(--fs-caption);
  }
  body.sidebar-open #map-search { display: none; }
  /* パネルを開いている間はツールバーを隠す（閉じるボタンと重なるため） */
  body.sidebar-open #toolbar { display: none; }
  /* 閉じるボタン（#mobile-menu-btn.sidebar-open）はパネル右上に重なるので、
     タブ列の右端を空けておく。調査用ページはタブが5つあり、空けないと
     いちばん右のタブ（編集）がボタンの下に入る */
  body.sidebar-open #sidebar-tabs { padding-right: 46px; }

  #map-info-bar { bottom: 30px; font-size: var(--fs-caption); }
}

/* ========================================
   Leaflet.Draw の編集ツールバーをツールバーの大ボタンと揃える
   （調査用GISの「図形を編集」「図形を削除」など）
   ======================================== */
/* 作図ツールバーはツールバー（#toolbar）の左隣に置く。
   ツールバーが縦並びのため、下にずらすと下がりすぎてしまう。
   実際の幅は JS が --toolbar-offset に設定する（js/gis-toolbar.js） */
.leaflet-top.leaflet-right { padding-right: var(--toolbar-offset, 0px); }

/* ツールバーと並びを揃えて縦に積む */
.leaflet-draw-toolbar {
  border: none !important;
  box-shadow: none !important;
  display: flex;
  flex-direction: column;
  align-items: stretch;   /* ボタン幅を揃える（縦並びで幅がばらつかないように） */
  gap: 4px;
  margin-top: 0 !important;
}
/* 描画ツールと編集ツールの2段の間隔 */
.leaflet-draw-toolbar + .leaflet-draw-toolbar { margin-top: 4px !important; }
.leaflet-draw-toolbar a {
  width: auto !important;
  height: auto !important;
  min-width: 62px;
  padding: 28px 8px 6px !important;
  white-space: nowrap;
  border: 1px solid var(--gray-200) !important;
  border-radius: var(--radius) !important;
  /* 既定のスプライト画像は使わず、下の ::before で Font Awesome を表示する */
  background-image: none !important;
  background-color: #fff !important;
  box-shadow: var(--shadow-lg);
  display: flex !important;
  align-items: flex-end;
  justify-content: center;
  font-size: var(--fs-caption);
  line-height: 1 !important;
  color: var(--gray-700);
  text-decoration: none;
  text-align: center;
  position: relative;
}
.leaflet-draw-toolbar a:hover { background-color: var(--gray-100) !important; }
.leaflet-draw-toolbar a.leaflet-disabled { opacity: 0.45; }
/* Leaflet既定ではツールチップ用に隠されているボタン名を、アイコン下に表示する */
.leaflet-draw-toolbar a .sr-only {
  position: static; width: auto; height: auto;
  clip: auto; clip-path: none; white-space: nowrap;
}
/* アイコン（ツールバーの大ボタンと同じ見た目に揃える） */
.leaflet-draw-toolbar a::before {
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: var(--icon-lg);
  color: var(--primary);
  position: absolute;
  top: 7px;
  left: 0;
  right: 0;
  text-align: center;
  line-height: 1;
}
.leaflet-draw-toolbar .leaflet-draw-draw-polyline::before  { content: '\f068'; }
.leaflet-draw-toolbar .leaflet-draw-draw-polygon::before   { content: '\f5ee'; }
.leaflet-draw-toolbar .leaflet-draw-draw-rectangle::before { content: '\f0c8'; }
.leaflet-draw-toolbar .leaflet-draw-draw-circle::before    { content: '\f111'; }
.leaflet-draw-toolbar .leaflet-draw-draw-marker::before    { content: '\f3c5'; }
.leaflet-draw-toolbar .leaflet-draw-edit-edit::before      { content: '\f044'; }
.leaflet-draw-toolbar .leaflet-draw-edit-remove::before    { content: '\f1f8'; }
.leaflet-draw-actions a {
  border-radius: var(--radius) !important;
  font-size: var(--fs-body);
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

