/* ============================
   MAP SECTION
   ============================ */

.map-scope {
  background-color: var(--color-white);
}

.map-header {
  display: flex;
  align-items: flex-start;
  gap: 48px;
  flex-wrap: wrap;
  flex-direction: column;
}

.map-header-left {
  flex: 0 0 auto;
}

.map-title {
  color: var(--color-primary);
}

.map-header-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 24px;
  align-self: flex-end;
  max-width: 50%;
}

.map-intro {
  color: var(--color-primary);
}

.map-cta {
  align-self: flex-end;
}

/* ---------- end frame / interactive map ---------- */
#end-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  touch-action: pan-y;
}

#end-frame .end-frame-media {
  position: relative;
  width: 100%;
}

#end-frame .pan-hint {
  display: none;
}

/* Hidden on desktop */
.map-continue-nav {
  display: none;
}

#end-frame-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* ---------- Compass ---------- */
.map-compass {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  pointer-events: none;
}

/* ---------- POI ---------- */
.poi {
  position: absolute;
  display: flex;
  align-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

/* Parco variant — white circle with gradient border */
.poi--parco {
  background: transparent;
}

.poi--parco .poi-icon::after {
  background: var(--color-white);
}

.poi-icon {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Gradient border ring around POI */
.poi-icon::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: linear-gradient(218.45deg, #ffffff 10.44%, #054738 92.93%);
  z-index: 0;
}

/* Dark green fill on top of gradient ring */
.poi-icon::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--color-primary);
  z-index: 0;
}

.poi-icon img {
  width: 24px;
  height: 18px;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/* Override AEM rule: html body [aria-hidden=true]:not(.overlay, path) */
.poi-icon img[aria-hidden='true'],
.map-compass[aria-hidden='true'],
.map-filter__icon[aria-hidden='true'] {
  display: block !important;
  visibility: visible !important;
}

/* ---------- Filter bar ---------- */
.map-filter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  justify-content: space-between;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2;
  white-space: nowrap;
}

.map-filter__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 0 !important;
  padding: 4px 16px 4px 4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

.map-filter__btn.active {
  background: var(--color-white);
}

/* Short/full labels for responsive filter text */
.filter-label-short {
  display: none;
}
.filter-label-full {
  display: inline;
}

/* Hide exploration button on desktop */
.map-explore-btn {
  display: none;
}

.map-filter__btn[data-filter='tutti'] {
  line-height: 100%;
  padding: 17px;
}

/* Scaled-down .poi-icon inside filter bar */
/* .map-filter__btn .poi-icon {
  width: 24px;
  height: 24px;
} */

/* .map-filter__btn .poi-icon img {
  width: 11px;
  height: 11px;
} */

/* Label tooltip — separate element 8px to the right */
.poi-label {
  line-height: normal;
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--color-white);
  font-size: 16px;
  padding: 11px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 2;
  isolation: isolate;
}

/* Gradient border on label */
.poi-label::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 21px;
  background: linear-gradient(218.45deg, #ffffff 10.44%, #054738 92.93%);
  z-index: -2;
}

/* Label fill on top of gradient */
.poi-label::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--color-primary);
  z-index: -1;
}

/* Hover: show label — disabled when panel is open */
html:not(.poi-panel-open) .poi:hover .poi-label {
  opacity: 1;
}

/* Parco tooltip variant — white bg, green text */
.poi--parco .poi-label {
  color: var(--color-primary);
}

.poi--parco .poi-label::after {
  background: var(--color-white);
}

html.poi-panel-open body {
  /* position: fixed;
  width: 100%; */
  overflow-y: hidden;
}

/* POI Panel */
#overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 5;
}

#poi-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 700px;
  max-width: 100%;
  height: 100%;
  background: var(--color-primary);
  color: var(--color-white);
  transform: translateX(100%);
  transition: transform 0.3s;
  padding: 40px 24px 24px 24px;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

#poi-title {
  color: var(--color-white);
  font-size: 40px;
  line-height: 40px;
}

#poi-panel.open {
  transform: translateX(0);
}

#poi-description {
  font-size: 18px;
  line-height: 100%;
}

/* Parco variant — white panel, green text */
#poi-panel.poi-panel--parco {
  background: var(--color-white);
  color: var(--color-primary);
}

