/* Paleta i typografia z patecwariatec.pl — te same tokeny, ten sam zestaw fontów. */

@font-face {
  font-family: 'Supreme';
  src: url('fonts/supreme-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Supreme';
  src: url('fonts/supreme-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Gambarino';
  src: url('fonts/gambarino-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Satoshi';
  src: url('fonts/satoshi-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'RulerMono';
  src: url('fonts/spacemono-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  --ink: #222220;
  --surface: #fffcfa;
  --card: #f2efea;
  --sand: #d3c9ba;
  --muted: #6b6663;
  --travel: #e5ff0f;
  --danger: #b3261e;
  --radius: 4px;
  --sky: #92c0e9;
  --sans: 'Supreme', system-ui, sans-serif;
  --label: 'Satoshi', 'Supreme', system-ui, sans-serif;
  --serif: 'Gambarino', Georgia, serif;
  --mono: 'RulerMono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

/* Własne reguły z display: flex/grid biją domyślne chowanie przeglądarki,
   więc element z atrybutem hidden potrafił zostać widoczny. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; inset: 0; background: var(--card); }

/* Leaflet dociągnięty do palety */
.leaflet-container { background: var(--card); font-family: var(--sans); }
.leaflet-control-attribution,
.leaflet-control-layers {
  background: rgba(255, 252, 250, 0.92) !important;
  color: var(--muted) !important;
  border: 1px solid var(--sand) !important;
  border-radius: var(--radius);
  font-size: 10px;
}
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar { border-radius: var(--radius); overflow: hidden; box-shadow: 0 4px 12px rgba(34, 34, 32, 0.14); }
.leaflet-bar a {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--sand);
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 17px;
}
.leaflet-touch .leaflet-bar a { width: 34px; height: 34px; line-height: 34px; }
.leaflet-right .leaflet-control { margin-right: 12px; }
.leaflet-top .leaflet-control { margin-top: 12px; }
/* Kontrolki nad podpisem mapy, nie na nim */
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-bottom.leaflet-right .leaflet-control-layers { margin-bottom: 26px; }
.leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 26px; }
.leaflet-bar a:hover { background: var(--travel); color: var(--ink); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(34, 34, 32, 0.14);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-content b { font-weight: 700; }

/* Panel */
#panel {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 344px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  background: rgba(255, 252, 250, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(34, 34, 32, 0.13);
  z-index: 1000;
}

.panel-head { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
h2 {
  margin: 0 0 9px;
  font-family: var(--label);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
#device { margin: 4px 0 0; font-size: 12px; }

.pill {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: 1px solid var(--sand);
  color: var(--muted);
  white-space: nowrap;
}
.pill.live { background: var(--travel); border-color: var(--travel); color: var(--ink); }
.pill.stale { background: var(--card); border-color: var(--sand); color: var(--muted); }
.pill.sos { background: var(--danger); border-color: var(--danger); color: #fff; }

.alert {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  background: rgba(179, 38, 30, 0.08);
  border: 1px solid rgba(179, 38, 30, 0.35);
  color: var(--danger);
}

.last { margin-top: 18px; }
.last-time { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ago { font-family: var(--serif); font-size: 27px; line-height: 1; letter-spacing: -0.025em; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 16px 0 0; }
.grid dt {
  font-family: var(--label);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.grid dd { margin: 3px 0 0; font-size: 14px; font-weight: 700; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
  gap: 8px;
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--sand);
  border-bottom: 1px solid var(--sand);
  text-align: center;
}
.stats b { display: block; font-size: 15px; font-weight: 700; }
.stats span {
  font-family: var(--label);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.profile { margin-top: 18px; }
#profile svg { display: block; width: 100%; height: 74px; overflow: visible; }

.block { margin-top: 20px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
}
.list li:hover { border-color: var(--sand); }
.list li .meta { color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.list li.msg { flex-direction: column; gap: 4px; }
.list li.msg .meta { text-align: left; }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--sand);
}
#poll { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; }
.actions { display: flex; gap: 8px; align-items: center; }
button, .actions a {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--travel);
  background: var(--travel);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
button:hover, .actions a:hover { background: var(--ink); border-color: var(--ink); color: var(--travel); }
#scope { background: transparent; border-color: var(--sand); color: var(--muted); }
#scope:hover { background: var(--ink); border-color: var(--ink); color: var(--surface); }
button:disabled { opacity: 0.5; cursor: default; }
button:disabled:hover { background: var(--travel); color: var(--ink); }

#panelToggle {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 16px;
  background: var(--surface);
  border-radius: var(--radius);
}

/* Gdzie są */
.place { margin-top: 16px; }
.place-name {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.place-context {
  margin: 3px 0 0;
  font-family: var(--label);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.place-coords { margin: 6px 0 0; color: var(--muted); font-size: 11px; }

/* Pogoda */
.weather {
  margin: 14px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius);
  background: var(--card);
  font-size: 13px;
}
.weather b { font-weight: 700; }

/* Oś czasu */
.timeline {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(560px, calc(100vw - 40px));
  padding: 10px 14px;
  background: rgba(255, 252, 250, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--sand);
  border-radius: 100px;
  box-shadow: 0 12px 30px rgba(34, 34, 32, 0.16);
}
.timeline button { padding: 0; width: 32px; height: 32px; flex: none; font-size: 12px; line-height: 1; }
.timeline .live-btn { width: auto; padding: 0 12px; background: transparent; border-color: var(--sand); color: var(--muted); }
.timeline .live-btn:hover { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.timeline #scrubTime { flex: none; font-size: 11px; color: var(--muted); white-space: nowrap; }
.scrub-wrap { position: relative; flex: 1; min-width: 60px; display: flex; align-items: center; }
.scrub-wrap::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  border-radius: 2px;
  background: var(--sand);
}
.scrub-ticks {
  position: absolute;
  z-index: 1;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 10px;
  transform: translateY(-50%);
  pointer-events: none;
}
.scrub-ticks i {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--dot, var(--ink));
  opacity: 0.55;
}
.timeline input[type='range'] {
  flex: 1;
  min-width: 60px;
  position: relative;
  z-index: 2;
  appearance: none;
  height: 14px;
  background: transparent; /* linię rysuje .scrub-wrap::before, inaczej przykryłaby kropki */
  cursor: pointer;
}
.timeline input[type='range']::-webkit-slider-runnable-track { height: 14px; background: transparent; }
.timeline input[type='range']::-moz-range-track { height: 14px; background: transparent; }
.timeline input[type='range']::-webkit-slider-thumb {
  appearance: none;
  margin-top: -1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(34, 34, 32, 0.4);
}
.timeline input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
}

/* Dziennik wyprawy — na desktopie osobna kolumna po prawej, na telefonie
   dopisany pod danymi w tym samym arkuszu. */
.journal {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 320px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px;
  background: rgba(255, 252, 250, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(34, 34, 32, 0.13);
  z-index: 1000;
}
.embed .journal { top: 14px; right: 14px; max-height: calc(100vh - 28px); }
.journal-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

/* Wpisy jak rozmowa: awatar w kolorze osoby, bakiel po lewej, kolejne
   wiadomosci tej samej osoby sklejone w jeden blok. */
.journal-list li { display: flex; gap: 8px; align-items: flex-end; }
.journal-list li.laczony { margin-top: -6px; }

.journal-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dot, var(--ink));
  color: var(--surface);
  font-family: var(--label);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
/* Zdjecie zamiast inicjalu; obwodka w kolorze osoby zostaje, zeby dalo sie
   rozpoznac, kto pisze, nawet gdy zdjecia sa podobne. */
.journal-avatar.foto {
  background-size: cover;
  background-position: center;
  color: transparent;
  box-shadow: inset 0 0 0 2px var(--dot, var(--ink));
}
.journal-avatar i.foto { background-size: cover; background-position: center; }
.journal-avatar.duo { background: none; position: relative; }
.journal-avatar.duo i {
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}
.journal-avatar.duo i:first-child { left: 0; top: 0; }
.journal-avatar.duo i:last-child { right: 0; bottom: 0; }
.journal-avatar.pusty { visibility: hidden; }

.journal-body { min-width: 0; flex: 1; }
.journal-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 4px 2px;
}
.journal-head .who {
  font-family: var(--label);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.03em;
}
.journal-head .when { font-family: var(--mono); font-size: 10px; color: var(--muted); }

.journal-text {
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 9px 13px;
  background: var(--card);
  border-radius: 16px 16px 16px 5px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.journal-list li.laczony .journal-text { border-radius: 5px 16px 16px 5px; }

/* Przełącznik osób */
.people { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.people button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 9px;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  background: transparent;
  border-color: var(--sand);
  color: var(--muted);
}
.people button:hover { background: var(--travel); border-color: var(--travel); color: var(--ink); }
.people button.waiting { opacity: 0.55; border-style: dashed; }
.people button.waiting:hover { background: transparent; border-color: var(--sand); color: var(--muted); }
.people button[aria-pressed='true'] {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--card);
}
.people button[aria-pressed='true']:hover { background: var(--travel); border-color: var(--travel); }
.people .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.people .name { font-weight: 700; }
.people .when { font-family: var(--mono); font-size: 10px; }
.people button.sos { border-color: var(--danger); color: var(--danger); }

/* Plan trasy */
.plan-camp {
  width: 14px;
  height: 14px;
  background: #6d4aa8;
  border: 2px solid var(--surface);
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 2px 6px rgba(34, 34, 32, 0.35);
}
.plan-peak {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 10px solid #6d4aa8;
  filter: drop-shadow(0 0 1.5px var(--surface)) drop-shadow(0 1px 2px rgba(34, 34, 32, 0.4));
}
.leaflet-tooltip.plan-label {
  padding: 2px 7px;
  background: var(--surface);
  color: #4b3277;
  border: 1px solid #6d4aa8;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 700;
  box-shadow: 0 3px 9px rgba(34, 34, 32, 0.16);
  white-space: nowrap;
}
.leaflet-tooltip.plan-label::before { display: none; }

/* Podpisy osób przy markerach */
.leaflet-tooltip.name-label {
  padding: 3px 9px;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--dot, var(--ink));
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(34, 34, 32, 0.16);
  white-space: nowrap;
}
.leaflet-tooltip.name-label::before { display: none; }
.leaflet-tooltip.name-label.focused { background: var(--dot, var(--ink)); color: var(--surface); }

/* Marker ostatniej pozycji — wypełnienie w kolorze osoby, puls w limonce */
.live-dot { position: relative; }
.live-dot::before,
.live-dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; }
.live-dot::before {
  background: var(--dot, var(--ink));
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--dot, var(--ink));
}
.live-dot::after {
  border: 2px solid var(--travel);
  animation: pulse 2.4s ease-out infinite;
}
.live-dot.sos::before { background: var(--danger); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--danger); }
.live-dot.sos::after { border-color: var(--danger); }
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.95; }
  100% { transform: scale(4.5); opacity: 0; }
}

