/* Kresy.info — układ: skrócony hero → mapa (≈75%) + panel opcji (≈25%), mobile: szuflada. */

/* ---------- HERO skrócony ---------- */
.kp-root .kp-hero.kp-hero--compact{ padding:30px 28px 26px; }
.kp-root .kp-hero.kp-hero--compact h1{ font-size:clamp(26px,3.2vw,38px); margin:0 auto 10px; max-width:980px; }
.kp-root .kp-hero.kp-hero--compact .kp-lead{ font-size:16px; line-height:1.55; margin:0 auto 16px; max-width:760px; }

/* ---------- Sekcja mapy ---------- */
.kp-root .kp-mapx{
  --mx-gap:20px; --mx-h:clamp(520px, calc(100vh - 170px), 860px);
  display:grid; grid-template-columns:minmax(0,3fr) minmax(300px,1fr); gap:var(--mx-gap);
  padding:4px 28px 28px; align-items:start; position:relative;
}
.kp-root .kp-mapx-stage{ min-width:0; display:flex; flex-direction:column; gap:10px; }
.kp-root .kp-mapx-bar{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.kp-root .kp-mapx-title{ margin:0; font-size:15px; font-weight:700; letter-spacing:.4px; color:var(--kp-ink); display:flex; align-items:center; gap:8px; font-family:var(--kp-sans); }
.kp-root .kp-mapx-title .kp-ico{ color:var(--kp-burgundy); }
.kp-root .kp-mapx-count{ font-size:12px; color:var(--kp-ink-soft); font-variant-numeric:tabular-nums; }
.kp-root .kp-mapx-bar-actions{ margin-left:auto; display:flex; gap:8px; }
.kp-root .kp-mapx-chip{
  display:inline-flex; align-items:center; gap:6px; border:1px solid var(--kp-line); background:var(--kp-surface);
  color:var(--kp-ink); font:600 12px/1 var(--kp-sans); padding:9px 13px; border-radius:999px; cursor:pointer;
  transition:background-color .2s, border-color .2s, color .2s;
}
.kp-root .kp-mapx-chip:hover{ border-color:var(--kp-burgundy); color:var(--kp-burgundy); }
.kp-root .kp-mapx-chip .kp-ico{ width:14px; height:14px; }

.kp-root .kp-mapx-canvas{ position:relative; border-radius:14px; overflow:hidden; border:1px solid var(--kp-line); box-shadow:var(--kp-shadow); }
.kp-root .kp-mapx #kp-map{ height:var(--mx-h) !important; width:100%; border:0 !important; border-radius:0 !important; margin:0; box-shadow:none !important; }

/* stany mapy */
.kp-root .kp-mapx-status{
  position:absolute; left:50%; top:14px; transform:translate(-50%,-8px); z-index:800;
  display:flex; align-items:center; gap:10px; max-width:calc(100% - 120px);
  background:rgba(251,248,241,.96); border:1px solid var(--kp-line); color:var(--kp-ink);
  padding:9px 14px; border-radius:999px; font:600 13px/1.3 var(--kp-sans);
  box-shadow:0 6px 22px rgba(43,35,32,.14); opacity:0; pointer-events:none;
  transition:opacity .2s, transform .2s;
}
.kp-root .kp-mapx-status[data-state="loading"], .kp-root .kp-mapx-status[data-state="empty"], .kp-root .kp-mapx-status[data-state="error"]{ opacity:1; transform:translate(-50%,0); pointer-events:auto; }
.kp-root .kp-mapx-status[data-state="error"]{ background:#fbecee; border-color:#e7b9bf; color:#6d1c26; }
.kp-root .kp-mapx-spin{ width:16px; height:16px; border-radius:50%; border:2px solid var(--kp-gold-soft); border-top-color:var(--kp-burgundy); animation:kpmx-spin .8s linear infinite; display:none; flex:0 0 auto; }
.kp-root .kp-mapx-status[data-state="loading"] .kp-mapx-spin{ display:inline-block; }
.kp-root .kp-mapx-retry{ display:none; border:0; background:var(--kp-burgundy); color:#fff; font:700 12px/1 var(--kp-sans); padding:7px 12px; border-radius:999px; cursor:pointer; flex:0 0 auto; }
.kp-root .kp-mapx-status[data-state="error"] .kp-mapx-retry{ display:inline-block; }
@keyframes kpmx-spin{ to{ transform:rotate(360deg); } }

/* klastry */
.kp-cl{ display:flex !important; align-items:center; justify-content:center; border-radius:50%; color:#fff; font:700 12px/1 'Inter',system-ui,sans-serif; box-shadow:0 0 0 4px rgba(255,255,255,.55), 0 4px 12px rgba(43,35,32,.25); transition:transform .15s; }
.kp-cl:hover{ transform:scale(1.08); }
.kp-cl span{ white-space:nowrap; padding:0 4px; }
.kp-cl-blizsze{ background:rgba(74,131,71,.92); }
.kp-cl-dalsze{ background:rgba(138,42,122,.9); }
.kp-popup-approx{ margin:6px 0; padding:5px 8px; border-radius:6px; background:#f5e6c4; color:#7a5413; font-size:12px; font-weight:600; }
.kp-popup-links a{ display:inline-block; margin:2px 10px 2px 0; }
.kp-search-hit{ animation:kpmx-pulse 1.4s ease-out 3; }
@keyframes kpmx-pulse{ 0%{ stroke-width:3; } 50%{ stroke-width:10; stroke-opacity:.4; } 100%{ stroke-width:3; } }

/* ---------- Panel opcji ---------- */
.kp-root .kp-mapx-panel{
  position:sticky; top:84px; max-height:calc(var(--mx-h) + 46px); overflow:auto; overscroll-behavior:contain;
  background:var(--kp-surface); border:1px solid var(--kp-line); border-radius:14px; box-shadow:var(--kp-shadow);
  padding:6px 18px 18px; margin-top:46px; scrollbar-width:thin;
}
.kp-root .kp-mapx-panel-head{ display:none; }
.kp-root .kp-mapx-group{ padding:14px 0; border-bottom:1px solid var(--kp-line-soft); display:flex; flex-direction:column; gap:8px; }
.kp-root .kp-mapx-group:last-child{ border-bottom:0; }
.kp-root .kp-mapx-label{ font:700 11px/1.3 var(--kp-sans); letter-spacing:1.2px; text-transform:uppercase; color:var(--kp-ink-soft); }
.kp-root .kp-mapx-panel select, .kp-root .kp-mapx-panel input[type=search]{
  width:100%; box-sizing:border-box; padding:10px 12px; border:1px solid var(--kp-line); border-radius:10px;
  background:var(--kp-paper-3); color:var(--kp-ink); font:500 14px/1.2 var(--kp-sans);
}
.kp-root .kp-mapx-panel select:focus, .kp-root .kp-mapx-panel input:focus{ outline:none; box-shadow:var(--kp-focus); border-color:var(--kp-gold); }
.kp-root .kp-mapx-link{ align-self:flex-start; background:none; border:0; padding:2px 0; color:var(--kp-burgundy); font:600 12px var(--kp-sans); cursor:pointer; border-bottom:1px dashed var(--kp-gold-soft); }

/* przełączniki warstw */
.kp-root .kp-mapx-layer{ display:flex; align-items:center; gap:10px; cursor:pointer; padding:7px 8px; margin:0 -8px; border-radius:10px; transition:background-color .15s; }
.kp-root .kp-mapx-layer:hover{ background:var(--kp-paper-2); }
.kp-root .kp-mapx-layer input{ position:absolute; opacity:0; width:1px; height:1px; }
.kp-root .kp-mapx-sw{ flex:0 0 34px; height:20px; border-radius:999px; background:#d9cfbd; position:relative; transition:background-color .2s; }
.kp-root .kp-mapx-sw::after{ content:""; position:absolute; left:3px; top:3px; width:14px; height:14px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.25); transition:transform .2s; }
.kp-root .kp-mapx-layer input:checked + .kp-mapx-sw::after{ transform:translateX(14px); }
.kp-root .kp-mapx-layer input:focus-visible + .kp-mapx-sw{ box-shadow:var(--kp-focus); }
.kp-root .kp-mapx-layer.blizsze input:checked + .kp-mapx-sw{ background:#4a8347; }
.kp-root .kp-mapx-layer.dalsze input:checked + .kp-mapx-sw{ background:#8a2a7a; }
.kp-root .kp-mapx-layer.trails input:checked + .kp-mapx-sw{ background:var(--kp-blue); }
.kp-root .kp-mapx-layer.cities input:checked + .kp-mapx-sw{ background:var(--kp-burgundy); }
.kp-root .kp-mapx-layer.approx input:checked + .kp-mapx-sw{ background:var(--kp-gold); }
.kp-root .kp-mapx-ln{ flex:1; font:600 14px/1.25 var(--kp-sans); color:var(--kp-ink); }
.kp-root .kp-mapx-ln small{ display:block; font-weight:500; font-size:11.5px; color:var(--kp-ink-soft); margin-top:2px; }
.kp-root .kp-mapx-layer em{ font:700 11px var(--kp-sans); font-style:normal; color:var(--kp-ink-soft); font-variant-numeric:tabular-nums; }

/* wyszukiwarka */
.kp-root .kp-mapx-search{ position:relative; }
.kp-root .kp-mapx-results{ display:flex; flex-direction:column; gap:4px; margin-top:6px; max-height:260px; overflow:auto; }
.kp-root .kp-mapx-results:empty{ display:none; }
.kp-root .kp-mapx-hit{ text-align:left; border:1px solid var(--kp-line); background:var(--kp-paper-3); border-radius:10px; padding:8px 10px; cursor:pointer; font:500 13px/1.3 var(--kp-sans); color:var(--kp-ink); transition:border-color .15s, background-color .15s; }
.kp-root .kp-mapx-hit:hover{ border-color:var(--kp-gold); background:var(--kp-surface-2); }
.kp-root .kp-mapx-hit em{ color:#8a6d4b; }
.kp-root .kp-mapx-hit small{ display:block; color:var(--kp-ink-soft); font-size:11.5px; margin-top:2px; }
.kp-root .kp-mapx-noresult{ font-size:12.5px; color:var(--kp-ink-soft); padding:4px 2px; }

/* szlaki w panelu: jedna kolumna */
.kp-root .kp-mapx-panel .kp-legend{ grid-template-columns:1fr; gap:8px; margin-top:0; }
.kp-root .kp-mapx-panel .kp-legend-item{ padding:10px 12px; }
.kp-root .kp-mapx-panel .kp-trail-sub{ font-size:11.5px; }
.kp-root .kp-mapx-panel .kp-hydro{ margin-top:0; }
.kp-root .kp-mapx-panel .kp-hydro-desc{ font-size:12px; margin:0; }

/* legenda */
.kp-root .kp-mapx-legend{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; font:500 13px/1.3 var(--kp-sans); color:var(--kp-ink); }
.kp-root .kp-mapx-legend li{ display:flex; align-items:center; gap:10px; }
.kp-root .kp-mapx-legend i{ flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; font-style:normal; }
.kp-root .lg-dot{ width:12px; height:12px; border-radius:50%; border:1px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.08); }
.kp-root .lg-dot.blizsze{ background:#4a8347; }
.kp-root .lg-dot.dalsze{ background:#8a2a7a; }
.kp-root .lg-dot.approx{ background:rgba(74,131,71,.45); border:1.5px dashed #b88a3c; }
.kp-root .lg-cluster{ width:26px; height:26px; border-radius:50%; background:rgba(74,131,71,.92); color:#fff; font:700 10px var(--kp-sans) !important; }
.kp-root .lg-city{ width:12px; height:12px; border-radius:50%; background:#8a2632; border:2px solid #fff; box-shadow:0 0 0 1px rgba(0,0,0,.15); }
.kp-root .kp-mapx-src{ margin:6px 0 0; font-size:11.5px; color:var(--kp-ink-muted); line-height:1.5; }

.kp-root .kp-mapx-drawer-btn, .kp-root .kp-mapx-backdrop{ display:none; }

/* wyszukiwarka + tablica w jednym rzędzie pod mapą */
.kp-root .kp-row-mapsearch.kp-row-mapsearch--single{ grid-template-columns:minmax(0,1fr); }

/* ---------- Tablet ---------- */
@media (max-width:1180px){
  .kp-root .kp-mapx{ grid-template-columns:minmax(0,7fr) minmax(280px,3fr); padding:4px 22px 24px; }
}

/* ---------- Mobile: mapa pełny ekran + szuflada ---------- */
@media (max-width:900px){
  .kp-root .kp-hero.kp-hero--compact{ min-height:0 !important; padding:22px 18px 20px !important; margin:0 0 4px !important; justify-content:flex-start !important; }
  .kp-root .kp-hero.kp-hero--compact h1{ font-size:clamp(24px,7vw,32px) !important; margin:0 0 8px !important; }
  .kp-root .kp-hero.kp-hero--compact .kp-lead{ font-size:14.5px !important; margin:0 !important; }
  .kp-root .kp-hero.kp-hero--compact .kp-hero-buttons{ margin-top:14px !important; }

  .kp-root .kp-mapx{ display:block; padding:0 0 16px; --mx-h:calc(100svh - 150px); }
  .kp-root .kp-mapx-bar{ padding:10px 14px 0; }
  .kp-root .kp-mapx-bar-actions{ margin-left:0; width:100%; }
  .kp-root .kp-mapx-canvas{ border-radius:0; border-left:0; border-right:0; }
  .kp-root .kp-mapx #kp-map{ height:var(--mx-h) !important; min-height:420px; }
  .kp-root .kp-mapx-drawer-btn{
    display:inline-flex; align-items:center; gap:8px; position:absolute; top:12px; right:12px; z-index:801;
    border:0; border-radius:999px; padding:11px 16px; background:var(--kp-burgundy); color:#fff;
    font:700 13px/1 var(--kp-sans); box-shadow:0 8px 24px rgba(109,28,38,.35); cursor:pointer;
  }
  .kp-root .kp-mapx-drawer-btn .kp-ico{ width:16px; height:16px; color:#fff; }
  .kp-root .kp-mapx-status{ top:64px; max-width:calc(100% - 24px); }

  .kp-root .kp-mapx-panel{
    position:fixed; left:0; right:0; bottom:0; top:auto; z-index:10001; margin:0;
    max-height:82svh; border-radius:20px 20px 0 0; padding:0 18px calc(22px + env(safe-area-inset-bottom));
    transform:translateY(105%); transition:transform .28s cubic-bezier(.2,.8,.2,1); box-shadow:0 -12px 40px rgba(43,35,32,.25);
  }
  .kp-root .kp-mapx.kp-panel-open .kp-mapx-panel{ transform:translateY(0); }
  .kp-root .kp-mapx-panel-head{
    display:flex; align-items:center; justify-content:space-between; position:sticky; top:0; z-index:2;
    background:var(--kp-surface); padding:16px 0 10px; border-bottom:1px solid var(--kp-line); font:700 16px var(--kp-sans); color:var(--kp-ink);
  }
  .kp-root .kp-mapx-panel-head::before{ content:""; position:absolute; top:6px; left:50%; width:40px; height:4px; margin-left:-20px; border-radius:4px; background:var(--kp-line); }
  .kp-root .kp-mapx-close{ border:0; background:var(--kp-paper-2); width:34px; height:34px; border-radius:50%; font-size:22px; line-height:1; cursor:pointer; color:var(--kp-ink); }
  .kp-root .kp-mapx-backdrop{ display:block; position:fixed; inset:0; z-index:10000; background:rgba(20,14,10,.45); opacity:0; pointer-events:none; transition:opacity .25s; }
  .kp-root .kp-mapx.kp-panel-open .kp-mapx-backdrop{ opacity:1; pointer-events:auto; }
}

/* ciemny motyw */
.kp-root.kp-dark .kp-mapx-status{ background:rgba(30,24,18,.95); color:#f5efe2; }
.kp-root.kp-dark .kp-mapx-sw{ background:#5a4d3e; }

/* źródła pod mapą */
.kp-root .kp-mapx-sources{ font:500 12.5px/1.55 var(--kp-sans); color:var(--kp-ink-soft); padding:2px 2px 0; }
.kp-root .kp-mapx-sources summary{ cursor:pointer; list-style:none; }
.kp-root .kp-mapx-sources summary::-webkit-details-marker{ display:none; }
.kp-root .kp-mapx-sources summary::after{ content:" Pokaż wykaz źródeł ▾"; color:var(--kp-burgundy); font-weight:600; white-space:nowrap; }
.kp-root .kp-mapx-sources[open] summary::after{ content:" Zwiń ▴"; }
.kp-root .kp-mapx-sources p{ margin:8px 0 4px; }
.kp-root .kp-mapx-sources ul{ margin:0; padding-left:18px; }
.kp-root .kp-mapx-sources li{ margin:2px 0; }
@media (max-width:900px){ .kp-root .kp-mapx-sources{ padding:8px 14px 0; } }

/* WIG */
.kp-root .kp-mapx-layer.wig input:checked + .kp-mapx-sw{ background:#6b5a3a; }
.kp-root .kp-mapx-wig{ display:flex; flex-direction:column; gap:2px; padding:0 0 4px 44px; }
.kp-root .kp-mapx-wig input[type=range]{ width:100%; accent-color:#6b5a3a; }
.kp-root .kp-mapx-wig input[disabled]{ opacity:.4; }
.kp-root .kp-mapx-wig small{ font-size:11.5px; color:var(--kp-ink-soft); min-height:14px; }
.kp-wig-tile{ image-rendering:auto; }

/* v10.30 — źródła, stopień pewności, miejscowości nieistniejące */
.kp-cert{ display:inline-block; margin-left:6px; padding:1px 8px; border-radius:20px; border:1px solid; font-size:10px; font-weight:700; letter-spacing:.4px; text-transform:uppercase; vertical-align:middle; }
.kp-cert-confirmed{ background:#e6efe1; color:#2f5a2a; border-color:#c5dbbb; }
.kp-cert-probable{ background:#f3ecdc; color:#6b5320; border-color:#e2d3ae; }
.kp-cert-verify{ background:#f1eeea; color:#6e6559; border-color:#cfc6b9; border-style:dashed; }
.kp-popup-src{ margin:8px 0 6px; padding-top:6px; border-top:1px dashed #e4d7c2; font-size:12px; }
.kp-popup-src-h{ font-weight:700; color:#5a2a2a; margin-bottom:2px; }
.kp-popup-src ul{ margin:2px 0 0 16px; padding:0; }
.kp-popup-src li{ margin:1px 0; color:#4a4038; }
.kp-popup-gone{ display:inline-block; margin-left:6px; padding:1px 7px; border-radius:4px; background:#3d3730; color:#f2eee7; font-size:10px; font-weight:600; letter-spacing:.4px; text-transform:uppercase; vertical-align:middle; }
.kp-popup-fate{ margin:4px 0 6px; padding:5px 8px; border-left:3px solid #3d3730; background:#f4f1ec; color:#3d3730; font-size:12px; font-style:italic; }
.kp-mapx-certlegend{ display:grid; gap:6px; font-size:12px; color:#4a4038; }
.kp-mapx-certlegend > div{ display:flex; align-items:flex-start; gap:8px; }
.kp-mapx-certlegend .kp-cert{ margin-left:0; flex:0 0 auto; }
.kp-mapx-gone-dot{ display:inline-block; width:11px; height:11px; border-radius:50%; border:2px solid #3d3730; background:#f2eee7; flex:0 0 auto; margin-top:2px; }

/* ---------- v10.31: kliknięcie w mapę — panel regionu + najbliższe miejscowości ---------- */
.kp-root .kp-mapx-canvas .leaflet-container{ cursor:crosshair; }
.kp-root .kp-mapx-canvas .leaflet-interactive{ cursor:pointer; }
.kp-map-hint{ position:absolute; left:50%; bottom:18px; transform:translateX(-50%); z-index:700; pointer-events:none;
  background:rgba(43,35,32,.82); color:#fbf8f1; font:600 12px/1.3 'Inter',system-ui,sans-serif; padding:8px 14px; border-radius:999px;
  box-shadow:0 6px 18px rgba(43,35,32,.25); white-space:nowrap; animation:kpmx-hint-in .5s ease-out both .8s; }
@keyframes kpmx-hint-in{ from{ opacity:0; transform:translate(-50%,8px); } to{ opacity:1; transform:translate(-50%,0); } }
.kp-region{ position:absolute; left:14px; bottom:14px; z-index:750; width:340px; max-width:calc(100% - 28px); max-height:calc(100% - 100px); overflow:auto;
  background:rgba(251,248,241,.97); border:1px solid var(--kp-line,#e2d8c6); border-left:4px solid var(--kp-burgundy,#8a2632); border-radius:12px;
  box-shadow:0 14px 36px rgba(43,35,32,.22); padding:14px 16px 12px; font:13px/1.45 'Inter',system-ui,sans-serif; color:var(--kp-ink,#2b2320);
  animation:kpmx-region-in .28s ease-out both; }
@keyframes kpmx-region-in{ from{ opacity:0; transform:translateY(10px); } to{ opacity:1; transform:none; } }
.kp-region[hidden]{ display:none; }
.kp-region-head{ display:flex; align-items:flex-start; gap:10px; justify-content:space-between; }
.kp-region-head h3{ margin:2px 0 0; font:700 21px/1.15 'Cormorant Garamond',Georgia,serif; color:var(--kp-burgundy,#8a2632); }
.kp-region-kicker{ font-size:10.5px; font-weight:700; letter-spacing:.5px; text-transform:uppercase; color:var(--kp-ink-soft,#6e6559); }
.kp-region-close{ border:0; background:transparent; font-size:22px; line-height:1; cursor:pointer; color:var(--kp-ink-soft,#6e6559); padding:0 2px; transition:color .2s; }
.kp-region-close:hover{ color:var(--kp-burgundy,#8a2632); }
.kp-region-here{ margin:8px 0 0; padding:6px 9px; background:#f3ecdc; border-radius:8px; font-size:12px; }
.kp-region-here span{ font-weight:700; }
.kp-region-stats{ display:grid; grid-template-columns:repeat(auto-fit,minmax(68px,1fr)); gap:6px; margin:10px 0 8px; }
.kp-region-stats div{ background:#fff; border:1px solid var(--kp-line,#e2d8c6); border-radius:9px; padding:7px 8px; }
.kp-region-stats strong{ display:block; font-size:17px; font-variant-numeric:tabular-nums; }
.kp-region-stats span{ font-size:10.5px; color:var(--kp-ink-soft,#6e6559); }
.kp-region-cert{ display:flex; flex-wrap:wrap; gap:4px; }
.kp-region-cert .kp-cert{ margin-left:0; }
.kp-region-sec{ margin:10px 0 5px; font-size:10.5px; font-weight:700; letter-spacing:.5px; text-transform:uppercase; color:var(--kp-ink-soft,#6e6559); }
.kp-region-towns{ display:flex; flex-wrap:wrap; gap:5px; }
.kp-region-town{ border:1px solid var(--kp-line,#e2d8c6); background:#fff; border-radius:999px; padding:4px 10px; font:600 12px/1.2 'Inter',system-ui,sans-serif; cursor:pointer; color:var(--kp-ink,#2b2320); transition:border-color .2s, color .2s; }
.kp-region-town:hover{ border-color:var(--kp-burgundy,#8a2632); color:var(--kp-burgundy,#8a2632); }
.kp-region-pows{ margin-top:8px; font-size:12px; }
.kp-region-pows summary{ cursor:pointer; font-weight:600; }
.kp-region-pows p{ margin:6px 0 0; }
.kp-region-actions{ display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; }
.kp-near-list{ margin:6px 0 0; padding:0; list-style:none; max-height:260px; overflow:auto; }
.kp-near-hit{ display:block; width:100%; text-align:left; border:0; border-bottom:1px solid #eee4d3; background:transparent; padding:6px 2px; cursor:pointer; font:13px/1.3 'Inter',system-ui,sans-serif; color:inherit; transition:background-color .15s; }
.kp-near-hit:hover{ background:#f6f0e4; }
.kp-near-hit small{ display:block; color:#6e6559; font-size:11px; margin-top:1px; }
@media (max-width:640px){
  .kp-region{ left:8px; right:8px; bottom:8px; width:auto; max-width:none; max-height:38%; padding:10px 12px; }
  .kp-region-stats strong{ font-size:15px; }
  .kp-near-list{ max-height:170px; }
  .kp-map-hint{ white-space:normal; width:calc(100% - 40px); text-align:center; bottom:62px; }
}
