* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --c-entry: #17a34a;
  --c-danger: #ef4444;
  --c-exit: #0d9488;
  --c-accent: #2e7cf6;
  --c-weir: #991b1b;
  --c-rental: #d97706;
  --c-river: #3ec1ff;
  --ink: #0f2436;
  --ink-soft: #51708a;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.55);
  --shadow: 0 8px 28px rgba(6, 24, 40, 0.22);
  --radius: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#map { position: fixed; inset: 0; z-index: 1; background: #0b1d2a; }

/* ---------- Glass surfaces ---------- */
#topbar, #locate-btn, #list-btn, #reset-btn, #poi-panel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ---------- Header ---------- */
#topbar {
  position: fixed;
  top: calc(10px + var(--sat));
  left: 12px;
  right: 12px;
  z-index: 1100;
  padding: 11px 14px 9px;
  border-radius: var(--radius);
}
#title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#title-row h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.15; }
#title-row p { font-size: 12px; font-weight: 500; color: #51708a; }

#lang-switch {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: rgba(15, 36, 54, 0.07);
  border-radius: 999px;
  flex-shrink: 0;
}
#lang-switch button {
  border: none;
  background: transparent;
  padding: 4px 9px;
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#lang-switch button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(6, 24, 40, 0.18);
}

#stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(15, 36, 54, 0.08);
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.stat b {
  font-size: 14px;
  font-weight: 700;
  color: #0c4a6e;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat span {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6d8aa1;
  white-space: nowrap;
}
.stat.warn b { color: #b91c1c; }

/* ---------- Floating buttons ---------- */
#locate-btn, #list-btn {
  position: fixed;
  z-index: 1100;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.12s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#locate-btn:active, #list-btn:active { transform: scale(0.94); }

#locate-btn {
  right: 12px;
  bottom: calc(96px + var(--sab));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#locate-btn svg { width: 24px; height: 24px; }
#locate-btn.active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

#list-btn {
  left: 12px;
  bottom: calc(96px + var(--sab));
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
}
#list-btn svg { width: 18px; height: 18px; }

/* Reset-view pill: appears once the user zooms in on a POI */
#reset-btn {
  position: fixed;
  z-index: 1100;
  left: 50%;
  bottom: calc(96px + var(--sab));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#reset-btn svg { width: 17px; height: 17px; }
#reset-btn:active { transform: translateX(-50%) scale(0.94); }
#reset-btn.hidden { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(8px); }

/* ---------- Bottom sheet ---------- */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 1150;
  background: rgba(8, 22, 36, 0.35);
  opacity: 1;
  transition: opacity 0.25s ease;
}
#sheet-backdrop.hidden { opacity: 0; pointer-events: none; }

#poi-panel {
  position: fixed;
  z-index: 1200;
  left: 0; right: 0; bottom: 0;
  max-height: 72%;
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  border-bottom: none;
  padding: 8px 18px calc(16px + var(--sab));
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
#poi-panel.hidden { transform: translateY(110%); box-shadow: none; }

#sheet-handle {
  width: 40px; height: 5px;
  background: rgba(15, 36, 54, 0.18);
  border-radius: 999px;
  margin: 6px auto 14px;
  cursor: pointer;
}
#poi-panel h2 {
  font-size: 12px;
  font-weight: 700;
  color: #51708a;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

#poi-list { list-style: none; }
#poi-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid rgba(15, 36, 54, 0.07);
  cursor: pointer;
  font-size: 15px;
  font-weight: 550;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
#poi-list li:last-child { border-bottom: none; }
#poi-list li:active { background: rgba(46, 124, 246, 0.07); border-radius: 10px; }

.li-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 11px;
  font-size: 16px;
}
.li-icon svg { width: 18px; height: 18px; }
.li-icon.entry { background: rgba(23, 163, 74, 0.13); color: var(--c-entry); }
.li-icon.danger { background: rgba(239, 68, 68, 0.13); color: var(--c-danger); }
.li-icon.exit { background: rgba(13, 148, 136, 0.13); color: var(--c-exit); }
.li-icon.weir { background: rgba(153, 27, 27, 0.15); color: var(--c-weir); }
.li-icon.rental { background: rgba(217, 119, 6, 0.14); color: var(--c-rental); }

.li-name { flex: 1; line-height: 1.3; }
.li-chevron { width: 16px; height: 16px; color: #9db2c2; flex-shrink: 0; }

.dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  flex-shrink: 0;
}
.dot.entry { background: var(--c-entry); }
.dot.danger { background: var(--c-danger); }
.dot.exit { background: var(--c-exit); }
.dot.weir { background: var(--c-weir); }
.dot.rental { background: var(--c-rental); }

#legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  padding: 14px 2px 4px;
  font-size: 12.5px; font-weight: 550; color: #51708a;
}
#legend span { display: flex; align-items: center; gap: 6px; }
#legend em { font-style: normal; }

/* ---------- Progress pill (visible while tracking on the river) ---------- */
#progress-pill {
  position: fixed;
  left: 50%;
  bottom: calc(160px + var(--sab));
  transform: translate(-50%, 12px);
  z-index: 1090;
  max-width: calc(100vw - 24px);
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 11px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#progress-pill.show { opacity: 1; transform: translate(-50%, 0); }
#progress-pill.danger { background: #d92f2f; border-color: #d92f2f; color: #fff; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(110px + var(--sab));
  transform: translate(-50%, 12px);
  z-index: 1300;
  max-width: min(420px, calc(100vw - 40px));
  background: rgba(12, 30, 46, 0.92);
  color: #eaf3fa;
  font-size: 13.5px;
  line-height: 1.4;
  padding: 11px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer disclaimer ---------- */
