/* Pistacchissimo — mappa (/mappa/, W3). Caricato da _main.php solo su body.is-map,
   dopo leaflet.css + MarkerCluster.css. Layout full-screen, pin/cluster/popup
   custom (palette pistacchio), pannello filtri floating (desktop) / sheet (mobile). */

/* ---- layout full-screen ---- */
body.is-map { overflow: hidden; }
body.is-map .site-footer { display: none; }

.map-shell { position: fixed; top: 48px; left: 0; right: 0; bottom: 64px; z-index: 1; }
#pst-map { position: absolute; inset: 0; background: #aadaff; }

/* Leaflet: font del sito + attribuzione discreta */
.leaflet-container { font-family: var(--font-body); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,.75); }
.leaflet-bar a { color: var(--n-700); }

/* ---- pin teardrop pistacchio ---- */
.pst-pin {
	position: absolute; bottom: 2px; left: 50%; margin-left: -13px;
	width: 26px; height: 26px; background: var(--pist-500); border: 2px solid #fff;
	border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
	box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
.pst-pin::after {
	content: ""; position: absolute; left: 50%; top: 50%;
	width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
	border-radius: 50%; background: #fff;
}
.leaflet-marker-icon.pst-pin-wrap:hover { z-index: 1000 !important; }

/* ---- cluster ---- */
.pst-cluster { background: rgba(132,165,58,.45); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.pst-cluster b { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--pist-500); color: #fff; font: 700 12px/1 var(--font-body); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.pst-cluster.medium b { width: 36px; height: 36px; background: var(--pist-600); font-size: 13px; }
.pst-cluster.large b  { width: 40px; height: 40px; background: var(--pist-700); font-size: 14px; }

/* ---- popup ---- */
.pst-popup .leaflet-popup-content-wrapper { background: var(--cream-50); border-radius: var(--r-lg); box-shadow: 0 12px 28px rgba(31,30,27,.22); border: 1px solid var(--n-100); padding: 0; }
.pst-popup .leaflet-popup-content { margin: 0; }
.pst-popup .leaflet-popup-tip { background: var(--cream-50); }
.pop { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 10px; }
.pop-cover { width: 84px; height: 84px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.9); }
.pop-cover .phi { width: 30px; height: 30px; }
.pop-cover.green  { background: linear-gradient(135deg, var(--pist-200), var(--pist-500)); }
.pop-cover.olive  { background: linear-gradient(135deg, var(--pist-300), var(--pist-700)); }
.pop-cover.brown  { background: linear-gradient(135deg, var(--terra-300), var(--terra-700)); }
.pop-cover.terra  { background: linear-gradient(135deg, var(--terra-100), var(--terra-500)); }
.pop-cover.cream  { background: linear-gradient(135deg, var(--cream-200), var(--paglia-400)); color: var(--terra-700); }
.pop-cover.paglia { background: linear-gradient(135deg, var(--paglia-200), var(--paglia-600)); color: var(--terra-900); }
.pop-cover.dark   { background: linear-gradient(135deg, var(--n-300), var(--n-700)); }
/* con foto (cover del luogo o dell'articolo citante meglio votato) il gradiente sparisce */
.pop-cover.has-img { overflow: hidden; background: none; }
.pop-cover.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pop-meta { min-width: 0; padding: 2px 6px 2px 0; }
.pop-meta h4 { margin: 0 0 4px; font: 700 15px/1.2 var(--font-display); color: var(--n-900); }
.pop-meta .ct { margin: 0 0 4px; font: 500 11px/1.3 var(--font-body); color: var(--n-500); text-transform: uppercase; letter-spacing: 0.03em; }
.pop-meta .rate { margin: 0 0 4px; font: 600 13px/1 var(--font-body); color: var(--n-900); }
.pop-meta .rate .star { color: var(--star); }
.pop-meta .addr { margin: 0 0 6px; font: 400 11px/1.35 var(--font-body); color: var(--n-700); }
.pop-meta .cta { font: 600 12px/1 var(--font-body); color: var(--pist-700); text-decoration: none; }
.pop-meta .cta:hover { text-decoration: underline; }

/* ---- contatore "N in vista" ---- */
.map-counter { position: absolute; z-index: 600; top: 12px; left: 12px; background: var(--n-900); color: var(--n-0); padding: 8px 14px; border-radius: var(--r-full); font: 600 12px/1 var(--font-body); display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow-2); }
.map-counter .ico { display: inline-flex; }
.map-counter .ico .phi { width: 14px; height: 14px; }

/* ---- FAB filtri (mobile) ---- */
.map-fab { position: absolute; z-index: 600; right: 14px; bottom: 18px; width: 56px; height: 56px; border-radius: 50%; background: var(--pist-500); color: var(--n-0); border: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(132,165,58,.5), 0 2px 6px rgba(0,0,0,.15); cursor: pointer; }
.map-fab .phi { width: 24px; height: 24px; }
.map-fab .badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--r-full); background: var(--terra-500); color: var(--n-0); font: 700 11px/20px var(--font-body); border: 2px solid var(--cream-50); }

