/******************************
 * 9251 Castle Map 専用CSS（安定・最小）
 * - 全画面マップ
 * - Cocoonのパンくず/タイトル/ヘッダー/フッター/モバイル固定ボタンを非表示
 * - ポップアップ：PC 520px / スマホ 96vw
 * - 画像：PC 480px / スマホ 幅100%
 * - モーダル：ほぼ全画面（クリック復活優先）
 ******************************/

/* =========================
   0) 9251だけ全画面リセット
   ========================= */
body.page-id-9251,
body.page-id-9251 #wrap,
body.page-id-9251 #container,
body.page-id-9251 #content,
body.page-id-9251 #content-in,
body.page-id-9251 #main,
body.page-id-9251 #main-in,
body.page-id-9251 #primary,
body.page-id-9251 .content,
body.page-id-9251 .content-in,
body.page-id-9251 .main,
body.page-id-9251 .main-in,
body.page-id-9251 .entry-content{
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
}

body.page-id-9251{
  overflow: hidden !important; /* 記事が前に出てくる事故防止 */
}

/* =========================
   1) 全画面マップ（最優先）
   ========================= */
body.page-id-9251 #map{
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100svh !important; /* iOS Safari */
  height: 100dvh !important; /* modern */
  display: block !important;
  z-index: 10 !important;
}

/* Leaflet UI は地図より前に */
body.page-id-9251 .leaflet-control-container{
  z-index: 1000 !important;
}

/* =========================
   2) Cocoonの上物を消す（9251だけ）
   ========================= */
/* パンくず（ホーム）/タイトル */
body.page-id-9251 .breadcrumb,
body.page-id-9251 .breadcrumbs,
body.page-id-9251 .breadcrumb-list,
body.page-id-9251 .breadcrumb-item,
body.page-id-9251 .wp-breadcrumb,
body.page-id-9251 .entry-title,
body.page-id-9251 .article-title,
body.page-id-9251 .article-header,
body.page-id-9251 header.article-header{
  display: none !important;
}

/* ヘッダー/フッター/サイドバー/モバイル固定ボタン */
body.page-id-9251 #header-container,
body.page-id-9251 #header,
body.page-id-9251 .header-container,
body.page-id-9251 #footer,
body.page-id-9251 #footer-container,
body.page-id-9251 .footer,
body.page-id-9251 #sidebar,
body.page-id-9251 .sidebar,
body.page-id-9251 .mobile-header,
body.page-id-9251 .mobile-header-menu,
body.page-id-9251 .mobile-menu,
body.page-id-9251 .navi-menu-button,
body.page-id-9251 .menu-button,
body.page-id-9251 .mobile-menu-buttons,
body.page-id-9251 .mobile-footer,
body.page-id-9251 .mobile-footer-menu,
body.page-id-9251 .go-to-top,
body.page-id-9251 .go-to-top-button{
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* === ロゴ調整（Leaflet左上ロゴだけに限定） === */
#logo-home img.custom-logo{
  width: 250px;
  height: auto;
  max-width: none;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 10px;
  border-radius: 6px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
  display: block;
}

/* === ロゴ＋切替ボタンの横並び === */
#logo-home{
  background: transparent;
}

/* ロゴ＋ボタンを横に並べる */
#logo-home .map-header-inner{
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 切替ボタン */
#logo-home .map-switch{
  display: flex;
  gap: 6px;
}

#logo-home .map-btn{
  padding: 5px 8px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  line-height: 1;
}

#logo-home .map-btn:hover{
  background: rgba(0,0,0,0.9);
}

#logo-home .map-btn.active{
  background: #ff6600;
}

@media screen and (max-width: 767px){

  /* ロゴ＋ボタン：スマホだけ縦に積む */
  #logo-home .map-header-inner{
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* ボタンは横並びのまま（好みで縦にもできる） */
  #logo-home .map-switch{
    width: 100%;
  }

  /* ボタン押しやすく */
  #logo-home .map-btn{
    font-size: 12px;
    padding: 7px 10px;
  }

  /* ロゴをちょい小さく＆余白も控えめ */
  #logo-home img.custom-logo{
    width: 160px;     /* ←ここ好みで 140〜180 */
    padding: 6px;
    margin-top: 0;    /* もう縦積みなので不要 */
  }
}

/* =========================
   4) Leaflet ポップアップ
   ========================= */
