/* =========================================================================
 * style.css — 院内ナビ
 * デザイン方針: 病院のウェイファインディング・サイン(案内標識)の語彙を借りる。
 *  - フロアチップ = エレベーターのボタン(円形・太字・高コントラスト)
 *  - 案内バー     = 濃色地に琥珀色アクセントのサインボード
 *  - それ以外は静かに: 白いカード、深緑のプライマリ、システムフォント
 * ========================================================================= */

:root {
  --ink: #14231f;          /* サインボードの濃緑黒 */
  --paper: #f4f6f5;
  --card: #ffffff;
  --brand: #0e6b5a;        /* 深緑(案内サインの基調色) */
  --brand-strong: #0a5445;
  --accent: #f4a300;       /* 琥珀(順路矢印の色) */
  --line: #d9e2df;
  --muted: #5b6b66;
  --danger: #b3372a;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(16, 40, 34, .14);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-size: 16px;
}

* { box-sizing: border-box; }
/* hidden 属性を最優先で無効化。
 * .loading / .guide などが display:flex を持つと UA の [hidden]{display:none} に
 * 勝ってしまい、element.hidden=true にしても消えなくなるため明示的に上書きする。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- ヘッダー ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  background: var(--brand); color: #fff;
}
.topbar__title { font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; }
.topbar__actions { display: flex; gap: 6px; }
.chipbtn {
  border: 1.5px solid rgba(255,255,255,.55); background: transparent;
  color: #fff; border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-size: .8rem; min-height: 34px;
}
.chipbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--ink); }

/* ---------- ステージ ---------- */
.stage { position: relative; flex: 1; min-height: 0; background: #0b1512; }
#showcase { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(11,21,18,.92); color: #dfe9e6; text-align: center; padding: 24px;
  z-index: 55;   /* 接続中/接続失敗時はマップ(30)や管理パネル(50)より前面 */
}
.loading__spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- マップ ---------- */
.minimap {
  position: absolute; top: 10px; right: 10px;
  background: rgba(255,255,255,.94); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px; z-index: 30;
}
.minimap canvas {
  display: block; width: 190px; height: 190px; border-radius: 10px;
  background: #eef3f1; touch-action: none; cursor: grab;
}
/* 拡大表示(Googleマップ風の全面マップ) */
.minimap--full { inset: 10px; width: auto; height: auto; display: flex; }
.minimap--full canvas { width: 100%; height: 100%; flex: 1; }

.minimap__ctrls {
  position: absolute; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.mapbtn {
  width: 34px; height: 34px; border-radius: 9px; padding: 0;
  border: 1px solid var(--line); background: rgba(255,255,255,.96);
  color: var(--ink); font-weight: 800; font-size: 1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(16,40,34,.18);
}
.mapbtn:active { background: var(--paper); }

.minimap__floors {
  position: absolute; top: 12px; left: 12px;
  display: flex; flex-direction: column; gap: 4px;
  max-height: calc(100% - 24px); overflow-y: auto;
}
.mapfloor {
  min-width: 32px; height: 28px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,.96); color: var(--ink);
  font-weight: 800; font-size: .72rem;
  box-shadow: 0 2px 8px rgba(16,40,34,.14);
}
.mapfloor[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.minimap__banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 8px 8px 8px 14px; font-size: .82rem; font-weight: 700;
  box-shadow: var(--shadow); z-index: 2;
  max-width: calc(100% - 110px); white-space: nowrap;
}
.minimap__banner span { overflow: hidden; text-overflow: ellipsis; }
.minimap__bannerX {
  border: 0; background: rgba(255,255,255,.18); color: #fff;
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  font-size: 1rem; line-height: 1; padding: 0;
}

/* 経路概要バー(全面マップ下部。Googleマップの経路確認→開始と同じ配置) */
.minimap__routebar {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px; z-index: 3;
}
.minimap__routeinfo { flex: 1; min-width: 0; }
.minimap__routedest {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: .95rem; white-space: nowrap; overflow: hidden;
}
.minimap__routedestName { overflow: hidden; text-overflow: ellipsis; }
.minimap__routemeta { color: var(--muted); font-size: .8rem; font-weight: 700; margin-top: 3px; }
.minimap__routebar .btn--primary { flex: none; min-height: 44px; padding: 0 16px; }
.minimap__routeX { background: var(--paper); color: var(--muted); }
@media (max-height: 520px) {
  /* 低い横画面では右上のマップボタン列が経路バーの高さまで届くため、右端を空ける */
  .minimap__routebar { right: 56px; }
}

