/* ─── RESET & BASE ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0e0e0e;
  --surface:   #161616;
  --surface2:  #1f1f1f;
  --border:    #2a2a2a;
  --accent:    #e8f542;   /* sharp acid yellow */
  --accent2:   #ff4d4d;   /* punch red for chains/warnings */
  --text:      #f0ede6;
  --text-dim:  #888;
  --sidebar-w: 340px;
  --radius:    6px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── LAYOUT ───────────────────────────────────────── */
body {
  display: flex;
  flex-direction: row;
}

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

#map {
  flex: 1;
  height: 100vh;
  position: relative;
}

#search-area-btn {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 8px 20px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 16px rgba(0,0,0,0.6);
  transition: background 0.15s, opacity 0.2s;
}

#search-area-btn:hover { background: var(--surface2); }
#search-area-btn.hidden { display: none; }

/* ─── HEADER / LOGO ────────────────────────────────── */
#sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

#logo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-main {
  font-family: var(--font-display);
  font-size: 42px;
  letter-spacing: 2px;
  line-height: 1;
  color: var(--accent);
  /* Subtle text shadow for punch */
  text-shadow: 2px 2px 0 rgba(232,245,66,0.15);
}

.logo-sub {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ─── SEARCH ───────────────────────────────────────── */
#search-bar {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

#location-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#location-input::placeholder { color: var(--text-dim); }
#location-input:focus { border-color: var(--accent); }

#locate-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}

#locate-btn svg {
  width: 18px;
  height: 18px;
  color: #0e0e0e;
  stroke: #0e0e0e;
}

#locate-btn:hover { opacity: 0.85; transform: scale(1.05); }
#locate-btn:active { transform: scale(0.95); }

/* ─── FILTERS ──────────────────────────────────────── */
#filters {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.filter-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

#filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0e0e;
  font-weight: 600;
}


/* ─── RESULTS ──────────────────────────────────────── */
#results-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 8px;
}

#results-area::-webkit-scrollbar { width: 4px; }
#results-area::-webkit-scrollbar-track { background: transparent; }
#results-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#results-header {
  padding: 12px 20px 8px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

#results-count {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
}

#results-list {
  list-style: none;
  padding: 8px 0;
}

.result-item {
  padding: 10px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.result-item:hover {
  background: var(--surface2);
  border-left-color: var(--accent);
}

.result-item.active {
  background: var(--surface2);
  border-left-color: var(--accent);
}

.result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.result-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  align-items: center;
}

.result-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.result-distance {
  font-size: 11px;
  color: var(--text-dim);
}

/* Empty state */
.results-empty {
  padding: 24px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.results-empty strong {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* ─── FOOTER ───────────────────────────────────────── */
#sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ─── MAP CUSTOMISATION ────────────────────────────── */
.leaflet-container {
  background: #1a1a1a !important;
  font-family: var(--font-body) !important;
}

/* Custom marker */
.unchained-marker {
  background: var(--accent);
  border: 2px solid #0e0e0e;
  border-radius: 50%;
  width: 12px !important;
  height: 12px !important;
  box-shadow: 0 0 0 3px rgba(232,245,66,0.25);
  transition: transform 0.15s;
}

.unchained-marker:hover,
.unchained-marker.active {
  transform: scale(1.5);
  box-shadow: 0 0 0 4px rgba(232,245,66,0.4);
}

/* Popup */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  color: var(--text) !important;
}

.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content { margin: 14px 16px !important; font-family: var(--font-body) !important; }

.popup-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--text);
}

.popup-type {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.popup-detail {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

.popup-detail a { color: var(--accent); }

.popup-osm {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.popup-osm summary {
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.popup-osm summary::-webkit-details-marker { display: none; }

.popup-osm[open] summary { color: var(--text); }

.popup-osm p {
  font-size: 11px;
  color: var(--text-dim);
  margin: 6px 0;
  line-height: 1.5;
}

.popup-osm a {
  font-size: 11px;
  color: var(--accent);
}


/* Attribution */
.leaflet-control-attribution {
  background: rgba(14,14,14,0.8) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--text-dim) !important; }

/* Layer switcher */
.leaflet-control-layers {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
  color: var(--text) !important;
}

.leaflet-control-layers-toggle {
  background-color: var(--surface) !important;
  width: 30px !important;
  height: 30px !important;
}

.leaflet-control-layers-expanded {
  padding: 8px 12px !important;
  font-family: var(--font-body) !important;
  font-size: 12px !important;
}

.leaflet-control-layers label {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 3px 0 !important;
  color: var(--text-dim) !important;
  cursor: pointer !important;
  transition: color 0.15s !important;
}

.leaflet-control-layers label:hover { color: var(--text) !important; }

/* Zoom controls */
.leaflet-bar {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
}
.leaflet-bar a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-bar a:hover { background: var(--surface2) !important; }

/* ─── LOADING ──────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,14,14,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#loading-overlay.hidden { display: none; }

#loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loading-text {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOAST ────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  z-index: 2000;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  animation: fadeInUp 0.2s ease;
}

#toast.hidden { display: none; }
#toast.error { border-color: var(--accent2); color: var(--accent2); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── STAT TICKER ──────────────────────────────────── */
#stat-ticker {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(14,14,14,0.88);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 9px 14px 9px 18px;
  max-width: min(460px, calc(100vw - 32px));
  width: max-content;
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#stat-ticker.visible {
  opacity: 1;
  pointer-events: auto;
}

#stat-text {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  white-space: normal;
}

#stat-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}

#stat-dismiss:hover { color: var(--accent); }

@media (min-width: 641px) {
  #stat-ticker {
    padding: 12px 18px 12px 22px;
    border-radius: 28px;
    gap: 12px;
  }

  #stat-text {
    font-size: 14px;
  }

  #stat-dismiss {
    font-size: 18px;
  }
}

