/**
 * Kit de mapa compartit: controls, clústers en donut, punts, halo i llegenda.
 */
:root {
  --sm-brand: #A237B5;
  --sm-brand-700: #7E2390;
  --sm-brand-50: #F6EDF8;
  --sm-ink: #2B2530;
  --sm-soft: #6E6675;
  --sm-line: #ECE6EF;
  --sm-bg: #FAF8FB;
  --sm-surface: #fff;
  --sm-radius: 14px;
  --sm-radius-sm: 8px;
  --sm-shadow-sm: 0 1px 2px rgba(43, 37, 48, .08), 0 1px 3px rgba(43, 37, 48, .06);
  --sm-shadow: 0 4px 14px rgba(43, 37, 48, .14), 0 1px 3px rgba(43, 37, 48, .08);
}

/* Controls ------------------------------------------------------------ */
.leaflet-container {
  font-family: inherit;
  /* Els controls (z-index 800-1000) no han de sortir per sobre de capçaleres fixes. */
  isolation: isolate;
  background: #EEF0F2;
}
.leaflet-container[data-base="dark"] {
  background: #262626;
}
.leaflet-container .leaflet-control-zoom,
.leaflet-container .leaflet-control-layers,
.leaflet-container .sm-tools {
  border: 0;
  border-radius: 12px;
  box-shadow: var(--sm-shadow);
  overflow: hidden;
}
.leaflet-container .leaflet-control-zoom a,
.sm-tools__btn {
  width: 36px;
  height: 36px;
  line-height: 36px;
  color: var(--sm-ink);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--sm-line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.leaflet-container .leaflet-control-zoom a:last-child,
.sm-tools__btn:last-child {
  border-bottom: 0;
}
.leaflet-container .leaflet-control-zoom a:hover,
.sm-tools__btn:hover {
  background: var(--sm-brand-50);
  color: var(--sm-brand-700);
}
.sm-tools__btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.leaflet-container .leaflet-control-layers-toggle {
  width: 40px;
  height: 40px;
  background-size: 22px;
}
.leaflet-container .leaflet-control-layers-expanded {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--sm-ink);
}
.leaflet-container .leaflet-control-layers label {
  margin: 0;
  padding: 3px 0;
  cursor: pointer;
}
.leaflet-container .leaflet-control-layers input {
  accent-color: var(--sm-brand);
  margin-right: 6px;
}
.leaflet-container .leaflet-control-layers-separator {
  border-top-color: var(--sm-line);
}
.leaflet-container .leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, .78);
  border-top-left-radius: 6px;
}
.leaflet-container :focus-visible {
  outline: 3px solid var(--sm-brand);
  outline-offset: 2px;
}

/* Popups i tooltips --------------------------------------------------- */
.leaflet-container .leaflet-popup-content-wrapper {
  border-radius: var(--sm-radius);
  box-shadow: var(--sm-shadow);
}
.leaflet-container .leaflet-popup-content {
  margin: 14px 16px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--sm-ink);
}
.leaflet-container .leaflet-tooltip.sm-tip {
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: var(--sm-shadow);
  color: var(--sm-ink);
  font-size: 13px;
  line-height: 1.35;
}
.sm-tip strong {
  display: block;
  font-weight: 700;
}
.sm-tip span {
  color: var(--sm-soft);
}

/* Clústers en donut --------------------------------------------------- */
.sm-cluster {
  background: none;
}
.sm-cluster svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .25));
  transition: transform .15s ease-out;
}
.sm-cluster:hover svg {
  transform: scale(1.08);
}
.sm-cluster text {
  font-family: inherit;
  font-weight: 700;
  fill: var(--sm-ink);
}

