/* ============================================
   高雄 観光案内マップ - スタイル
   iPhone 縦画面（幅 375〜430px）を基準に設計
   ============================================ */

:root {
  --color-bg: #ffffff;
  --color-text: #1f2933;
  --color-muted: #616e7c;
  --color-border: #d9e2ec;
  --color-primary: #0f609b;
  --color-danger: #b00020;
  --header-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  /* カテゴリ色（app.js の CATEGORIES と対応） */
  --cat-sightseeing: #1565c0;
  --cat-food: #e65100;
  --cat-market: #2e7d32;
  --cat-nightmarket: #6a1b9a;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic",
    "Noto Sans JP", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  /* iOS Safari のアドレスバーを考慮した高さ */
  height: 100dvh;
  overscroll-behavior: none;
}

/* スクリーンリーダー専用テキスト */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- ヘッダー ---------- */

.app-header {
  flex: none;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--color-bg);
  box-shadow: var(--header-shadow);
  z-index: 1001; /* Leaflet のペインより手前 */
}

.app-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

/* ---------- 検索ボックス ---------- */

.search-box {
  position: relative;
  margin-bottom: 8px;
}

#search-input {
  width: 100%;
  padding: 10px 40px 10px 12px;
  font-size: 16px; /* iOS の自動ズームを防ぐため 16px 以上 */
  border: 1px solid var(--color-border);
  border-radius: 8px;
  -webkit-appearance: none;
  appearance: none;
}

#search-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--color-muted);
  cursor: pointer;
}

/* 検索候補リスト（検索窓の直下に重ねて表示） */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  max-height: 40dvh;
  overflow-y: auto;
  z-index: 1200;
}

.search-result-item {
  margin: 0;
}

.search-result-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: 15px;
  text-align: left;
  color: var(--color-text);
  cursor: pointer;
}

.search-result-button:active {
  background: #eef3f8;
}

.search-result-category {
  flex: none;
  font-size: 13px;
  color: var(--color-muted);
}

/* ---------- カテゴリフィルタ ---------- */

.category-filters {
  display: flex;
  flex-wrap: wrap; /* 横スクロールだと端のボタンが「無い」ように見えるため折り返す */
  gap: 6px;
  padding-bottom: 2px;
}

.category-button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 5px 10px;
  font-size: 13px;
  border: 2px solid var(--cat-color, var(--color-border));
  border-radius: 20px;
  background: var(--cat-color, #eee);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

/* 非表示中（オフ）のカテゴリは白抜きにする */
.category-button[aria-pressed="false"] {
  background: #fff;
  color: var(--cat-color, var(--color-muted));
  opacity: 0.75;
}

/* ---------- エリア切替 ---------- */

.area-jump {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.area-button {
  flex: 1;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--color-primary);
  border-radius: 18px;
  background: #fff;
  color: var(--color-primary);
  cursor: pointer;
}

.area-button:active {
  background: #e8f0f7;
}

/* ---------- 地図 ---------- */

.map-container {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
}

/* カテゴリ別マーカー（divIcon） */
.marker-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 4px;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  font-size: 17px;
  background: var(--cat-color, #555);
}

/* ---------- 状態表示（読込中・エラー・結果なし） ---------- */

.status-message {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  font-size: 14px;
  text-align: center;
  background: rgba(31, 41, 51, 0.88);
  color: #fff;
  border-radius: 8px;
  z-index: 1000;
}

.status-message.is-error {
  background: var(--color-danger);
}

/* ---------- 現在地ボタン ---------- */

.locate-button {
  position: absolute;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 22px;
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 1000;
}

.locate-button:active {
  opacity: 0.85;
}

/* ---------- 周辺スポット取得ボタン ---------- */

.fetch-nearby-button {
  position: absolute;
  left: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 22px;
  background: #2e7d32;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  z-index: 1000;
}

.fetch-nearby-button:active {
  opacity: 0.85;
}

.fetch-nearby-button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* OSMから自動取得したスポットは白抜きピンで区別する */
.marker-pin--osm {
  background: #fff;
  border-color: var(--cat-color, #555);
}

/* ---------- 詳細パネル（ボトムシート） ---------- */

.detail-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 70dvh;
  overflow-y: auto;
  background: var(--color-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 1100;
}

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(31, 41, 51, 0.6);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 1;
}

.detail-photo-wrap {
  position: relative;
  width: 100%;
  height: 180px;
  background: #eceff1;
}

/* 写真の出典クレジット（CCライセンス表示） */
.detail-photo-credit {
  position: absolute;
  right: 0;
  bottom: 0;
  max-width: 85%;
  padding: 2px 8px;
  font-size: 10px;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px 0 0 0;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 写真の登録ボタン(選択・貼り付け) */
.photo-actions {
  display: flex;
  gap: 8px;
  margin: 10px 16px 0;
}

.photo-action-button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #f5f7fa;
  color: var(--color-text);
  cursor: pointer;
}

.photo-action-button:active {
  background: #e8edf2;
}

/* 写真の下の「Googleで調べる」ボタン */
.web-search-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  margin: 10px 16px 0;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--color-primary);
}

.web-search-link:active {
  background: #e8f0f7;
}

.detail-body {
  padding: 12px 16px 16px;
}

.detail-category {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--cat-color, var(--color-muted));
}

.detail-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.detail-name {
  margin: 0;
  font-size: 20px;
  flex: 1;
}

/* お気に入り(⭐)ボタン */
.favorite-button {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
  line-height: 1;
  color: #9aa5b1;
  cursor: pointer;
}

.favorite-button[aria-pressed="true"] {
  color: #f9a825;
  border-color: #f9a825;
  background: #fff8e1;
}

/* 訪問済み(✓)ボタン */
.visited-button {
  flex: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  font-size: 20px;
  line-height: 1;
  color: #9aa5b1;
  cursor: pointer;
}

.visited-button[aria-pressed="true"] {
  color: #fff;
  border-color: #2e7d32;
  background: #2e7d32;
}

/* 訪問済みスポットのマーカーは控えめに表示 */
.marker-pin--visited {
  opacity: 0.5;
}

.detail-distance {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
}

.detail-verify {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--color-danger);
  font-weight: 600;
}

.detail-description {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.6;
}

.detail-address {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--color-muted);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.map-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
}

/* ---------- 幅の広い画面での微調整 ---------- */

@media (min-width: 600px) {
  .detail-panel {
    max-width: 480px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}
