/*
 * デモ 6 枚で共有する画面の枠。**地図のスタイルではない。**
 *
 * `DESIGN.md` §1 が「決めない」と書いている領域（デモサイトの装飾）なので、
 * ここは AI が決めてよい。**地図の配色には触らない。**
 *
 * 色は `styles/modern-dark.json` にある値を借りている。
 * デモだけ別の色を持つと、地図と枠が別々の地図に見える。
 */
:root {
  color-scheme: dark;

  /* すべて styles/modern-dark.json から借りた値。**新しい色を作っていない** */
  --bg: #14161a;          /* label の halo 側。枠と地図を分ける一段暗い色 */
  --panel: #1b1f24;       /* 地図の background / earth */
  --line: #2e343b;        /* roads-minor */
  --text: #d8dce1;        /* label-place-city */
  --muted: #aab2bc;       /* label-place-neighbourhood */
  --code: #1e252a;        /* landcover */
}

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

body {
  /* **決め打ちの inset を使わない。**
   * 以前は地図を `position:absolute; inset:5.5rem 0 0` で置いていたため、
   * ヘッダが折り返すと**地図が文字に被った**（実測: 幅 390px で 39px 被り）。
   * 行の高さは中身が決める。数字を書かない。 */
  display: grid;
  grid-template-rows: auto 1fr;
  /* 100vh はモバイルのアドレスバーで跳ねる */
  min-height: 100dvh;

  background: var(--bg);
  color: var(--text);
  font: 14px/1.7 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

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

.site-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.site-header h1 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
  /* 見出しの最終行に 1 語だけ残るのを防ぐ */
  text-wrap: balance;
}

.site-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  /* 読み幅を抑える。長い日本語が画面幅いっぱいに伸びると行を追いにくい */
  max-width: 68ch;
  text-wrap: pretty;
}

.site-header code,
.notice code {
  background: var(--code);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* --- ページ間の行き来 --------------------------------------------------- */

/* **各ページが相互にリンクしていなかった。**公開サイトの訪問者は index しか辿れず、
 * 他のページがあることを知る手段が無かった。 */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0;
  border-bottom: 1px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
}

.site-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--line);
}

/* いまどこにいるかを示す。**示さないと、押しても何も起きなかったように見える** */
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--text);
}

.site-nav a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 2px;
}

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

/* grid の行は既定で中身より小さくならない。0 を許さないと地図が画面から溢れる */
.map-area {
  min-height: 0;
  position: relative;
}

mmj-map,
#map {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- 配信元が無いときの案内 ---------------------------------------------- */

.notice {
  display: grid;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
  color: var(--text);
}

/* `hidden` を CSS で殺さない。display を書いた時点で UA スタイルの
 * [hidden]{display:none} に勝ち、**地図が出ていても案内が被り続ける**
 * （実際にそうなっていた）。 */
.notice[hidden] {
  display: none;
}

.notice .box {
  max-width: 34rem;
}

.notice h2 {
  font-size: 1.25rem;
  margin: 0 0 0.75rem;
  text-wrap: balance;
}

.notice p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  text-wrap: pretty;
}

.notice a {
  color: var(--text);
}

/* --- 押した点の表示（cluster / poi） -------------------------------------- */

.picked {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
}

.picked[hidden] {
  display: none;
}

/* --- 配色を見くらべる（themes.html） -------------------------------------- */

/* 全部を同時に出す。**並べないと比べられない。**
 * 1 枚ずつ切り替える作りにすると、前の色を記憶で比べることになる。 */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  /* 枠線ではなく隙間の地色で区切る。線を引くと 1 枚ずつに額縁が付いて見える */
  gap: 1px;
  background: var(--line);
  height: 100%;
  min-height: 0;
  /* 列が減ると行が増える。**1 枚が潰れるくらいなら縦に溢れさせて送る** */
  grid-auto-rows: minmax(14rem, 1fr);
  overflow-y: auto;
}

.theme-cell {
  position: relative;
  margin: 0;
  min-height: 0;
  overflow: hidden;
}

/* 名前は地図の上に重ねる。行を分けると、地図の高さが 4 枚バラバラになる */
.theme-cell figcaption {
  position: absolute;
  left: 0.5rem;
  top: 0.5rem;
  z-index: 1;
  display: grid;
  gap: 0.1rem;
  max-width: calc(100% - 4.5rem);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  /* 下の地図は 4 枚とも色が違う。**どの色の上でも読めるよう、枠側は固定の暗色**
   * （地図の色を借りると、light の上で白文字が消える） */
  background: rgb(20 22 26 / 88%);
  color: #d8dce1;
  font-size: 0.8rem;
  line-height: 1.5;
}

.theme-cell figcaption span {
  color: var(--muted);
}

.theme-cell figcaption code {
  color: var(--muted);
  font-size: 0.75rem;
}

/* 横に 2 枚ずつ置くと、狭い画面では 1 枚が指の幅ほどになる */
@media (max-width: 1100px) {
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {
  .theme-grid {
    grid-template-columns: 1fr;
  }
}

/* --- サイトの色を当てる（brand.html） ------------------------------------- */

.brand-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.85rem;
}

.brand-bar[hidden] {
  display: none;
}

.brand-bar label {
  color: var(--muted);
}

.brand-bar input[type="color"] {
  /* 既定の見た目は OS ごとに違う。**枠だけ揃えて、中身は OS に任せる** */
  inline-size: 3rem;
  block-size: 1.9rem;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
}

.brand-bar select {
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.brand-samples {
  display: flex;
  gap: 0.35rem;
}

.brand-samples button {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 160ms ease;
}

.brand-samples button:hover {
  transform: scale(1.12);
}

.brand-samples button:active {
  transform: scale(0.96);
}

.brand-samples button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* そのまま貼れる 1 行。**見せないと「どう書くのか」が伝わらない** */
.brand-snippet {
  flex: 1 1 22rem;
  min-inline-size: 0;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  background: var(--code);
  color: var(--muted);
}

.brand-map {
  min-height: 0;
  block-size: 100%;
}

