/* ==========================================================================
   ReCreate digital map — scoped widget stylesheet
   --------------------------------------------------------------------------
   Every rule is scoped under `.rc-map` so the stylesheet can be dropped into a
   WordPress theme without leaking into the surrounding page, and so theme rules
   are less likely to leak in. Nothing here touches `body`, `html` or `*`.
   ========================================================================== */

.rc-map {
  /* Public theming API — override these on the container, inline or in the
     theme, to restyle the widget without editing this file. */
  --rc-primary: #662091;
  --rc-primary-soft: rgba(102, 32, 145, 0.12);
  --rc-accent: #27AAE1;
  --rc-surface: rgba(255, 255, 255, 0.92);
  --rc-text: #1c2340;
  --rc-muted: #5b6480;
  --rc-radius: 12px;
  --rc-font: 'Poppins', 'Segoe UI', Arial, sans-serif;
  --rc-height: 70vh;
  --rc-min-height: 420px;
  --rc-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);

  position: relative;   /* anchor for overlays — the map, not the page */
  display: block;
  width: 100%;
  height: var(--rc-height);
  min-height: var(--rc-min-height);
  margin: 0;
  overflow: hidden;
  border-radius: var(--rc-radius);
  background: #f3f5f9;
  font-family: var(--rc-font);
  color: var(--rc-text);
  isolation: isolate;   /* keeps our z-indexes out of the theme's stacking order */
}

/* Themes routinely set a global box-sizing that breaks Leaflet's pixel maths.
   Re-assert sane values inside the widget only. */
.rc-map,
.rc-map *,
.rc-map *::before,
.rc-map *::after {
  box-sizing: border-box;
}

/* Leaflet mounts into this child so the container can also host the status
   banner without Leaflet clobbering it. */
.rc-map .rc-map__canvas {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 100%;
}

.rc-map .leaflet-container {
  height: 100%;
  width: 100%;
  background: #f3f5f9;
  font-family: var(--rc-font);
  font-size: 14px;
  line-height: 1.45;
}

/* Themes often force `img { max-width: 100% }` plus margins on figures; Leaflet
   tiles must stay untouched or the raster seams show. */
.rc-map .leaflet-tile,
.rc-map .leaflet-marker-icon,
.rc-map .leaflet-image-layer {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   Logo badge (a Leaflet control, so it is clipped by the map, not the page)
   -------------------------------------------------------------------------- */

.rc-map .rc-logo {
  background: var(--rc-surface);
  backdrop-filter: blur(8px);
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: var(--rc-shadow);
  width: 168px;
  max-width: 40vw;
}

.rc-map .rc-logo a {
  display: block;
  line-height: 0;
  border: 0;
  box-shadow: none;
}

.rc-map .rc-logo a:focus-visible {
  outline: 2px solid var(--rc-primary);
  outline-offset: 4px;
  border-radius: 10px;
}

.rc-map .rc-logo img {
  width: 100%;
  height: auto;
  display: block;
}

/* --------------------------------------------------------------------------
   Layer control
   -------------------------------------------------------------------------- */

.rc-map .leaflet-control-layers {
  font-family: var(--rc-font);
  background: var(--rc-surface);
  border: 0;
  border-radius: var(--rc-radius);
  padding: 10px 12px;
  box-shadow: var(--rc-shadow);
  color: var(--rc-text);
  max-width: min(280px, 60vw);
}

.rc-map .rc-control__toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 5px 8px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--rc-primary);
  cursor: pointer;
}

.rc-map .rc-control__toggle:hover {
  background: var(--rc-primary-soft);
}

.rc-map .rc-control__toggle:focus-visible {
  outline: 2px solid var(--rc-primary);
  outline-offset: 1px;
}

.rc-map .rc-control__toggle span {
  font-size: 15px;
  line-height: 1;
}

/* max-height is set from the map size in JS: a percentage would resolve
   against Leaflet's auto-height corner container and be ignored. */
.rc-map .rc-control__body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.rc-map .rc-control.is-collapsed .rc-control__body {
  display: none;
}

.rc-map .leaflet-control-layers label {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 2px 0;
  font-size: 13px;
  font-weight: 400;
  color: inherit;
  cursor: pointer;
}

.rc-map .leaflet-control-layers-group-name {
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rc-primary);
  margin: 10px 0 4px;
}

.rc-map .leaflet-control-layers-selector {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(102, 32, 145, 0.6);
  border-radius: 4px;
  margin: 0 8px 0 0;
  position: relative;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.rc-map .leaflet-control-layers-selector:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 32, 145, 0.25);
}

.rc-map .leaflet-control-layers-selector:checked {
  background: var(--rc-primary);
  border-color: var(--rc-primary);
}

.rc-map .leaflet-control-layers-selector:checked::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* A small colour chip next to each overlay name, injected by the widget so the
   legend and the map agree without a separate legend box. */
.rc-map .rc-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 7px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.rc-map .rc-swatch.is-square {
  border-radius: 1px;
}

.rc-map .rc-swatch.is-round {
  border-radius: 50%;
}

.rc-map .rc-quick-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(28, 35, 64, 0.15);
}

