/* ============================================
   SOMOS LOMAS — MAPA DE CLUSTERS (clusters.php)
   ============================================ */

.cm { max-width: 1440px; margin: 0 auto; padding: 2rem 2rem 3rem; }

/* ---- INTRO ---- */
.cm-intro {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem;
  margin-bottom: 1.5rem;
}
.cm-intro__title {
  font-family: var(--font-d); font-size: 40px; font-weight: 700;
  color: var(--dark); line-height: 1.1;
}
.cm-intro__title em { font-style: italic; color: var(--red); }
.cm-intro__sub { margin-top: .6rem; max-width: 560px; font-size: 15px; color: var(--muted); line-height: 1.55; }
.cm-intro__stat { text-align: right; flex-shrink: 0; }
.cm-intro__n { display: block; font-family: var(--font-d); font-size: 44px; font-weight: 700; color: var(--dark); line-height: 1; }
.cm-intro__l { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---- LAYOUT ---- */
.cm-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem;
  height: clamp(520px, calc(100vh - var(--nav-h) - 3rem), 860px);
}

/* ---- MAPA ---- */
.cm-map {
  position: relative; overflow: hidden;
  background: #1f7a35;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab; outline: none;
}
.cm-map:focus-visible { box-shadow: var(--shadow-md), 0 0 0 3px var(--red); }
.cm-map.is-dragging { cursor: grabbing; }
.cm-svg { display: block; width: 100%; height: 100%; }

.cm-shape {
  fill: transparent; stroke: transparent; stroke-width: 1.5;
  vector-effect: non-scaling-stroke; stroke-linejoin: round;
  cursor: pointer; transition: fill .15s, stroke .15s;
}
.cm-map:not(.is-dragging) .cm-shape:hover { fill: rgba(208, 25, 25, .16); stroke: var(--red); }
.cm-map.show-outlines .cm-shape { fill: rgba(208, 25, 25, .07); stroke: rgba(208, 25, 25, .6); stroke-width: 1; }
.cm-map.is-searching .cm-shape.is-match { fill: rgba(255, 196, 0, .35); stroke: #B7791F; stroke-width: 1.5; }
.cm-map .cm-shape.is-selected,
.cm-map .cm-shape.is-selected:hover {
  fill: rgba(208, 25, 25, .42); stroke: var(--red-dark); stroke-width: 2.5;
}

.cm-labels text {
  font-family: 'Source Sans 3', 'Myriad Pro', 'DM Sans', sans-serif; font-weight: 600;
  fill: #141414; text-anchor: middle; pointer-events: none;
}

/* ---- CONTROLES ---- */
.cm-controls {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  display: flex; flex-direction: column; gap: 6px;
}
.cm-btn {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: var(--white); color: var(--dark); border: none;
  font-size: 22px; line-height: 1; box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s;
}
.cm-btn:hover { background: var(--cream); color: var(--red); }
.cm-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.cm-btn:disabled { opacity: .45; cursor: default; }
.cm-btn[aria-pressed="true"] { background: var(--red); color: var(--white); }
.cm-btn .cm-ico-collapse { display: none; }
.cm-map.is-full .cm-btn .cm-ico-expand { display: none; }
.cm-map.is-full .cm-btn .cm-ico-collapse { display: inline; }

/* ---- CHIP DE SELECCIÓN ---- */
.cm-chip {
  position: absolute; left: 14px; top: 14px; z-index: 3; max-width: calc(100% - 84px);
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border-radius: var(--radius-full);
  padding: 6px 6px 6px 16px; box-shadow: var(--shadow-md);
}
.cm-chip[hidden] { display: none; }
.cm-chip__code {
  font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--red);
  background: var(--red-light); border-radius: var(--radius-full); padding: 3px 8px;
}
.cm-chip__code:empty { display: none; }
.cm-chip__name { font-weight: 600; font-size: 14px; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-chip__close {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; border: none;
  background: var(--cream-2); color: var(--dark); font-size: 18px; line-height: 1;
}
.cm-chip__close:hover { background: var(--red); color: var(--white); }

/* ---- TOOLTIP / AVISO ---- */
.cm-tip {
  position: absolute; z-index: 4; pointer-events: none;
  background: var(--dark); color: var(--white);
  font-size: 13px; font-weight: 500; padding: 6px 10px; border-radius: var(--radius-sm);
  white-space: nowrap; box-shadow: var(--shadow-md);
}
.cm-tip[hidden] { display: none; }
.cm-tip span { color: var(--silver-light); font-weight: 400; margin-left: 6px; }
.cm-hint {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 20, .45); color: var(--white);
  font-size: 18px; font-weight: 500; text-align: center; padding: 1rem;
  opacity: 0; transition: opacity .25s;
}
.cm-hint.is-visible { opacity: 1; }

