/* =============================================================
   ジャパンデータ 共通スタイル
   （index.html は自前のインラインCSSを使用。本ファイルは
    trade-area / heatmap / ranking / about で共有する）
   ============================================================= */
:root {
  --primary:   #1a4fa0;
  --primary-light: #e8f0fb;
  --accent:    #e8a020;
  --danger:    #c0392b;
  --danger-bg: #fdf0ef;
  --success:   #27ae60;
  --success-bg:#f0fdf4;
  --warning:   #d97706;
  --warning-bg:#fffbeb;
  --bg:        #f0f4f8;
  --surface:   #ffffff;
  --text:      #1a1a2e;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --radius:    8px;
  --shadow:    0 1px 4px rgba(0,0,0,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans JP', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); }

/* ---------------- ヘッダー / ナビ ---------------- */
header {
  background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; height: 52px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
header .logo { font-size: 15px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
header .logo span { color: #ffd700; }
header .logo a { color: #fff; text-decoration: none; }
nav { display: flex; gap: 2px; margin-left: 16px; }
nav a {
  color: rgba(255,255,255,.8); text-decoration: none; white-space: nowrap;
  padding: 6px 12px; border-radius: var(--radius); font-size: 13px; transition: .15s;
}
nav a:hover, nav a.active { background: rgba(255,255,255,.15); color: #fff; }
header .spacer { flex: 1; }
.header-info { font-size: 11px; color: rgba(255,255,255,.6); }

/* ---------------- レイアウト ---------------- */
.layout-split { display: grid; height: calc(100vh - 52px); }
#map { width: 100%; height: 100%; }
#map-container { position: relative; }

/* ---------------- パネル ---------------- */
.panel { background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.panel.left  { border-right: 1px solid var(--border); }
.panel.right { border-left: 1px solid var(--border); }
.panel-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel-title { font-size: 16px; font-weight: 700; }
.panel-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; }

/* ---------------- 指標カード ---------------- */
.metrics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.metric-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.metric-card.wide { grid-column: 1 / -1; }
.metric-label { font-size: 10px; color: var(--muted); margin-bottom: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.metric-unit { font-size: 11px; font-weight: 400; color: var(--muted); }
.metric-delta { font-size: 10px; margin-top: 3px; font-weight: 500; }
.metric-delta.up { color: var(--success); }
.metric-delta.down { color: var(--danger); }
.metric-delta.neutral { color: var(--muted); }

.section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 14px 0 8px; display: flex; align-items: center; gap: 5px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ---------------- フォーム要素 ---------------- */
.input, select.input {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px; color: var(--text); background: var(--surface);
  font-family: inherit;
}
.btn {
  border: none; border-radius: var(--radius); padding: 8px 16px;
  font-size: 13px; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; transition: .15s;
}
.btn:hover { background: #163f80; }
.btn.secondary { background: var(--surface); color: var(--primary); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--primary-light); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; transition: .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- スコアゲージ ---------------- */
.score-section { text-align: center; padding: 8px 0; }
.score-gauge-wrap { position: relative; width: 150px; margin: 0 auto 6px; }
.score-gauge-wrap svg { width: 100%; }
.score-number { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-rank { font-size: 12px; color: var(--muted); }

/* ---------------- バッジ ---------------- */
.risk-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.risk-badge.low  { background: var(--success-bg); color: var(--success); }
.risk-badge.mid  { background: var(--warning-bg); color: var(--warning); }
.risk-badge.high { background: var(--danger-bg);  color: var(--danger); }

/* ---------------- 凡例 ---------------- */
.map-legend { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); font-size: 11px; min-width: 200px; }
.legend-title { font-weight: 600; margin-bottom: 6px; }
.legend-scale { height: 10px; border-radius: 4px; margin: 4px 0; }
.legend-labels { display: flex; justify-content: space-between; color: var(--muted); }

/* ---------------- ローディング ---------------- */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--muted); gap: 8px; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------------- データ出典 ---------------- */
.data-source { font-size: 10px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; line-height: 1.6; }
.placeholder-state { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--muted); gap: 12px; padding: 24px; }
.placeholder-state .icon { width: 56px; height: 56px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.placeholder-state p { font-size: 13px; line-height: 1.6; }

/* ---------------- 共通注記 ---------------- */
.notice { background: var(--warning-bg); border: 1px solid #fcd34d; border-radius: var(--radius); padding: 10px 12px; font-size: 11px; color: var(--warning); line-height: 1.5; margin-top: 12px; }

/* ==================== モバイル/タブレット対応 ==================== */
/* ナビ8項目＋ロゴ＋出典が1行に収まらない〜1080px帯では、ヘッダーを折返し＋
   ナビ横スクロールに切替（デスクトップ手前でナビ文字が縦に潰れるのを防ぐ）。 */
@media (max-width: 1080px) {
  /* 2カラム地図レイアウトを縦積みに */
  .layout, .layout-split { grid-template-columns: 1fr !important; height: auto !important; min-height: 0 !important; }
  #map-container { height: 56vh !important; min-height: 300px; }
  #map { height: 100%; }
  .panel, .panel.left, .panel.right { border: none !important; border-top: 1px solid var(--border) !important; max-height: none !important; overflow: visible !important; }
  .panel-body { overflow-y: visible !important; max-height: none !important; }

  /* ヘッダー・ナビ（多項目を横スクロールに） */
  header { flex-wrap: wrap; height: auto; min-height: 48px; padding: 6px 10px; gap: 6px; }
  header .logo { font-size: 14px; }
  header .spacer { display: none; }
  .header-info { display: none; }
  nav { order: 3; width: 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  nav::-webkit-scrollbar { height: 0; }
  nav a { white-space: nowrap; padding: 6px 9px; font-size: 12px; }

  /* カード・操作バー */
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .searchbar, .ind-bar { padding: 8px 10px; }
  .searchbar .input.addr { min-width: 140px; }
  body { font-size: 13px; }
}
@media (max-width: 440px) {
  .metrics-grid { grid-template-columns: 1fr; }
  #map-container { height: 50vh !important; }
}
