/* =========================================================================
   CITTÀ NARRATA — Interactive Map Viewer (horizontal / hotspots layout)
   ========================================================================= */

body.mappa-page {
  background: var(--paper);
  min-height: 100vh;
}

/* ───── HERO ───── */
.mappa-hero {
  position: relative;
  padding: 130px 48px 30px;
  overflow: hidden;
  background: var(--paper);
}
.mappa-hero::before {
  content: "";
  position: absolute;
  top: -10%;
  right: -10%;
  width: 50vw;
  height: 50vw;
  max-width: 700px;
  max-height: 700px;
  background: radial-gradient(closest-side, rgba(231,76,94,0.18), transparent 70%);
  border-radius: 50%;
  filter: blur(30px);
  pointer-events: none;
  z-index: 0;
}
.mappa-hero-inner {
  position: relative;
  z-index: 2;
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 32px;
  align-items: end;
}
.mappa-hero-left h1 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-stretch: 110%;
  font-size: clamp(40px, 5vw, 78px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 14px 0 14px;
  text-wrap: balance;
}
.mappa-hero-left h1 em {
  font-style: italic;
  font-weight: 500;
  color: var(--coral);
}
.mappa-hero-left p.lead {
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink-mute);
  max-width: 580px;
  text-wrap: pretty;
}
.mappa-meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.mappa-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(26,22,18,0.06);
  border: 1px solid rgba(26,22,18,0.1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.mappa-pill .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  background: var(--coral);
  color: var(--cream);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}
.mappa-pill.is-coral {
  background: var(--coral);
  color: var(--cream);
  border-color: transparent;
}
.mappa-pill.is-coral .dot {
  display: inline-block;
  width: 7px; height: 7px;
  background: var(--cream);
  border-radius: 50%;
  animation: pulse-dot 1.8s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

/* ───── TOOLBAR (filters + legend) ───── */
.mappa-toolbar {
  position: relative;
  z-index: 3;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.mappa-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.mappa-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--cream);
  border: 1px solid rgba(26,22,18,0.12);
  border-radius: 999px;
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .25s;
}
.mappa-filter-chip:hover { border-color: var(--coral); color: var(--coral); }
.mappa-filter-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}
.mappa-filter-chip .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  background: rgba(26,22,18,0.08);
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0;
}
.mappa-filter-chip.active .count {
  background: rgba(251,246,236,0.2);
  color: var(--cream);
}