#disclaimer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1050;
  background: rgba(10, 26, 40, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #c8d9e6;
  font-size: 11px;
  padding: 7px 12px calc(7px + var(--sab));
  text-align: center;
  line-height: 1.45;
}
#disclaimer a { color: #8ecbf0; text-decoration: none; }
#disclaimer strong { color: #fff; }

/* ---------- Map markers ---------- */
.poi-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  color: #fff;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.poi-icon.danger, .poi-icon.weir { width: 36px; height: 36px; }
.poi-icon svg { width: 60%; height: 60%; }
.poi-icon.entry { background: var(--c-entry); }
.poi-icon.danger { background: var(--c-danger); }
.poi-icon.exit { background: var(--c-exit); }
.poi-icon.weir { background: var(--c-weir); }
.poi-icon.rental { background: var(--c-rental); }
.poi-icon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* small marker for exit zones (centred icon) */
.zone-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-exit); color: #fff; font-size: 14px; line-height: 1;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.zone-icon svg { width: 60%; height: 60%; }

/* ---------- START / ENDE pills at the trip endpoints ---------- */
.route-label {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: 0 3px 12px rgba(6, 24, 40, 0.4);
  pointer-events: none;
}
/* start: below its marker · end: above, so it never covers the exit/bridge */
.route-label.start {
  transform: translate(-50%, 24px);
  color: #0e6b30;
  border: 2px solid var(--c-entry);
}
.route-label.end {
  transform: translate(-50%, calc(-100% - 24px));
  color: #0f766e;
  border: 2px solid var(--c-exit);
}

/* ---------- User location dot ---------- */
.user-dot-wrap { position: relative; width: 20px; height: 20px; }
.user-dot {
  position: absolute; inset: 2px;
  background: var(--c-accent);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.user-pulse {
  position: absolute; inset: -8px;
  border-radius: 50%;
  background: rgba(46, 124, 246, 0.35);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ---------- Leaflet chrome ---------- */
.leaflet-popup-content-wrapper {
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.leaflet-popup-content { font-size: 14px; line-height: 1.5; margin: 14px 16px; color: var(--ink); }
.leaflet-popup-content .popup-title {
  display: flex; align-items: center; gap: 7px;
  font-weight: 700; font-size: 15px; margin-bottom: 5px; letter-spacing: -0.01em;
}
.leaflet-popup-content .popup-title.danger, .leaflet-popup-content .popup-title.weir { color: var(--c-danger); }
.popup-ic { display: inline-flex; flex-shrink: 0; }
.popup-ic svg { width: 17px; height: 17px; }
.popup-ic.entry { color: var(--c-entry); }
.popup-ic.danger { color: var(--c-danger); }
.popup-ic.exit { color: var(--c-exit); }
.popup-ic.weir { color: var(--c-weir); }
.popup-ic.rental { color: var(--c-rental); }
.leaflet-popup-content .popup-img {
  display: block;
  width: 100%;
  max-height: 150px;
  object-fit: cover;
  border-radius: 12px;
  margin: 4px 0 8px;
}
.leaflet-popup-content .popup-img.zoomable { cursor: zoom-in; }
/* shown while the photo file doesn't exist yet – displays the expected filename */
.popup-img-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 105px;
  border-radius: 12px;
  margin: 4px 0 8px;
  background: rgba(15, 36, 54, 0.05);
  border: 1.5px dashed rgba(15, 36, 54, 0.22);
  color: #8aa2b5;
  font-size: 11.5px;
  font-weight: 550;
}
.popup-img-ph svg { width: 22px; height: 22px; }

/* ---------- Lightbox: tap a popup photo to view it full-screen ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(5, 15, 25, 0.93);
  cursor: zoom-out;
  opacity: 1;
  transition: opacity 0.22s ease;
}
#lightbox.hidden { opacity: 0; pointer-events: none; }
#lightbox-img {
  max-width: min(94vw, 900px);
  max-height: 80vh;
  border-radius: 14px;
  box-shadow: 0 14px 48px rgba(0, 0, 0, 0.6);
  transform: scale(1);
  transition: transform 0.22s ease;
}
#lightbox.hidden #lightbox-img { transform: scale(0.94); }
#lightbox-cap { color: #dbe7f1; font-size: 14px; font-weight: 650; text-align: center; }
#lightbox-close {
  position: absolute;
  top: calc(14px + var(--sat));
  right: 14px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#lightbox-close svg { width: 17px; height: 17px; }
.leaflet-popup-content .popup-link {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--c-accent);
  color: #fff !important;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.leaflet-bar {
  border: none !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}
.leaflet-bar a { color: var(--ink) !important; }

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.6) !important;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 9.5px !important;
  border-radius: 8px 8px 0 0;
}

/* keep Leaflet attribution/zoom clear of the disclaimer footer */
.leaflet-bottom { bottom: calc(34px + var(--sab)); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .leaflet-control-zoom { display: none; } /* pinch to zoom on touch */
}

/* keep zoom control clear of the locate button on desktop */
.leaflet-control-zoom { margin-bottom: 84px !important; margin-right: 12px !important; }

@media (min-width: 700px) {
  #topbar { left: 16px; right: auto; min-width: 360px; }
  #poi-panel {
    left: 16px; right: auto; bottom: 46px;
    width: 360px;
    border-radius: 20px;
    border-bottom: 1px solid var(--glass-border);
    max-height: 68%;
  }
  #poi-panel.hidden { transform: translateY(calc(100% + 60px)); }
  #sheet-backdrop { display: none; }
  #sheet-handle { display: none; }
  #poi-panel { padding-top: 18px; }
  #list-btn { bottom: 46px; left: 16px; }
  #locate-btn { bottom: 46px; }
}
