/* Mappa 3D di Cefalù — complementa css/app.css (usa le sue variabili) */

.home-map.home-map--3d {
  height: auto;
  overflow: visible;
  border: 0;
  background: none;
  border-radius: 0;
  touch-action: auto;
}

.m3d {
  --sky: linear-gradient(180deg, #9fd3ef, #e9f6fb);
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* senza questo la colonna si allarga al contenuto (elenco tour) e la mappa esce dallo schermo */
  gap: 12px;
  max-width: 100%;
}
.m3d > * { min-width: 0; }
.m3d[data-phase="golden"] { --sky: linear-gradient(180deg, #f08f55, #ffd9a8); }
.m3d[data-phase="night"] { --sky: linear-gradient(180deg, #08142e, #243a73); }

/* testo e link sotto la mappa (leggibili anche senza JavaScript) */
.map-seo { margin: 12px 2px 0; font-size: 0.86rem; line-height: 1.55; color: var(--muted); }
.map-seo a { color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

/* ---- suggerimento "adesso" ---- */
.m3d-now {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(120deg, var(--navy), #0e5169);
  color: #fff;
  box-shadow: var(--shadow);
}
.m3d-now[hidden] { display: none; }
.m3d-now-txt { display: grid; gap: 2px; min-width: 0; flex: 1 1 220px; }
.m3d-now-txt span { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #9fe3f0; }
.m3d-now-txt b { font-family: var(--display); font-weight: 600; font-size: 1.02rem; line-height: 1.25; }
.m3d-now-go {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--sun);
  color: #3a2300;
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}
.m3d-now-go:hover { filter: brightness(1.05); }

/* ---- palco mappa ---- */
.m3d-stage {
  position: relative;
  height: clamp(460px, 74vh, 640px);
  border-radius: 20px;
  overflow: hidden;
  isolation: isolate;
  background: var(--sky);
  border: 1px solid rgba(28, 36, 48, 0.1);
  box-shadow: var(--shadow);
  transition: background 0.6s;
}
.m3d-stage > .m3d-canvas,
.m3d-stage > .m3d-canvas.maplibregl-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.m3d-canvas .maplibregl-canvas { outline: none; }
.m3d-canvas .maplibregl-ctrl-attrib { font-size: 10px; }
.m3d-canvas .maplibregl-ctrl-bottom-right { z-index: 2; }

.m3d-poster {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  border: 0;
  background: linear-gradient(160deg, rgba(10, 42, 56, 0.55), rgba(0, 168, 193, 0.35)), var(--sky);
  color: #fff;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.5s, visibility 0.5s;
}
.m3d-poster strong { font-family: var(--display); font-size: 1.35rem; font-weight: 600; }
.m3d-poster span { font-size: 0.9rem; opacity: 0.92; }
.m3d-poster .m3d-poster-ico {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 0 rgba(242, 107, 31, 0.6);
  animation: m3d-pulse 2s infinite;
}
.m3d-stage.is-ready .m3d-poster { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes m3d-pulse { 70% { box-shadow: 0 0 0 16px rgba(242, 107, 31, 0); } 100% { box-shadow: 0 0 0 0 rgba(242, 107, 31, 0); } }

/* ---- filtri ---- */
.m3d-chips {
  position: absolute;
  z-index: 4;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.m3d-chips::-webkit-scrollbar { display: none; }
.m3d-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(10, 42, 56, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(10, 42, 56, 0.12);
}
.m3d-chip i { font-style: normal; font-weight: 700; font-size: 0.72rem; opacity: 0.6; }
.m3d-chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.m3d-chip--toggle { margin-left: 4px; background: rgba(255, 255, 255, 0.7); }
.m3d-chip--toggle.is-on { background: var(--sea); border-color: var(--sea); }

/* ---- luce ---- */
.m3d-light {
  position: absolute;
  z-index: 4;
  top: 54px;
  left: 10px;
  display: flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(10, 42, 56, 0.14);
}
.m3d-light button {
  min-height: 30px;
  padding: 0 0.62rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 0.74rem;
  cursor: pointer;
}
.m3d-light button.is-on { background: var(--ink); color: #fff; }

/* ---- bottoni destra ---- */
.m3d-ctrl {
  position: absolute;
  z-index: 4;
  top: 54px;
  right: 10px;
  display: grid;
  gap: 8px;
}
.m3d-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(10, 42, 56, 0.2);
}
.m3d-btn:hover { background: #fff; color: var(--coral); }

/* ---- pin ---- */
.m3d-mk { z-index: 1; }
.m3d-mk.is-hidden { display: none; }
.m3d-pin {
  --c: var(--coral);
  position: relative;
  display: block;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--c);
  transform: rotate(-45deg) scale(0);
  transform-origin: 50% 100%;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(10, 42, 56, 0.35);
  animation: m3d-drop 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  animation-delay: calc(0.6s + var(--i, 0) * 45ms);
  transition: filter 0.2s, opacity 0.3s;
}
.m3d-pin:hover, .m3d-mk.is-sel .m3d-pin { filter: brightness(1.12); z-index: 2; }
.m3d-mk.is-sel .m3d-pin { transform: rotate(-45deg) scale(1.28); animation: none; }
.m3d-pin-in { position: absolute; inset: 0; display: grid; place-items: center; transform: rotate(45deg); }
.m3d-pin.has-offer::after {
  content: "★";
  position: absolute;
  top: -9px;
  right: -9px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--sun);
  color: #3a2300;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  transform: rotate(45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.m3d-pin.is-approx { border-style: dashed; }
@keyframes m3d-drop { from { transform: rotate(-45deg) scale(0); } to { transform: rotate(-45deg) scale(1); } }
.m3d-far .m3d-pin { width: 28px; height: 28px; }
.m3d-far .m3d-pin-in svg { width: 14px; height: 14px; }

/* luoghi */
.m3d-place {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 3px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.74rem;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(10, 42, 56, 0.28);
}
.m3d-place-dot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--sun);
}
.m3d-far .m3d-place-lb { display: none; }
.m3d-far .m3d-place { padding: 3px; }

/* tour: attenua il resto */
.m3d--tour .m3d-mk:not(.is-stop) { opacity: 0.28; pointer-events: none; }
.m3d--tour .m3d-mk--place { opacity: 0.5; }
.m3d--tour .m3d-chips, .m3d--tour .m3d-light { opacity: 0.35; pointer-events: none; }
.m3d-mk.is-stop .m3d-pin { animation: none; transform: rotate(-45deg) scale(1.1); }
.m3d-num {
  --c: var(--coral);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-weight: 900;
  font-size: 0.88rem;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.25s;
}
.m3d-mk.is-cur .m3d-num { transform: scale(1.35); box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.45), 0 3px 12px rgba(0, 0, 0, 0.45); }
.m3d-mk.is-past .m3d-num { opacity: 0.7; }
.m3d-mk.is-stop { z-index: 3; }

/* ---- scheda ---- */
.m3d-sheet {
  position: absolute;
  z-index: 5;
  left: 10px;
  right: 10px;
  bottom: 10px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 34px rgba(10, 42, 56, 0.35);
  transform: translateY(130%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.25s, visibility 0.35s;
}
.m3d-sheet.is-open { transform: none; opacity: 1; visibility: visible; }
.m3d-x {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(10, 42, 56, 0.08);
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.m3d-card {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 12px;
  padding-right: 26px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(242, 107, 31, 0.15);
}
.m3d-go {
  font-style: normal;
  font-size: 1.9rem;
  line-height: 1;
  color: var(--coral);
  font-weight: 700;
}
.m3d-card-img {
  --c: var(--coral);
  width: 84px;
  height: 84px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(150deg, var(--c), var(--navy));
}
.m3d-card-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.m3d-card-body { min-width: 0; }
.m3d-card-body h4 { margin: 2px 0 2px; font-family: var(--display); font-weight: 600; font-size: 1.1rem; line-height: 1.2; }
.m3d-card-body p { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m3d-card-body .m3d-offer { color: var(--coral); font-weight: 800; }
.m3d-card-body .m3d-approx { font-size: 0.72rem; font-style: italic; }
.m3d-cat {
  --c: var(--coral);
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  color: var(--c);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.m3d-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.m3d-act {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(10, 42, 56, 0.16);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 0.86rem;
  text-decoration: none;
}
.m3d-act--main { flex: 2 1 auto; background: var(--coral); border-color: var(--coral); color: #fff; }

/* ---- passo del tour ---- */
.m3d-step { --c: var(--coral); }
.m3d-step-top { display: flex; align-items: center; gap: 8px; padding-right: 30px; }
.m3d-step-n {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--c);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}
.m3d-step-t { font-size: 0.76rem; font-weight: 800; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m3d-x--in { top: 0; right: 0; }
.m3d-step h4 { margin: 6px 0 3px; font-family: var(--display); font-weight: 600; font-size: 1.15rem; line-height: 1.2; }
.m3d-step p { margin: 0; font-size: 0.9rem; line-height: 1.4; color: #34455c; }
.m3d-step-link {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, #fff);
  color: var(--c);
  font-weight: 900;
  font-size: 0.82rem;
  text-decoration: none;
}
.m3d-story-btn {
  display: inline-flex;
  align-items: center;
  margin: 6px 6px 0 0;
  min-height: 34px;
  padding: 0 12px;
  border: 1.5px solid var(--c);
  border-radius: 999px;
  background: #fff;
  color: var(--c);
  font: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  cursor: pointer;
}
.m3d-story {
  margin-top: 8px;
  padding: 10px 12px;
  max-height: 9.5em;
  overflow-y: auto;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 8%, #fff);
}
.m3d-story p { font-size: 0.88rem; line-height: 1.5; }
.m3d-step-tools { display: flex; flex-wrap: wrap; }
.m3d-listen.is-on { background: var(--c); color: #fff; }
.m3d-dots { display: flex; gap: 5px; margin: 10px 0 8px; }
.m3d-dots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(10, 42, 56, 0.12); }
.m3d-dots i.past { background: color-mix(in srgb, var(--c) 55%, #fff); }
.m3d-dots i.on { background: var(--c); }
.m3d-step-nav { display: flex; gap: 6px; }
.m3d-step-nav button {
  flex: 1;
  min-height: 40px;
  border: 1.5px solid rgba(10, 42, 56, 0.16);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
}
.m3d-step-nav button:disabled { opacity: 0.35; cursor: default; }
.m3d-step-nav .m3d-step-play { flex: 1.4; background: var(--c); border-color: var(--c); color: #fff; }
.m3d-step-read {
  display: block;
  margin-top: 8px;
  text-align: center;
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--c);
}

/* ---- elenco tour ---- */
.m3d-tours-head h3 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.15rem; }
.m3d-tours-head p { margin: 2px 0 0; font-size: 0.84rem; color: var(--muted); }
.m3d-tour-list {
  display: flex;
  gap: 10px;
  margin: 10px calc(var(--pad) * -1) 0;
  padding: 2px var(--pad) 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.m3d-tour-list::-webkit-scrollbar { display: none; }
.m3d-tour {
  --c: var(--coral);
  flex: 0 0 min(220px, 68%);
  scroll-snap-align: start;
  display: grid;
  gap: 3px;
  padding: 12px 14px 12px 16px;
  border: 0;
  border-left: 6px solid var(--c);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.m3d-tour b { font-family: var(--display); font-weight: 600; font-size: 1rem; line-height: 1.2; }
.m3d-tour span { font-size: 0.78rem; color: var(--muted); }
.m3d-tour em { margin-top: 4px; font-style: normal; font-weight: 900; font-size: 0.82rem; color: var(--c); }
.m3d-tour:hover { transform: translateY(-2px); }

/* area di tocco piu' grande per i pin (dita!) */
.m3d-pin::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; }
.m3d-place::before { content: ""; position: absolute; inset: -6px; }
.m3d-place { position: relative; }

/* tasto chiudi e suggerimento (telefono) */
.m3d-close {
  position: absolute;
  z-index: 6;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 10px;
  display: none;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(10, 42, 56, 0.4);
}
.m3d-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 108px;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 16px;
  max-width: calc(100% - 28px);
  border-radius: 999px;
  background: rgba(10, 42, 56, 0.88);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  animation: m3d-hint 6.5s both;
}
.m3d-hint[hidden] { display: none; }
@keyframes m3d-hint { 0% { opacity: 0; transform: translate(-50%, -8px); } 8%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* ---- schermo intero ---- */
body.m3d-lock { overflow: hidden; }
.m3d.is-full {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
  background: #fff;
}
.m3d.is-full .m3d-stage { height: 100dvh; border-radius: 0; border: 0; box-shadow: none; }
.m3d.is-full .m3d-now, .m3d.is-full .m3d-tours { display: none; }
.m3d.is-full .m3d-close { display: inline-flex; }
.m3d.is-full .m3d-chips { top: calc(10px + env(safe-area-inset-top, 0px)); left: 150px; }
.m3d.is-full .m3d-light { top: calc(62px + env(safe-area-inset-top, 0px)); }
.m3d.is-full .m3d-ctrl { top: calc(62px + env(safe-area-inset-top, 0px)); }
.m3d.is-full .m3d-sheet { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
.m3d.is-full .m3d-btn[data-act="full"] { display: none; }

/* telefono: pulsanti piu' grandi, scheda piu' comoda */
@media (pointer: coarse) {
  .m3d-btn { width: 46px; height: 46px; }
  .m3d-chip { min-height: 40px; }
  .m3d-light button { min-height: 34px; }
  .m3d-act, .m3d-step-nav button { min-height: 46px; }
  .m3d-x { width: 36px; height: 36px; top: 4px; right: 6px; }
  .m3d-x--in { top: -2px; right: -2px; }
}

@media (min-width: 720px) {
  .m3d-stage { height: 580px; }
  .m3d-tour-list { margin-inline: 0; padding-inline: 0; flex-wrap: wrap; overflow: visible; }
  .m3d-tour { flex: 1 1 200px; }
  .m3d-sheet { left: 14px; right: auto; margin: 0; width: 420px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .m3d-pin { animation: none; transform: rotate(-45deg); }
  .m3d-poster .m3d-poster-ico { animation: none; }
}
