/* ═══════════════════════════════════════════════
   ETNA ZERO TREMILA — mappa.css
   Mappa interattiva 3D del percorso
   ═══════════════════════════════════════════════ */

.mappa { padding: 130px 0 100px; }

.mappa-header { margin-bottom: 36px; }
.mappa-header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: var(--fs-h2);
  font-weight: 900;
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--white);
  margin-top: 12px;
}

/* ── Contenitore mappa ── */
.map-shell {
  background: var(--crater);
  border: 1px solid var(--deep);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--deep);
}
.map-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--pumice);
}
.map-stats b { font-size: 20px; font-weight: 900; letter-spacing: 0.02em; color: var(--glow); }
.map-tools { display: flex; flex-wrap: wrap; gap: 6px; }

/* Selettore percorso (sotto l'intro): pulsanti uniti a segmenti */
.map-routes { display: inline-flex; margin-top: 24px; }
.map-routes .tool { min-height: 46px; min-width: 120px; padding: 0 24px; font-size: 16px; border-radius: 0; }
.map-routes .tool + .tool { margin-left: -1px; }
.map-routes .tool:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.map-routes .tool:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.map-routes .tool.active { position: relative; }

.tool {
  min-height: 36px;
  padding: 0 14px;
  background: var(--deep);
  border: 1px solid #3a251d;
  border-radius: var(--radius);
  color: var(--snow);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.tool:hover { border-color: var(--ember); color: var(--white); }
.tool:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
.tool.icon { width: 36px; padding: 0; font-size: 18px; }
.tool.active { background: var(--ember); border-color: var(--ember); color: var(--white); }
.tool:disabled { opacity: .35; cursor: default; }

.map-viewport {
  position: relative;
  height: min(74vh, 680px);
  min-height: 420px;
  background: var(--lava);
}
#map { position: absolute; inset: 0; }

.map-loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: var(--lava);
  transition: opacity .5s ease, visibility .5s ease;
  z-index: 3;
}
.map-loading span {
  width: 42px; height: 42px;
  border: 3px solid var(--deep);
  border-top-color: var(--ember);
  border-radius: 50%;
  animation: cp-spin .9s linear infinite;
}
.map-loading.done { opacity: 0; visibility: hidden; }
.map-loading.error span { display: none; }
.map-loading.error::after { content: attr(data-msg); color: var(--pumice); font-size: 14px; padding: 0 24px; text-align: center; }
@keyframes cp-spin { to { transform: rotate(360deg); } }

.map-hint {
  padding: 9px 16px;
  font-size: 12px;
  color: var(--ash);
  border-top: 1px solid var(--deep);
}

/* ── Marker checkpoint ──
   Il bottone è posizionato da MapLibre (position e transform inline):
   la grafica sta nello span interno, così hover e stato attivo possono scalare. */
.cp-marker { padding: 0; border: 0; background: none; cursor: pointer; }
.cp-marker:focus-visible { outline: none; }
.cp-pin {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2.5px solid var(--glow);
  background: var(--lava);
  color: var(--white);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 0 4px rgba(240,125,48,0.18), 0 4px 14px rgba(0,0,0,0.6);
  transition: transform .18s ease, background .18s ease;
}
.cp-pin::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--glow);
  opacity: 0;
  animation: cp-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
.cp-marker:hover .cp-pin { transform: scale(1.15); }
.cp-marker:focus-visible .cp-pin { outline: 2px solid var(--white); outline-offset: 3px; }
.cp-marker.is-edge .cp-pin { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(232,184,75,0.2), 0 4px 14px rgba(0,0,0,0.6); }
.cp-marker.is-edge .cp-pin::before { border-color: var(--gold); }
.cp-marker.is-peak .cp-pin { width: 40px; height: 40px; font-size: 18px; border-color: var(--ember); }
.cp-marker.is-active .cp-pin { background: var(--ember); border-color: var(--white); transform: scale(1.2); }
.cp-marker.is-active .cp-pin::before { border-color: var(--ember); }
@keyframes cp-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  100% { transform: scale(2.1); opacity: 0; }
}

