/* ==========================================================================
   Widoki terenowe (/b/, /evac/, /i/): wspólne komponenty.
   Telefon, rękawice, noc: cele dotyku min. 52 px, tekst bazowy 17 px.
   ========================================================================== */

.page {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(120px + env(safe-area-inset-bottom));
}

/* ── Pasek górny ──────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-bar);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}

.topbar .brand-mark { color: var(--accent-ink); height: 32px; margin-right: auto; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-ui) ease;
}
.icon-btn .ico { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(0.96); }

/* ── Nagłówek obiektu ─────────────────────────────────────────────────── */

.site-head { padding: 10px 0 18px; }

.site-head h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
}

.site-address {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  color: var(--ink-2);
  font-size: var(--fs-m);
}
.site-address .ico { width: 20px; height: 20px; margin-top: 2px; color: var(--ink-3); }
.site-address span { flex: 1; }

.here-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 6px 12px 6px 8px;
  border-radius: var(--r-m);
  background: var(--blue-wash);
  color: var(--blue-ink);
  font-size: var(--fs-m);
}
.here-chip .ico { width: 20px; height: 20px; }
.here-chip strong { font-family: var(--font-cond); font-weight: 700; }
.floor[aria-current="location"] { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }

.chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  color: var(--ink);
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: var(--fs-s);
  text-decoration: none;
  white-space: nowrap;
  background: var(--surface);
  transition: transform var(--t-press) var(--ease-out);
}
.chip-link .ico { width: 18px; height: 18px; color: var(--accent-ink); }
.chip-link:active { transform: scale(0.97); }

/* Pasek faktów: najważniejsze parametry w jednym rzędzie */
.facts {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 1px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--line);
  overflow: hidden;
}
@media (max-width: 479px) {
  .facts[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.fact {
  padding: 10px 10px 11px;
  min-width: 0;
  background: var(--surface);
}
.fact-value {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: var(--fs-xl);
  line-height: 1.05;
  overflow-wrap: break-word;
}
.fact--long .fact-value { font-size: var(--fs-l); line-height: 1.1; }
.fact-label {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  line-height: 1.2;
}

/* ── Tabliczki (podpis systemu: znak bezpieczeństwa w miniaturze) ─────── */

.plate {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--r-s);
  background: var(--red);
  color: var(--on-signal);
}
.plate .ico { width: 26px; height: 26px; stroke-width: 2; }
.plate--green { background: var(--green); }
.plate--blue { background: var(--blue); }
.plate--yellow { background: var(--yellow); color: var(--on-yellow); }
.plate--neutral { background: var(--surface-2); color: var(--ink-2); }

/* ── Grupy i wiersze ──────────────────────────────────────────────────── */

.group { margin-top: 22px; }

.group-title {
  margin: 0 2px 10px;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: var(--fs-l);
  color: var(--ink);
}

.list {
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--t-ui) ease;
}
.list > * + * { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.row--static { cursor: default; }
.row--static:active { background: none; }

.row-text { flex: 1; min-width: 0; }
.row-title {
  display: block;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: var(--fs-l);
  line-height: 1.15;
}
.row-sub {
  display: block;
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--fs-s);
  line-height: 1.3;
}
.row-end {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: var(--fs-s);
  white-space: nowrap;
}
.row-end .ico { width: 22px; height: 22px; }
.row-end strong {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: var(--fs-l);
  color: var(--ink);
}

/* Rozwijane sekcje: grid 0fr → 1fr, bez animowania height */
.disclosure > .row .chev { transition: transform var(--t-ui) var(--ease-out); }
.disclosure[data-open="true"] > .row .chev { transform: rotate(180deg); }
.disclosure-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-sheet) var(--ease-out);
}
.disclosure[data-open="true"] > .disclosure-body { grid-template-rows: 1fr; }
.disclosure-inner { overflow: hidden; min-height: 0; }
.disclosure-pad { padding: 4px 14px 16px; }

/* Wiersz danych (etykieta / wartość) */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-m);
}
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ── Przyciski ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-m);
  background: var(--accent);
  color: var(--on-signal);
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: var(--fs-l);
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-ui) ease;
}
.btn .ico { width: 22px; height: 22px; }
.btn:active { transform: scale(0.97); }
.btn--quiet {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn--small { min-height: 44px; font-size: var(--fs-m); padding: 0 14px; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ── Pasek akcji pod kciukiem ─────────────────────────────────────────── */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-bar);
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar .btn { flex: 1; min-width: 0; }
.actionbar .btn--call { flex: 2.2; justify-content: flex-start; gap: 12px; padding: 0 14px; }
.btn-call-text { display: grid; min-width: 0; text-align: left; line-height: 1.1; }
.btn-call-text b { font-weight: 700; }
.btn-call-text small {
  font-family: var(--font);
  font-weight: 500;
  font-size: var(--fs-xs);
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Komunikat na żywo ────────────────────────────────────────────────── */

.live {
  position: sticky;
  top: calc(60px + env(safe-area-inset-top));
  z-index: var(--z-banner);
  display: flex;
  gap: 12px;
  margin: 4px 0 6px;
  padding: 14px;
  border-radius: var(--r-l);
  background: var(--blue);
  color: var(--on-signal);
  box-shadow: var(--shadow-lift);
}
.live[hidden] { display: none; }
.live .ico { width: 26px; height: 26px; margin-top: 1px; }
.live-title { font-family: var(--font-cond); font-weight: 700; font-size: var(--fs-l); line-height: 1.15; }
.live-body { margin-top: 2px; font-size: var(--fs-m); }
.live--danger { background: var(--red); }
.live--warning { background: var(--yellow); color: var(--on-yellow); }
.live--success { background: var(--green); }
.live:not([hidden]) {
  transition: opacity var(--t-ui) ease, transform var(--t-sheet) var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(-8px); }
}

/* ── Stan: ładowanie, brak, offline ───────────────────────────────────── */

.skeleton { padding-top: 12px; }
.sk {
  border-radius: var(--r-m);
  background: linear-gradient(90deg, var(--surface-2) 0 40%, var(--line) 50%, var(--surface-2) 60% 100%);
  background-size: 300% 100%;
  animation: sk 1.4s ease infinite;
}
@keyframes sk { from { background-position: 100% 0; } to { background-position: 0 0; } }
.sk-title { height: 34px; width: 72%; }
.sk-line { height: 18px; width: 54%; margin-top: 12px; }
.sk-facts { height: 66px; margin-top: 18px; border-radius: var(--r-l); }
.sk-list { height: 210px; margin-top: 24px; border-radius: var(--r-l); }

.empty {
  padding: 56px 8px;
  text-align: center;
}
.empty .plate { width: 56px; height: 56px; margin-bottom: 16px; }
.empty h1 { font-size: var(--fs-xl); }
.empty p { margin: 8px auto 0; max-width: 34ch; color: var(--ink-2); }
.empty .btn { margin-top: 20px; }

.netstate {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: var(--r-m);
  background: var(--yellow-wash);
  color: var(--yellow-ink);
  font-size: var(--fs-s);
  font-weight: 500;
}
.netstate[hidden] { display: none; }
.netstate .ico { width: 18px; height: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: var(--z-toast);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--r-m);
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  transform: translateX(-50%);
  transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out);
  @starting-style { opacity: 0; transform: translate(-50%, 8px); }
}

