/* ============================================================
   LABEL — Map page (Gilded Noir Leaflet theme)
   Loaded only by map.html / fr/map.html, after main.css and
   leaflet.css. Styles the consent gate, the map shell and every
   piece of Leaflet chrome in espresso + gold.
   ============================================================ */

/* ---------- Controls row ---------- */
.map-controls { display: flex; flex-wrap: wrap; gap: 1rem; margin: 2.4rem 0 1.6rem; align-items: center; }

.map-list-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  padding: 0.6rem 1.1rem;
  clip-path: var(--cut);
  transition: all 0.3s var(--ease);
  flex: none;
}
.map-list-link svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.map-list-link:hover { background: var(--gold); color: var(--noir); }

/* ---------- Map shell ---------- */
.map-shell {
  position: relative;
  border: 1px solid rgba(201, 162, 39, 0.25);
  clip-path: var(--cut);
  background: var(--espresso);
}
#map {
  width: 100%;
  height: clamp(440px, 64vh, 720px);
  background: var(--noir);
}
#map[hidden] { display: none; }

/* ---------- GDPR consent gate ---------- */
.map-consent {
  min-height: clamp(440px, 64vh, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.3rem;
  padding: clamp(2rem, 6vw, 4rem);
  background:
    radial-gradient(ellipse 60% 70% at 50% 100%, rgba(201, 162, 39, 0.12), transparent 70%),
    var(--espresso);
}
.map-consent[hidden] { display: none; }
.map-consent .pin-mark { width: 64px; height: 64px; filter: drop-shadow(0 0 14px rgba(201, 162, 39, 0.45)); }
.map-consent h2 { font-size: clamp(1.6rem, 3.4vw, 2.4rem); max-width: 22ch; }
.map-consent p {
  color: var(--ash);
  font-size: 0.95rem;
  max-width: 52ch;
  margin: 0;
}
.map-consent p a { color: var(--champagne); text-decoration: underline; text-underline-offset: 3px; }
.map-consent p a:hover { color: var(--gold); }

/* ---------- Leaflet container ---------- */
.leaflet-container {
  background: var(--noir);
  font-family: var(--sans);
}

/* The "Black style": push CARTO dark_all into warm gilded noir */
.leaflet-tile-pane {
  filter: sepia(0.25) hue-rotate(-8deg) saturate(0.85) brightness(0.92) contrast(1.05);
}

/* ---------- Zoom buttons ---------- */
.leaflet-touch .leaflet-bar,
.leaflet-bar {
  border: 1px solid var(--gold-soft);
  border-radius: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}
.leaflet-bar a,
.leaflet-touch .leaflet-bar a {
  background: var(--espresso);
  color: var(--gold);
  border-bottom: 1px solid rgba(201, 162, 39, 0.25);
  border-radius: 0;
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-family: var(--sans);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.leaflet-bar a:last-child { border-bottom: none; }
.leaflet-bar a:hover, .leaflet-bar a:focus { background: var(--gold); color: var(--noir); }
.leaflet-bar a.leaflet-disabled { background: var(--espresso); color: rgba(154, 147, 138, 0.4); }

/* ---------- Attribution (license requirement — keep readable) ---------- */
.leaflet-control-attribution {
  background: rgba(14, 12, 9, 0.82) !important;
  color: var(--ash);
  font-size: 0.66rem;
  padding: 2px 8px;
}
.leaflet-control-attribution a { color: var(--champagne); }
.leaflet-control-attribution a:hover { color: var(--gold); }

/* ---------- Custom gold pin markers ---------- */
.map-pin { background: none; border: none; }
.map-pin svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 0 7px rgba(201, 162, 39, 0.55)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6));
  transition: transform 0.3s var(--ease), filter 0.3s var(--ease);
  transform-origin: 50% 100%;
}
.map-pin:hover svg { transform: scale(1.12); }
.map-pin.active svg {
  transform: scale(1.22);
  filter: drop-shadow(0 0 12px rgba(201, 162, 39, 0.85)) drop-shadow(0 3px 5px rgba(0, 0, 0, 0.6));
}
.map-pin-user .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--champagne);
  border: 2px solid var(--noir);
  box-shadow: 0 0 0 4px rgba(232, 213, 163, 0.35), 0 0 14px rgba(232, 213, 163, 0.7);
}

/* ---------- Popups ---------- */
.leaflet-popup-content-wrapper {
  background: var(--espresso);
  color: var(--ivory);
  border: 1px solid var(--gold-soft);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.6);
}
.leaflet-popup-tip {
  background: var(--espresso);
  border: 1px solid var(--gold-soft);
  box-shadow: none;
}
.leaflet-popup-content { margin: 1.1rem 1.2rem; line-height: 1.55; }
.leaflet-popup-close-button { color: var(--ash) !important; font-family: var(--sans); padding: 6px 8px 0 0 !important; }
.leaflet-popup-close-button:hover { color: var(--gold) !important; }

