/* Mapa paczek terenu MSFS 2024 – oprawa jak redzikowski.com: ciepła czerń, płaskie złoto,
   Newsreader / Hanken Grotesk / JetBrains Mono (mono tylko dla danych technicznych). */
:root {
  --bg: #0c0b0a;
  --bg-soft: #100e0c;
  --bg-lift: #161311;
  --panel: rgba(255, 255, 255, .03);
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .17);
  --ink: #ede7dc;
  --muted: #a39c8e;
  --faint: #6f695e;
  --accent: #f0cc3f;
  --accent-ink: #14100a;
  --accent-soft: rgba(240, 204, 63, .14);
  --good: #5fd39a;
  --z0: #5fb88a;
  --z1: #f0cc3f;
  --z2: #f08a24;
  --z3: #ff5a4f;
  --radius: 10px;
  --font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --side: 400px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: var(--side) 1fr; height: 100dvh; }

/* ── panel boczny ───────────────────────────────────────────── */
.side { display: flex; flex-direction: column; min-height: 0; background: var(--bg-soft); border-right: 1px solid var(--line); position: relative; z-index: 2; }
.sheet-handle { display: none; }
.side-head { padding: 22px 22px 14px; }
.brand { font-family: var(--font-display); font-size: 17px; color: var(--ink); letter-spacing: .01em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: 31px; line-height: 1.08; margin: 14px 0 8px; letter-spacing: -.01em; }
h1 em { font-style: italic; color: var(--accent); }
.lead { margin: 0; color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.stats dt { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; }
.stats dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: 15px; color: var(--ink); }

.list-view, .detail-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.tools { padding: 4px 22px 10px; display: grid; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--bg-lift); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; transition: border-color .15s; }
.search:focus-within { border-color: var(--accent); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); font: inherit; padding: 10px 0; }
.search kbd { font-family: var(--font-mono); font-size: 11px; color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select { background: var(--bg-lift); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; font: inherit; font-size: 13px; }
select:focus { outline: 0; border-color: var(--accent); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-right: auto; cursor: pointer; }
.check input { accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--bg-lift); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; }
.seg button { background: none; border: 0; border-radius: 7px; padding: 5px 10px; font-size: 13px; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.count { margin: 0; padding: 0 22px 8px; font-size: 12px; color: var(--faint); }
.list { list-style: none; margin: 0; padding: 0 12px 16px; overflow-y: auto; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: var(--radius); padding: 10px 10px; transition: background .12s, border-color .12s; }
.item:hover, .item.hot { background: var(--panel); border-color: var(--line); }
.item.sel { background: var(--accent-soft); border-color: rgba(240, 204, 63, .45); }
.item b { font-weight: 600; font-size: 14.5px; }
.item .ver { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); align-self: center; }
.item .sub { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.badge { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink); }
.badge.soon { color: var(--faint); border-style: dashed; }
.empty { color: var(--muted); padding: 20px 12px; font-size: 14px; }