.mappa-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-mute);
}
.mappa-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.04em;
}
.mappa-legend-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 32% 30%, #ff7686 0%, var(--coral) 38%, var(--coral-deep) 100%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.3), inset 0 1px 1px rgba(255,255,255,0.4);
}
.mappa-legend-dot.epigrafe {
  background: radial-gradient(circle at 32% 30%, #4d8de4 0%, var(--blue) 38%, var(--blue-deep) 100%);
}
.mappa-legend-dot.moderno {
  background: radial-gradient(circle at 32% 30%, #3f3a35 0%, var(--ink-soft) 38%, var(--ink) 100%);
}

/* ───── MAP CANVAS (horizontal) ───── */
.mappa-viewer {
  position: relative;
  padding: 0 48px 60px;
  background: var(--paper);
}
.mappa-canvas-wrap {
  position: relative;
  max-width: 1500px;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 28px;
  padding: 18px;
  box-shadow:
    0 30px 80px -30px rgba(26,22,18,0.45),
    0 8px 24px -10px rgba(26,22,18,0.2);
  overflow: hidden;
}
.mappa-canvas-frame {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: var(--cream);
  /* Default landscape until PDF dimensions known */
  aspect-ratio: 3 / 2;
}
.mappa-canvas-frame canvas {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 1;
}
.mappa-canvas-loading,
.mappa-canvas-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px;
  text-align: center;
  background:
    repeating-linear-gradient(45deg, rgba(231,76,94,0.04) 0 8px, transparent 8px 24px),
    var(--cream);
  color: var(--ink-soft);
  z-index: 0;
}
.mappa-canvas-loading {
  background: var(--cream);
  z-index: 4;
  pointer-events: none;
  transition: opacity .4s;
}
.mappa-canvas-frame.is-ready .mappa-canvas-loading { opacity: 0; pointer-events: none; }
.mappa-canvas-loading .spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(26,22,18,0.15);
  border-top-color: var(--coral);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mappa-canvas-loading .label,
.mappa-canvas-fallback strong {
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 18px;
  color: var(--ink);
  font-weight: 600;
}
.mappa-canvas-fallback svg { width: 56px; height: 56px; color: var(--coral); }
.mappa-canvas-fallback p {
  font-size: 14px;
  max-width: 360px;
  line-height: 1.5;
  color: var(--ink-mute);
}
.mappa-canvas-fallback code {
  background: rgba(26,22,18,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* ─ Hotspot layer ─ */
.mappa-hotspots {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.mappa-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
}
.mappa-hotspot:focus { outline: none; }

.mappa-hotspot-pin {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(26px, 2.8vw, 38px);
  height: clamp(26px, 2.8vw, 38px);
  border-radius: 6px;
  color: var(--cream);
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-stretch: 110%;
  font-size: clamp(11px, 1.15vw, 15px);
  letter-spacing: -0.01em;
  background:
    radial-gradient(circle at 32% 30%, #ff7686 0%, var(--coral) 38%, var(--coral-deep) 78%, #8d2535 100%);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.28),
    inset 0 2px 4px rgba(255,255,255,0.4),
    0 4px 10px -2px rgba(193,58,75,0.55),
    0 0 0 2px rgba(251,246,236,0.85),
    0 0 0 3px rgba(26,22,18,0.18);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.mappa-hotspot[data-kind="epigrafe"] .mappa-hotspot-pin {
  background:
    radial-gradient(circle at 32% 30%, #4d8de4 0%, var(--blue) 40%, var(--blue-deep) 78%, #08305e 100%);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.28),
    inset 0 2px 4px rgba(255,255,255,0.32),
    0 4px 10px -2px rgba(0,74,153,0.55),
    0 0 0 2px rgba(251,246,236,0.85),
    0 0 0 3px rgba(26,22,18,0.18);
}
.mappa-hotspot[data-kind="moderno"] .mappa-hotspot-pin {
  background:
    radial-gradient(circle at 32% 30%, #3f3a35 0%, var(--ink-soft) 40%, var(--ink) 78%, #0a0805 100%);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.4),
    inset 0 2px 4px rgba(255,255,255,0.18),
    0 4px 10px -2px rgba(0,0,0,0.5),
    0 0 0 2px rgba(251,246,236,0.85),
    0 0 0 3px rgba(26,22,18,0.18);
}

.mappa-hotspot:hover { z-index: 5; }
.mappa-hotspot:hover .mappa-hotspot-pin {
  transform: scale(1.4) translateY(-4px);
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.22),
    inset 0 3px 6px rgba(255,255,255,0.45),
    0 12px 24px -6px rgba(193,58,75,0.55),
    0 0 0 2px var(--cream),
    0 0 0 4px var(--coral);
}
.mappa-hotspot[data-kind="epigrafe"]:hover .mappa-hotspot-pin {
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.22),
    inset 0 3px 6px rgba(255,255,255,0.4),
    0 12px 24px -6px rgba(0,74,153,0.55),
    0 0 0 2px var(--cream),
    0 0 0 4px var(--blue);
}
.mappa-hotspot[data-kind="moderno"]:hover .mappa-hotspot-pin {
  box-shadow:
    inset 0 -2px 4px rgba(0,0,0,0.32),
    inset 0 3px 6px rgba(255,255,255,0.22),
    0 12px 24px -6px rgba(0,0,0,0.55),
    0 0 0 2px var(--cream),
    0 0 0 4px var(--ink);
}

/* tooltip */
.mappa-hotspot-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  transform: translateX(-50%) translateY(6px);
  background: var(--ink);
  color: var(--cream);
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  box-shadow: 0 12px 24px -8px rgba(26,22,18,0.45);
  max-width: 260px;
  text-overflow: ellipsis;
  overflow: hidden;
}
.mappa-hotspot-label::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--ink);
}
.mappa-hotspot:hover .mappa-hotspot-label,
.mappa-hotspot:focus-visible .mappa-hotspot-label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Filtered out */
.mappa-hotspot.is-hidden { display: none; }
/* Dim the others when one is hovered */
.mappa-hotspots:hover .mappa-hotspot:not(:hover) .mappa-hotspot-pin { opacity: 0.55; }

/* ───── Edit mode (calibration) ───── */
body.is-edit .mappa-hotspot { cursor: grab; }
body.is-edit .mappa-hotspot.is-dragging { cursor: grabbing; z-index: 100; }
body.is-edit .mappa-hotspot-pin {
  outline: 1.5px dashed rgba(251,246,236,0.9);
  outline-offset: 4px;
}
body.is-edit .mappa-hotspot-label { opacity: 1; transform: translateX(-50%) translateY(0); }

.mappa-edit-panel {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--ink);
  color: var(--cream);
  padding: 18px;
  border-radius: 18px;
  z-index: 999;
  width: 320px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
  font-family: "Hanken Grotesk", sans-serif;
}
.mappa-edit-panel h4 {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.mappa-edit-panel p {
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.7;
}
.mappa-edit-panel .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mappa-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--coral);
  color: var(--cream);
  border: none;
  border-radius: 999px;
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .25s, transform .25s;
}
.mappa-edit-btn:hover { background: var(--coral-deep); transform: translateY(-1px); }
.mappa-edit-btn.ghost {
  background: transparent;
  color: var(--cream);
  border: 1px solid rgba(251,246,236,0.3);
}
.mappa-edit-btn.ghost:hover { background: rgba(251,246,236,0.12); }
.mappa-edit-status {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.6;
}
.mappa-edit-json {
  width: 100%;
  height: 140px;
  background: rgba(0,0,0,0.4);
  color: var(--cream);
  border: 1px solid rgba(251,246,236,0.18);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  resize: vertical;
}