/* ── Arkusz pełnoekranowy (plany, mapy lokalizacji) ───────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] {
  transition: opacity var(--t-ui) ease, transform var(--t-sheet) var(--ease-drawer);
  @starting-style { opacity: 0; transform: translateY(24px); }
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { font-size: var(--fs-l); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-title p { color: var(--ink-3); font-size: var(--fs-xs); }
.sheet-close { width: var(--tap); height: var(--tap); }

.sheet-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #E9ECEA;
  touch-action: none;
}
.sheet-stage > img,
.sheet-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  user-select: none;
  -webkit-user-drag: none;
}
.sheet-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #3F474C;
  text-align: center;
}

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-tabs {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.sheet-tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  min-width: 56px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-m);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: var(--fs-l);
  scroll-snap-align: center;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-signal);
}

.zoom-tools { display: flex; gap: 6px; }

/* ── Pinezki na planie ────────────────────────────────────────────────── */

.pin-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.pin {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: var(--r-s);
  background: var(--red);
  color: var(--on-signal);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.35);
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
}
.pin::after { content: ""; position: absolute; inset: -12px; } /* od pola wypełnienia: 28 + 24 = 52 px */
.pin .ico { width: 20px; height: 20px; }
.pin--yellow { background: var(--yellow); color: var(--on-yellow); }
.pin--green { background: var(--green); }
.pin--blue { background: var(--blue); }
.pin--neutral { background: #5B6469; }
.pin.is-active { outline: 3px solid #1B2023; outline-offset: 2px; }

.pin-here { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; will-change: transform; }
.pin-here--left { flex-direction: row-reverse; }
.pin-here-dot { width: 24px; height: 24px; border-radius: 50%; border: 4px solid #fff; background: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.pin-here-label {
  padding: 2px 8px;
  border-radius: var(--r-s);
  background: var(--blue);
  color: #fff;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: var(--fs-s);
  white-space: nowrap;
}

.pin-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-l);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  max-height: calc(50% - 24px); /* margines 12 px od krawędzi plus 12 px luzu: karta nie dochodzi do środka sceny */
  overflow: auto;
  overscroll-behavior: contain;
  transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(8px); }
}
.pin-card--top { top: 12px; bottom: auto; @starting-style { transform: translateY(-8px); } }
.pin-card.is-open { align-items: flex-start; touch-action: pan-y; }
.pin-card-close { width: var(--tap); height: var(--tap); }
.pin-card-text { flex: 1; min-width: 0; }
.pin-card-text[role="button"] { cursor: pointer; }
.pin-card-text strong { display: block; font-family: var(--font-cond); font-size: var(--fs-l); line-height: 1.15; }
.pin-card-text p {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--fs-s);
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pin-card.is-open .pin-card-text p { display: block; overflow: visible; }
.pin-card-photo {
  flex: none;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
  background: var(--surface-2);
  cursor: pointer;
}
.pin-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.pin-photo { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: rgb(10 12 14 / 0.92); overscroll-behavior: contain; }
.pin-photo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pin-photo button { position: absolute; top: 12px; right: 12px; }

@media (prefers-reduced-motion: reduce) {
  .pin-card, .pin-card--top { transition: opacity var(--t-ui) ease; @starting-style { opacity: 0; transform: none; } }
}

/* ── Stopka ───────────────────────────────────────────────────────────── */

.foot {
  margin-top: 36px;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  text-align: center;
}
.foot a { color: inherit; }

/* Ruch: tylko gdy użytkownik nie prosi o ograniczenie */
@media (prefers-reduced-motion: reduce) {
  .disclosure-body, .disclosure > .row .chev { transition: none; }
  .sheet[open] { transition: opacity var(--t-ui) ease; @starting-style { opacity: 0; transform: none; } }
  .live:not([hidden]) { transition: opacity var(--t-ui) ease; @starting-style { opacity: 0; transform: none; } }
  .sk { animation: none; }
}

@media (hover: hover) and (pointer: fine) {
  .row:not(.row--static):hover { background: var(--surface-2); }
  .icon-btn:hover { background: var(--surface-2); }
}