/* ---- PANTALLA COMPLETA ---- */
.cm-map.is-full {
  position: fixed; inset: 0; z-index: 10000; border-radius: 0;
  height: auto; max-height: none;
}
body.cm-no-scroll { overflow: hidden; }

/* ---- PANEL ---- */
.cm-panel {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.cm-detail {
  flex-shrink: 0; max-height: calc(100% - 150px); overflow-y: auto; overscroll-behavior: contain;
  padding: 1.25rem; border-bottom: 1px solid var(--border); background: var(--cream);
}
.cm-detail__empty { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.cm-detail__empty[hidden] { display: none; }
.cm-detail__icon {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--white); color: var(--red);
}
.cm-detail__eyebrow { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.cm-detail__name { font-family: var(--font-d); font-size: 26px; font-weight: 700; color: var(--dark); line-height: 1.15; margin-top: .35rem; }
.cm-detail__code { margin-top: .4rem; font-size: 13px; color: var(--muted); }
.cm-detail__code:empty { display: none; }
.cm-detail__code strong { color: var(--dark); font-weight: 600; }
.cm-detail__photo {
  margin: 0 0 .75rem; aspect-ratio: 11 / 5; overflow: hidden;
  border-radius: var(--radius-md); background: var(--cream-2);
}
.cm-detail__photo[hidden] { display: none; }
.cm-detail__photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cm-detail__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: .6rem; }
.cm-detail__tags:empty { display: none; }
.cm-tag {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--dark); background: var(--cream-2); border-radius: var(--radius-full); padding: 4px 10px;
}
.cm-tag--zona { color: var(--red); background: var(--red-light); }
.cm-fact {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--border);
}
.cm-fact[hidden] { display: none; }
.cm-fact__icon { flex-shrink: 0; color: var(--red); margin-top: 2px; }
.cm-fact__label { font-size: 13px; font-weight: 500; color: var(--red); }
.cm-fact__value { font-size: 14px; color: var(--dark); line-height: 1.45; margin-top: 2px; }
.cm-fact__value a { color: var(--dark); text-decoration: underline; text-decoration-color: rgba(208, 25, 25, .45); text-underline-offset: 3px; }
.cm-fact__value a:hover { color: var(--red); text-decoration-color: currentColor; }
.cm-detail__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1rem; }
.cm-detail__btn { padding: 9px 14px; font-size: 13px; }
.cm-detail__btn.btn-outline { background: var(--white); }

.cm-search { padding: 1rem 1.25rem .5rem; }
.cm-search input {
  width: 100%; border: 1px solid rgba(0, 0, 0, .14); border-radius: var(--radius-md);
  padding: 11px 14px; font-size: 14px; background: var(--white); color: var(--text);
}
.cm-search input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(208, 25, 25, .12); }
.cm-search__count { margin-top: .5rem; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.cm-list { position: relative; list-style: none; overflow-y: auto; flex: 1; min-height: 0; padding: 0 .75rem 1rem; overscroll-behavior: contain; }
.cm-list li[hidden] { display: none; }
.cm-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 9px 10px; text-align: left; font-size: 14px; color: var(--text);
}
.cm-item:hover { background: var(--cream-2); }
.cm-item:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.cm-item.is-active { background: var(--red); color: var(--white); }
.cm-item__code { font-size: 11px; font-weight: 600; color: var(--muted); flex-shrink: 0; }
.cm-item.is-active .cm-item__code { color: rgba(255, 255, 255, .8); }
.cm-list__empty { padding: 0 1.25rem 1.25rem; font-size: 14px; color: var(--muted); }

.cm-note { margin-top: 1rem; font-size: 12px; color: var(--muted); }

/* ---- RESPONSIVE ---- */
@media (max-width: 960px) {
  .cm { padding: 1.25rem 1rem 2.5rem; }
  .cm-intro { align-items: flex-start; flex-direction: column; gap: .75rem; }
  .cm-intro__title { font-size: 30px; }
  .cm-intro__stat { text-align: left; display: flex; align-items: baseline; gap: 8px; }
  .cm-intro__n { font-size: 28px; }
  .cm-layout { grid-template-columns: 1fr; height: auto; }
  .cm-detail { max-height: none; overflow: visible; }
  .cm-detail__photo { aspect-ratio: 16 / 9; }
  .cm-map { height: clamp(300px, calc((100vw - 2rem) / 1.5), 70vh); }
  .cm-list { max-height: 360px; }
  .cm-btn { width: 38px; height: 38px; }
}