.cp-tag {
  position: absolute;
  left: 50%; bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: rgba(16,12,11,0.85);
  border: 1px solid var(--deep);
  color: var(--snow);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.cp-marker:hover .cp-tag, .cp-marker.is-active .cp-tag { opacity: 1; }

/* ── Scheda checkpoint ── */
.cp-card {
  position: absolute;
  top: 16px; right: 16px;
  width: min(360px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 24px 24px 22px;
  background: rgba(30,19,17,0.94);
  backdrop-filter: blur(6px);
  border: 1px solid #3a251d;
  border-top: 3px solid var(--ember);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  z-index: 2;
  animation: cp-in .25s cubic-bezier(.2,.8,.2,1);
}
.cp-card[hidden] { display: none; }
@keyframes cp-in { from { opacity: 0; transform: translateY(10px); } }

.cp-close {
  position: absolute; top: 8px; right: 10px;
  width: 34px; height: 34px;
  background: none; border: 0;
  color: var(--pumice);
  font-size: 26px; line-height: 1;
  cursor: pointer;
}
.cp-close:hover { color: var(--white); }
.cp-eyebrow { font-size: 12px; }
.cp-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 30px;
  font-weight: 900;
  line-height: 0.95;
  text-transform: uppercase;
  color: var(--white);
  margin: 8px 30px 0 0;
}
.cp-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--deep);
  border-bottom: 1px solid var(--deep);
}
.cp-val {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  color: var(--glow);
}
.cp-lbl {
  display: block;
  margin-top: 4px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pumice);
}
.cp-desc { margin-top: 14px; font-size: 14px; line-height: 1.55; color: var(--snow); }
.cp-coord { margin-top: 10px; font-size: 12px; color: var(--ash); font-variant-numeric: tabular-nums; }
.cp-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.cp-dir { text-align: center; padding: 12px 20px; }
.cp-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Profilo altimetrico ── */
.profile { padding: 16px 16px 12px; border-top: 1px solid var(--deep); }
.profile-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.profile-head .eyebrow { font-size: 12px; }
.profile-gpx::after { content: '↓'; }
.profile-chart { position: relative; height: 150px; cursor: crosshair; touch-action: pan-y; }
.profile-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.profile-chart .pc-dot { cursor: pointer; }
.profile-tip {
  position: absolute; top: 0;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: var(--radius);
  background: var(--deep);
  color: var(--snow);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Elenco tappe ── */
.cp-list-wrap { margin-top: 48px; }
.cp-list {
  list-style: none;
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.cp-list button {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  text-align: left;
  background: var(--crater);
  border: 1px solid var(--deep);
  border-radius: 8px;
  color: var(--snow);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.cp-list button:hover, .cp-list button.is-active { border-color: var(--ember); transform: translateY(-2px); }
.cp-list .num {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid var(--glow);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 900;
}
.cp-list button.is-active .num { background: var(--ember); border-color: var(--ember); }
.cp-list strong {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--white);
}
.cp-list small { display: block; margin-top: 3px; font-size: 13px; color: var(--pumice); }

/* ── MapLibre ── */
.maplibregl-ctrl-attrib {
  background: rgba(16,12,11,0.7) !important;
  color: var(--ash) !important;
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--pumice) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .cp-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .mappa { padding: 100px 0 72px; }
  .map-viewport { height: 70vh; min-height: 380px; }
  .map-toolbar { padding: 10px 12px; }
  .map-tools { width: 100%; flex-wrap: nowrap; }
  .map-tools .tool { padding: 0 8px; font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; }
  .map-tools .tool:not(.icon) { flex: 1; }
  .map-routes { display: flex; width: 100%; }
  .map-routes .tool { flex: 1; min-width: 0; }
  .cp-card {
    top: auto; right: 8px; left: 8px; bottom: 8px;
    width: auto;
    max-height: 62%;
    padding: 16px 16px 14px;
  }
  .cp-title { font-size: 24px; }
  .cp-stats { margin-top: 12px; padding: 10px 0; }
  .cp-val { font-size: 22px; }
  .cp-desc { margin-top: 10px; font-size: 13px; }
  .cp-coord { display: none; }
  .cp-actions { margin-top: 12px; }
  .cp-dir { padding: 10px 16px; }
  .cp-list { grid-template-columns: 1fr; }
  .profile-chart { height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-pin::before { animation: none; }
}
