/* 地図まわりの部品（フロア・部屋と人の一覧・施錠・十字キー・言語・地図の設定）と、見やすさ・スマホ・動きを減らす設定。
   style.css は触らず、ここで重ねる。色の組み合わせは test/a11y.test.js が計算で確かめる（下の --a11y- の物）。 */
:root {
  /* 文字の色（本文 4.5:1 以上）。ブランドのオレンジ #da532c は白地で 4.0:1 しかなく本文に使えない＝濃い色を別に持つ */
  --brand-text: #b4421f;
  --muted-strong: #4b5563;
  --focus-ring: #1d4ed8;
  --danger-text: #b91c1c;
  --lock-text: #92400e;
  --lock-bg: #fef3c7;
}

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* 注目の枠（キーボードで動かす人が今どこにいるか分かる）。ブラウザの既定に頼らず、必ず太く見せる */
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
#map:focus-visible { outline-offset: -3px; }

/* 文字の色の補正 */
.hint, .note, .room-help, .mic-note, .people .zone, .people .status-text, .feed time, .rec-info, .key-box summary, .acct-meta { color: var(--muted-strong); }
.join button, .room-box button.primary { background: var(--brand-text); border-color: var(--brand-text); }
.people .talking, .room-box a, .join h1 small { color: var(--brand-text); }
.join h1 small { border-color: var(--brand-text); }
.admin-box button.danger, .admin-box .bad { color: var(--danger-text); }