/* Punts --------------------------------------------------------------- */
.sm-pin {
  background: none;
}
.sm-pin__dot {
  display: block;
  width: var(--s, 16px);
  height: var(--s, 16px);
  border-radius: 50%;
  background: var(--c) var(--i, none) center / 62% no-repeat;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 1px 4px rgba(0, 0, 0, .3);
  box-sizing: border-box;
  transition: transform .15s ease-out;
}
.sm-pin__dot.has-icon {
  border-width: 2px;
}
.sm-pin__dot.is-hollow {
  background: #fff;
  border: 3px solid var(--c);
}
.sm-pin:hover .sm-pin__dot {
  transform: scale(1.25);
}

/* Halo ---------------------------------------------------------------- */
.sm-halo {
  background: none;
  pointer-events: none;
}
.sm-halo__ring {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  box-sizing: border-box;
  animation: sm-halo 1.4s ease-out infinite;
}
@keyframes sm-halo {
  from {
    transform: scale(.4);
    opacity: 1;
  }
  to {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* Llegenda ------------------------------------------------------------ */
.sm-legend {
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  box-shadow: var(--sm-shadow);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 260px;
}
.sm-legend__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--sm-soft);
  padding: 2px 6px 4px;
}
.sm-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  padding: 4px 6px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--sm-ink);
  text-align: left;
  cursor: pointer;
  user-select: none;
}
.sm-legend__item:hover {
  background: var(--sm-brand-50);
}
.sm-legend__swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}
.sm-legend__label {
  flex: 1;
}
.sm-legend__count {
  color: var(--sm-soft);
  font-variant-numeric: tabular-nums;
}
.sm-legend__item.is-off {
  opacity: .45;
}
.sm-legend__item.is-off .sm-legend__swatch {
  background: #fff;
  box-shadow: 0 0 0 1px var(--c);
}

@media (prefers-reduced-motion: reduce) {
  .sm-halo__ring {
    animation: none;
  }
  .sm-cluster svg,
  .sm-pin__dot {
    transition: none;
  }
}

/* Punt amb anell: registre amb més informació (p. ex. trajectòria). */
.sm-pin__dot.has-ring {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sm-brand), 0 2px 5px rgba(0, 0, 0, .3);
}

/* Botons comuns ------------------------------------------------------- */
.sm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #D8D0DD;
  background: #fff;
  color: var(--sm-ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.sm-btn:hover {
  border-color: var(--sm-brand);
  color: var(--sm-brand-700);
}
.sm-btn--primary {
  background: var(--sm-brand);
  border-color: var(--sm-brand);
  color: #fff;
}
.sm-btn--primary:hover {
  background: var(--sm-brand-700);
  color: #fff;
}

/* Panell d'agrupació (sota els botons d'eines) ------------------------- */
.sm-tools-wrap {
  position: relative;
}
.sm-tools__btn.is-active {
  background: var(--sm-brand-50);
  color: var(--sm-brand-700);
}
.sm-tools__panel {
  position: absolute;
  top: 0;
  right: calc(100% + 10px);
  width: 250px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--sm-shadow);
  color: var(--sm-ink);
  font-size: 13px;
  line-height: 1.4;
  cursor: default;
}
.leaflet-left .sm-tools__panel {
  right: auto;
  left: calc(100% + 10px);
}
.sm-tools__panel[hidden] {
  display: none;
}
.sm-tools__panel-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--sm-soft);
}
.sm-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-weight: 600;
  cursor: pointer;
}
.sm-switch input,
.sm-range input {
  accent-color: var(--sm-brand);
}
.sm-switch input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.sm-range {
  display: block;
  margin: 0;
}
.sm-range > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.sm-range output {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sm-range input {
  width: 100%;
  margin: 0;
}
.sm-range input:disabled {
  opacity: .4;
}
.sm-tools__hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--sm-soft);
}

/* Llegenda amb icona (p. ex. mapa de vida: pastís, taüt…) */
.sm-legend__swatch.has-icon {
  width: 22px;
  height: 22px;
  background: var(--c) var(--i) center / 60% no-repeat;
}
.sm-legend__item.is-off .sm-legend__swatch.has-icon {
  background: var(--c) var(--i) center / 60% no-repeat;
  opacity: .5;
}
