/**
 * Caprigran – Mapa de socios
 *
 * Los colores están en variables: ajústalos a los de la web en .cgs
 * (o sobrescríbelos desde el CSS del tema).
 */

.cgs {
	--cgs-color: #2f4f2f;            /* Color principal (botones, grupos) */
	--cgs-color-contraste: #ffffff;
	--cgs-nucleo: #8a3324;           /* Núcleo selectivo */
	--cgs-control: #c98a1b;          /* Control lechero oficial */
	--cgs-base: #5b7f3a;             /* Ganadería base */
	--cgs-none: #619828;             /* Sin nivel indicado: verde Caprigran */
	--cgs-texto: inherit;
	--cgs-borde: rgba(0, 0, 0, .15);
	--cgs-radio: 6px;

	font: inherit;
	color: var(--cgs-texto);
}

/* Filtros ---------------------------------------------------------------- */

.cgs-filtros {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: .75rem 1rem;
	margin-bottom: 1rem;
}

.cgs-filtro {
	display: flex;
	flex-direction: column;
	gap: .25rem;
	min-width: 12rem;
	flex: 0 1 16rem;
}

.cgs-filtro__label {
	font-size: .875em;
	font-weight: 600;
}

.cgs-filtro select {
	width: 100%;
	min-height: 2.5rem;
	padding: .4rem .6rem;
	border: 1px solid var(--cgs-borde);
	border-radius: var(--cgs-radio);
	background-color: #fff;
	font: inherit;
	color: inherit;
}

.cgs-reset {
	min-height: 2.5rem;
	padding: .4rem .9rem;
	border: 1px solid var(--cgs-color);
	border-radius: var(--cgs-radio);
	background: transparent;
	color: var(--cgs-color);
	font: inherit;
	cursor: pointer;
}

.cgs-reset:hover,
.cgs-reset:focus-visible {
	background: var(--cgs-color);
	color: var(--cgs-color-contraste);
}

.cgs-reset[hidden] {
	display: none;
}

.cgs-contador {
	margin: 0 0 0 auto;
	align-self: center;
	font-size: .9375em;
}

/* Mapa ------------------------------------------------------------------- */

.cgs-mapa {
	position: relative;
	z-index: 0;            /* Que el mapa no se ponga por encima de cabeceras fijas o menús */
	isolation: isolate;
	width: 100%;
	height: var(--cgs-alto, 600px);
	min-height: 320px;
	border-radius: var(--cgs-radio);
	overflow: hidden;
	background: #e8eef0;
}

@media (max-width: 767px) {
	.cgs-mapa {
		height: min(var(--cgs-alto, 600px), 70vh);
	}

	.cgs-filtro {
		flex: 1 1 100%;
	}

	.cgs-contador {
		margin-left: 0;
	}
}

/* El tema pone img { max-width: 100%; height: auto } y eso descoloca las teselas */
.cgs-mapa img,
.cgs-mapa .leaflet-tile {
	max-width: none !important;
	max-height: none !important;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	box-shadow: none !important;
}

/* Leaflet 1.9 pinta las teselas con mix-blend-mode: plus-lighter; con el mapa
   en medio píxel (el contenedor de la web queda centrado en x,5 px) los bordes
   se suman y aparecen líneas blancas. En modo normal desaparecen. */
.cgs-mapa .leaflet-container img.leaflet-tile,
.cgs-mapa img.leaflet-tile {
	mix-blend-mode: normal !important;
}

.cgs-noscript {
	padding: 2rem;
	text-align: center;
}

.cgs-mapa .leaflet-container,
.cgs-mapa.leaflet-container {
	font: inherit;
}

/* Marcadores ------------------------------------------------------------- */

.cgs-pin {
	background: none;
	border: 0;
}

.cgs-pin span {
	display: block;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	border: 3px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
	background: var(--cgs-none);
	transition: transform .15s ease;
}

.cgs-pin:hover span,
.cgs-pin:focus span {
	transform: scale(1.2);
}