.mappick {
  position: absolute; z-index: 3; width: 190px;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  padding: 10px;
}
.mappick__name {
  font-weight: 800; font-size: .85rem; margin: 0 2px 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mappick .btn { display: block; width: 100%; margin-top: 6px; }

/* ---------- タグ選択アクション(3Dビュー内のタグ→出発地/目的地) ---------- */
.tagprompt {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 14px; z-index: 35;   /* マップ(30)より前、案内バー(40)より後ろ */
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px;
  max-width: calc(100% - 24px);
}
.tagprompt__name {
  font-weight: 800; font-size: .92rem; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tagprompt__btns { display: flex; gap: 8px; flex: none; }
.tagprompt__x { background: var(--paper); color: var(--muted); flex: none; }

/* ---------- フロアチップ(エレベーターボタン風) ---------- */
.floorchip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 6px;
  border: 2.5px solid var(--brand); border-radius: 50%;
  color: var(--brand); font-weight: 800; font-size: .85rem;
  background: #fff; flex: none;
}
.floorchip--onDark { border-color: var(--accent); color: var(--accent); background: transparent; }
.floorchip--sm { min-width: 26px; height: 26px; border-width: 2px; font-size: .7rem; }

/* ---------- 目的地シート ---------- */
.sheet {
  background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 24px rgba(16,40,34,.14);
  max-height: 42vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet__grip {
  width: 44px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 8px auto 4px;
}
.sheet__search { padding: 6px 14px 10px; }
.sheet__search input {
  width: 100%; min-height: 46px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--paper);
  padding: 0 14px; font-size: 1rem;
}
.destlist { overflow-y: auto; padding: 0 8px 12px; }
.destlist__group {
  font-size: .74rem; font-weight: 800; color: var(--muted);
  letter-spacing: .08em; padding: 10px 10px 4px;
}
.destitem {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; text-align: left;
  padding: 11px 10px; border-radius: 12px; min-height: 52px;
}
.destitem:active { background: var(--paper); }
.destitem__name { font-weight: 700; font-size: .98rem; flex: 1; }
.destitem__arrow { color: var(--muted); font-weight: 800; }
.destlist__empty { color: var(--muted); text-align: center; padding: 18px; }

/* ---------- 目的地カード ---------- */
.card {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b));
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; z-index: 45; /* 案内バー(40)より前面 */
}
.card__close {
  position: absolute; top: 6px; right: 8px; border: 0; background: transparent;
  font-size: 1.5rem; color: var(--muted); width: 40px; height: 40px; z-index: 1;
}
.card__meta { color: var(--muted); font-size: .85rem; margin: 8px 0 12px; min-height: 1em; }

