/* =============================================================
   Commons World — community-map.css
   Styles [cw_community_map] and [cw_community_register].
   Uses the theme's design tokens (base.css :root) with literal
   fallbacks, so it still looks right on any page or template.
   ============================================================= */

.cw-cm,
.cw-cm-register {
  --_navy: var(--cw-navy, #142844);
  --_gold: var(--cw-gold, #c8a24a);
  --_gold-deep: var(--cw-gold-deep, #9f7b2b);
  --_cream: var(--cw-cream-light, #fffaf1);
  --_ink: var(--cw-ink, #10213a);
  --_muted: var(--cw-text-muted, #5f7083);
  --_border: var(--cw-border, rgba(16, 33, 58, 0.16));
  --_radius: var(--cw-radius-md, 16px);
  --_font: var(--cw-font-body, "Source Sans 3 var", system-ui, sans-serif);
  --_serif: var(--cw-font-heading, "Source Serif 4 var", Georgia, serif);
  font-family: var(--_font);
  color: var(--_ink);
}

/* ---- search bar above the map ------------------------------------------ */
.cw-cm__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}
.cw-cm__search {
  flex: 1 1 16rem;
  min-width: 0;
  width: auto;
}
.cw-cm__go,
.cw-cm__near {
  flex: 0 0 auto;
  width: auto;
}
.cw-cm__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Message directly under the search buttons (progress and location errors). */
.cw-cm__toolnote[hidden] {
  display: none;
}
.cw-cm__toolnote {
  margin: -0.2rem 0 0.9rem;
  padding: 0.65rem 0.85rem;
  border-left: 3px solid var(--_gold);
  border-radius: var(--cw-radius-sm, 10px);
  background: var(--_cream);
  color: var(--_ink);
  font-size: var(--cw-fs-small, 0.95rem);
  line-height: 1.45;
}

/* ---- the map frame ------------------------------------------------------ */
.cw-cm__canvas {
  width: 100%;
  min-height: 240px;
  border: 1px solid var(--_border);
  border-radius: var(--_radius);
  overflow: hidden;
  background: var(--cw-cream, #f7f1e7);
  box-shadow: 0 10px 28px rgba(11, 29, 51, 0.1);
  /* Keep Leaflet's panes/controls below sticky headers and modals. */
  position: relative;
  z-index: 0;
  isolation: isolate;
}
.cw-cm .leaflet-container,
.cw-cm-register .leaflet-container {
  font-family: var(--_font);
  background: var(--cw-cream, #f7f1e7);
}

/* A light warm tint so the stock OpenStreetMap tiles sit comfortably on the
   cream pages instead of looking like a foreign widget. Remove this rule for
   the plain OpenStreetMap look. */
.cw-cm__canvas .leaflet-tile-pane {
  filter: sepia(0.16) saturate(0.88);
}

.cw-cm__status {
  margin: 0.8rem 0 0;
  min-height: 1.4em;
  font-size: var(--cw-fs-small, 0.95rem);
  color: var(--_muted);
}

/* ---- the pin ------------------------------------------------------------ */
.cw-cm-pin {
  background: none;
  border: 0;
}
.cw-cm-pin span {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--_gold);
  border: 2px solid var(--_navy);
  box-shadow: 0 5px 10px rgba(11, 29, 51, 0.35);
}
.cw-cm-pin span::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--_navy);
}
.cw-cm-pin:focus-visible span,
.cw-cm-pin:hover span {
  background: var(--cw-gold-soft, #d8b85f);
}
.cw-cm-pin:focus-visible {
  outline: none;
}
.cw-cm-pin:focus-visible span {
  box-shadow: 0 0 0 3px rgba(200, 162, 74, 0.55), 0 5px 10px rgba(11, 29, 51, 0.35);
}

/* ---- popups ------------------------------------------------------------- */
.cw-cm .leaflet-popup-content-wrapper,
.cw-cm-register .leaflet-popup-content-wrapper {
  background: var(--_cream);
  color: var(--_ink);
  border-radius: var(--cw-radius-sm, 10px);
  border: 1px solid var(--cw-gold-border, rgba(191, 148, 56, 0.34));
  box-shadow: 0 12px 28px rgba(11, 29, 51, 0.22);
}
.cw-cm .leaflet-popup-tip,
.cw-cm-register .leaflet-popup-tip {
  background: var(--_cream);
}
.cw-cm-popup {
  display: grid;
  gap: 0.3rem;
  font-family: var(--_font);
  line-height: 1.4;
}
.cw-cm-popup__name {
  font-family: var(--_serif);
  font-size: 1.1rem;
  color: var(--_navy);
}
.cw-cm-popup__place {
  font-size: 0.9rem;
  color: var(--_muted);
}
.cw-cm-popup__pillar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--_ink);
}
.cw-cm-popup__pillar-label {
  padding: 0.05rem 0.45rem;
  border-radius: var(--cw-radius-pill, 9999px);
  background: var(--_navy);
  color: var(--cw-cream, #f7f1e7);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cw-cm-popup__note {
  font-size: 0.85rem;
  color: var(--_muted);
  font-style: italic;
}
.cw-cm-popup__mail,
.cw-cm-popup__reveal {
  justify-self: start;
  margin-top: 0.25rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--_navy);
  text-decoration: underline;
  text-decoration-color: var(--_gold);
  text-underline-offset: 3px;
  word-break: break-all;
}
.cw-cm-popup__reveal {
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
.cw-cm-popup__mail:hover,
.cw-cm-popup__reveal:hover {
  color: var(--_gold-deep);
}

/* ---- the "you searched here" pin: same shape, inverted colours --------- */
.cw-cm-pin--here span {
  background: var(--_navy);
  border-color: var(--_gold);
}
.cw-cm-pin--here span::after {
  background: var(--_gold);
}
.cw-cm-here-tip.leaflet-tooltip {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--cw-gold-border, rgba(191, 148, 56, 0.34));
  border-radius: var(--cw-radius-sm, 10px);
  background: var(--_cream);
  color: var(--_navy);
  font-family: var(--_font);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 6px 14px rgba(11, 29, 51, 0.22);
}
.cw-cm-here-tip.leaflet-tooltip-top::before {
  border-top-color: var(--_cream);
}

/* ---- nearest communities, listed under the map ------------------------- */
.cw-cm__nearest[hidden] {
  display: none;
}
.cw-cm__nearest {
  margin-top: 1rem;
}
.cw-cm__nearest-title {
  margin: 0 0 0.6rem;
  font-family: var(--_serif);
  font-size: 1.15rem;
  color: var(--_navy);
}
.cw-cm__nearest-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cw-cm__nearest-item {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.95rem;
  text-align: left;
  font: inherit;
  color: var(--_ink);
  background: var(--_cream);
  border: 1px solid var(--_border);
  border-radius: var(--cw-radius-sm, 10px);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cw-cm__nearest-item:hover,
.cw-cm__nearest-item:focus-visible {
  border-color: var(--_gold);
  box-shadow: 0 0 0 3px rgba(200, 162, 74, 0.28);
  outline: none;
}
.cw-cm__nearest-name {
  font-family: var(--_serif);
  font-size: 1.05rem;
  color: var(--_navy);
}
.cw-cm__nearest-meta {
  font-size: 0.9rem;
  color: var(--_muted);
}
.cw-cm__nearest-dist {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--_gold-deep);
}

/* ---- grouped pins (several communities close together) ---------------- */
.cw-cm-cluster {
  background: none;
  border: 0;
}
.cw-cm-cluster span {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--_navy);
  color: var(--cw-cream, #f7f1e7);
  border: 3px solid var(--_gold);
  box-shadow: 0 0 0 4px rgba(200, 162, 74, 0.28), 0 6px 14px rgba(11, 29, 51, 0.35);
  font-family: var(--_font);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}
.cw-cm-cluster:hover span,
.cw-cm-cluster:focus-visible span {
  background: var(--cw-navy-soft, #1b3456);
  box-shadow: 0 0 0 5px rgba(200, 162, 74, 0.5), 0 6px 14px rgba(11, 29, 51, 0.35);
}
.cw-cm-cluster:focus-visible {
  outline: none;
}

/* ---- popup that lists several communities ----------------------------- */
.cw-cm-popup--list {
  gap: 0.5rem;
}
.cw-cm-popup__count {
  font-family: var(--_serif);
  font-size: 1.05rem;
  color: var(--_navy);
}
.cw-cm-popup__scroll {
  display: grid;
  gap: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.25rem;
}
.cw-cm-popup__item + .cw-cm-popup__item {
  padding-top: 0.75rem;
  border-top: 1px solid var(--cw-gold-border, rgba(191, 148, 56, 0.34));
}

/* Zoom buttons in the theme's colours. */
.cw-cm .leaflet-bar a,
.cw-cm-register .leaflet-bar a {
  background: var(--_cream);
  color: var(--_navy);
  border-bottom-color: var(--_border);
}
.cw-cm .leaflet-bar a:hover,
.cw-cm-register .leaflet-bar a:hover {
  background: #fff;
  color: var(--_gold-deep);
}
.cw-cm .leaflet-control-attribution,
.cw-cm-register .leaflet-control-attribution {
  background: rgba(255, 250, 241, 0.85);
  font-size: 0.7rem;
}

/* ---- registration form -------------------------------------------------- */
.cw-cm-register__form {
  max-width: 40rem;
}
.cw-cm-register__place {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.cw-cm-register__place .cw-field__input {
  flex: 1 1 14rem;
  min-width: 0;
  width: auto;
}
.cw-cm-register__place .cw-btn {
  flex: 0 0 auto;
  width: auto;
}
.cw-cm-register__help {
  margin: 0.55rem 0 0.7rem;
  font-size: var(--cw-fs-small, 0.95rem);
  color: var(--_muted);
}
.cw-cm-register__map {
  margin-bottom: 0.25rem;
}
.cw-cm-register__done {
  max-width: 40rem;
  padding: 1.5rem;
  border: 1px solid var(--cw-gold-border, rgba(191, 148, 56, 0.34));
  border-radius: var(--_radius);
  background: var(--_cream);
}
.cw-cm-register__done h3 {
  margin: 0 0 0.4rem;
  font-family: var(--_serif);
  color: var(--_navy);
}
.cw-cm-register__done p {
  margin: 0;
}

/* Honeypot: off-screen, not display:none (some bots skip display:none). */
.cw-cm__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---- small screens ------------------------------------------------------ */
@media (max-width: 600px) {
  .cw-cm__go,
  .cw-cm__near {
    flex: 1 1 calc(50% - 0.3rem);
  }
  .cw-cm__canvas {
    border-radius: var(--cw-radius-sm, 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cw-cm-pin span {
    transition: none;
  }
}
