/* ============================================================================
   Droga do Iron Train — dark desert theme
   ============================================================================ */

:root {
  --bg:        #0a0a0a;
  --bg-elev:   #141414;
  --bg-elev2:  #1c1c1c;
  --line:     rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --text:      #ededed;
  --text-dim:  #9a9a9a;
  --text-mute: #6c6c6c;
  --sand:      #d4a574;
  --sand-deep: #b8895a;
  --plane:     #4a9eff;
  --bus:       #f5a623;
  --pickup:    #e85d4f;
  --train:     #d4a574;
  --topbar-h:  84px;
  --sidebar-w: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ─── Topbar ────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(10,10,10,0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  max-width: 1800px;
  margin: 0 auto;
}

.title-block h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.title-block .subtitle {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: var(--sand);
  letter-spacing: 0.02em;
}

.counters {
  display: flex;
  gap: 24px;
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 0;
}
.counter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin-bottom: 2px;
}
.counter-value {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */

.layout {
  position: fixed;
  top: var(--topbar-h);
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px 18px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.sidebar-title {
  margin: 4px 4px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-mute);
}

.stages {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.stage {
  position: relative;
  padding: 12px 12px 14px 44px;
  margin-bottom: 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
  border: 1px solid transparent;
}
.stage:hover {
  background: var(--bg-elev2);
}
.stage.active {
  background: var(--bg-elev2);
  border-color: var(--line-strong);
}

.stage::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 18px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-elev2);
  border: 2px solid var(--text-mute);
  z-index: 2;
  transition: border-color 120ms ease, background 120ms ease;
}
.stage.visited::before {
  border-color: var(--sand);
  background: var(--sand);
}
.stage.active::before {
  border-color: var(--sand);
  background: var(--sand);
  box-shadow: 0 0 0 4px rgba(212,165,116,0.18);
}

/* connector line between stage dots */
.stage:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 32px;
  bottom: -8px;
  width: 2px;
  background: var(--line-strong);
  z-index: 1;
}
.stage.visited:not(:last-child)::after {
  background: var(--sand-deep);
}

.stage-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.stage-city {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.stage-date {
  font-size: 11px;
  color: var(--text-mute);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stage-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.stage-transport-icon {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stage-transport-icon svg {
  width: 100%; height: 100%;
}

.stage-vibe {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
  font-style: italic;
}

.final-note {
  margin: 18px 4px 0;
  padding: 12px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  font-size: 12px;
  color: var(--sand);
  text-align: center;
  letter-spacing: 0.02em;
}

/* ─── Map area ──────────────────────────────────────────────────────────── */

.map-wrap {
  position: relative;
  background: #050505;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

/* Override mapbox attribution for darkness */
.mapboxgl-ctrl-attrib {
  background: rgba(0,0,0,0.55) !important;
  color: var(--text-dim) !important;
}
.mapboxgl-ctrl-attrib a { color: var(--text-dim) !important; }

/* ─── Controls ──────────────────────────────────────────────────────────── */

.controls {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 5;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(20,20,20,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
  letter-spacing: 0.01em;
}
.btn:hover:not(:disabled) {
  background: rgba(40,40,40,0.92);
  border-color: var(--sand);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--sand);
  color: #1a1208;
  border-color: var(--sand);
}
.btn-primary:hover:not(:disabled) {
  background: #e2b687;
  border-color: #e2b687;
}

/* ─── Legend ────────────────────────────────────────────────────────────── */

.legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: rgba(20,20,20,0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  z-index: 5;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

/* ─── Custom markers ────────────────────────────────────────────────────── */

.marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--sand);
  border: 2px solid #0a0a0a;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.25), 0 2px 6px rgba(0,0,0,0.5);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.marker:hover {
  transform: scale(1.35);
}
.marker.active {
  transform: scale(1.45);
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px rgba(212,165,116,0.35), 0 2px 8px rgba(0,0,0,0.6);
}
.marker[data-transport="samolot"] { background: var(--plane); }
.marker[data-transport="autobus"] { background: var(--bus); }
.marker[data-transport="pickup"]  { background: var(--pickup); }
.marker[data-transport="pociąg"]  { background: var(--train); }

.marker-label {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 0 8px rgba(0,0,0,0.7);
  letter-spacing: 0.03em;
  pointer-events: none;
}

/* ─── Popup overrides ───────────────────────────────────────────────────── */

.mapboxgl-popup-content {
  background: rgba(18,18,18,0.96) !important;
  color: var(--text) !important;
  border: 1px solid var(--line-strong);
  border-radius: 12px !important;
  padding: 14px 16px 16px !important;
  font-family: inherit !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.55) !important;
  max-width: 280px;
}
.mapboxgl-popup-tip { display: none !important; }
.mapboxgl-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 22px !important;
  padding: 4px 10px !important;
}
.mapboxgl-popup-close-button:hover {
  background: transparent !important;
  color: var(--text) !important;
}

.popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.popup-city {
  font-size: 16px;
  font-weight: 600;
}
.popup-date {
  font-size: 12px;
  color: var(--sand);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  gap: 12px;
}
.popup-row strong {
  color: var(--text);
  font-weight: 500;
}
.popup-vibe {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  font-style: italic;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ─── Drawer toggle (mobile only) ───────────────────────────────────────── */

.drawer-toggle {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(20,20,20,0.92);
  backdrop-filter: blur(14px);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
}

/* ─── Responsive ────────────────────────────────────────────────────────── */

@media (max-width: 1023px) {
  :root { --topbar-h: 64px; }

  .topbar-inner { padding: 0 14px; gap: 8px; }
  .title-block h1 { font-size: 16px; }
  .title-block .subtitle { font-size: 11px; }
  .counters { gap: 14px; }
  .counter-value { font-size: 11px; }
  .counter-label { font-size: 9px; }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0; right: 0;
    bottom: 0;
    top: auto;
    height: 65vh;
    max-height: 65vh;
    border-right: none;
    border-top: 1px solid var(--line-strong);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 25;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.55);
  }
  .sidebar.open {
    transform: translateY(0);
  }

  .drawer-toggle { display: block; }

  .controls {
    bottom: 70px; /* leave space for drawer toggle */
    left: 12px;
  }
  .legend {
    bottom: 70px;
    right: 12px;
    font-size: 11px;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .counters { gap: 10px; }
  .counter:first-child { display: none; } /* hide distance on tiny screens, time matters more */
  .controls { flex-direction: column; }
  .btn { font-size: 12px; padding: 8px 10px; }
  .legend { display: none; } /* sufficient via marker colors */
}

/* ─── Loading state ─────────────────────────────────────────────────────── */

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 13px;
  z-index: 4;
  pointer-events: none;
}
.map-loading.hidden { display: none; }
