:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --ink: #171717;
  --muted: #6f6c66;
  --line: rgba(23, 23, 23, 0.12);
  --line-strong: rgba(23, 23, 23, 0.22);
  --gold: #cfa64a;
  --gold-soft: rgba(207, 166, 74, 0.17);
  --blue: #2b5fb8;
  --green: #2e7d50;
  --red: #b74335;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.92), transparent 34rem),
    linear-gradient(135deg, #fff 0%, var(--bg) 48%, #ece8df 100%);
}

button,
input,
select { font: inherit; }
button { cursor: pointer; }

.site-shell {
  width: min(1540px, calc(100% - 28px));
  margin: 0 auto;
  padding: clamp(24px, 4vw, 58px) 0;
}

.hero {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5.6rem);
  line-height: .95;
  letter-spacing: -0.065em;
}

.lead {
  max-width: 850px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.16rem);
  line-height: 1.58;
}

.planner-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.planner-topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(248,247,244,.74));
}

.floor-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
}

.floor-tab {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  transition: .2s ease;
}

.floor-tab[aria-pressed="true"] {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 10px 24px rgba(0,0,0,.16);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.icon-btn,
.text-btn {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.9);
  box-shadow: 0 6px 18px rgba(0,0,0,.05);
  transition: transform .2s ease, border-color .2s ease, background .2s ease;
}

.icon-btn {
  width: 44px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 850;
  line-height: 1;
}

.text-btn {
  padding: 0 14px;
  font-size: .88rem;
  font-weight: 800;
}

.icon-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #fff;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  min-height: min(860px, 78vh);
}

.map-panel {
  position: relative;
  min-height: 720px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(0,0,0,.035) 1px, transparent 1px),
    #f7f5f0;
  background-size: 42px 42px;
}

.map-header-float {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 8;
  max-width: min(520px, calc(100% - 36px));
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 42px rgba(0,0,0,.1);
  pointer-events: none;
}

.map-title {
  margin: 0 0 3px;
  font-size: 1.08rem;
  letter-spacing: -.03em;
}

.map-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.map-stage.is-dragging { cursor: grabbing; }

.map-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
}

.floor-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 28px 44px rgba(0,0,0,.15));
}

.hotspot {
  position: absolute;
  border: 2px solid rgba(207,166,74,.62);
  border-radius: 18px;
  background: rgba(207,166,74,.08);
  color: var(--ink);
  opacity: .96;
  transform: translateZ(0);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.hotspot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgba(207,166,74,.18), 0 10px 22px rgba(0,0,0,.22);
  transform: translate(-50%, -50%);
}

.hotspot::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: calc(50% + 22px);
  max-width: 190px;
  padding: 6px 9px;
  border: 1px solid rgba(0,0,0,.09);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.hotspot:hover,
.hotspot.is-active {
  border-color: var(--ink);
  background: rgba(255,255,255,.24);
  box-shadow: 0 0 0 5px rgba(207,166,74,.2), inset 0 0 0 999px rgba(255,255,255,.08);
  z-index: 4;
}

.hotspot:hover::after,
.hotspot.is-active::after {
  opacity: 1;
  transform: translate(-50%, 2px);
}

.hotspot.is-hidden { display: none; }

.map-panel.hotspots-off .hotspot {
  opacity: 0;
  pointer-events: none;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: rgba(255,255,255,.82);
}

.search-card,
.detail-card,
.room-list-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 34px rgba(0,0,0,.06);
}

.search-card { padding: 14px; }

.search-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.search-input,
.category-select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
}

.search-input:focus,
.category-select:focus {
  border-color: rgba(207,166,74,.8);
  box-shadow: 0 0 0 4px var(--gold-soft);
}

.detail-card {
  padding: 18px;
}

.detail-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #7a5a0c;
  font-size: .74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.badge[data-type="evento"] { background: rgba(43,95,184,.13); color: #224a8d; }
.badge[data-type="esposizione"] { background: rgba(46,125,80,.13); color: #1f623b; }
.badge[data-type="tecnico"] { background: rgba(183,67,53,.13); color: #8a3328; }
.badge[data-type="percorso"], .badge[data-type="collegamento"] { background: rgba(23,23,23,.08); color: #333; }

.detail-card h2 {
  margin: 0 0 10px;
  font-size: 1.55rem;
  line-height: 1.04;
  letter-spacing: -.045em;
}

.detail-card p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.55;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.action-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--ink);
  color: #fff;
  font-size: .86rem;
  font-weight: 850;
}

.action-btn.secondary {
  background: #fff;
  color: var(--ink);
}

.room-list-card {
  min-height: 0;
  overflow: hidden;
}

.room-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.room-list-head h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -.02em;
}

.count-pill {
  min-width: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  font-size: .78rem;
  font-weight: 850;
}

.room-list {
  max-height: 330px;
  overflow: auto;
  padding: 8px;
}

.room-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 10px;
  background: transparent;
  text-align: left;
  transition: .18s ease;
}

.room-item:hover,
.room-item.is-active {
  border-color: var(--line);
  background: var(--surface-2);
}

.room-name {
  display: block;
  font-size: .95rem;
  font-weight: 850;
}