.map-pop { min-width: 200px; max-width: 250px; }
.map-pop .cat {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  padding: 0.18rem 0.55rem;
  margin-bottom: 0.55rem;
}
.map-pop h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--ivory);
  margin: 0 0 0.25rem;
  line-height: 1.15;
}
.map-pop .city {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ash);
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.map-pop .city svg { width: 12px; height: 12px; flex: none; }
.map-pop .blurb { font-size: 0.86rem; color: var(--ash); margin: 0 0 0.7rem; }
.map-pop .pop-link {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--gold-soft);
  padding-bottom: 1px;
}
.map-pop .pop-link:hover { color: var(--champagne); border-color: var(--champagne); }

/* ---------- Action buttons (popup + bottom sheet) ---------- */
.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.9rem;
}
.map-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  clip-path: var(--cut);
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}
.map-act svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.map-act:hover, .map-act:focus-visible { background: var(--gold); color: var(--noir); }
.map-act.solid { background: var(--gold); color: var(--noir); }
.map-act.solid:hover, .map-act.solid:focus-visible { background: var(--champagne); }
.map-act:focus-visible { outline: 2px solid var(--champagne); outline-offset: 2px; }

/* ---------- Embedded map panel on the directory page ---------- */
.dir-map-panel { margin-bottom: 2.4rem; }
.dir-map-panel[hidden] { display: none; }
.dir-map-panel #map { height: clamp(360px, 46vh, 540px); }
.dir-map-panel .map-consent { min-height: 340px; padding: 2rem 1.4rem; gap: 1rem; }
.dir-map-panel .map-consent .pin-mark { width: 52px; height: 52px; }
.dir-map-panel .map-consent h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); }

/* ---------- Near-me chip active (live position following) ---------- */
#mapNear.active {
  background: var(--gold);
  color: var(--noir);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.45);
}

/* ---------- Mobile bottom sheet (business details) ---------- */
.map-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 320; /* above the tabbar */
  background: var(--espresso);
  border-top: 1px solid var(--gold-soft);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  padding: 0.6rem 1.2rem calc(1.2rem + 72px + env(safe-area-inset-bottom));
  box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.65);
  transform: translateY(102%);
  transition: transform 0.32s var(--ease);
  max-height: 62vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.map-sheet.open { transform: translateY(0); }
.map-sheet[hidden] { display: none; }
.map-sheet-bar {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: rgba(201, 162, 39, 0.4);
  margin: 0.2rem auto 0.9rem;
}
.map-sheet-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(201, 162, 39, 0.3);
  color: var(--ash);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}
.map-sheet-close:hover, .map-sheet-close:focus-visible { color: var(--gold); border-color: var(--gold); }
.map-sheet-close:focus-visible { outline: 2px solid var(--champagne); outline-offset: 2px; }
.map-sheet .map-pop { min-width: 0; max-width: none; padding-right: 2.6rem; }
.map-sheet h3 { font-size: 1.5rem; }
.map-sheet .map-actions .map-act { flex: 1 1 auto; }

@media (min-width: 761px) {
  .map-sheet { display: none; } /* desktop uses Leaflet popups */
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  /* Full-bleed, taller map — the page IS the map on a phone */
  .map-shell {
    margin-inline: calc(50% - 50vw);
    border-left: none;
    border-right: none;
    clip-path: none;
  }
  #map { height: min(72vh, calc(100dvh - 220px)); min-height: 420px; }
  .map-consent { height: auto; min-height: 56vh; }

  /* Compact control row: list link + near-me share one line, chips scroll */
  .map-controls { flex-direction: row; flex-wrap: wrap; gap: 0.7rem; margin: 1.4rem 0 1.1rem; }
  .map-list-link, #mapNear { flex: 1 1 40%; justify-content: center; min-height: 48px; }
  #mapNear { display: inline-flex; align-items: center; }
  .map-controls .chips { flex: 1 1 100%; }

  /* Thumb-reachable zoom; keep clear of the attribution line */
  .leaflet-bottom.leaflet-right { margin-bottom: 2rem; }
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 46px; height: 46px; line-height: 46px; font-size: 1.15rem; }

  /* Popups never used on phones, but if one slips through keep it sane */
  .leaflet-popup-content-wrapper { max-width: 86vw; }
}

@media (prefers-reduced-motion: reduce) {
  .map-pin svg { transition: none; }
  .map-sheet { transition: none; }
}
