/* XBAZAR 2.0 - Mappa delle attività */

:root {
  --azzurro: #1F6FB2;        /* il segnaposto blu del logo */
  --azzurro-cielo: #5DA9E9;
  --rosso: #D63A2A;          /* il segnaposto rosso: promozioni */
  --verde: #2C8A47;          /* la piattaforma verde: vetrine */
  --ocra: #D99A00;           /* novità */
  --ink: #1B2A3A;
  --ink-2: #51606F;
  --line: #DCE4EB;
  --wash: #F1F5F8;
  --surface: #FFFFFF;

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 22px;
  --shadow: 0 1px 2px rgba(27, 42, 58, .12), 0 6px 22px rgba(27, 42, 58, .14);

  --top-h: 116px;            /* barra + filtri, su telefono */
  --peek: 92px;              /* altezza del foglio chiuso */
  --safe-b: env(safe-area-inset-bottom, 0px);

  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--wash);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--azzurro); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid var(--azzurro-cielo); outline-offset: 2px; }

/* ---------- mappa ---------- */
#map { position: fixed; inset: 0; background: #E7ECEF; z-index: 0; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-bottom.leaflet-right { margin-bottom: calc(var(--peek) + var(--safe-b)); }
.leaflet-control-zoom { display: none; }

/* ---------- barra superiore ---------- */
.topbar {
  position: fixed; z-index: 30; left: 0; right: 0; top: 0;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand search menu" "chips chips chips";
  gap: 8px 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { grid-area: brand; display: block; width: 48px; height: 48px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); padding: 2px; }
.brand img { width: 100%; height: 100%; object-fit: contain; display: block; }
.search {
  grid-area: search;
  display: flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 6px 0 14px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  color: var(--ink-2);
}
.search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent; color: var(--ink);
  font-size: 16px;
}
.search input::placeholder { color: #7D8A97; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { box-shadow: 0 0 0 3px var(--azzurro-cielo), var(--shadow); }
.search-clear { border: 0; background: var(--wash); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; }
.icon-btn {
  border: 0; background: var(--surface); width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; box-shadow: var(--shadow); color: var(--ink);
}
.menu-btn { grid-area: menu; }

.chips {
  grid-area: chips;
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -12px; padding: 2px 12px 8px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px 0 11px; border-radius: 18px;
  border: 0; background: var(--surface); box-shadow: 0 1px 2px rgba(27,42,58,.14), 0 3px 10px rgba(27,42,58,.10);
  font-size: 14.5px; font-weight: 600; color: var(--ink); white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--azzurro)); }