/* 言語の切り替え（入室の前から使える） */
.lang-toggle { position: fixed; top: 6px; right: 6px; z-index: 20; font: inherit; font-size: 12px; padding: 4px 10px; border: 1px solid var(--muted-strong); border-radius: 14px; background: #fff; color: var(--ink); cursor: pointer; }
.office .side { padding-top: 40px; }

/* フロアの切り替え */
.floor-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.floor-btn { font: inherit; font-size: 13px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.floor-btn.on { border-color: var(--brand-text); font-weight: 700; }
.floor-btn.on::before { content: "✓ "; } /* 今のフロア：色だけでなく印でも */

/* 部屋と人の一覧 */
.nav-box h2 { margin-top: 12px; }
.nav-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.nav-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.nav-list li.locked { border-left: 4px double var(--lock-text); padding-left: 6px; background: var(--lock-bg); }
.nav-list .room-name { font-weight: 600; }
.nav-list .room-meta { color: var(--muted-strong); font-size: 12px; margin-right: auto; }
.nav-list li.locked .room-meta { color: var(--lock-text); font-weight: 700; }
.nav-list li.locked .room-meta::before { content: "🔒 "; }
.act, .go-person { font: inherit; font-size: 12px; padding: 4px 10px; border: 1px solid var(--muted-strong); border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; }
.act:disabled { opacity: .6; cursor: default; }
.act.knock-in { border-color: var(--brand-text); }
.people .status-text { font-size: 11px; }
.people li { flex-wrap: wrap; }

/* タッチ用の十字キー（スマホ・タブレットだけ） */
.dpad { display: none; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 56px); gap: 6px; justify-content: center; margin: 10px auto 4px; touch-action: none; }
.dpad-btn { font: inherit; font-size: 20px; border: 2px solid var(--muted-strong); border-radius: 12px; background: #fff; color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.dpad-btn:active { background: var(--lock-bg); }
.dpad-ArrowUp { grid-column: 2; grid-row: 1; }
.dpad-ArrowLeft { grid-column: 1; grid-row: 2; }
.dpad-ArrowDown { grid-column: 2; grid-row: 2; }
.dpad-ArrowRight { grid-column: 3; grid-row: 2; }

/* 地図の設定（管理者） */
.map-admin .map-floor { border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; padding: 6px 8px; min-width: 0; }
.map-admin .map-row { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: flex-end; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.map-admin .field { display: grid; gap: 2px; font-size: 11px; color: var(--muted-strong); }
.map-admin .field.name input { width: 9em; }
.map-admin .field.num input { width: 5em; }
.map-admin input, .map-admin select { font: inherit; font-size: 13px; padding: 4px 6px; border: 1px solid var(--muted-strong); border-radius: 6px; }
.map-admin form, .map-admin .map-row { margin-top: 0; }
.map-admin .map-row button { font-size: 12px; }
.map-admin .reset { margin-top: 10px; }

/* 配置図（部屋の四角をドラッグで動かし、四隅で大きさを変える）。ポインタイベントで、マウスもタッチも同じ。指で動かす間はページを動かさない */
.map-edit { margin: 8px 0; display: grid; gap: 6px; }
.map-edit-svg { display: block; width: 100%; height: auto; max-height: 60vh; background: #fbfaf8; border: 1px solid var(--line); border-radius: 8px; touch-action: none; user-select: none; -webkit-user-select: none; }
.map-floor-bg { fill: #fbfaf8; }
.map-spawn { fill: var(--muted-strong); }
.map-label { fill: var(--ink); pointer-events: none; }
.map-zone { fill: #dbeafe; stroke: var(--focus-ring); stroke-width: 3; cursor: move; touch-action: none; }
.map-zone.work { fill: #e5e7eb; stroke: var(--muted-strong); }
.map-zone.reception { fill: #ffedd5; stroke: var(--brand-text); }
.map-zone.editing { stroke-dasharray: 14 8; } /* 保存前のプレビュー：色だけでなく破線でも */
.map-zone.bad { fill: #fee2e2; stroke: var(--danger-text); }
.map-handle { fill: #fff; stroke: var(--ink); stroke-width: 3; touch-action: none; }
.map-handle[data-mode="nw"], .map-handle[data-mode="se"] { cursor: nwse-resize; }
.map-handle[data-mode="ne"], .map-handle[data-mode="sw"] { cursor: nesw-resize; }
.map-edit-bar { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 12px; }
.map-edit-bar[hidden] { display: none; }
.map-edit-msg { flex: 1 1 100%; color: var(--ink); }
.map-edit-msg.bad { color: var(--danger-text); font-weight: 700; }

/* スマホ（360px から）：横にはみ出さない・押しやすい大きさ */
@media (max-width: 800px) {
  .office { grid-template-columns: minmax(0, 1fr); }
  .stage { padding: 8px; }
  .side { min-width: 0; padding: 40px 10px 14px; }
  .dpad { display: grid; }
  .controls { flex-wrap: wrap; }
  .join form { padding: 18px; }
  .join { padding: 8px; }
  .invite-box form, .admin-box form { grid-template-columns: minmax(0, 1fr); }
  .invite-list input, .invite-url { min-width: 0; }
  /* 通話の操作（マイク・状態・使い方・退室）は画面の下に固定＝地図を拡大して縦に長くなっても、常に指が届く。
     地図は自分の枠（.stage）の中で縦横にスクロールする（ページ全体は伸びない）。パソコンの幅（801px 以上）は変えない */
  .stage { max-height: 70vh; max-height: 70dvh; min-height: 220px; }
  .me .controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,.08); }
  .side { padding-bottom: 130px; } /* 固定の操作が最後の欄に重ならない余白（操作は2段に折れても約 110px） */
  .office ~ .notice-stack { bottom: 124px; } /* 知らせ（トースト・承認待ち）も固定の操作の上に出す */
}
@media (pointer: coarse) {
  .dpad { display: grid; }
  .act, .go-person, .floor-btn, .controls button, .controls select, .lang-toggle, .banner-button, .join button { min-height: 44px; }
  .act, .go-person { padding: 6px 12px; }
  /* 通知の「応じる」「あとで」、チャットの送信・タブ・宛先、機器の選択、通知の許可、会議から戻るなどの押す所も 44px 以上（docs/map.md の 5.） */
  .toast-actions button, .chat-form button, .chat-tab, #chat-dm-with, .device-panel select, .device-panel button, .notify-box button, #mic-wait-skip, #meeting-return-btn, #room-join, #room-clear { min-height: 44px; }
  #map { touch-action: manipulation; } /* タップで移動。ページの縦スクロールは邪魔しない */
}
@media (max-width: 400px) {
  .controls button, .controls select { flex: 1 1 auto; }
  .nav-list li { gap: 4px 6px; }
}

/* 地図の拡大・縮小（狭い画面で大きな地図を読む）。枠が横にスクロールしても、操作は左端に残る */
.map-zoom { position: sticky; left: 0; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; width: max-content; max-width: 100%; margin: 0 0 6px; }
.map-zoom[hidden] { display: none; }
.map-zoom button { font: inherit; font-size: 13px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--muted-strong); border-radius: 8px; background: #fff; color: var(--ink); cursor: pointer; }
.map-zoom button:disabled { opacity: .45; cursor: default; }

/* 動きを減らす設定：アニメーションと滑らかなスクロールを止める（地図の歩きは app.js 側で直接移動に切り替える） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
