/* 色はすべてここで決める。ダークモードは端末の設定に合わせて自動で切り替える。
   面と文字は少し青みのある無彩色、色が付くのは地図のピンと「知らせる」の札だけにする */
:root {
  color-scheme: light dark;
  --accent: #1e3a5f; /* 紺: 確認済みの非公式拠点・主なボタン */
  --on-accent: #fff;
  --pending: #ea8a00; /* オレンジ: 未確認 */
  --on-pending: #111827;
  --official: #0f7b4f; /* 緑: 公式の避難所（避難場所の標識の色） */
  --me: #007aff; /* 青: 現在地 */
  --surface: #fff;
  --surface-2: #eceff4;
  --fg: #111827;
  --fg-2: #4b5565;
  --muted: #6b7487;
  --border: rgb(17 24 39 / 0.1);
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 12px rgb(0 0 0 / 0.1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #60a5fa;
    --on-accent: #0b0d14;
    --pending: #f59e0b;
    --on-pending: #0b0d14;
    --official: #4cc38a;
    --surface: #11141c;
    --surface-2: #1a1e28;
    --fg: #eef0f5;
    --fg-2: #a3a9b8;
    --muted: #7a8296;
    --border: rgb(238 240 245 / 0.1);
    --danger: #f87171;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 12px rgb(0 0 0 / 0.3);
  }
  .maplibregl-ctrl.maplibregl-ctrl-attrib { background: var(--surface); color: var(--fg); }
  .maplibregl-ctrl-attrib a { color: var(--fg); }
  .maplibregl-ctrl-attrib-button { filter: invert(1); }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* display を決めた要素（.replay など）でも hidden で消す */
html, body { margin: 0; height: 100%; background: var(--surface); color: var(--fg); }
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.icon { display: block; width: 18px; height: 18px; }

/* 押したときの反応は色と、ほんの少しの縮みだけ */
.chip, .round, .kind, .btn, .close, .pin__shape {
  transition: background-color 150ms var(--ease), color 150ms var(--ease),
    border-color 150ms var(--ease), transform 150ms var(--ease);
}
.chip:active, .round:active, .kind:active:not(:disabled), .btn:active { transform: scale(0.98); }

/* 地図の出典表示を下のドックに隠さない（--dock-h は app.js が入れる） */
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: var(--dock-h, 0px); }

