/*
 * Карта в анкете пункта: отметка точки, «Моё место», ссылка 2ГИС.
 * Чей файл: исполнитель карты (js/geo.js).
 * Подключён в index.html после owner.css. Шторка карты — sheet({ size: 'map' })
 * из ui.js (вид шторки — в owner.css, здесь только содержимое карты).
 * Ловушка: maplibre ставит контейнеру .maplibregl-map { position: relative } —
 * размер карте задаёт обёртка (position:absolute; inset:0 у обёртки, 100% у карты).
 */

/* ── поле «Пункт на карте» ─────────────────────────────────────────────── */
.lead-form .fill-box.geo-box { display: block; height: auto; padding: 0; cursor: default; overflow: hidden; position: relative; background: var(--card); border-radius: 24px; box-shadow: none; }
.lead-form .fill-box.geo-box:focus-within { box-shadow: none; }
/* рамка ошибки поверх маленькой карты (inset-тень коробки карта бы закрыла) */
.lead-form .fill-box.geo-box::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 3; box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow .15s ease; }
.lead-form .fill-box.geo-box.err::after { box-shadow: inset 0 0 0 1.5px var(--red); }

.geo-empty { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 16px; text-align: left; color: #fff; background: transparent; border: 0; cursor: pointer; }
.geo-empty-ic { flex: none; width: 48px; height: 48px; border-radius: 14px; background: #3a3a3a; color: #fff; display: grid; place-items: center; }
.geo-empty-ic svg.i { width: 24px; height: 24px; }
.geo-empty-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.geo-empty-tx .t-b { font-weight: 600; }
.geo-empty .chev { flex: none; color: var(--chev); display: flex; }
.geo-empty .chev svg.i { width: 18px; height: 18px; }
.geo-empty:focus-visible, .geo-chg:focus-visible, .gis-paste:focus-visible, .gis-take-b:focus-visible { outline: 2px solid var(--lime); outline-offset: -2px; border-radius: 20px; }

/* маленькая карта: 168 px, неподвижная, метка по центру */
.geo-mini { position: relative; height: 168px; overflow: hidden; background: #e9e6e1; }
.geo-mini-map { width: 100%; height: 100%; }
.geo-mini canvas { outline: none; }
.geo-mini .geo-pin { width: 32px; height: 42px; top: 50%; }
.geo-mini.off { background: #3a3a3a radial-gradient(circle at 50% 50%, #444 0, #3a3a3a 70%); }
.geo-mini-xy { position: absolute; left: 12px; bottom: 10px; z-index: 2; font: 400 13px/18px var(--font); letter-spacing: -.08px; color: var(--grey); }

.geo-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 12px 10px 16px; }
.geo-ok { flex: none; color: var(--green); display: flex; }
.geo-ok svg.i { width: 22px; height: 22px; }
.geo-row-tx { flex: 1; min-width: 0; }
.geo-row-tx .t-c { overflow-wrap: anywhere; }
.geo-chg { flex: none; height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--card2); color: #fff; font: 600 15px/20px var(--font); letter-spacing: -.23px; cursor: pointer; }

/* метка-капля: остриё внизу — это точка */
.geo-pin { position: absolute; left: 50%; top: 50%; z-index: 2; width: 40px; height: 52px; transform: translate(-50%, -100%); pointer-events: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .45)); }
.geo-pin-svg { display: block; width: 100%; height: 100%; }
.geo-pin-dot { position: absolute; left: 50%; bottom: -2px; width: 8px; height: 4px; margin-left: -4px; border-radius: 50%; background: rgba(0, 0, 0, .35); }

/* ── поле «Ссылка на 2ГИС» ─────────────────────────────────────────────── */
.lead-form .gis-box { padding-right: 8px; }
.lead-form .gis-box .fill-input { font-size: 16px; }
.gis-paste { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 10px; border: 0; border-radius: 20px; background: var(--card2); color: #fff; font: 600 15px/20px var(--font); letter-spacing: -.23px; cursor: pointer; white-space: nowrap; }
.gis-paste svg.i { width: 20px; height: 20px; color: var(--grey); }
.lead-form .gis-f .fill-hint.ok { color: var(--green); }
.lead-form .gis-f .fill-hint.warn { color: var(--amber); }
.lead-form .gis-f .fill-hint.err { color: var(--red); }
.gis-take { margin: 10px 12px 0; }
.gis-take-b { height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--card2); color: #fff; font: 600 15px/20px var(--font); letter-spacing: -.23px; cursor: pointer; }
@media (max-width: 359px) {
  .gis-paste { padding: 0 12px; }
  .gis-paste svg.i { display: none; }
}

/* ── выбор точки: шторка size:'map' ───────────────────────────────────── */
.geo-pick { position: absolute; inset: 0; overflow: hidden; background: #e9e6e1; }
.geo-pick-map { width: 100%; height: 100%; }
.geo-pick .maplibregl-ctrl-attrib, .geo-pick .maplibregl-ctrl-bottom-right, .geo-pick .maplibregl-ctrl-bottom-left,
.geo-mini .maplibregl-ctrl-attrib, .geo-mini .maplibregl-ctrl-bottom-right, .geo-mini .maplibregl-ctrl-bottom-left { display: none !important; }

/* строка поиска справа от круглой «закрыть» (её ставит owner.css на safe-t + 6) */
.geo-search { position: absolute; z-index: 4; top: calc(var(--safe-t) + 6px); left: calc(16px + var(--safe-l) + 52px); right: calc(16px + var(--safe-r)); display: flex; align-items: center; gap: 4px; height: 44px; margin: 0; padding: 0 4px 0 16px; border-radius: 22px; background: var(--bg); box-shadow: 0 4px 16px rgba(0, 0, 0, .35); }
.geo-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; padding: 0; background: transparent; color: #fff; font: 400 16px/20px var(--font); letter-spacing: -.3px; caret-color: var(--lime); -webkit-appearance: none; appearance: none; }
.geo-search input::placeholder { color: var(--grey2); }
.geo-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.geo-search-go { flex: none; width: 36px; height: 36px; border: 0; border-radius: 18px; background: transparent; color: var(--grey); display: grid; place-items: center; cursor: pointer; }
.geo-search-go svg.i { width: 20px; height: 20px; }
.geo-search:focus-within { box-shadow: 0 4px 16px rgba(0, 0, 0, .35), inset 0 0 0 1.5px #5a5a5a; }

.geo-fab { position: absolute; z-index: 4; right: calc(16px + var(--safe-r)); bottom: 16px; width: 48px; height: 48px; border: 0; border-radius: 24px; background: var(--bg); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); cursor: pointer; }
.geo-fab svg.i { width: 24px; height: 24px; }
.geo-fab[aria-busy="true"] { opacity: .6; }
.geo-zoom { position: absolute; z-index: 4; right: 16px; top: 50%; transform: translateY(-50%); display: none; flex-direction: column; border-radius: 16px; overflow: hidden; background: var(--bg); box-shadow: 0 4px 16px rgba(0, 0, 0, .35); }
.geo-zoom button { width: 48px; height: 44px; border: 0; background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; }
.geo-zoom button + button { border-top: 1px solid #3a3a3a; }
.geo-zoom svg.i { width: 22px; height: 22px; }
.geo-pick.is-err .geo-search, .geo-pick.is-err .geo-fab, .geo-pick.is-err .geo-zoom, .geo-pick.is-err .geo-pin { display: none; }

/* «вы здесь» на светлой подложке, как n1-me */
.geo-me { width: 16px; height: 16px; border: 3px solid #1f1f1f; border-radius: 50%; background: #fff; box-shadow: 0 0 0 10px rgba(38, 38, 38, .16); }

/* карта не загрузилась */
/* z 4: круглая «закрыть» шторки (z 5) остаётся над слоем ошибки */
.geo-err { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: calc(var(--safe-t) + 64px) 24px 24px; background: var(--bg); text-align: center; }
.geo-err[hidden] { display: none; }
.geo-err-ic { color: var(--grey2); display: flex; margin-bottom: 6px; }
.geo-err-ic svg.i { width: 44px; height: 44px; }
.geo-err .btn { margin-top: 14px; }

/* низ шторки: что делать и главная кнопка */
.geo-foot { display: flex; flex-direction: column; }
/* подсказка всегда на две строки: низ шторки не меняет высоту при смене подсказки,
   иначе холст карты и метка расходятся (maplibre пропускает первый resize) */
.geo-foot-s { margin: 4px 0 14px; min-height: 40px; color: var(--grey); }
.geo-foot-s.warn { color: var(--amber); }
.geo-foot-b[hidden] { display: none; }
.geo-alt { display: flex; flex-direction: column; gap: 8px; }
.geo-foot .btn[disabled] { opacity: .45; }

@media (min-width: 1024px) {
  .geo-search { top: 16px; left: 16px; right: auto; width: min(440px, calc(100% - 120px)); }
  .geo-zoom { display: flex; }
  .geo-err { padding-top: 24px; }
  .geo-foot { flex-direction: row; align-items: center; gap: 20px; }
  .geo-foot-tx { flex: 1; min-width: 0; }
  .geo-foot-t { display: none; }
  .geo-foot-s { margin: 0; min-height: 20px; }
  .geo-foot .btn.wide { width: auto; min-width: 240px; padding: 0 28px; }
  .geo-alt { flex-direction: row; }
}

/* ── карточка заявки: карта над адресом ───────────────────────────────── */
.lead-card .geo-mini-card { height: 168px; }
.lead-card .geo-mini-card + .row::before { display: none; }