.rc-map .rc-quick-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.rc-map .rc-quick-btn {
  flex: 1;
  border: 0;
  border-radius: 999px;
  padding: 7px 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rc-map .rc-quick-btn.is-primary {
  background: var(--rc-primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(102, 32, 145, 0.25);
}

.rc-map .rc-quick-btn.is-secondary {
  background: var(--rc-primary-soft);
  color: var(--rc-primary);
}

.rc-map .rc-quick-btn:hover {
  transform: translateY(-1px);
}

.rc-map .rc-quick-btn:focus-visible {
  outline: 2px solid var(--rc-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Popups
   -------------------------------------------------------------------------- */

.rc-map .leaflet-popup-content-wrapper {
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--rc-radius);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  padding: 2px;
}

.rc-map .leaflet-popup-content {
  margin: 12px 14px;
  width: auto !important;   /* Leaflet writes an inline width; this wins it back */
  max-width: min(88vw, 620px);
  font-size: 14px;
  line-height: 1.5;
  color: var(--rc-text);
}

.rc-map .leaflet-popup-close-button {
  color: var(--rc-primary) !important;
  padding: 6px 8px 0 0 !important;
  font-size: 20px !important;
}

.rc-map .rc-popup-title {
  margin: 0 0 8px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rc-primary);
}

.rc-map .rc-popup-sub {
  margin: -4px 0 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rc-muted);
}

/* Metadata rendered as a definition list rather than <b>key</b>: value soup. */
.rc-map .rc-fields {
  display: grid;
  grid-template-columns: minmax(88px, auto) 1fr;
  gap: 3px 12px;
  margin: 0;
  font-size: 13px;
}

.rc-map .rc-fields dt {
  margin: 0;
  font-weight: 600;
  color: var(--rc-muted);
}

.rc-map .rc-fields dd {
  margin: 0;
  color: var(--rc-text);
  overflow-wrap: anywhere;
}

.rc-map .rc-empty {
  margin: 0;
  font-size: 13px;
  font-style: italic;
  color: var(--rc-muted);
}

.rc-map .rc-popup-img {
  display: block;
  width: 100%;
  height: auto;
  margin: 10px 0 0;
  border-radius: 8px;
}

/* Long-form country dossier */
.rc-map .rc-dossier {
  width: min(78vw, 600px);
  max-height: var(--rc-popup-max-h, min(56vh, 420px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  font-size: 13.5px;
  line-height: 1.55;
}

.rc-map .rc-dossier h1,
.rc-map .rc-dossier h2,
.rc-map .rc-dossier h3 {
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--rc-primary);
}

.rc-map .rc-dossier h1:first-child,
.rc-map .rc-dossier h2:first-child,
.rc-map .rc-dossier h3:first-child {
  margin-top: 0;
}

.rc-map .rc-dossier p {
  margin: 0 0 10px;
}

.rc-map .rc-dossier ul,
.rc-map .rc-dossier ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.rc-map .rc-dossier li {
  margin: 0 0 3px;
}

.rc-map .rc-dossier blockquote {
  margin: 0 0 10px;
  padding: 2px 0 2px 10px;
  border-left: 3px solid var(--rc-primary-soft);
  color: var(--rc-muted);
}

.rc-map .rc-dossier a {
  color: var(--rc-primary);
  overflow-wrap: anywhere;
}

.rc-map .rc-dossier img,
.rc-map .rc-dossier .popup-img-large {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  margin: 4px 0 10px;
  border-radius: 8px;
  background: #eceff5;
}

.rc-map .rc-dossier table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin: 0 0 10px;
}

.rc-map .rc-dossier th,
.rc-map .rc-dossier td {
  border: 1px solid rgba(28, 35, 64, 0.15);
  padding: 4px 6px;
  text-align: left;
}

.rc-map .rc-dossier::-webkit-scrollbar {
  width: 10px;
}

.rc-map .rc-dossier::-webkit-scrollbar-track {
  border-radius: 10px;
  background: #f0f2f6;
}

.rc-map .rc-dossier::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background: #c7ccd8;
}

/* --------------------------------------------------------------------------
   Feature interaction
   -------------------------------------------------------------------------- */

.rc-map .rc-feature-hover {
  filter: drop-shadow(0 0 10px rgba(102, 32, 145, 0.55));
}

.rc-map .leaflet-interactive:focus-visible {
  outline: 3px solid var(--rc-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Status banner (loading / partial failure)
   -------------------------------------------------------------------------- */

.rc-map .rc-status {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  z-index: 1200;
  max-width: min(92%, 520px);
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--rc-surface);
  box-shadow: var(--rc-shadow);
  font-size: 13px;
  color: var(--rc-text);
  text-align: center;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.rc-map .rc-status[hidden] {
  display: none;
}

.rc-map .rc-status.is-error {
  color: #8a1a24;
  background: rgba(255, 240, 241, 0.97);
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  .rc-map {
    --rc-height: 78vh;
    --rc-min-height: 380px;
  }

  .rc-map .rc-logo {
    width: 118px;
    padding: 7px 10px;
  }

  .rc-map .leaflet-control-layers {
    padding: 10px;
    font-size: 12px;
    max-width: 62vw;
  }

  /* Height stays under the JS-driven --rc-popup-max-h so the dossier is always
     bounded by the map rather than the viewport. */
  .rc-map .rc-dossier {
    width: 74vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rc-map * {
    transition: none !important;
    animation: none !important;
  }
}