/* ---------- 出発地・目的地パネル(Googleマップ風) ---------- */
.route { display: flex; align-items: stretch; gap: 10px; padding-right: 30px; }
.route__rail {
  width: 14px; flex: none; display: flex; flex-direction: column;
  align-items: center; padding: 15px 0;
}
.route__railStart {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2.5px solid var(--ink); background: #fff; flex: none;
}
.route__railLine {
  flex: 1; width: 0; margin: 3px 0;
  border-left: 2px dotted var(--muted);
}
.route__railEnd {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); flex: none;
}
.route__fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.route__field {
  display: flex; align-items: center; gap: 8px; min-height: 44px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--paper); padding: 4px 10px; text-align: left;
}
.route__field:active { background: #eceff0; }
.route__fieldLabel {
  flex: none; width: 3.4em; font-size: .68rem; font-weight: 800;
  color: var(--muted); letter-spacing: .04em;
}
.route__fieldName {
  flex: 1; min-width: 0; font-weight: 700; font-size: .92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.route__swap {
  align-self: center; flex: none; width: 38px; height: 38px;
  border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
  font-size: 1.05rem; font-weight: 800; color: var(--brand); padding: 0;
}
.route__swap:active { background: var(--paper); }
.frommenu { display: flex; gap: 8px; margin-top: 8px; }
.frommenu .btn { flex: 1; }
.card__actions { display: flex; gap: 10px; }
.linkbtn {
  display: block; margin: 12px auto 0; border: 0; background: transparent;
  color: var(--brand); font-weight: 700; text-decoration: underline; font-size: .85rem;
}

/* ---------- ボタン ---------- */
.btn {
  border: 0; border-radius: 12px; font-weight: 800;
  min-height: 48px; padding: 0 18px; flex: 1;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:active { background: var(--brand-strong); }
.btn--ghost { background: #fff; border: 2px solid var(--brand); color: var(--brand); }
.btn--ghostDark { background: transparent; border: 1.5px solid rgba(255,255,255,.6); color: #fff; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { min-height: 38px; padding: 0 12px; font-size: .85rem; flex: none; }

/* ---------- 写真から現在地推定(photoloc) ---------- */
.photoloc {
  position: fixed; inset: 0; z-index: 60;           /* カード(45)より前面 */
  background: rgba(16, 40, 34, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.photoloc__panel {
  position: relative; width: 100%; max-width: 420px; max-height: 86vh;
  overflow-y: auto;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 16px 16px;
}
.photoloc__title { margin: 0 28px 10px 0; font-size: 1.05rem; font-weight: 800; }
.photoloc__note { margin: 0 0 12px; font-size: .88rem; line-height: 1.55; }
.photoloc__hint { margin: 10px 0 0; font-size: .74rem; color: var(--muted); text-align: center; }
.photoloc__take { display: block; width: 100%; }
.photoloc__bar {
  height: 8px; border-radius: 4px; background: var(--paper);
  border: 1px solid var(--line); overflow: hidden;
}
.photoloc__barfill { height: 100%; width: 0%; background: var(--brand); transition: width .3s ease; }
.photoloc__warn {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 10px;
  background: #fdf3e7; color: #8a5410; font-size: .84rem; font-weight: 700;
}
.photoloc__list { display: flex; flex-direction: column; gap: 8px; }
.photoloc__cand {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--paper); padding: 8px; text-align: left; min-height: 64px;
}
.photoloc__cand:active { background: #eceff0; }
.photoloc__thumb {
  width: 96px; height: 72px; object-fit: cover; border-radius: 8px; flex: none;
  background: var(--line);
}
.photoloc__candBody {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap;
}
.photoloc__candName { font-weight: 700; font-size: .9rem; min-width: 0; }
.photoloc__score { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.photoloc__retry { display: block; width: 100%; margin-top: 12px; }

/* ---------- 案内バー(サインボード) ---------- */
.guide {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + var(--safe-b));
  display: flex; align-items: stretch; gap: 12px;
  background: var(--ink); color: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px 12px 0; z-index: 40;
}
.guide__accent { width: 6px; border-radius: 6px 0 0 6px; background: var(--accent); flex: none; align-self: stretch; }
.guide__body { flex: 1; min-width: 0; padding-left: 2px; }
.guide__dest {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.02rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.guide__progress { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.guide__bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.22); overflow: hidden; }
.guide__barfill { height: 100%; width: 0%; background: var(--accent); transition: width .4s ease; }
#guideStats { font-variant-numeric: tabular-nums; font-size: .82rem; white-space: nowrap; }
.guide__notice { margin: 8px 0 0; font-size: .82rem; color: var(--accent); font-weight: 700; }
.guide__btns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  align-content: center; flex: none;
}
.guide__btns .btn--sm { padding: 0 10px; white-space: nowrap; }
.btn--ghostDark[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--ink);
}

/* ---------- 管理パネル ---------- */
.admin {
  position: absolute; top: 10px; left: 10px; width: min(320px, calc(100% - 20px));
  background: rgba(255,255,255,.97); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; z-index: 50;
  max-height: calc(100% - 20px); overflow-y: auto;
}
.admin__title { margin: 0 0 8px; font-size: .95rem; }
.admin__live { margin: 0; display: grid; gap: 4px; font-size: .78rem; }
.admin__live div { display: flex; gap: 8px; }
.admin__live dt { color: var(--muted); width: 82px; flex: none; }
.admin__live dd { margin: 0; word-break: break-all; font-family: ui-monospace, monospace; }
.admin__row { display: flex; gap: 8px; margin-top: 10px; }
.admin__row input {
  flex: 1; min-height: 38px; border-radius: 10px;
  border: 1.5px solid var(--line); padding: 0 10px;
}
.admin__list { margin: 10px 0 0; padding-left: 20px; font-size: .82rem; }
.admin__hint { font-size: .74rem; color: var(--muted); margin: 10px 0 0; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b));
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 10px 18px; font-size: .88rem; font-weight: 700;
  box-shadow: var(--shadow); z-index: 60; max-width: calc(100% - 32px);
}

/* ---------- モーション配慮 ---------- */
@media (prefers-reduced-motion: reduce) {
  .loading__spinner { animation: none; }
  .guide__barfill { transition: none; }
}

/* ---------- 大画面(タブレット/PC) ---------- */
@media (min-width: 760px) {
  .sheet { max-width: 420px; margin-left: auto; border-radius: 18px 0 0 0; }
  .card { left: auto; width: 400px; }
  .guide { left: auto; width: 480px; }
}