.map-backdrop { position: absolute; inset: 0; z-index: 1100; background: rgba(31,30,27,.4); backdrop-filter: blur(2px); }

/* ---- pannello filtri (mobile: bottom-sheet) ---- */
.map-panel { position: absolute; z-index: 1200; left: 0; right: 0; bottom: 0; background: var(--cream-50); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(0,0,0,.18); display: flex; flex-direction: column; max-height: 82%; transform: translateY(101%); transition: transform .22s ease; }
.map-panel[data-sheet="1"] { transform: translateY(0); }

.map-panel .panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px 12px; border-bottom: 1px solid var(--n-100); cursor: pointer; user-select: none; position: relative; }
.map-panel .panel-head::before { content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 2px; background: var(--n-200); }
.map-panel .panel-head h3 { flex: 1; margin: 0; font: 700 15px/1 var(--font-display); color: var(--n-900); }
.map-panel .panel-head .badge-count { background: var(--pist-500); color: var(--n-0); padding: 3px 8px; border-radius: var(--r-full); font: 700 10px/1 var(--font-body); }
.map-panel .panel-head .chev { display: none; }
.map-panel .panel-head .sheet-close { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--n-100); color: var(--n-700); font: 600 16px/1 var(--font-body); cursor: pointer; }

.map-panel .panel-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }

.filter-group h4 { font: 600 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--n-500); margin: 0 0 10px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chips .chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; border-radius: var(--r-full); background: var(--n-0); border: 1px solid var(--n-200); font: 500 12px/1 var(--font-body); color: var(--n-700); cursor: pointer; }
.filter-chips .chip .ico { width: 20px; height: 20px; border-radius: 50%; background: #FBF7EC; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.filter-chips .chip .ico svg { width: 14px; height: 14px; display: block; }
.filter-chips .chip.active { background: var(--pist-500); color: var(--n-0); border-color: var(--pist-500); box-shadow: 0 2px 6px rgba(132,165,58,.3); }
.filter-chips .chip.active .ico { background: rgba(255,255,255,.25); }

.filter-slider input[type="range"] { width: 100%; accent-color: var(--pist-500); margin: 4px 0; }
.filter-slider .slider-value { text-align: center; font: 600 13px/1 var(--font-body); color: var(--pist-700); margin-top: 6px; }
.filter-slider .slider-value .star { color: var(--star); }

.filter-select { width: 100%; appearance: none; padding: 10px 36px 10px 12px; border-radius: var(--r-md); border: 1px solid var(--n-200); background: var(--n-0) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%2384817A' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 12px center; font: 500 13px/1 var(--font-body); color: var(--n-900); cursor: pointer; }

.filter-apply { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--n-100); padding: 14px 18px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--cream-100); }
.filter-apply .preview { flex: 1; font: 500 12px/1.3 var(--font-body); color: var(--n-500); }
.filter-apply .preview strong { color: var(--pist-700); font-weight: 700; }
.filter-apply .reset { background: transparent; color: var(--n-700); border: 0; font: 500 12px/1 var(--font-body); padding: 8px; cursor: pointer; text-decoration: underline; }
.filter-apply .apply { background: var(--pist-500); color: var(--n-0); border: 0; padding: 10px 18px; border-radius: var(--r-full); font: 600 13px/1 var(--font-body); cursor: pointer; box-shadow: 0 2px 8px rgba(132,165,58,.4); }

/* ===================== DESKTOP ===================== */
@media (min-width: 1024px) {
	body.is-map .d-content { padding: 0; max-width: none; height: 100vh; overflow: hidden; }
	.map-shell { position: relative; top: 0; bottom: 0; height: 100vh; }

	.map-counter { top: 18px; left: auto; right: 24px; }

	.map-fab, .map-backdrop { display: none; }

	/* pannello → floating top-left, aperto di default, collassabile */
	.map-panel { top: 24px; left: 24px; right: auto; bottom: auto; width: 320px; max-height: calc(100% - 48px); border-radius: var(--r-lg); box-shadow: var(--shadow-3); border: 1px solid var(--n-100); transform: none; }
	.map-panel .panel-head { background: var(--cream-100); border-radius: var(--r-lg) var(--r-lg) 0 0; }
	.map-panel .panel-head::before { display: none; }
	.map-panel .panel-head h3 { font: 600 13px/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.06em; color: var(--n-700); }
	.map-panel .panel-head .sheet-close { display: none; }
	.map-panel .panel-head .chev { display: block; color: var(--n-500); font-size: 14px; transition: transform .2s; }
	.map-panel[data-collapsed="1"] { max-height: 49px; overflow: hidden; }
	.map-panel[data-collapsed="1"] .panel-head .chev { transform: rotate(-90deg); }
}