/* ─── ABOUT OVERLAY ─────────────────────────────────── */
#about-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(14,14,14,0.92);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

#about-overlay.open { display: flex; }

#about-inner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
  padding: 48px 48px 40px;
  max-height: 90vh;
  overflow-y: auto;
}

#about-inner::-webkit-scrollbar { width: 4px; }
#about-inner::-webkit-scrollbar-track { background: transparent; }
#about-inner::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#about-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

#about-close:hover {
  color: var(--accent);
  background: var(--surface2);
}

.about-headline {
  font-family: var(--font-display);
  font-size: 52px;
  letter-spacing: 1px;
  line-height: 1.05;
  color: var(--accent);
  margin-bottom: 32px;
}

.about-section-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 1px;
  color: var(--text);
  margin-bottom: 16px;
}

#about-inner p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 16px;
}

#about-inner p:last-child { margin-bottom: 0; }

.about-closing {
  color: var(--text-dim) !important;
  font-size: 14px !important;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 8px;
}

.about-closing strong { color: var(--accent); }

@media (max-width: 640px) {
  #about-inner {
    padding: 40px 24px 28px;
  }
  .about-headline { font-size: 38px; }
}

/* ─── SIDEBAR HANDLE (hidden on desktop) ───────────── */
#sidebar-handle { display: none; }

/* ─── HEADER CONTROLS ───────────────────────────────── */
#header-controls { display: flex; gap: 6px; align-items: center; }
#search-toggle-btn,
#filter-toggle-btn { display: none; }
#filter-dot        { display: none; }

#about-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
#about-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-dim);
  transition: stroke 0.15s;
}
#about-btn:hover svg { stroke: var(--text); }

/* ─── MOBILE ───────────────────────────────────────── */
@media (max-width: 640px) {
  body { flex-direction: column; }

  #sidebar {
    width: 100%;
    height: auto;
    max-height: 45dvh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    transition: max-height 0.25s ease;
  }

  #sidebar.collapsed {
    max-height: 52px;
    overflow: hidden;
  }

  #sidebar.collapsed ~ #map { height: calc(100dvh - 52px); }

  #map { height: 55dvh; }

  /* Compact header — flex row: logo left, buttons right */
  #sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
  }
  .logo-main { font-size: 28px; }
  .logo-sub { font-size: 10px; }

  /* Header icon buttons */
  #header-controls {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
  }

  #search-toggle-btn,
  #filter-toggle-btn { display: flex; }

  #about-btn,
  #search-toggle-btn,
  #filter-toggle-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
  }

  #about-btn svg,
  #search-toggle-btn svg,
  #filter-toggle-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-dim);
    transition: stroke 0.15s;
  }

  #sidebar.search-open #search-toggle-btn,
  #sidebar.filter-open #filter-toggle-btn {
    border-color: var(--accent);
    background: rgba(232,245,66,0.1);
  }

  #sidebar.search-open #search-toggle-btn svg,
  #sidebar.filter-open #filter-toggle-btn svg {
    stroke: var(--accent);
  }

  /* Filter active dot */
  #filter-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
  }
  #filter-dot.visible { display: block; }

  /* Hide search + filters by default */
  #search-bar { display: none; }
  #filters    { display: none; }

  /* Reveal when toggled */
  #sidebar.search-open #search-bar { display: flex; }
  #sidebar.filter-open #filters    { display: block; }

  /* Horizontal-scroll chips — no wrapping */
  #filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #filter-chips::-webkit-scrollbar { display: none; }

  /* Hide attribution — already in Leaflet corner */
  #sidebar-footer { display: none; }

  /* Drag handle */
  #sidebar-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px 0 4px;
    cursor: pointer;
    flex-shrink: 0;
  }
  #sidebar-handle::before {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
  }
}
