/* ---------------------------------------------------------------------
   Tokens
   Palette re-derived from the previous teal/navy identity, checked for
   WCAG 2.1 AA contrast (text pairs verified >= 4.5:1, most >= 6:1).
--------------------------------------------------------------------- */
:root {
  --bg: #F6F4EF;
  --panel: #FFFFFF;
  --panel-2: #EDEAE2;
  --border: #D8D3C7;

  --ink: #1E2A2E;
  --ink-muted: #45565C;
  --ink-faint: #5B6B70;

  --teal: #0F6E63;
  --teal-dark: #0B4A43;
  --teal-tint: #E3F2EF;

  --amber: #9A5B12;
  --amber-dark: #7A4610;
  --amber-tint: #FBEEE0;

  --focus: #0B4A43;

  --cat-1: #2E6F9E; --cat-1-tint: #E6EEF3;
  --cat-2: #A6415A; --cat-2-tint: #F4E8EB;
  --cat-3: #B07D1D; --cat-3-tint: #F6EFE4;
  --cat-4: #3F7D53; --cat-4-tint: #E8EFEA;
  --cat-5: #6E5091; --cat-5-tint: #EEEAF2;

  --shadow: 0 1px 2px rgba(20, 30, 30, 0.06), 0 10px 26px rgba(20, 30, 30, 0.09);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Public Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p { margin: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------------
   Accessibility helpers
--------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--teal-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  z-index: 4000;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  line-height: normal;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--ink-faint);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }

/* ---------------------------------------------------------------------
   Header
--------------------------------------------------------------------- */
.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--teal-dark);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.header-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  width: min(420px, 40vw);
  min-width: 180px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  padding: 0 4px 0 16px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  background: none;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input:focus-visible { outline: none; }
.header-search:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 999px; }

.search-icon-btn, .search-clear-btn { width: 36px; height: 36px; }

/* ---------------------------------------------------------------------
   Body layout
--------------------------------------------------------------------- */
.app-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 20px 28px;
}

.side-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.filters-panel { padding: 18px; gap: 16px; }

.drawer-header { display: none; }

.panel-section { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.tags-section { min-height: 0; flex: 1; overflow-y: auto; }

.panel-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-transform: uppercase;
}

/* Categories */
.category-list { display: flex; flex-direction: column; gap: 4px; }

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--panel-2);
  text-align: left;
}
.category-item:hover { background: var(--border); }
.category-item[aria-pressed="true"] {
  background: var(--cat-tint, var(--teal-tint));
  border-color: var(--cat-color, var(--teal));
}

.category-item-main { display: flex; align-items: flex-start; gap: 10px; min-width: 0; flex: 1; }

.category-dot {
  width: 10px; height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cat-color, var(--teal));
}

.category-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  min-width: 0;
  white-space: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
}
.category-item[aria-pressed="true"] .category-name { font-weight: 700; }

.category-count { font-size: 13px; font-weight: 500; color: var(--ink-faint); flex-shrink: 0; }
.category-item[aria-pressed="true"] .category-count { display: none; }

.category-check { flex-shrink: 0; color: var(--cat-color, var(--teal)); display: none; }
.category-item[aria-pressed="true"] .category-check { display: flex; }

/* Tags */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
}
.tag-chip:hover { border-color: var(--ink-faint); }
.tag-chip[aria-pressed="true"] {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 600;
}
.tag-check { display: none; }
.tag-chip[aria-pressed="true"] .tag-check { display: inline-flex; }
.tag-check svg { width: 12px; height: 12px; display: block; }