body.page-id-9251 .leaflet-popup-content-wrapper{
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Leaflet既定マージン殺し */
body.page-id-9251 .leaflet-popup-content{
  margin: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  letter-spacing: .2px;
  position: relative; /* ←閉じるボタン/画像の重なり安定 */
}

/* 枠フィット */
body.page-id-9251 .custom-popup{
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  line-height: 1.6;
}

/* リンク折返し */
body.page-id-9251 .leaflet-popup-content a,
body.page-id-9251 .custom-popup a{
  overflow-wrap: anywhere;
  word-break: break-word;
  color: #0078d7;
  text-decoration: none;
  border-bottom: 1px dashed rgba(0,120,215,.5);
  padding: 2px 0;
}
body.page-id-9251 .leaflet-popup-content a:hover,
body.page-id-9251 .custom-popup a:hover{
  border-bottom-style: solid;
}

/* ★ここ超重要：画像のz-index爆盛り禁止（モーダル死ぬ＆×が隠れる原因） */
body.page-id-9251 .leaflet-popup-content img,
body.page-id-9251 .custom-popup img{
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 1;          /* ←普通に1でOK */
  border-radius: 6px;
}

/* 閉じるボタンは画像より前に固定 */
body.page-id-9251 .leaflet-popup-close-button{
  font-size: 30px !important;
  width: 44px !important;
  height: 44px !important;
  line-height: 42px !important;
  text-align: center !important;
  padding: 0 !important;
  margin: 0 !important;
  color: #333 !important;
  background: rgba(255,255,255,.85) !important; /* 背景つけて見失わない */
  border: none !important;
  border-radius: 10px !important;
  cursor: pointer !important;
  position: absolute !important;
  top: 6px !important;
  right: 6px !important;
  z-index: 9999 !important; /* ←画像(1)より確実に上 */
}

/* ===== PC：ポップアップ 520px / 画像 480px ===== */
@media (min-width: 768px){
  body.page-id-9251 .leaflet-popup-content-wrapper{
    width: 520px !important;
    max-width: 520px !important;
  }
  body.page-id-9251 .leaflet-popup-content{
    padding: 14px 16px !important;
    font-size: 16px !important;
    line-height: 1.7 !important;
    max-height: 70vh !important;
  }
  body.page-id-9251 .leaflet-popup-content img,
  body.page-id-9251 .custom-popup img{
    width: 480px !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 8px auto 10px !important;
  }
}

/* ===== スマホ：ポップアップ 96vw / 画像 幅100% ===== */
@media (max-width: 767px){
  body.page-id-9251 img.custom-logo{
    width: 180px;
    padding: 5px;
    margin-top: 10px;
  }

  body.page-id-9251 .leaflet-popup-content-wrapper{
    width: 96vw !important;
    max-width: 96vw !important;
  }
  body.page-id-9251 .leaflet-popup-content{
    padding: 10px 12px 12px !important;
    font-size: 15.5px !important;
    line-height: 1.75 !important;
    max-height: 60vh !important;
  }
  body.page-id-9251 .leaflet-popup-content img,
  body.page-id-9251 .custom-popup img{
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 38vh !important;
    object-fit: cover !important;
    display: block !important;
    margin: 8px auto 10px !important;
  }

  /* ズームボタンは好みで */
  body.page-id-9251 .leaflet-control-zoom{ display:none !important; }

  body.page-id-9251 .leaflet-control-attribution{
    font-size: 10px;
    bottom: 15px !important;
    right: 6px !important;
  }
}

/* =========================
   5) モーダル（クリック優先の素直版）
   ========================= */
body.page-id-9251 .modal{
  z-index: 200000 !important;
  pointer-events: auto !important;
}

body.page-id-9251 .modal-slide{
  max-width: 98vw !important;
  max-height: 92vh !important;
}

body.page-id-9251 .modal-slide img{
  max-width: 98vw !important;
  max-height: 92vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* 矢印＆閉じる */
body.page-id-9251 .modal button.prev,
body.page-id-9251 .modal button.next{
  font-size: 44px !important;
  z-index: 200001 !important;
}
body.page-id-9251 .modal-close{
  font-size: 44px !important;
  z-index: 200002 !important;
}

/* =========================
   9251: モーダル土台を復活（これがないと開いても見えない）
   ========================= */
body.page-id-9251 .modal{
  display: none;                 /* JSが display:block に変える前提 */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.8);
  z-index: 200000 !important;    /* 最前面 */
}

body.page-id-9251 .modal-gallery{
  position: relative;
  width: 100%;
  height: 100%;
}

body.page-id-9251 .modal-slide{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;                /* JSが表示する前提 */
  max-width: 98vw;
  max-height: 92vh;
}

body.page-id-9251 .modal-slide img{
  display: block;
  max-width: 98vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ボタン類 */
body.page-id-9251 .modal button.prev,
body.page-id-9251 .modal button.next{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 200001;
}

body.page-id-9251 .modal .prev{ left: 10px; }
body.page-id-9251 .modal .next{ right: 10px; }

body.page-id-9251 .modal-close{
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 44px;
  color: #fff;
  cursor: pointer;
  z-index: 200002;
}

/* 万が一テーマが display:none!important を持ってても、JSが display:block にしたら勝つ保険 */
body.page-id-9251 .modal[style*="display: block"]{
  display: block !important;
  pointer-events: auto !important;
}

/* ===== モーダル画像を限界まで大きく ===== */
body.page-id-9251 .modal-slide{
  max-width: 100vw !important;
  max-height: 100vh !important;
}

body.page-id-9251 .modal-slide img{
  max-width: 96vw !important;   /* 横ほぼフル */
  max-height: 94vh !important; /* 縦ほぼフル */
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* =========================
   メニュートグルボタン（共通）
   ========================= */
.layers-toggle-button{
  background: #ffffff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: all .2s ease;
}

.layers-toggle-button:hover{
  background: #f0f0f0;
}

/* 開いているとき（閉じる状態） */
.layers-toggle-button.is-open{
  background: #333;
  color: #fff;
  border-color: #333;
}

/* =========================
   レイヤーパネル本体
   ========================= */
.custom-layers-panel{
  background: rgba(255,255,255,0.97);
  border-radius: 12px;
  padding: 12px 12px 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  max-height: 75vh;
  overflow-y: auto;
  min-width: 280px;
}

/* PC表示 */
@media (min-width: 768px){
  .custom-layers-panel{
    width: 380px;
    font-size: 15px;
  }

  .layers-toggle-button{
    font-size: 15px;
    padding: 8px 14px;
  }
}

/* =========================
   スマホ表示
   ========================= */
@media (max-width: 767px){

  /* ボタンを親指で押しやすく */
  .layers-toggle-button{
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 20px;
  }

  /* パネルは画面に収まるサイズで */
  .custom-layers-panel{
    width: 92vw;
    max-width: 92vw;
    max-height: 70vh;
    padding: 10px;
    font-size: 14px;
  }

  /* チェックボックス行のタップ領域拡張 */
  .leaflet-control-layers-overlays label,
  .leaflet-control-layers-base label{
    display: block;
    padding: 4px 2px;
    line-height: 1.6;
  }

  .leaflet-control-layers input[type="checkbox"]{
    transform: scale(1.1);
    margin-right: 6px;
  }
}

/* =========================
   検索UIも馴染ませる
   ========================= */
#search-container{
  background: #f7fbff;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
}

#search-box{
  border-radius: 6px;
  border: 1px solid #ccc;
}

#search-button{
  border-radius: 6px;
  background: #0078d7;
  color: #fff;
  border: none;
  padding: 6px 0;
}

