/* ───────────── MAP ───────────── */

#map-view {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 0;
  /* Opaque background prevents the cards behind (still in DOM) from flashing
     through when iOS Safari invalidates the MapLibre WebGL canvas on
     PWA wake or visibility resume. */
  background: var(--bg);
  /* New stacking context so re-renders of sibling DOM don't trigger a
     repaint of the map's compositing layer. */
  isolation: isolate;
  will-change: transform;
}

/* Desktop : la carte ne recouvre pas la sidebar (248px) */
@media (min-width: 769px) {
  #map-view {
    left: 248px;
  }
}
/* MapLibre canvas background while tiles load. */
#map-view .maplibregl-map { background: var(--bg); font-family: inherit; }
#map-view .maplibregl-canvas { outline: none; }
/* Compact attribution: nudged off the bottom controls. */
.maplibregl-ctrl-bottom-right { padding: 2px 4px; }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: .7; }

@keyframes map-pulse {
  0%   { transform: scale(1);   opacity: .8; }
  100% { transform: scale(2.4); opacity: 0;  }
}

.map-pulse {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  position: relative;
  border: 2px solid white;
}

.map-pulse::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: inherit;
  opacity: .4;
  animation: map-pulse 1.5s ease-out infinite;
}
[data-pin].pin-selected {
  box-shadow: 0 4px 16px rgba(40,28,15,.40) !important;
  transform: scale(1.1);
}

.map-pin-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1C1814;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 2px 6px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(60,40,20,.16);
  pointer-events: none;
}
/* Pin label keeps a white background in both themes — readability over the
   map tiles matters more than matching the warm palette. */

/* ── Map filter chips (toggle which categories show as pins) ── */
/* Wrapper: chips + locate-btn grouped, horizontally centred. */
.map-controls {
  position: absolute;
  bottom: 2.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: .6rem;
  max-width: calc(100% - 1.5rem);
}

/* Contrast inverts vs the tile theme: dark bar over light tiles, light bar
   over dark tiles. */
.map-filter-bar {
  position: relative;
  display: flex;
  gap: .25rem;
  padding: .3rem;
  background: rgba(18,15,12,.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  white-space: nowrap;
}
html.dark .map-filter-bar {
  /* Warm surface tone matching the burger menu (var(--surface) dark). */
  background: rgba(50,45,39,.92);
  box-shadow: 0 2px 12px rgba(0,0,0,.45);
}
/* Sliding highlight behind the active chip — set width + translateX in JS. */
.map-filter-pill {
  position: absolute;
  top: .3rem;
  left: 0;
  height: calc(100% - .6rem);
  width: 0;
  background: #F8F2E8;
  border-radius: 10px;
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.32,.72,0,1), width .25s cubic-bezier(.32,.72,0,1);
  pointer-events: none;
  z-index: 0;
}
html.dark .map-filter-pill { background: #F8F2E8; }
.map-filter-chip {
  position: relative;
  z-index: 1;
  border: none;
  background: transparent;
  color: rgba(248,242,232,.65);
  padding: .4rem .85rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.map-filter-chip:hover { color: #F8F2E8; }
.map-filter-chip.on    { color: #1B1612; }
html.dark .map-filter-chip       { color: rgba(248,242,232,.55); }
html.dark .map-filter-chip:hover { color: #F8F2E8; }
html.dark .map-filter-chip.on    { color: #1B1612; }
@media (max-width: 768px) {
  /* Group sits at the bottombar's vertical centre (env + 1.5rem + 15px). */
  .map-controls { bottom: calc(env(safe-area-inset-bottom, 0px) + 1.5rem + 15px); }
  .map-filter-bar { padding: .25rem; }
  .map-filter-chip { padding: .35rem .7rem; font-size: .75rem; }
}

@media (max-width: 768px) {
  #map-view {
    position: fixed !important;
    top: 52px !important;
    left: 0 !important; right: 0 !important;
    bottom: 0 !important;
    height: auto !important;
    z-index: 360 !important;
  }
}


/* ───────────── User geolocation (Apple-Maps-like blue dot) ───────────── */
#locate-btn {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border-radius: 12px;
  border: none;
  /* Mirrors the chip-bar contrast: dark over light tiles, light over dark. */
  background: rgba(18,15,12,.92);
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  color: rgba(248,242,232,.85);
  cursor: pointer;
  transition: background .15s, color .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
html.dark #locate-btn {
  background: rgba(50,45,39,.92);
  color: rgba(248,242,232,.85);
  box-shadow: 0 2px 12px rgba(0,0,0,.45);
}
#locate-btn:active { transform: scale(.94); }
#locate-btn:focus { outline: none; }
#locate-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
#locate-btn svg { width: 16px; height: 16px; display: block; }
/* Background stays identical across states — only the icon colour shifts. */
html #locate-btn[data-state="tracking"] { color: #4d9eff; }
html #locate-btn[data-state="pending"]  { color: #4d9eff; }
#locate-btn[data-state="pending"] svg { animation: locate-pending 1s linear infinite; }
@keyframes locate-pending { to { transform: rotate(360deg); } }

/* Apple Maps-like user dot: white halo + blue core + soft pulse */
.user-loc-icon { background: transparent !important; border: none !important; }
.user-dot-ring {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(60,40,20,.10), 0 2px 8px rgba(28,24,20,.30);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.user-dot-core {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #0A7AFF;
}
.user-dot-pulse {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: #0A7AFF;
  opacity: .35;
  animation: user-dot-pulse 2s ease-out infinite;
  pointer-events: none;
}
@keyframes user-dot-pulse {
  0%   { transform: scale(1);   opacity: .35; }
  80%  { transform: scale(3.2); opacity: 0; }
  100% { transform: scale(3.2); opacity: 0; }
}

/* Discrete toast at top of map view */
.locate-toast {
  position: absolute;
  top: 1rem; left: 50%; transform: translateX(-50%);
  z-index: 600;
  background: rgba(28,24,20,.88);
  color: #fff;
  padding: .55rem .9rem;
  border-radius: 10px;
  font-size: .82rem; font-weight: 500;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(28,24,20,.30);
  transition: opacity .3s;
  pointer-events: none;
  max-width: calc(100% - 2rem);
}
@media (max-width: 768px) {
  .locate-toast { top: calc(env(safe-area-inset-top, 0px) + 4rem); }
}


