/**
 * Citrosuco — Mapa de Eventos — estilos de frontend.
 *
 * Tudo é escopado em .cme-wrapper. As cores vêm de CSS custom properties
 * injetadas pelo shortcode (--cme-cor-*, --cme-fonte).
 */

.cme-wrapper,
.cme-wrapper *,
.cme-wrapper *::before,
.cme-wrapper *::after {
	box-sizing: border-box;
}

.cme-wrapper {
	position: relative;
	width: 100%;
	overflow: hidden;
	font-family: var(--cme-fonte, "Raleway", system-ui, sans-serif);
}

.cme-container {
	position: relative;
	width: 100%;
	margin: 0 auto;
}

/* ------------------------------------------------------- Viewport / Zoom */
.cme-viewport {
	position: absolute;
	inset: 0;
	overflow: hidden;
	background: var(--cme-cor-oceano, #f5f5f5);
	touch-action: none; /* gestos de pan/pinça tratados via JS */
	cursor: grab;
}

.cme-viewport.cme-zoomed:active {
	cursor: grabbing;
}

/* O stage mantém SEMPRE a proporção real do mapa (2:1): largura = 100% do
   viewport e altura ditada pelo próprio SVG (height:auto). O zoom/pan (JS)
   escala o stage para preencher o viewport — inclusive no mobile, onde o
   container é mais alto. Assim o mapa nunca fica achatado nem desalinha dos
   pins (que se posicionam em % deste mesmo box). */
.cme-stage {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	transform-origin: 0 0;
	will-change: transform;
}

/* ----------------------------------------------------------------- SVG */
.cme-svg-bg {
	display: block;
	width: 100%;
	height: auto;
	line-height: 0;
	background: var(--cme-cor-oceano, #f5f5f5);
}

/* O SVG define a própria altura (width:100% + height:auto), o que mantém o
   container e a camada de pins exatamente sobre o mapa. */
.cme-svg-bg svg {
	display: block;
	width: 100%;
	height: auto;
	user-select: none;
	pointer-events: none;
}

/* ---------------------------------------------------------------- Pins */
.cme-pins {
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 5;
}

/* Ancoragem geográfica: a PONTA do pin (bottom-center) fica exatamente sobre a
   coordenada (x, y) — que vem da geolocalização/calibração. translate(-50%,-100%)
   move a gota para que a ponta aterrisse no ponto; transform-origin bottom center
   faz o hover crescer sem deslocar a ponta. */
.cme-pin {
	position: absolute;
	width: clamp(32px, 2.4vw, 44px);
	aspect-ratio: 68 / 89;
	color: var(--cme-cor-pin, #fe8100);
	cursor: pointer;
	pointer-events: auto;
	/* Contra-escala pelo zoom (--cme-zoom) para o pin manter tamanho de tela
	   constante, estilo marcador de mapa, em qualquer nível de zoom. */
	transform: translate(-50%, -100%) scale(calc(1 / var(--cme-zoom, 1)));
	transform-origin: bottom center;
	transition: transform 0.2s ease;
	filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
	z-index: 10;
}

.cme-pin:hover,
.cme-pin:focus-visible,
.cme-pin.cme-pin-active {
	transform: translate(-50%, -100%) scale(calc(1.15 / var(--cme-zoom, 1)));
	outline: none;
	z-index: 30; /* traz o pin sob o cursor/ativo para a frente em clusters */
}

.cme-pin svg {
	display: block;
	width: 100%;
	height: 100%;
	pointer-events: none;
}

.cme-pin svg path {
	fill: currentColor;
}

/* Glow verde no hover (atrás do pin). */
.cme-pin::before {
	content: "";
	position: absolute;
	width: 230%;
	aspect-ratio: 1;
	left: 50%;
	top: 28%;
	transform: translate(-50%, -50%);
	border-radius: 50%;
	background: var(--cme-cor-glow-hover, #4e9f44);
	opacity: 0;
	transition: opacity 0.2s ease;
	z-index: -1;
	pointer-events: none;
}

.cme-pin:hover::before,
.cme-pin:focus-visible::before {
	opacity: 0.3;
}

/* Badge de contagem em pins agrupados (cluster). Como o pin já é
   contra-escalado pelo zoom, o badge herda essa escala e fica do tamanho de
   tela constante junto com a gota. */
.cme-pin-count {
	position: absolute;
	top: -2px;
	right: -6px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	background: #fff;
	color: var(--cme-cor-pin, #fe8100);
	border: 2px solid var(--cme-cor-pin, #fe8100);
	border-radius: 999px;
	font-size: 11px;
	font-weight: 800;
	line-height: 16px;
	text-align: center;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
	pointer-events: none;
	z-index: 2;
}

/* Hit area ampliada (mobile). */
.cme-pin::after {
	content: "";
	position: absolute;
	top: -10px;
	left: -16px;
	right: -16px;
	bottom: -36px;
}

/* Legenda do país. */
.cme-pin-label {
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	margin-top: 6px;
	padding: 3px 10px;
	white-space: nowrap;
	font-size: clamp(10px, 0.85vw, 13px);
	font-weight: 700;
	color: #1a1a1a;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 10px;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
	letter-spacing: 0.02em;
	user-select: none;
	pointer-events: none;
	transition: background 0.2s ease, color 0.2s ease;
}

.cme-pin:hover .cme-pin-label,
.cme-pin:focus-visible .cme-pin-label {
	background: var(--cme-cor-label-bg-hover, #fe8100);
	color: #fff;
}

.cme-wrapper.cme-hide-labels .cme-pin-label {
	display: none;
}

/* -------------------------------------------------------------- Modal */
.cme-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	background: rgba(0, 0, 0, 0.6);
	font-family: var(--cme-fonte, "Raleway", system-ui, sans-serif);
}

.cme-modal.is-open {
	display: block;
	animation: cmeFade 0.2s ease;
}

@keyframes cmeFade {
	from { opacity: 0; }
	to { opacity: 1; }
}

.cme-modal-content {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: calc(100% - 40px);
	max-width: 560px;
	max-height: calc(100vh - 40px);
	background: var(--cme-cor-modal-bg, #005d32);
	color: var(--cme-cor-modal-texto, #fff);
	border-radius: 20px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
	overflow: hidden;
	display: flex;
	animation: cmePop 0.25s ease;
}

@keyframes cmePop {
	from { opacity: 0; transform: translate(-50%, -48%); }
	to { opacity: 1; transform: translate(-50%, -50%); }
}

.cme-modal-image {
	width: 270px;
	min-height: 380px;
	flex-shrink: 0;
	object-fit: cover;
}

.cme-modal-image[hidden] {
	display: none;
}

.cme-modal-close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 10;
	color: var(--cme-cor-modal-texto, #fff);
	background: rgba(0, 0, 0, 0.3);
	border: 0;
	cursor: pointer;
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: background 0.2s, transform 0.3s;
}

.cme-modal-close:hover,
.cme-modal-close:focus-visible {
	background: rgba(0, 0, 0, 0.5);
	transform: rotate(90deg);
	outline: none;
}

.cme-modal-body {
	flex: 1;
	padding: 40px 30px;
	overflow-y: auto;
	min-width: 0;
}

.cme-modal-title {
	font-weight: 700;
	font-size: clamp(22px, 2.4vw, 32px);
	color: var(--cme-cor-modal-texto, #fff);
	margin: 0 0 20px;
	line-height: 1.1;
	padding-right: 36px;
}

.cme-modal-info {
	font-weight: 500;
	font-size: clamp(13px, 1.1vw, 15px);
	color: var(--cme-cor-modal-texto, #fff);
	line-height: 1.5;
}

.cme-modal-info p {
	margin: 0 0 8px;
}

.cme-modal-info strong {
	font-weight: 700;
}

.cme-modal-descricao {
	margin-top: 16px;
	font-size: clamp(13px, 1.1vw, 15px);
	line-height: 1.6;
	color: var(--cme-cor-modal-texto, #fff);
}

.cme-modal-descricao p {
	margin: 0 0 12px;
}

.cme-modal-descricao a {
	color: inherit;
	text-decoration: underline;
}

/* -------- Modal em modo "cluster" (múltiplos eventos no mesmo ponto) -------- */
.cme-modal.cme-modal-multi .cme-modal-image {
	display: none !important;
}

.cme-modal-events {
	display: flex;
	flex-direction: column;
	gap: 14px;
	color: var(--cme-cor-modal-texto, #fff);
}

.cme-modal-events-head {
	padding-right: 40px; /* respira longe do botão de fechar */
}

.cme-modal-events-title {
	font-weight: 700;
	font-size: clamp(22px, 2.4vw, 30px);
	margin: 0;
	line-height: 1.1;
}

.cme-modal-events-sub {
	margin: 6px 0 0;
	font-size: 13px;
	opacity: 0.78;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

/* Lista compacta de eventos no modal cluster: cada item é um botão que abre
   o detalhe completo do evento no mesmo modal (com botão "Voltar"). */
.cme-cluster-items {
	list-style: none;
	margin: 16px 0 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.cme-cluster-item-wrap {
	margin: 0;
}

.cme-cluster-item {
	display: flex;
	align-items: center;
	gap: 10px;
	width: 100%;
	text-align: left;
	padding: 12px 14px;
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 10px;
	cursor: pointer;
	color: var(--cme-cor-modal-texto, #fff);
	font-family: inherit;
	transition: background 0.15s ease, transform 0.1s ease;
}

.cme-cluster-item:hover,
.cme-cluster-item:focus-visible {
	background: rgba(255, 255, 255, 0.16);
	outline: none;
}

.cme-cluster-item:active {
	transform: scale(0.99);
}

.cme-cluster-item-body {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.cme-cluster-item-title {
	font-weight: 700;
	font-size: 15px;
	line-height: 1.25;
}

.cme-cluster-item-sub {
	font-size: 13px;
	opacity: 0.78;
}

.cme-cluster-item-chevron {
	font-size: 22px;
	line-height: 1;
	opacity: 0.7;
	flex-shrink: 0;
}

.cme-modal-back {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin: 0 0 14px;
	padding: 6px 12px 6px 8px;
	background: rgba(255, 255, 255, 0.08);
	border: 0;
	border-radius: 999px;
	cursor: pointer;
	color: inherit;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	transition: background 0.15s ease;
}

.cme-modal-back:hover,
.cme-modal-back:focus-visible {
	background: rgba(255, 255, 255, 0.18);
	outline: none;
}

.cme-modal-back span {
	font-size: 18px;
	line-height: 1;
}

@media (max-width: 768px) {
	.cme-modal-content {
		flex-direction: column;
		max-height: 92vh;
		width: calc(100% - 24px);
	}
	.cme-modal-image {
		width: 100% !important;
		height: auto !important;
		aspect-ratio: 4 / 3;
		max-height: 200px !important;
		min-height: 0 !important;
	}
	.cme-modal-body {
		padding: 22px;
	}
}

/* --------------------------------------------------- Crosshair (preview) */
.cme-coords {
	position: absolute;
	top: 12px;
	left: 12px;
	background: rgba(0, 0, 0, 0.85);
	color: #fff;
	padding: 10px 14px;
	border-radius: 6px;
	font: 12px/1.4 ui-monospace, monospace;
	z-index: 30;
	display: none;
}

.cme-wrapper.cme-crosshair-on .cme-coords {
	display: block;
}

.cme-coords small {
	display: block;
	font-size: 11px;
	color: #d1d5db;
	margin-top: 4px;
}

.cme-wrapper.cme-crosshair-on .cme-container {
	cursor: crosshair;
}

/* ------------------------------------------------ Painel de lista de eventos */
.cme-list {
	position: absolute;
	top: 14px;
	right: 14px;
	bottom: 14px;
	z-index: 40;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 10px;
	max-width: calc(100% - 28px);
	pointer-events: none; /* deixa cliques passarem para os pins atrás da faixa */
	font-family: var(--cme-fonte, "Raleway", system-ui, sans-serif);
}

.cme-list-toggle {
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: #fff;
	color: #1a1a1a;
	border: 0;
	cursor: pointer;
	padding: 9px 15px;
	border-radius: 999px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	font-weight: 700;
	font-size: 13px;
	line-height: 1;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.cme-list-toggle:hover,
.cme-list-toggle:focus-visible {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
	outline: none;
}

.cme-list-count {
	background: var(--cme-cor-pin, #fe8100);
	color: #fff;
	border-radius: 999px;
	padding: 1px 7px;
	font-size: 11px;
	font-weight: 700;
	min-width: 18px;
	text-align: center;
}

.cme-list.is-open .cme-list-toggle {
	display: none;
}

.cme-list-panel {
	pointer-events: auto;
	display: none;
	flex: 1 1 auto;
	min-height: 0;
	flex-direction: column;
	width: min(320px, calc(100vw - 40px));
	background: rgba(255, 255, 255, 0.97);
	border-radius: 16px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
	overflow: hidden;
	animation: cmeListIn 0.18s ease;
}

@keyframes cmeListIn {
	from { opacity: 0; transform: translateY(-6px); }
	to { opacity: 1; transform: translateY(0); }
}

.cme-list.is-open .cme-list-panel {
	display: flex;
}

.cme-list-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
	font-size: 15px;
	color: #1a1a1a;
}

.cme-list-close {
	background: none;
	border: 0;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	color: #666;
	padding: 0 4px;
}

.cme-list-close:hover {
	color: #000;
}

.cme-list-controls {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 12px 14px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cme-list-search,
.cme-list-filter {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	font-size: 13px;
	font-family: inherit;
	background: #fff;
	color: #1a1a1a;
}

.cme-list-search:focus,
.cme-list-filter:focus {
	outline: none;
	border-color: var(--cme-cor-pin, #fe8100);
}

.cme-list-items {
	list-style: none;
	margin: 0;
	padding: 6px;
	overflow-y: auto;
	flex: 1 1 auto;
	min-height: 0;
}

.cme-list-item {
	margin: 0;
}

.cme-list-item[hidden] {
	display: none;
}

.cme-list-item-btn {
	display: flex;
	flex-direction: column;
	gap: 2px;
	width: 100%;
	text-align: left;
	background: none;
	border: 0;
	cursor: pointer;
	padding: 10px 10px;
	border-radius: 8px;
	color: #1a1a1a;
	font-family: inherit;
	transition: background 0.12s ease;
}

.cme-list-item-btn:hover,
.cme-list-item-btn:focus-visible {
	background: rgba(0, 0, 0, 0.05);
	outline: none;
}

.cme-list-item-title {
	font-weight: 700;
	font-size: 14px;
	line-height: 1.25;
}

.cme-list-item-sub {
	font-size: 12px;
	color: #666;
}

.cme-list-empty {
	padding: 18px 14px;
	margin: 0;
	font-size: 13px;
	color: #666;
	text-align: center;
}

@media (max-width: 600px) {
	.cme-list {
		top: 10px;
		right: 10px;
		bottom: 10px;
		left: 10px;
		max-width: none;
		align-items: stretch;
	}
	.cme-list-toggle {
		align-self: flex-end;
		padding: 11px 18px;
		font-size: 14px;
	}
	.cme-list-panel {
		width: 100%;
		border-radius: 18px;
	}
	.cme-list-head {
		padding: 14px 16px;
		font-size: 16px;
	}
	.cme-list-close {
		font-size: 30px;
		padding: 0 8px;
	}
	.cme-list-search,
	.cme-list-filter {
		padding: 12px 12px;
		font-size: 16px; /* >=16px evita zoom automático do iOS ao focar */
	}
	.cme-list-item-btn {
		padding: 14px 12px;
	}
	.cme-list-item-title {
		font-size: 15px;
	}
	.cme-list-item-sub {
		font-size: 13px;
	}
}

/* No mobile o mapa ganha altura: a proporção 2:1 do globo deixaria o mapa baixo
   demais (~195px num celular). Como a visualização inicial já dá zoom nos últimos
   eventos, uma altura maior torna os pins fáceis de tocar. Width definida (100%)
   + height definida fazem o navegador ignorar o aspect-ratio inline do container. */
@media (max-width: 768px) {
	.cme-container {
		height: 72vh;
		min-height: 440px;
		max-height: 680px;
	}
}