/* =========================
   6) 管理フォーム（#add-spot-form）
   ========================= */
body.page-id-9251 #add-spot-form{
  position: fixed !important;
  top: 70px !important;
  left: 12px !important;
  right: 12px !important;
  margin: 0 auto !important;
  max-width: 560px !important;

  z-index: 300000 !important; /* map(10) / leaflet-ui(1000) / modal(200000)より上 */
  background: rgba(255,255,255,.98) !important;
  border: 1px solid #ccc !important;
  border-radius: 14px !important;
  box-shadow: 0 12px 36px rgba(0,0,0,.30) !important;

  max-height: 78vh !important;
  overflow: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding: 12px 12px 14px !important;
}

/* 中身（フォーム内） */
body.page-id-9251 #add-spot-form .form-inner{
  font-size: 15px;
  line-height: 1.6;
}

body.page-id-9251 #add-spot-form h3{
  margin: 6px 0 10px;
  font-size: 18px;
}

body.page-id-9251 #add-spot-form label{
  display: block;
  margin: 8px 0;
}

body.page-id-9251 #add-spot-form input[type="text"],
body.page-id-9251 #add-spot-form select,
body.page-id-9251 #add-spot-form textarea{
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  background: #fff;
}

body.page-id-9251 #add-spot-form textarea{
  min-height: 90px;
  resize: vertical;
}

body.page-id-9251 #add-spot-form button{
  border-radius: 10px;
  border: 1px solid #ccc;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

body.page-id-9251 #add-spot-form #submit-spot{
  background: #0078d7;
  color: #fff;
  border-color: #0078d7;
  width: 100%;
  margin-top: 10px;
}

body.page-id-9251 #add-spot-form #cancel-spot{
  background: #f6f6f6;
  width: 100%;
  margin-top: 8px;
}

/* 既存画像プレビュー */
body.page-id-9251 #add-spot-form #image-preview img{
  border-radius: 8px;
}

/* スマホ：上を詰める */
@media (max-width: 767px){
  body.page-id-9251 #add-spot-form{
    top: 58px !important;
    max-width: 96vw !important;
    max-height: 75vh !important;
  }
}

/* =========================
   近くの宿（楽天）安定版
   ========================= */

.nearby-hotels{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,.15);
}

.nearby-hotels__head{
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.nearby-hotels__head .pr{
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.25);
}

.nearby-hotels__body{
  display: grid;
  gap: 10px;
}

