/* 地図ページ専用（body.page-map）。共通のヘッダ・フッタ・ボタン等は site.css。 */

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* 地図ページは画面に固定する（iOS Safari では 100dvh がポップアップ（埋め込み動画）の表示中にずれ、下に白い余白が出るため使わない） */
body.page-map {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  overflow: hidden;
  overscroll-behavior: none;
}

body.page-map .map-main {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

#map {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

/* 右ペインの開閉タブ（ペインの左端に貼り付く。PC は has-list、スマホは pane-open で開く） */
.pane-tab {
  position: absolute;
  top: 50%;
  right: 0;
  z-index: 1003;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1px solid #cbd5e1;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #fff;
  color: #1f2937;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: -2px 0 6px rgba(0, 0, 0, 0.15);
}

.pane-tab:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.pane-tab:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.pane-tab-label {
  writing-mode: vertical-rl;
  letter-spacing: 2px;
}

@media (min-width: 769px) {
  .map-main.has-list .pane-tab {
    right: 341px; /* ペイン幅 340px + 境界線 1px */
  }
}

/* スマホ幅: ペインは地図に重ねて下から引き上げるボトムシート。タブはシートの上辺中央に付く */
@media (max-width: 768px) {
  /* シートの出入り（translateY）が地図領域の外＝フッタに被らないよう、地図領域でクリップする */
  body.page-map .map-main {
    overflow: hidden;
  }

  .map-main .camera-list {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1002;
    display: block;
    box-sizing: border-box;
    width: auto;
    height: 55%;
    overflow-y: auto;
    background: #fff;
    color: #111827;
    border-top: 1px solid #e2e8f0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }

  .map-main.pane-open .camera-list {
    transform: none;
    visibility: visible;
  }

  .pane-tab {
    top: auto;
    right: auto;
    bottom: 0;
    left: 50%;
    flex-direction: row;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid #cbd5e1;
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    transform: translateX(-50%);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15);
    /* シートと同じ時間・同じイージングで上下し、閉じるときにシートより先に下へ出ないようにする */
    transition: bottom 0.2s ease;
  }

  .pane-tab-label {
    writing-mode: horizontal-tb;
    letter-spacing: 1px;
  }

  .map-main.pane-open .pane-tab {
    bottom: 55%;
  }

  /* 初回だけ: タブが「キラリン」と光る（きなり〜ベージュの光が左から右へ走り、枠がふわっと光る。動かさないのでシートとずれない） */
  @keyframes pane-tab-glint {
    0% { transform: translateX(-130%) skewX(-20deg); }
    55%, 100% { transform: translateX(130%) skewX(-20deg); }
  }

  @keyframes pane-tab-glow {
    0%, 100% { box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(224, 206, 170, 0); }
    30%, 70% { box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15), 0 0 0 6px rgba(224, 206, 170, 0.85); }
  }

  .pane-tab.is-shine {
    overflow: hidden;
    animation: pane-tab-glow 1.6s ease-in-out 1;
  }

  .pane-tab.is-shine::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, transparent 30%, rgba(224, 206, 170, 0.95) 50%, transparent 70%);
    pointer-events: none;
    animation: pane-tab-glint 1.6s ease-in-out 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .camera-list,
  .pane-tab { transition: none !important; }
}

/* ポップアップのプレビューカード */
.popup-card {
  min-width: 180px;
}

/* ポップアップ内の映像（16:9、ポップアップ幅に追従） */
.popup-video {
  position: relative;
  width: 100%;
  margin: 6px 0 4px;
  aspect-ratio: 16 / 9;
  background: #000;
}

.popup-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.popup-name {
  display: block;
  font-size: 14px;
  line-height: 1.4;
}

.popup-meta {
  display: block;
  margin: 2px 0 8px;
  font-size: 12px;
  color: #64748b;
}

/* Leaflet の「.leaflet-container a」の色指定より強くするため 2 クラスで指定 */
.popup-card .btn-primary {
  padding: 6px 12px;
  font-size: 13px;
  color: #fff;
}

/* PC 幅: 地図の右に一覧ペイン。表示範囲のカメラが閾値以下のときだけ出る（JS が .has-list を付け外しする） */
.camera-list {
  display: none; /* スマホ幅では常に非表示。PC 幅は下の media query で上書き */
}

@media (min-width: 769px) {
  /* 常に DOM 上には存在させ、幅 0 ↔ 340px をアニメーションしてスライドさせる */
  .camera-list {
    display: block;
    flex: 0 0 0;
    width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    background: #fff;
    border-left: 0 solid #e2e8f0;
    color: #111827;
    visibility: hidden;
  }

  .camera-list > * {
    width: 340px; /* ペイン幅が変化しても中身は折り返さず、右から出入りさせる */
  }

  .map-main.has-list .camera-list {
    flex-basis: 340px;
    width: 340px;
    overflow-y: auto;
    border-left-width: 1px;
    visibility: visible;
  }

}

@media (prefers-reduced-motion: reduce) {
  .camera-list { transition: none !important; }
}

.camera-list h2 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 12px 16px;
  font-size: 15px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.camera-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.camera-list li[hidden] {
  display: none;
}