/* ── szczegóły paczki ───────────────────────────────────────── */
.detail-view { overflow-y: auto; padding: 0 22px 20px; scrollbar-width: thin; }
.back { align-self: flex-start; background: none; border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: 13px; color: var(--muted); margin: 2px 0 14px; }
.back:hover { color: var(--ink); border-color: var(--line-strong); }
.d-title { font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.1; margin: 0; }
.d-ver { font-family: var(--font-mono); font-size: 12px; color: var(--faint); margin-top: 6px; }
.d-summary { color: var(--muted); font-size: 14px; margin: 12px 0 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius); padding: 9px 14px; font-weight: 600; font-size: 14px; border: 1px solid var(--line-strong); background: var(--bg-lift); color: var(--ink); }
.btn:hover { text-decoration: none; border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.disabled { opacity: .55; pointer-events: none; }
.block { border-top: 1px solid var(--line); padding: 14px 0 4px; }
.block h3 { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13.5px; }
.bar i { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; display: block; }
.bar i span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar em { font-style: normal; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.res { display: flex; gap: 6px; flex-wrap: wrap; }
.res span { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.peaks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.peaks li { display: flex; justify-content: space-between; font-size: 14px; }
.peaks em { font-style: normal; font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; font-family: var(--font-mono); font-size: 12.5px; }

.side-foot { padding: 12px 22px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }

/* ── mapa ───────────────────────────────────────────────────── */
.map-wrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0f0e0c; }
.leaflet-container { font: inherit; background: #0f0e0c; }
.map-ui { position: absolute; left: 14px; right: 14px; display: flex; gap: 8px; align-items: center; pointer-events: none; z-index: 500; }
.map-ui > * { pointer-events: auto; }
.map-ui.top { top: 14px; justify-content: flex-end; }
.map-ui.bottom { bottom: 26px; }
.map-ui .seg, .chip, .legend { background: rgba(16, 14, 12, .88); backdrop-filter: blur(8px); border: 1px solid var(--line-strong); box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.chip { border-radius: var(--radius); padding: 6px 12px; font-size: 13px; color: var(--ink); }
.chip:hover { border-color: var(--ink); }
.legend { border-radius: var(--radius); padding: 8px 10px; display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.legend .t { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-right: 4px; }
.legend button { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid transparent; border-radius: 99px; padding: 3px 9px; font-size: 12.5px; color: var(--ink); }
.legend button:hover { border-color: var(--line-strong); }
.legend button.off { opacity: .4; }
.legend button.off .dot { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--muted); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--bg); z-index: 600; transition: opacity .3s; }
.loading.gone { opacity: 0; pointer-events: none; }

/* ciemny podkład: OSM odwrócone do ciepłej czerni (bez klucza API) */
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.78) contrast(.92) saturate(.35) sepia(.12); }
body[data-base="satellite"] .leaflet-container, body[data-base="streets"] .leaflet-container { background: #1a1815; }

.leaflet-control-zoom { border: 1px solid var(--line-strong) !important; box-shadow: 0 8px 24px rgba(0, 0, 0, .35) !important; }
.leaflet-control-zoom a { background: rgba(16, 14, 12, .9) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(12, 11, 10, .7) !important; color: var(--faint) !important; font-size: 10.5px; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip.tip { background: rgba(16, 14, 12, .95); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, .45); padding: 8px 11px; font: 13px/1.4 var(--font); }
.leaflet-tooltip.tip::before { display: none; }
.tip b { display: block; font-size: 14px; }
.tip span { color: var(--muted); font-size: 12px; }
.tip .go { color: var(--accent); }

/* ── telefon: lista jako wysuwany arkusz ─────────────────────── */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .map-wrap { position: fixed; inset: 0; }
  .side { position: fixed; left: 0; right: 0; bottom: 0; height: 46dvh; border-right: 0; border-top: 1px solid var(--line-strong); border-radius: 16px 16px 0 0; box-shadow: 0 -16px 40px rgba(0, 0, 0, .5); transition: height .25s ease; }
  .side.min { height: 96px; }
  .side.max { height: 88dvh; }
  .sheet-handle { display: grid; place-items: center; height: 22px; background: none; border: 0; flex: none; }
  .sheet-handle span { width: 42px; height: 4px; border-radius: 99px; background: var(--line-strong); }
  .side-head { padding: 0 16px 8px; }
  .side-head .brand, .side-head .lead { display: none; }
  h1 { font-size: 22px; margin: 2px 0 0; }
  .stats { display: none; }
  .tools, .count { padding-left: 16px; padding-right: 16px; }
  .detail-view { padding: 0 16px 16px; }
  .side-foot { display: none; }
  .map-ui.top { top: 10px; justify-content: space-between; }
  .map-ui .seg button { padding: 5px 8px; font-size: 12.5px; }
  .chip { padding: 6px 10px; font-size: 12.5px; }
  .map-ui.bottom { top: 54px; bottom: auto; }
  .legend .t { display: none; }
}