.room-type {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.room-arrow {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.help-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: rgba(248,247,244,.8);
  color: var(--muted);
  font-size: .86rem;
}

.zoom-indicator {
  color: var(--ink);
  font-weight: 850;
}

@media (max-width: 1120px) {
  .planner-layout { grid-template-columns: 1fr; }
  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .room-list-card { grid-column: 1 / -1; }
  .map-panel { min-height: 680px; }
}

@media (max-width: 760px) {
  .site-shell { width: min(100% - 18px, 1540px); padding-top: 22px; }
  .planner-topbar { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-start; }
  .floor-tabs { width: 100%; border-radius: 18px; }
  .floor-tab { flex: 1; }
  .map-panel { min-height: 560px; }
  .map-header-float {
    top: 12px;
    left: 12px;
    right: 12px;
    max-width: none;
  }
  .side-panel { grid-template-columns: 1fr; }
  .room-list-card { grid-column: auto; }
  .hotspot::after { display: none; }
  .help-strip { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .map-panel { min-height: 520px; }
  .icon-btn { width: 40px; min-height: 40px; }
  .text-btn { min-height: 40px; }
  .map-title { font-size: 1rem; }
  .map-subtitle { font-size: .82rem; }
}


/* === Interazione sala: scheda descrizione + link pagina dedicata === */
.map-info-card {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 12;
  width: min(430px, calc(100% - 36px));
  max-height: min(58vh, 520px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(23,23,23,.14);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 28px 70px rgba(0,0,0,.18);
  backdrop-filter: blur(18px);
  animation: mapInfoIn .2s ease-out;
}

@keyframes mapInfoIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.map-info-card[hidden] { display: none; }

.map-info-card h3 {
  margin: 0 34px 10px 0;
  font-size: 1.45rem;
  line-height: 1.04;
  letter-spacing: -.045em;
}

.map-info-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.map-info-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(0,0,0,.08);
}

.map-info-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.feature-list {
  display: grid;
  gap: 7px;
  margin: 12px 0 2px;
  padding: 0;
  list-style: none;
}

.feature-list li {
  position: relative;
  padding-left: 21px;
  color: var(--ink);
  font-size: .92rem;
  line-height: 1.42;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(207,166,74,.15);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  line-height: 1;
}

.action-btn:hover { filter: brightness(.96); }

.hotspot {
  cursor: pointer;
}

.hotspot.is-active::before {
  animation: hotspotPulse 1.6s ease-in-out infinite;
}

@keyframes hotspotPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(207,166,74,.18), 0 10px 22px rgba(0,0,0,.22); }
  50% { box-shadow: 0 0 0 16px rgba(207,166,74,.08), 0 10px 22px rgba(0,0,0,.22); }
}

.room-page-body {
  background: linear-gradient(135deg, #fff 0%, var(--bg) 56%, #ece8df 100%);
}

.room-page {
  width: min(1060px, calc(100% - 28px));
  margin: 0 auto;
  padding: clamp(26px, 5vw, 72px) 0;
}

.room-page-card {
  border: 1px solid var(--line);
  border-radius: 32px;
  background: rgba(255,255,255,.9);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.room-page-header {
  padding: clamp(24px, 5vw, 52px);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,247,244,.76));
}

.room-page-header h1 {
  margin: 12px 0 12px;
  font-size: clamp(2.1rem, 6vw, 4.8rem);
}

.room-page-content {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 24px;
  padding: clamp(22px, 4vw, 42px);
}

.room-page-content h2,
.room-page-content h3 {
  margin: 0 0 10px;
  letter-spacing: -.035em;
}

.room-page-content p {
  color: var(--muted);
  line-height: 1.64;
}

.room-page-side {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--surface-2);
}

.room-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 760px) {
  .map-info-card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 48vh;
    border-radius: 20px;
  }

  .room-page-content {
    grid-template-columns: 1fr;
  }
}

/* === V3: Popup reale sopra la mappa 3D === */
.map-popup-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 18, 18, .38);
  backdrop-filter: blur(8px);
  animation: popupOverlayIn .16s ease-out;
}

.map-popup-overlay[hidden] {
  display: none !important;
}

.map-popup-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(76vh, 680px);
  overflow: auto;
  padding: clamp(22px, 3vw, 30px);
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 30px;
  background: rgba(255,255,255,.97);
  color: var(--ink);
  box-shadow: 0 34px 110px rgba(0,0,0,.34);
  animation: popupCardIn .18s ease-out;
}

.map-popup-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 42px 14px 0;
}

.map-popup-card h3 {
  margin: 0 44px 12px 0;
  font-size: clamp(1.55rem, 3vw, 2.3rem);
  line-height: 1.02;
  letter-spacing: -.055em;
}

.map-popup-card p {
  margin: 0 0 13px;
  color: var(--muted);
  line-height: 1.62;
}

.map-popup-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 12px 26px rgba(0,0,0,.12);
  cursor: pointer;
}

.map-popup-close:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.map-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.map-panel.has-popup .map-stage {
  cursor: default;
}

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

@keyframes popupCardIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 760px) {
  .map-popup-overlay {
    align-items: end;
    padding: 12px;
  }

  .map-popup-card {
    width: 100%;
    max-height: 72vh;
    border-radius: 24px;
  }
}