.camera-list button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.camera-list button:hover {
  background: #f8fafc;
}

.camera-list button.is-active {
  background: #dbeafe;
}

.camera-list button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

.camera-name {
  display: block;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.camera-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: #64748b;
}

/* 選択中のカメラの詳細サマリー（一覧の該当項目の下に伸長表示） */
.camera-detail {
  padding: 8px 16px 12px;
  background: #eff6ff;
  border-bottom: 1px solid #bfdbfe;
  font-size: 12px;
  line-height: 1.6;
  color: #334155;
}

.camera-detail[hidden] {
  display: none;
}

.camera-detail dl {
  margin: 0 0 8px;
}

.camera-detail dt {
  float: left;
  clear: left;
  width: 4.5em;
  color: #64748b;
}

.camera-detail dd {
  margin: 0 0 2px 4.5em;
}

.camera-detail .btn-primary {
  padding: 6px 12px;
  font-size: 13px;
}

/* カテゴリ別のしずく型ピン（白地に絵文字だけ。クラスタの色と紛れないよう色分けしない） */
.pin-wrap {
  background: none;
  border: 0;
}

.pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border: 2px solid #9ca3af;
  border-radius: 50% 50% 50% 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transform: rotate(-45deg);
}

/* 配信中（live）のピンは赤系。録画・停止中は白のまま */
.pin.pin-live {
  background: #fee2e2;
  border-color: #ef4444;
}

.pin span {
  font-size: 14px;
  line-height: 1;
  transform: rotate(45deg);
}

/* 凡例 */
.map-legend {
  padding: 6px 10px;
  border-radius: 6px;
  background: #fff;
  opacity: 0.75;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  line-height: 1.7;
  color: #1f2937;
}

.map-legend .is-dim {
  opacity: 0.35;
}

.map-legend .legend-pin {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin: 0 5px 0 3px;
  box-sizing: border-box;
  border: 2px solid #9ca3af;
  border-radius: 50% 50% 50% 0;
  background: #fff;
  transform: rotate(-45deg);
  vertical-align: -1px;
}
.map-legend .legend-pin.pin-live {
  background: #fee2e2;
  border-color: #ef4444;
}

.map-legend .legend-state {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #e5e7eb;
  color: #4b5563;
}

/* 録画中のカメラのポップアップ（映像は表示したまま「録画」ラベルを出す） */
.popup-recorded {
  margin: 6px 0;
  font-size: 12px;
  color: #374151;
}

/* 配信者で絞り込み中のバナー（地図の上中央） */
.channel-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 1001;
  max-width: calc(100% - 140px);
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: #1f2937;
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.channel-banner a {
  margin-left: 6px;
  color: #93c5fd;
}

/* 右ペインの索引（都道府県・カテゴリ）。カメラ一覧に切り替わるまでの既定表示 */
.pane-index {
  box-sizing: border-box; /* 幅 340px に padding を含める（はみ出して右が切れていた） */
  padding: 4px 16px 20px;
}

.camera-list .pane-index h2 {
  position: static;
  margin: 14px 0 0;
  padding: 0 0 6px;
  border: 0;
  border-bottom: 1px solid #d8d8d9; /* 本文ページの h2（site.css）と同じ下罫線。サイズは変えない */
  font-size: 15px;
}

.camera-list .tag-desc {
  margin: 0;
  padding: 8px 16px 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-sub);
}

.camera-list .tag-prefs {
  padding-top: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ebebec;
}

.pane-index .region {
  margin: 12px 0 4px;
  font-size: 12px;
}

/* リンクはチップ（ボタン）表示。件数は右に薄く */
.pane-index .tree-list {
  gap: 6px;
  margin: 4px 0 6px;
  font-size: 13px;
}

.pane-index .tree-list li {
  min-width: 0;
}

.pane-index .tree-list a {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid #e0ceaa;
  border-radius: 4px;
  background: #f4eede;
  color: #3c3c43;
  text-decoration: none;
  line-height: 1.3;
}

.pane-index .tree-list a:hover {
  border-color: #3c3c43;
  background: #3c3c43;
  color: #fff;
}

.pane-index .tree-list a:hover .count {
  color: #ebebec;
}

/* 絞り込み中のカテゴリ */
.pane-index .tree-list a.is-active {
  border-color: #3c3c43;
  background: #3c3c43;
  color: #fff;
}

.pane-index .tree-list a.is-active .count {
  color: #ebebec;
}

.pane-index .tree-list a:focus-visible {
  outline: 2px solid #3c3c43;
  outline-offset: 1px;
}

.pane-index .tree-list a .count {
  margin: 0;
  color: #6d6d72;
  font-size: 11px;
}

.pane-up {
  margin: 12px 0 0;
  font-size: 12px;
}

/* 配信停止中のカメラのポップアップ（映像の代わりに出す案内） */
.popup-paused {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  background: #fffbeb;
  color: #78350f;
  font-size: 13px;
  line-height: 1.6;
}

/* 配信停止中のカメラのポップアップ（映像の代わりに出す案内） */
.popup-paused {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  background: #fffbeb;
  color: #78350f;
  font-size: 13px;
  line-height: 1.6;
}