/* Tryb osadzenia — tytuł i urządzenie zostawiamy stronie-gospodarzowi */
.embed h1,
.embed #device { display: none; }
.embed .panel-head { justify-content: flex-start; }
.embed #panel { padding: 16px; top: 14px; left: 14px; max-height: calc(100vh - 28px); }
.embed .people { margin-top: 12px; }  /* bez tytułu chipy dotykały plakietki statusu */
.embed #panelToggle { top: 14px; left: 14px; }

/* Niska ramka — zbijamy rytm pionowy, żeby zmieściło się bez przewijania */
@media (max-height: 760px) {
  #panel { padding: 16px; gap: 0; }
  .last { margin-top: 12px; }
  .grid { gap: 9px 14px; margin-top: 12px; }
  .stats { margin-top: 12px; padding: 11px 0; }
  .profile, .block { margin-top: 13px; }
  #profile svg { height: 58px; }
  .panel-foot { margin-top: 13px; padding-top: 10px; }
  .ago { font-size: 23px; }
  h1 { font-size: 22px; }
}

/* Tablet i wąskie okna — panel nie może zjadać połowy kadru */
@media (min-width: 721px) and (max-width: 900px) {
  #panel { width: 300px; padding: 16px; }
  .grid { grid-template-columns: 1fr; gap: 8px; }
  .grid > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .grid dd { margin: 0; }
}

@media (max-width: 720px) {
  .embed #panel, #panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 46vh;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  #panel[hidden] { display: none; }
  #panelToggle { display: block; }
  /* Na telefonie dziennik nie jest osobną kolumną, tylko dalszą częścią arkusza */
  #journalSlot .journal, .embed #journalSlot .journal {
    position: static;
    width: auto;
    max-height: none;
    margin-top: 20px;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }
  /* Oś czasu nad arkuszem z danymi, żeby nie zasłaniała go ani nie chowała się pod nim */
  .timeline { bottom: calc(46vh + 14px); width: calc(100vw - 28px); padding: 8px 10px; gap: 8px; }
  #panel[hidden] ~ .timeline { bottom: 20px; }
}
