@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap");

.pcr-widget,
.pcr-widget * {
  box-sizing: border-box;
}

.pcr-widget {
  container-name: pcr-widget;
  container-type: inline-size;
  --pcr-primary: #607EB8;
  --pcr-secondary: #f8fafc;
  --pcr-text: #4F596A;
  --pcr-muted: #657084;
  --pcr-border: #E5E9F0;
  --pcr-soft: color-mix(in srgb, var(--pcr-primary) 10%, white);
  width: 100%;
  min-width: 0;
  overflow: hidden;
  background: #fff;
  color: var(--pcr-text);
  border: 1px solid var(--pcr-border);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(31, 43, 67, 0.08);
  font-family: var(--pcr-font, "Poppins", sans-serif);
}

.pcr-widget.pcr-borderless {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.pcr-widget.pcr-flat {
  box-shadow: none;
}

.pcr-header {
  display: flex;
  padding: 26px 24px 14px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.pcr-header h2 {
  margin: 0;
  color: var(--pcr-text);
  font-size: var(--pcr-title-font-size, 30px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}

.pcr-header p {
  max-width: 680px;
  margin: 7px 0 0;
  color: var(--pcr-muted);
  font-size: 14px;
  line-height: 1.45;
}

.pcr-heading {
  min-width: 0;
}

.pcr-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-direction: row;
  align-items: flex-start;
  align-self: flex-start;
  margin-left: auto;
  gap: 8px;
}

.pcr-download-report {
  appearance: none;
  display: inline-flex;
  min-height: 38px;
  padding: 9px 16px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--pcr-primary);
  background: #fff;
  border: 1px solid var(--pcr-border);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}

.pcr-download-report svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: currentColor;
}

.pcr-download-report:hover {
  background: var(--pcr-soft);
  border-color: color-mix(in srgb, var(--pcr-primary) 18%, white);
  box-shadow: 0 5px 14px rgba(16, 24, 40, .08);
  transform: translateY(-1px);
}

.pcr-download-report:active {
  box-shadow: none;
  transform: translateY(0);
}

.pcr-download-report:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--pcr-primary) 40%, white);
  outline-offset: 2px;
}

@container pcr-widget (max-width: 700px) {
  .pcr-header-actions {
    gap: 6px;
  }

  .pcr-download-report {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 11px;
  }
}

.pcr-map-card {
  margin: 0 24px 14px;
  overflow: hidden;
  border: 1px solid var(--pcr-border);
  border-radius: 18px;
  background: #eef2f7;
}

.pcr-map-wrap {
  position: relative;
  width: 100%;
  min-height: 550px;
  overflow: hidden;
  background: #eef2f7;
}

.pcr-map {
  position: absolute;
  inset: 0;
}

/* MapLibre paints the basemap; Leaflet must receive map drag gestures. */
.pcr-map .maplibregl-canvas-container,
.pcr-map .maplibregl-canvas {
  pointer-events:none !important;
}

.pcr-map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--pcr-muted);
  font-size: 13px;
  text-align: center;
}

.pcr-crimeometer-logo {
  position: absolute;
  z-index: 401;
  top: 12px;
  left: 12px;
  display: inline-flex;
  max-width: min(120px, calc(100% - 84px));
  padding: 4px 6px;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(229, 233, 240, 0.72);
  border-radius: 7px;
  box-shadow: 0 6px 18px rgba(31, 43, 67, 0.08);
  text-decoration: none;
}

.pcr-crimeometer-logo img {
  display: block;
  width: 99px;
  max-width: 100%;
  height: auto;
}

.pcr-crime-legend {
  position: absolute;
  z-index: 401;
  bottom: 42px;
  left: 50%;
  display: inline-flex;
  min-height: 28px;
  padding: 5px 9px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(229, 233, 240, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 4px 14px rgba(31, 43, 67, 0.08);
  color: #657084;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
  transform: translateX(-50%);
}

.pcr-crime-legend-scale {
  display: block;
  width: 88px;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f7b6b2 0%, #e56a61 50%, #9f1d1d 100%);
}

.pcr-map-pin-icon,
.pcr-map-pin-icon * {
  box-sizing: border-box;
}

.pcr-map-pin-icon span {
  display: block;
  width: 34px;
  height: 34px;
  position: relative;
}

.pcr-map-pin-icon img {
  display: block;
  width: 34px;
  height: 34px;
  max-width: none;
  object-fit: contain;
}

.pcr-powered {
  display: flex;
  padding: 0 24px 12px;
  justify-content: flex-end;
}

.pcr-powered a {
  display: inline-flex;
}

.pcr-powered img {
  display: block;
  width: auto;
  max-width: 150px;
  height: 25px;
}

.pcr-map .leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(213,219,230,.95) !important;
  border-radius: 14px !important;
  box-shadow: 0 10px 24px rgba(21,32,51,.14) !important;
}

.pcr-map .leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  border: 0 !important;
  color: #4F596A !important;
  background: rgba(255,255,255,.96) !important;
  font-family: var(--pcr-font, Poppins, Arial, sans-serif) !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.pcr-map .leaflet-control-zoom a:hover,
.pcr-map .leaflet-control-zoom a:focus-visible {
  background: #F3F4F6 !important;
  color: #4B5563 !important;
  border-color: #E5E7EB !important;
}