/* 雨雲レーダーの切り替え（地図の右上） */
.map-radar {
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  line-height: 1.5;
  color: #1f2937;
}
/* 右ペインの一番上に固定するフィルタ（録画を除く・雨雲レーダー・災害河川） */
.camera-list > .map-radar {
  position: sticky;
  top: 0;
  z-index: 5;
  border-radius: 0;
  border-bottom: 1px solid #d8d8d9;
  background: #f5f5f5;
  box-shadow: none;
  padding: 8px 16px;
  box-sizing: border-box; /* ペイン幅 340px の内側に padding を収める（付けないと右に 32px はみ出して切れる） */
}
.map-radar label { cursor: pointer; display: block; }
/* 時点は「雨雲レーダー」の右に折り返さず並べる */
.map-radar .radar-label { display: inline-block; }
.map-radar .radar-asof { display: inline-block; margin-left: 8px; font-size: 11px; color: #6b7280; white-space: nowrap; }
.map-radar .radar-asof:empty { display: none; }

/* 3 つのチェック（チェックボックス＋文字で 1 ブロック）を横に並べる。幅が足りなければブロック単位で折り返す。時点の表示は雨雲レーダーのすぐ右 */
.camera-list > .map-radar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
}
.camera-list > .map-radar label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.camera-list > .map-radar .radar-label { display: inline-flex; }
.camera-list > .map-radar #map-disaster-slot { display: contents; }

/* 現在地ボタン（倍率ボタンの下） */
.map-locate a { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; color: #1f2937; }

/* 右ペインの広告（索引・カメラ一覧の下） */
.camera-list .pane-ad { margin: 1rem 16px; width: auto; }

/* 右ペイン: よく見られているライブカメラ（一番下、広告の下）。リストは詳細ページと同じ .cam-list */
.camera-list .pane-popular { box-sizing: border-box; padding: 4px 24px 24px 28px; }
.camera-list .pane-popular h2 { position: static; margin: 14px 0 6px; padding: 0 0 6px; border: 0; border-bottom: 1px solid #d8d8d9; font-size: 15px; }

.camera-list .pane-intro { box-sizing: border-box; padding: 4px 24px 28px 28px; font-size: 13px; line-height: 1.7; color: #3c3c43; }
.camera-list .pane-intro h2 { position: static; margin: 14px 0 8px; padding: 0 0 6px; border: 0; border-bottom: 1px solid #d8d8d9; font-size: 15px; }
.camera-list .pane-intro p { margin: 0 0 8px; }
.camera-list .pane-intro-links { font-size: 12px; }

/* 気象庁の警報・注意報（トップの右ペイン）。段階が高いほど濃く */
.pane-index .tree-list a.is-alert-1 {
  border-color: #e6cf8a;
  background: #fbf1cf;
}

.pane-index .tree-list a.is-alert-2 {
  border-color: #e0a29b;
  background: #f9dcd8;
}

.pane-index .tree-list a.is-alert-3 {
  border-color: #8b1a1a;
  background: #b3261e;
  color: #fff;
}

.pane-index .tree-list a.is-alert-3 .count {
  color: #fff;
}

/* クラスターの「少ない」色を緑から青にする（地図の背景が緑系で、埋もれるため） */
.marker-cluster-small {
  background-color: rgba(158, 202, 236, 0.6);
}

.marker-cluster-small div {
  background-color: rgba(52, 130, 210, 0.6);
}

/* 地震情報カード（トップの右ペイン。震度4以上が発生から 12 時間表示される） */
.pane-index .quake-card {
  position: relative;
  display: block;
  margin: 0 0 8px;
  padding: 8px 28px 6px 12px;
  border: 1px solid #e0a29b;
  border-left: 5px solid #d9382b;
  border-radius: 4px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.pane-index .quake-card::after {
  content: '\203A';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 22px;
  line-height: 1;
}

.pane-index .quake-card:hover { background: #fff8f7; }
.pane-index .quake-card .qc-title { display: block; font-weight: 700; font-size: 15px; }

.pane-index .quake-card .qc-badge {
  display: inline-block;
  margin: 3px 0 4px;
  padding: 1px 8px;
  border-radius: 4px;
  background: #d9382b;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.pane-index .quake-card.is-rank-4 { border-left-color: #e8903a; }
.pane-index .quake-card.is-rank-4 .qc-badge { background: #e8903a; }
.pane-index .quake-card.is-rank-8,
.pane-index .quake-card.is-rank-9 { border-left-color: #7b1010; }
.pane-index .quake-card.is-rank-8 .qc-badge,
.pane-index .quake-card.is-rank-9 .qc-badge { background: #7b1010; }
.pane-index .quake-card .qc-body { display: flex; align-items: flex-start; gap: 8px; }
.pane-index .quake-card .qc-icon { flex: none; width: 28px; height: 28px; }
.pane-index .quake-card .qc-text { font-size: 13px; line-height: 1.45; }
.pane-index .quake-card .qc-time { display: block; margin-top: 2px; color: #888; font-size: 11px; }