/* Reset button */
.reset-button {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink-faint);
  font-weight: 600;
  font-size: 13px;
}
.reset-button.active {
  border-color: var(--amber);
  background: var(--amber-tint);
  color: var(--amber-dark);
}
.reset-button:hover.active { background: #f6e2c8; }

/* ---------------------------------------------------------------------
   Map
--------------------------------------------------------------------- */
.map-panel {
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}

#map { width: 100%; height: 100%; }

.leaflet-control-zoom {
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
  border: none !important;
}
.leaflet-control-zoom a {
  font-family: var(--font-display) !important;
  color: var(--ink) !important;
}

.marker-popup { font-family: var(--font-body); min-width: 200px; }
.marker-popup h1 { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.marker-popup p { font-size: 13px; color: var(--ink-muted); margin-bottom: 6px; }
.marker-popup a { color: var(--teal); font-weight: 600; font-size: 13px; }
.marker-popup a:hover { color: var(--teal-dark); }
.marker-popup .popup-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.marker-popup .popup-tag {
  font-size: 11px; font-weight: 600; color: var(--teal);
  background: var(--teal-tint); padding: 3px 9px; border-radius: 999px;
  text-decoration: none;
}
.marker-popup .popup-tag:hover { background: #cfe8e3; }

/* ---------------------------------------------------------------------
   Results panel
--------------------------------------------------------------------- */
.results-panel { padding: 0; }

.results-summary {
  padding: 18px 18px 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.count-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel-2);
  padding: 2px 10px;
  border-radius: 999px;
}

.panel-hint { padding: 4px 18px 12px; font-size: 12px; color: var(--ink-faint); flex-shrink: 0; }

.places-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.place-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 11px 10px;
  border-radius: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  background: none;
}
.place-item:hover { background: var(--panel-2); }
.place-item:last-child { border-bottom: none; }
.place-item--no-location { cursor: default; color: var(--ink-faint); }
.place-item--no-location:hover { background: none; }

.place-dot {
  width: 8px; height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--cat-color, var(--teal));
}

.place-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  min-width: 0;
  white-space: normal;
  overflow-wrap: break-word;
  text-wrap: pretty;
}
.place-item--no-location .place-name { color: inherit; font-weight: 500; }

/* ---------------------------------------------------------------------
   Footer
--------------------------------------------------------------------- */
.app-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding: 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.app-footer .banner { max-height: 46px; width: auto; }

/* ---------------------------------------------------------------------
   Mobile drawers + floating actions
--------------------------------------------------------------------- */
.scrim { display: none; }
.mobile-actions { display: none; }

@media (max-width: 1024px) {
  .app-body {
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    position: relative;
  }

  .map-panel { border-radius: 0; border: none; box-shadow: none; margin: 12px 12px 0; border-radius: var(--radius-lg); flex: 1; min-height: 0; }

  .app-footer { display: none; }

  .header-search { width: auto; flex: 1; }
  .app-header { flex-wrap: wrap; }

  .mobile-actions {
    display: flex;
    gap: 10px;
    padding: 12px;
    flex-shrink: 0;
  }

  .pill-button {
    flex: 1;
    position: relative;
    height: 50px;
    border-radius: 999px;
    background: var(--panel);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--ink);
  }

  .pill-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--teal-tint);
    color: var(--teal-dark);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .pill-badge-alert {
    position: absolute;
    top: -6px; right: -6px;
    background: var(--amber);
    color: #fff;
  }

  .side-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(360px, 86vw);
    z-index: 3000;
    border-radius: 0;
    transition: transform 0.22s ease;
  }
  .filters-panel { left: 0; transform: translateX(-100%); }
  .results-panel { right: 0; transform: translateX(100%); }
  .side-panel.open { transform: translateX(0); }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .drawer-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; }

  .filters-panel { padding: 0 18px 18px; }
  .filters-panel .panel-section:first-of-type { padding-top: 18px; }
  .reset-button { margin: 0 0 4px; }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 22, 0.4);
    z-index: 2500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .scrim.open { opacity: 1; pointer-events: auto; }
}

@media (max-width: 560px) {
  .app-header { padding: 12px 14px; }
  .brand-title { font-size: 15px; }
  .header-search { order: 3; width: 100%; flex-basis: 100%; }
}