/* ===== カード ===== */
.nearby-hotel-card{
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid #c5e1a5;
  border-radius: 12px;
  background: #fff;
  overflow: visible;
  position: relative;
}

/* ===== 画像 ===== */
.nearby-hotel-card__img{
  position: relative;
}

.nearby-hotel-card__img img{
  width: 96px !important;
  height: 72px !important;
  object-fit: cover !important;
  border-radius: 10px;
  display: block;
  margin: 0 !important;
  max-height: none !important;
}

/* 画像左下ラベル（ある場合） */
.nearby-hotel-card__credit{
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0,0,0,.65);
  color: #fff;
  z-index: 3;
  pointer-events: none;
}

/* ===== テキスト ===== */
.nearby-hotel-card__name{
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 6px;
}

/* ボタン */
.nearby-hotel-card__btn{
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  background: #8bc34a;
  color: #fff !important;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  text-decoration: none;
  text-align: center;
  border: none;
  transition: all .2s ease;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.nearby-hotel-card__btn:hover{
  background: #7cb342;
  transform: translateY(-1px);
}

.nearby-hotel-card__btn:active{
  transform: scale(0.97);
  background: #689f38;
}

/* ===== 楽天トラベル表記（確実に表示） ===== */
.nearby-hotel-card__meta{
  margin-top: 4px;
  display: block;
}

.nearby-hotel-card__meta::after{
  content: "楽天トラベル";
  display: block;
  font-size: 9px;
  color: #999;
  margin-top: 4px;
  opacity: 0.7;
  line-height: 1.2;
}

/* ===== 距離表示 ===== */
.nearby-hotel-card__top{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.nearby-hotel-card__dist{
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

/* ===== もっと見る ===== */
.nearby-hotels__more{
  text-align: center;
  margin-top: 6px;
}

.nearby-hotels__morebtn{
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  background: #f5f5f5;
  border: 1px solid #ccc;
  font-weight: 700;
  cursor: pointer;
}

.nearby-hotels__morebtn:hover{
  background: #e0e0e0;
}

/* ===== エラー ===== */
.nearby-hotels__err,
.nearby-hotels__empty{
  font-size: 13px;
  color: #888;
  text-align: center;
  padding: 8px;
}

/* ===== 評価（★） ===== */
.nearby-hotel-card__rating{
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 6px;
  font-size: 12px;
}

.nearby-hotel-card__rating .score{
  font-weight: 700;
}

.nearby-hotel-card__rating .count{
  color: black;
}

/* 星：塗りつぶし（--pctで割合） */
.nearby-hotel-card__rating .stars{
  position: relative;
  display: inline-block;
  line-height: 1;
  letter-spacing: 0.08em;
  color:  rgb(86, 86, 86); /* ベース（灰色） */
}

.nearby-hotel-card__rating .stars::after{
  content: "★★★★★";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--pct, 0%);
  overflow: hidden;
  white-space: nowrap;
  color: #f2b01e; /* 塗り（ゴールド） */
}


/* =========================
   FIX：スマホで右側切れる問題 完全対応
   ========================= */
@media (max-width: 767px){

  /* 右カラムがちゃんと縮むようにする（最重要） */
  .nearby-hotel-card{
    grid-template-columns: 80px minmax(0, 1fr);
    width: 100%;
    box-sizing: border-box;
  }

  /* 右側コンテンツのはみ出し防止 */
  .nearby-hotel-card__meta{
    min-width: 0;
    overflow: hidden;
  }

  /* ホテル名の折り返し */
  .nearby-hotel-card__name{
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* ★評価バッジのはみ出し防止 */
  .nearby-hotel-card__rating{
    flex-wrap: wrap;
    max-width: 100%;
  }

  /* 距離表示は無理に縮めない */
  .nearby-hotel-card__dist{
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ボタンのはみ出し防止 */
  .nearby-hotel-card__btn{
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 念のため全体の横スクロール防止 */
  .nearby-hotels__body{
    overflow-x: hidden;
  }
}

/* =========================
   最終FIX：宿カード画像サイズを絶対に固定（9251だけ）
   ========================= */
body.page-id-9251 .leaflet-popup-content .nearby-hotels .nearby-hotel-card__img img,
body.page-id-9251 .custom-popup .nearby-hotels .nearby-hotel-card__img img{
  width: 96px !important;
  height: 72px !important;
  max-width: 96px !important;
  max-height: 72px !important;
  object-fit: cover !important;
  margin: 0 !important;
  display: block !important;
}

@media (max-width: 767px){
  body.page-id-9251 .leaflet-popup-content .nearby-hotels .nearby-hotel-card__img img,
  body.page-id-9251 .custom-popup .nearby-hotels .nearby-hotel-card__img img{
    width: 80px !important;
    height: 60px !important;
    max-width: 80px !important;
    max-height: 60px !important;
  }
}