.cgs-pin--nucleo_selectivo span { background: var(--cgs-nucleo); }
.cgs-pin--control_lechero span  { background: var(--cgs-control); }
.cgs-pin--ganaderia_base span   { background: var(--cgs-base); }

.cgs-cluster {
	background: none;
	border: 0;
}

.cgs-cluster span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	border-radius: 50%;
	background: var(--cgs-color);
	color: var(--cgs-color-contraste);
	font-weight: 700;
	font-size: 14px;
	box-shadow: 0 0 0 5px rgba(255, 255, 255, .7), 0 2px 6px rgba(0, 0, 0, .3);
}

/* Ficha (popup) ---------------------------------------------------------- */

.cgs-popup .leaflet-popup-content-wrapper {
	border-radius: var(--cgs-radio);
}

.cgs-popup .leaflet-popup-content {
	margin: 1rem 1.1rem;
	font-size: 15px;
	line-height: 1.4;
}

/* Selectores con .cgs .cgs-ficha delante para que no los pisen los estilos del tema. */
.cgs .cgs-ficha > * {
	margin-top: 0;
	margin-block-start: 0;
}

.cgs .cgs-ficha .cgs-ficha__nombre {
	margin: 0 0 .2rem;
	padding: 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: normal;
	text-transform: none;
}

.cgs .cgs-ficha .cgs-ficha__lugar {
	margin: 0 0 .6rem;
	font-size: 15px;
	opacity: .8;
}

.cgs .cgs-ficha .cgs-ficha__nivel {
	display: inline-block;
	margin: 0 0 .7rem;
	padding: .15rem .55rem;
	border-radius: 999px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
	color: #fff;
	background: var(--cgs-none);
}

.cgs .cgs-ficha .cgs-ficha__nivel--nucleo_selectivo { background: var(--cgs-nucleo); }
.cgs .cgs-ficha .cgs-ficha__nivel--control_lechero  { background: var(--cgs-control); }
.cgs .cgs-ficha .cgs-ficha__nivel--ganaderia_base   { background: var(--cgs-base); }

.cgs .cgs-ficha .cgs-ficha__contacto {
	margin: 0 0 .8rem;
	padding: 0;
	list-style: none;
}

.cgs .cgs-ficha .cgs-ficha__contacto li {
	margin: .15rem 0;
	padding: 0;
	word-break: break-word;
}

.cgs .cgs-ficha .cgs-ficha__contacto li::before {
	content: none;
}

.cgs .cgs-ficha a {
	color: var(--cgs-color);
}

.cgs .cgs-ficha .cgs-ficha__ruta {
	display: inline-block;
	padding: .45rem .9rem;
	border-radius: var(--cgs-radio);
	background: var(--cgs-color);
	color: var(--cgs-color-contraste);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
}

.cgs .cgs-ficha .cgs-ficha__ruta:hover,
.cgs .cgs-ficha .cgs-ficha__ruta:focus-visible {
	opacity: .9;
	text-decoration: underline;
}

/* Leyenda ---------------------------------------------------------------- */

.cgs-leyenda {
	display: flex;
	flex-wrap: wrap;
	gap: .5rem 1.25rem;
	margin: .75rem 0 0;
	padding: 0;
	list-style: none;
	font-size: .875em;
}

.cgs-leyenda li {
	display: flex;
	align-items: center;
	gap: .4rem;
	margin: 0;
}

.cgs-dot {
	display: inline-block;
	width: 12px;
	height: 12px;
	border-radius: 50%;
	background: var(--cgs-none);
}

.cgs-dot--nucleo_selectivo { background: var(--cgs-nucleo); }
.cgs-dot--control_lechero  { background: var(--cgs-control); }
.cgs-dot--ganaderia_base   { background: var(--cgs-base); }

/* Aviso «Usa dos dedos» en pantallas táctiles */
.cgs-gesto {
	position: absolute;
	inset: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(29, 30, 57, .72);
	color: #fff;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
	text-align: center;
	opacity: 0;
	pointer-events: none;
	transition: opacity .25s ease;
}

.cgs-gesto.is-visible {
	opacity: 1;
}