/* 上部: 絞り込みとメニュー */
.top {
  position: fixed; z-index: 2; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px; margin: -4px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow); font-weight: 600; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.chip .tag { width: 20px; height: 20px; font-size: 12px; margin-left: -6px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip[aria-pressed="true"] .tag { background: transparent; border-color: currentColor; color: inherit; }

/* 現在地に戻るボタン。右下、地図の出典の行（開いたとき約 32px）より上 */
.round.fab { position: fixed; z-index: 2; right: 12px; bottom: calc(var(--dock-h, 0px) + 44px); color: var(--me); }
.round {
  flex: none; margin-left: auto; width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
  color: var(--fg-2); display: flex; align-items: center; justify-content: center;
}

/* 通信できないときの帯と、「ここに何がある？」のカード */
.banner, .card {
  position: fixed; z-index: 3; top: calc(64px + env(safe-area-inset-top)); left: 12px; right: 12px;
  max-width: 520px; margin: 0 auto; box-shadow: var(--shadow);
}
.banner { padding: 8px 12px; border-radius: 12px; background: var(--danger); color: var(--surface); font-size: 14px; }
.card { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.banner:not([hidden]) ~ .card { top: calc(112px + env(safe-area-inset-top)); }
.card h2 { display: flex; align-items: center; gap: 8px; margin: 0 48px 4px 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0 0 12px 32px; color: var(--fg-2); }
.close {
  position: absolute; top: 4px; right: 4px; width: 44px; height: 44px; border-radius: 10px;
  border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center;
}

/* 下部: 知らせるボタン */
.dock {
  position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0; background: var(--surface); box-shadow: 0 -4px 12px rgb(0 0 0 / 0.08);
}
.dock h2 { margin: 0 0 8px; font-size: 14px; font-weight: 400; color: var(--fg-2); }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* 種類のボタン。地図のピンと同じ「漢字1文字の札」を上に置く（横並びだと「宿泊・車中泊」が折り返す） */
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kind {
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 4px; border: 1px solid transparent; border-radius: 10px;
  background: var(--surface-2); font-size: 14px; line-height: 20px;
}
.kind[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tag {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--accent); font-size: 13px; font-weight: 600; line-height: 1;
}
.kind[aria-pressed="true"] .tag { background: transparent; border-color: currentColor; color: inherit; }
.tag--pending { background: var(--pending); border-color: var(--pending); color: var(--on-pending); }
.tag--confirmed { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tag--official { background: var(--official); border-color: var(--official); color: #fff; }

/* ピン。Apple マップのように、白い縁の丸に種類の一文字、下に名前。中心が地点。
   MapLibre が外側の要素の transform を使うので、拡大は内側の丸にかける。詳細を開いているピンは大きくして前に出す */
.pin { width: 44px; height: 44px; padding: 0; border: 0; background: none; display: flex; align-items: center; justify-content: center; }
.pin__shape {
  display: flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  border: 2px solid #fff; border-radius: 50%; font-size: 13px; font-weight: 600; line-height: 1;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.25);
}
.pin__name {
  position: absolute; top: 40px; left: 50%; transform: translateX(-50%);
  max-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11px; font-weight: 600; line-height: 14px; color: var(--fg);
  text-shadow: 0 0 2px var(--surface), 0 0 2px var(--surface), 0 0 3px var(--surface);
}
.pin--selected { z-index: 1; }
.pin--selected .pin__shape { transform: scale(1.25); }
.pin--confirmed .pin__shape { background: var(--accent); color: var(--on-accent); }
.pin--pending .pin__shape { background: var(--pending); color: var(--on-pending); }
.pin--official .pin__shape { background: var(--official); color: #fff; }
.pin--faded { opacity: 0.45; }
.pin--new .pin__shape { animation: pop 600ms var(--ease); }
@keyframes pop { from { transform: scale(0.2); opacity: 0; } }

/* デモの再生バー（ドックの中。知らせるボタンの代わりに出す） */
.replay { display: flex; gap: 8px; align-items: center; }
.replay__clock { min-width: 5ch; font-size: 20px; font-weight: 600; }
.replay input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--accent); }
.replay select { min-height: 44px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--fg); font: inherit; }
.me {
  width: 16px; height: 16px; border-radius: 50%; background: var(--me); border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgb(0 122 255 / 0.2), 0 1px 4px rgb(0 0 0 / 0.3);
}

/* シート（下から出る）と中央のダイアログ */
dialog { border: 0; padding: 0; color: var(--fg); background: var(--surface); }
dialog::backdrop { background: rgb(0 0 0 / 0.36); }
dialog.sheet { width: 100%; max-width: 640px; max-height: 85dvh; margin: auto auto 0; border-radius: 16px 16px 0 0; }
dialog.center { width: calc(100% - 32px); max-width: 480px; border-radius: 16px; }
/* 詳細はモーダルにしないので、自分で画面の下に固定する。ドックの上に重ねる */
#detail {
  position: fixed; z-index: 4; inset: auto 0 0; max-height: 60dvh; overflow-y: auto;
  box-shadow: 0 -4px 16px rgb(0 0 0 / 0.16);
}
#detail .close { z-index: 1; }
.sheet-body .detail__title { display: flex; align-items: center; gap: 8px; margin-right: 48px; }
.meta { color: var(--fg-2); font-size: 14px; }
.meta:empty { display: none; }
/* つまみ。下に引くとシートが閉じる（app.js） */
.grabber { height: 20px; touch-action: none; cursor: grab; }
.grabber::before {
  content: ""; display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px;
  background: var(--fg); opacity: 0.2;
}
.grabber + .close { top: 12px; }
.grabber ~ .sheet-body { padding-top: 8px; }
dialog.sheet { transition: transform 200ms var(--ease); }
dialog.sheet.dragging { transition: none; }
dialog[open] { animation: rise 300ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  dialog[open] { animation: none; }
  .chip, .round, .kind, .btn, .close, .pin__shape, dialog.sheet { transition: none; }
}
.sheet-body { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet-body h1 { margin: 0 0 12px; font-size: 24px; font-weight: 600; line-height: 1.25; }
.sheet-body h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.sheet-body p { margin: 0 0 8px; }
.sheet-body ul { margin: 0 0 8px; padding-left: 20px; color: var(--fg-2); }
.sheet-body li + li { margin-top: 8px; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); font-weight: 600;
}
.btn--primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn--danger { width: 100%; margin: 16px 0 4px; background: none; color: var(--danger); border-color: var(--danger); }
#consent-ok { width: 100%; margin-top: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin: 16px 0 0; }
label { display: block; margin: 16px 0 4px; font-size: 13px; color: var(--muted); }
textarea {
  width: 100%; padding: 8px 12px; font: inherit; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); resize: vertical;
}
.error { min-height: 16px; margin: 8px 0; color: var(--danger); font-size: 13px; }
.error:empty { display: none; }
.note { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); }
.note p { margin: 0; }
.link { flex: none; min-height: 44px; border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: 12px; }
.sheet-body details { padding: 8px 0; border-bottom: 1px solid var(--border); }
.sheet-body details p, .sheet-body details ul { margin-bottom: 8px; color: var(--fg-2); }
.sheet-body summary { display: flex; align-items: center; min-height: 44px; font-weight: 600; cursor: pointer; }
.credits { margin-top: 16px; font-size: 12px; line-height: 20px; color: var(--muted); }
.credits a { color: inherit; }