.pcr-map .leaflet-control-zoom a + a {
  border-top: 1px solid rgba(213,219,230,.95) !important;
}

.pcr-map .leaflet-control-attribution {
  padding: 3px 8px !important;
  border-radius: 999px 0 0 0 !important;
  background: rgba(255,255,255,.88) !important;
  color: #657084 !important;
  box-shadow: 0 4px 14px rgba(21,32,51,.08) !important;
  font-size: 10px !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.pcr-map .leaflet-control-attribution * {
  -webkit-user-select: none !important;
  user-select: none !important;
}

.pcr-map .leaflet-control-attribution a {
  color: #657084 !important;
  text-decoration: none !important;
}

.pcr-map .leaflet-control-attribution a:hover {
  color: var(--pcr-primary) !important;
}

.pcr-attribution-toggle {
  display: none;
}

.pcr-attribution-content {
  display: inline;
}

@container pcr-widget (max-width: 480px) {
  .pcr-map .leaflet-control-attribution {
    position: relative;
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 28px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: flex-end !important;
    overflow: visible !important;
    border-radius: 14px 0 0 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .pcr-map .leaflet-bottom.leaflet-right {
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    pointer-events: none;
  }

  .pcr-map .leaflet-bottom.leaflet-right .leaflet-control-attribution {
    pointer-events: auto;
  }

  .pcr-map .pcr-attribution-toggle {
    position: relative !important;
    z-index: 2 !important;
    display: flex;
    flex: 0 0 28px !important;
    width: 28px !important;
    height: 28px !important;
    margin: 0 !important;
    padding: 0;
    border: 0;
    border-radius: 14px 0 0 0;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.94);
    color: #657084;
    box-shadow: 0 4px 14px rgba(21,32,51,.10);
    font: 700 14px/1 var(--pcr-font, Poppins, Arial, sans-serif);
    cursor: pointer;
  }

  .pcr-map .pcr-attribution-content {
    position: absolute !important;
    right: 28px !important;
    bottom: 0 !important;
    left: 0 !important;
    display: flex !important;
    width: auto !important;
    height: 28px !important;
    max-width: none !important;
    padding: 0 8px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    overflow: hidden !important;
    border-radius: 8px 0 0 0 !important;
    background: rgba(255,255,255,.96) !important;
    color: #657084 !important;
    font-size: 9px !important;
    line-height: 1 !important;
    text-align: right !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(4px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s ease;
  }

  .pcr-map .pcr-attribution-content a {
    flex: 0 0 auto;
    white-space: nowrap !important;
  }

  .pcr-map .pcr-attribution-content a:last-child {
    margin-left: 6px !important;
  }

  .pcr-map .leaflet-control-attribution.is-expanded .pcr-attribution-content {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .pcr-map .leaflet-control-attribution.is-expanded .pcr-attribution-toggle {
    color: var(--pcr-primary);
  }
}

.pcr-map.leaflet-gesture-handling-scroll-warning::after,
.pcr-map.leaflet-gesture-handling-touch-warning::after {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 760;
  max-width: min(280px, calc(100% - 36px));
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(79,89,106,.84);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  opacity: 1;
  transform: translate(-50%, -50%);
  animation: pcr-gesture-message-fade 1.5s ease forwards;
  box-shadow: 0 10px 28px rgba(21,32,51,.22);
}

.pcr-map.leaflet-gesture-handling-warning-fading::after {
  opacity: 0;
}

@keyframes pcr-gesture-message-fade {
  0%, 72% { opacity: 1; }
  100% { opacity: 0; }
}

.pcr-map.leaflet-gesture-handling-touch-warning::after {
  content: attr(data-gesture-handling-touch-content);
}

.pcr-map.leaflet-gesture-handling-scroll-warning::after {
  content: attr(data-gesture-handling-scroll-content);
}

@container pcr-widget (max-width: 640px) {
  .pcr-header {
    padding: 20px 18px 12px;
  }

  .pcr-header h2 {
    font-size: 23px !important;
    line-height: 1.08;
  }

  .pcr-header p {
    font-size: 13px;
  }

  .pcr-map-card {
    margin: 0 18px 12px;
  }

  .pcr-powered {
    padding: 0 18px 12px;
  }
}

@container pcr-widget (max-width: 700px) {
  .pcr-powered img {
    height: 20px;
  }
}

@container pcr-widget (max-width: 480px) {
  .pcr-header {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
  }

  .pcr-header h2 {
    font-size: 20px !important;
  }

  .pcr-header-actions {
    align-self: flex-start;
    margin-left: auto;
  }

  .pcr-download-report span {
    display: none;
  }

  .pcr-download-report {
    width: 36px;
    min-height: 34px;
    padding: 0;
  }

  .pcr-map-wrap {
    min-height: 550px;
  }
}

/* Keep the descriptive copy on its own full-width header row. */
.pcr-header {
  display: block;
}

.pcr-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.pcr-header-actions {
  align-self: center;
}

.pcr-subtitle {
  display: block;
  width: 100%;
  max-width: none !important;
}

@container pcr-widget (max-width: 480px) {
  .pcr-header-top { gap: 10px; }
}

/* Match the compact title-to-subtitle spacing used by the other widgets. */
@container pcr-widget (max-width: 560px) {
  .pcr-header p {
    margin-top: 5px;
  }
}