/* ───── Selected place card (slides up when a hotspot is clicked) ───── */
.mappa-detail-fab {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  background: var(--cream);
  color: var(--ink);
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 540px;
  width: calc(100% - 44px);
  box-shadow: 0 30px 60px -20px rgba(26,22,18,0.35), 0 6px 16px rgba(26,22,18,0.12);
  z-index: 200;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .35s;
  opacity: 0;
}
.mappa-detail-fab.is-active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.mappa-detail-fab-num {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--coral);
  color: var(--cream);
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 700;
  font-size: 17px;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.25), inset 0 2px 4px rgba(255,255,255,0.35);
}
.mappa-detail-fab[data-kind="epigrafe"] .mappa-detail-fab-num { background: var(--blue); }
.mappa-detail-fab[data-kind="moderno"] .mappa-detail-fab-num { background: var(--ink); }
.mappa-detail-fab-body { flex: 1; min-width: 0; }
.mappa-detail-fab-kind {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 2px;
}
.mappa-detail-fab[data-kind="epigrafe"] .mappa-detail-fab-kind { color: var(--blue); }
.mappa-detail-fab[data-kind="moderno"] .mappa-detail-fab-kind { color: var(--ink-mute); }
.mappa-detail-fab-title {
  font-family: "Bricolage Grotesque", sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.mappa-detail-fab-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--ink);
  color: var(--cream);
  text-decoration: none;
  border-radius: 999px;
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: background .25s, transform .25s;
}
.mappa-detail-fab-cta:hover { background: var(--coral); transform: translateX(3px); }
.mappa-detail-fab-cta svg { width: 14px; height: 14px; }
.mappa-detail-fab-close {
  position: absolute;
  top: -10px; right: -10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--cream);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(26,22,18,0.3);
  transition: transform .25s;
}
.mappa-detail-fab-close:hover { transform: rotate(90deg); }
.mappa-detail-fab-close svg { width: 12px; height: 12px; }

/* ───── Responsive ───── */
@media (max-width: 980px) {
  .mappa-hero { padding: 110px 22px 24px; }
  .mappa-hero-inner { grid-template-columns: 1fr; gap: 18px; }
  .mappa-meta-row { justify-content: flex-start; }
  .mappa-toolbar { padding: 0 22px; }
  .mappa-viewer { padding: 0 22px 50px; }
  .mappa-detail-fab-cta span { display: none; }
  .mappa-detail-fab-cta { padding: 11px; }
}
@media (max-width: 720px) {
  .mappa-canvas-wrap { padding: 10px; border-radius: 20px; }
  .mappa-hotspot-pin {
    width: 24px; height: 24px;
    font-size: 11px;
  }
  .mappa-detail-fab { padding: 10px 12px; gap: 10px; }
  .mappa-detail-fab-num { width: 36px; height: 36px; font-size: 14px; }
  .mappa-detail-fab-title { font-size: 14px; }
}