.chip .n { font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] .n { color: #C9D4DE; }
.chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px #fff; }

/* ---------- segnaposto ---------- */
.xb-pin { background: none; border: 0; }
.pin {
  position: absolute; left: 0; bottom: 0;
  width: 30px; height: 30px;
  transform: translate(-50%, 0);
}
.pin-body {
  position: absolute; left: 50%; bottom: 6px;
  width: 26px; height: 26px; margin-left: -13px;
  border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: var(--c, var(--azzurro));
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(27,42,58,.35);
  transition: transform .18s ease, width .18s, height .18s;
}
.pin-body::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px;
  border-radius: 50%; background: #fff;
}
.pin img {
  position: absolute; left: 50%; bottom: 6px; width: 28px; height: 28px; margin-left: -14px;
  object-fit: contain; filter: drop-shadow(0 2px 3px rgba(27,42,58,.35));
}
.pin-label {
  position: absolute; left: 50%; top: 32px; transform: translateX(-50%);
  max-width: 150px; padding: 2px 8px; border-radius: 6px;
  background: rgba(255,255,255,.94); color: var(--ink);
  font-size: 12px; font-weight: 600; line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 3px rgba(27,42,58,.2);
  display: none; pointer-events: auto; cursor: pointer;
}
.pin.lbl .pin-label { display: block; }
.pin.is-active .pin-body { transform: rotate(-45deg) scale(1.35); box-shadow: 0 0 0 6px rgba(31,111,178,.25), 0 3px 8px rgba(27,42,58,.4); }
.pin.is-active .pin-label { display: block; background: var(--ink); color: #fff; top: 40px; }
.pin.is-active img { transform: scale(1.3); }

.xb-cluster { background: none; }
.xb-cluster span {
  display: grid; place-items: center; width: 100%; height: 100%;
  border-radius: 50%; background: var(--azzurro); color: #fff;
  font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums;
  border: 3px solid #fff; box-shadow: 0 0 0 5px rgba(31,111,178,.22), 0 2px 6px rgba(27,42,58,.3);
}
.xb-cluster.has-promo span { background: linear-gradient(135deg, var(--azzurro) 60%, var(--rosso) 60%); }

.me { width: 18px; height: 18px; border-radius: 50%; background: var(--azzurro); border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(31,111,178,.5); animation: me 2s infinite; }
@keyframes me { 0% { box-shadow: 0 0 0 0 rgba(31,111,178,.5); } 70% { box-shadow: 0 0 0 18px rgba(31,111,178,0); } 100% { box-shadow: 0 0 0 0 rgba(31,111,178,0); } }

/* ---------- foglio (elenco / scheda) ---------- */
.sheet {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  --avail: calc(100dvh - var(--top-h));
  height: calc(var(--peek) + var(--safe-b));
  background: var(--surface);
  border-radius: var(--r-l) var(--r-l) 0 0;
  box-shadow: 0 -4px 24px rgba(27,42,58,.16);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: height .32s cubic-bezier(.2,.8,.2,1);
}
.sheet[data-state="half"] { height: calc(var(--avail) * .55); }
.sheet[data-state="full"] { height: var(--avail); }
.sheet.is-dragging { transition: none; }

.sheet-grip {
  flex: none; border: 0; background: transparent; height: 26px; width: 100%;
  display: grid; place-items: center; touch-action: none;
}
.sheet-grip span { width: 44px; height: 5px; border-radius: 3px; background: #C5CFD8; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-detail { display: block; overflow-y: auto; overscroll-behavior: contain; outline: none; padding-bottom: calc(24px + var(--safe-b)); }

.list-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px 12px;
}
.list-head h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.list-head h2 small { display: block; font-size: 13.5px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.sort { flex: none; display: flex; background: var(--wash); border-radius: 18px; padding: 3px; }
.sort button { border: 0; background: transparent; padding: 5px 11px; border-radius: 15px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.sort button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(27,42,58,.15); }

.list { list-style: none; margin: 0; padding: 0 8px calc(16px + var(--safe-b)); overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.row {
  width: 100%; border: 0; background: transparent; text-align: left;
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 8px; border-radius: var(--r-s);
}
.row:hover { background: var(--wash); }
.row.is-active { background: #E6F0F9; }
.thumb {
  width: 46px; height: 46px; border-radius: 12px; overflow: hidden;
  display: grid; place-items: center;
  background: var(--c, var(--azzurro)); color: #fff;
  font-weight: 800; font-size: 17px; letter-spacing: -.02em;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-name { display: block; font-weight: 650; font-size: 16px; line-height: 1.25; }
.row-sub { display: block; color: var(--ink-2); font-size: 13.5px; line-height: 1.35; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.row-dist { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 6px; background: var(--wash); color: var(--ink); }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.tag-promo { --c: var(--rosso); background: #FCE9E6; color: #9E2416; }
.tag-vetrina { --c: var(--verde); background: #E3F2E7; color: #1D5E30; }
.tag-news { --c: var(--ocra); background: #FBF0D2; color: #7A5600; }

.empty { padding: 28px 20px; text-align: center; color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.empty button { margin-top: 14px; }

/* ---------- scheda attività ---------- */
.d-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 8px; background: var(--surface); }
.text-btn { border: 0; background: transparent; display: inline-flex; align-items: center; gap: 4px; font-weight: 650; color: var(--azzurro); padding: 6px 8px; border-radius: 8px; text-decoration: none; font-size: 15px; }
.text-btn:hover { background: var(--wash); }
.text-btn .ico { width: 18px; height: 18px; }

.cover { margin: 0 16px; height: 170px; flex: none; border-radius: var(--r-m); overflow: hidden; background: var(--c, var(--azzurro)); position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover iframe { width: 100%; height: 100%; border: 0; display: block; }
.cover.mono { height: 112px; display: flex; align-items: flex-end; padding: 16px 18px; color: rgba(255,255,255,.95); }
.cover.mono span { font-size: 52px; line-height: .9; font-weight: 800; letter-spacing: -.04em; font-variation-settings: "opsz" 96; }
.cover.mono::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 26px solid rgba(255,255,255,.14); }

.d-head { padding: 16px 16px 4px; }
.d-head h2 { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -.025em; font-variation-settings: "opsz" 72; }
.d-addr { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; }
.d-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; padding: 14px 16px 6px; }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px; border-radius: 14px; border: 0;
  background: var(--wash); color: var(--azzurro); text-decoration: none;
  font-size: 13px; font-weight: 650;
}
.act:hover { background: #E3ECF4; }
.act-main { background: var(--azzurro); color: #fff; }
.act-main:hover { background: #185C95; }

.block { margin: 14px 16px 0; padding: 14px 16px; border-radius: var(--r-m); }
.block h3 { margin: 0 0 6px; font-size: 16px; font-weight: 750; display: flex; align-items: center; gap: 8px; }
.block-promo { background: #FCE9E6; }
.block-promo h3 { color: #9E2416; }
.block-news { background: #FBF0D2; }
.block-news h3 { color: #7A5600; }
.block-vetrina { background: #E3F2E7; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.block-vetrina p { margin: 0; color: #1D5E30; font-size: 14.5px; }
.block-vetrina h3 { color: #1D5E30; margin-bottom: 2px; }
.vetrina-card { display: block; padding: 0; overflow: hidden; }
.vetrina-img { display: block; width: 100%; padding: 0; border: 0; background: #CFE6D6; aspect-ratio: 16 / 10; overflow: hidden; }
.vetrina-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.vetrina-img:hover img { transform: scale(1.03); }
.vetrina-body { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px 14px; }
.vetrina-body p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.btn { border: 0; border-radius: 22px; padding: 10px 18px; font-weight: 700; background: var(--azzurro); color: #fff; white-space: nowrap; text-decoration: none; display: inline-block; }
.btn-verde { background: var(--verde); }
.btn-verde:hover { background: #22703A; }

.rich { font-size: 15.5px; line-height: 1.55; overflow-wrap: anywhere; }
.rich p { margin: 0 0 .6em; }
.rich p:last-child { margin-bottom: 0; }
.rich img { max-width: 100%; height: auto; border-radius: 10px; }
.rich iframe { width: 100%; aspect-ratio: 16/9; height: auto; border: 0; border-radius: 10px; }
.rich table { max-width: 100%; }
.descr { padding: 16px 16px 0; }
.descr h3 { margin: 0 0 6px; font-size: 16px; font-weight: 750; }

.qr { margin: 18px 16px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.qr summary { cursor: pointer; font-weight: 650; color: var(--ink-2); font-size: 14.5px; }
.qr-box { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.qr-box p { margin: 0; font-size: 14px; color: var(--ink-2); }
.qr-code { flex: none; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-code img, .qr-code canvas { display: block; width: 120px; height: 120px; }

/* ---------- pulsanti flottanti ---------- */
.fabs {
  position: fixed; z-index: 15; right: 12px;
  bottom: calc(var(--peek) + var(--safe-b) + 14px);
  display: flex; flex-direction: column; gap: 10px;
  transition: opacity .2s, transform .2s;
}
.fab {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.fab:hover { color: var(--azzurro); }
.fab.is-on { background: var(--azzurro); color: #fff; }
body.sheet-open .fabs { opacity: 0; transform: translateY(16px); pointer-events: none; }

/* ---------- pannelli e finestre ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(27,42,58,.38); display: flex; align-items: flex-end; justify-content: center; }
.overlay-dark { background: rgba(14,22,31,.7); }
.panel, .vetrina, .menu {
  background: var(--surface); width: 100%; max-width: 720px;
  border-radius: var(--r-l) var(--r-l) 0 0;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 40px);
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.panel { height: 78dvh; }
.vetrina { height: calc(100dvh - 24px); max-width: 1100px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; flex: 1; font-size: 19px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) { #vetrinaOpen { display: none; } }
.panel-head .icon-btn { box-shadow: none; background: var(--wash); width: 40px; height: 40px; }
.panel-tabs { flex: none; display: flex; gap: 4px; padding: 8px 12px 0; border-bottom: 1px solid var(--line); }
.panel-tabs button { border: 0; background: transparent; padding: 8px 14px 10px; font-weight: 650; color: var(--ink-2); border-bottom: 3px solid transparent; }
.panel-tabs button[aria-selected="true"] { color: var(--azzurro); border-bottom-color: var(--azzurro); }
.panel-body { flex: 1; min-height: 0; overflow: auto; }
.panel-body iframe, .vetrina iframe { width: 100%; height: 100%; border: 0; display: block; flex: 1; }
.maps-list { list-style: none; margin: 0; padding: 12px; }
.maps-list a { display: block; padding: 14px 16px; border-radius: 12px; background: var(--wash); text-decoration: none; color: var(--ink); font-weight: 650; margin-bottom: 8px; }
.maps-list a:hover { background: #E3ECF4; }

.menu { max-width: 420px; padding-bottom: calc(12px + var(--safe-b)); }
.menu a { display: block; padding: 14px 20px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 17px; }
.menu a:hover { background: var(--wash); }
.menu a[aria-current="page"] { color: var(--azzurro); }
.menu .menu-cta { margin: 10px 16px 0; border-radius: 24px; background: var(--azzurro); color: #fff; text-align: center; }
.menu .menu-cta:hover { background: #185C95; }

.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(var(--top-h) + 8px);
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14.5px; font-weight: 550; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- schermi grandi ---------- */
@media (min-width: 900px) {
  :root { --top-h: 0px; --peek: 0px; }
  .topbar {
    left: 16px; right: auto; top: 16px; width: 404px; padding: 0;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .chips { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .chips { margin: 0; padding: 2px 0 8px; flex-wrap: nowrap; }
  .sheet {
    left: 16px; right: auto; top: 136px; bottom: 16px; width: 404px; height: auto !important;
    border-radius: var(--r-l); box-shadow: var(--shadow); transition: none;
  }
  .sheet-grip { display: none; }
  .list-head { padding-top: 16px; }
  .d-top { padding-top: 12px; }
  .fabs { bottom: 96px; right: 16px; }
  body.sheet-open .fabs { opacity: 1; transform: none; pointer-events: auto; }
  .leaflet-control-zoom { display: block; }
  .leaflet-bottom.leaflet-right { margin-bottom: 0; }
  .leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; font-size: 20px; }
  .leaflet-touch .leaflet-bar { border: 0; box-shadow: var(--shadow); border-radius: 12px; overflow: hidden; }
  .overlay { align-items: center; }
  .panel, .vetrina, .menu { border-radius: var(--r-l); }
  .menu { position: absolute; right: 16px; top: 16px; }
  .overlay#menu { align-items: flex-start; justify-content: flex-end; }
  .toast { top: 20px; left: calc(50% + 210px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- integrazione WordPress ---------- */
html.xb-mappa { margin-top: 0 !important; }
body.admin-bar { --wpbar: 32px; }
@media (max-width: 782px) { body.admin-bar { --wpbar: 46px; } #wpadminbar { position: fixed !important; } }
body.admin-bar #map { top: var(--wpbar); }
body.admin-bar .topbar { top: var(--wpbar); }
body.admin-bar .sheet { --avail: calc(100dvh - var(--top-h) - var(--wpbar)); }
@media (min-width: 900px) {
  body.admin-bar .topbar { top: calc(16px + var(--wpbar)); }
  body.admin-bar .sheet { top: calc(136px + var(--wpbar)); }
}
.menu .xb-menu-list { list-style: none; margin: 0; padding: 6px 0 0; }
.menu .xb-menu-list ul { list-style: none; margin: 0; padding: 0 0 0 16px; }
.menu .current-menu-item > a { color: var(--azzurro); }
.menu-extra { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 4px; }