#poi-panel.poi-panel--parco #poi-title {
  color: var(--color-primary);
}

#poi-panel.poi-panel--parco #close-panel {
  color: var(--color-primary);
}

#poi-panel.poi-panel--parco .poi-panel-link {
  color: var(--color-primary);
}

#poi-panel.poi-panel--parco .poi-panel-link img {
  filter: brightness(0) saturate(100%) invert(12%) sepia(32%) saturate(1200%)
    hue-rotate(120deg) brightness(92%) contrast(95%);
}

#overlay.active {
  opacity: 1;
  pointer-events: auto;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

#close-panel {
  top: 16px;
  right: 16px;
  font-size: 28px;
  color: var(--color-white);
  background: none;
  border: none;
  cursor: pointer;
  align-self: flex-end;
}

.poi-panel-image {
  width: 100%;
}

.poi-panel-image img {
  width: 100%;
  display: block;
  object-fit: cover;
}

.poi-panel-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.poi-panel-category {
  margin-top: 40px;
}

.poi-panel-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-white);
  text-decoration: none;
  font-size: 16px;
}

.poi-panel-link img {
  width: 32px;
  height: 32px;
  display: block;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 480px) {
  /* Frame takes full viewport height, clips overflow */
  #end-frame {
    height: 100vh;
  }

  /* Only disable touch-action when in exploration mode */
  html.map-scroll-locked #end-frame {
    touch-action: none; /* allow JS-driven horizontal pan */
  }

  /* Media wrapper matches the image's natural rendered size.
     Position relative so POIs (absolute, %) stay relative to image.
     width: max-content shrink-wraps to the image's actual width. */
  #end-frame .end-frame-media {
    position: relative;
    height: 100%;
    width: max-content;
  }

  /* Image maintains natural size; may overflow viewport for panning */
  #end-frame-img {
    min-height: 100%;
    width: auto;
    max-width: none;
    object-fit: contain; /* Maintain aspect ratio, allow overflow */
  }

  /* Hide compass on mobile */
  .map-compass,
  .map-compass[aria-hidden='true'] {
    display: none !important;
    visibility: hidden !important;
  }

  /* Hide POI labels on mobile */
  .poi-label {
    display: none !important;
  }

  /* Hide POIs initially on mobile */
  .poi {
    display: none !important;
  }

  .poi.exploration-active {
    display: block !important;
  }

  /* Show exploration button on mobile */
  .map-explore-btn {
    display: flex;
  }

  /* Filter bar mobile positioning - move to top */
  .map-filter {
    top: 16px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
  }

  .map-filter.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Pan hint — bottom center of frame */
  #end-frame .pan-hint {
    display: block;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 380px;
    height: 170px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 3;
  }

  #end-frame .pan-hint.visible {
    opacity: 1;
  }

  #end-frame .pan-hint.hidden {
    opacity: 0;
  }

  /* Map explore button — center of frame */
  .map-explore-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 24px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 3;
    transition: opacity 0.3s ease;
  }

  .map-explore-btn svg {
    width: 24px;
    height: 24px;
  }

  .map-explore-label {
    color: white;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
  }

  .map-explore-btn.hidden {
    display: none;
  }

  /* Continue navigation button — same position as pan-hint, hidden initially */
  .map-continue-nav {
    display: flex;
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 16px 32px !important;
    font-size: 16px;
    line-height: 20px;
    text-transform: uppercase;
    background: transparent;
    color: var(--color-white);
    border: 2px solid var(--color-white);
    cursor: pointer;
    z-index: 3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    white-space: nowrap;
    font-family: inherit;
  }

  .map-continue-nav.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .map-filter__btn {
    font-size: 12px;
    padding: 6px 12px 6px 4px;
    width: auto;
    justify-content: center;
  }

  .map-filter__btn[data-filter='tutti'] {
    padding: 20px;
  }

  /* Crop Parco label on mobile */
  .map-filter__btn[data-filter='parco'] .filter-label-full {
    display: none;
  }
  .map-filter__btn[data-filter='parco'] .filter-label-short {
    display: inline;
  }

  .map-header {
    flex-direction: column;
    gap: 24px;
  }

  .map-header-right {
    align-items: flex-start;
    max-width: unset;
  }

  .map-intro {
    font-size: 16px;
  }

  .map-cta {
    align-self: flex-start;
  }
}
