/* ============================================================
   RedBorder · Mappa Mobile V1.5
   Bottom sheet unificato con stati: peek / mid / half / full / event / event-expanded
   Tutto namespacato con .rb-mob- per non collidere col tuo CSS esistente.
   ============================================================ */

:root {
  --rb-red: #ff0000;
  --rb-ink: #111111;
  --rb-mute: #6b6b6b;
  --rb-line: #e7e3da;
  --rb-cream: #f5f1e8;
  --rb-paper: #faf7f0;
  --rb-cat-fashion: #ff0000;
  --rb-cat-design: #1A5CBA;
  --rb-cat-arte: #F5C518;
  --rb-cat-after: #111111;

  --rb-mob-sheet-peek: max(90px, 14dvh);
  --rb-mob-sheet-mid: max(180px, 30dvh);
  --rb-mob-sheet-half: min(46dvh, calc(100dvh - 140px));
  --rb-mob-sheet-full: calc(100dvh - 80px);
  --rb-mob-sheet-event-min: 200px;
  --rb-mob-anim: 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Container root ─────────────────────────────────────── */
.rb-mob {
  position: fixed;
  inset: 0;
  height: 100dvh;
  max-height: 100dvh;
  background: #f5f3f0;
  font-family: inherit;
  overflow: hidden;
  z-index: 100;
}

/* ── Map area (clipped above the sheet) ─────────────────── */
.rb-mob__map-clip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--rb-mob-sheet-h, min(46dvh, calc(100dvh - 140px)));
  overflow: hidden;
  transition: bottom var(--rb-mob-anim);
}
.rb-mob--sheet-live .rb-mob__map-clip,
.rb-mob--sheet-live .rb-mob__sheet {
  transition: none !important;
}
.rb-mob__map {
  position: absolute;
  inset: 0;
  background: var(--rb-paper);
  /* Isolate Leaflet's internal z-index values (200–700) from the outer
     stacking context so the top bar, chips, and sheet can sit above them. */
  isolation: isolate;
}

/* ── Top floating row: back + search ────────────────────── */
.rb-mob__top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 800;
  pointer-events: none;
}
.rb-mob__top > * { pointer-events: auto; }

.rb-mob__icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: none;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rb-mob__search {
  flex: 1;
  height: 40px;
  border-radius: 999px;
  background: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  padding: 0 14px 0 38px;
  font-size: 13px;
  color: var(--rb-ink);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat;
  background-position: 13px center;
  background-size: 16px;
  outline: none;
}
.rb-mob__search::placeholder { color: var(--rb-mute); }

/* ── Category chips row ─────────────────────────────────── */
.rb-mob__chips {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  display: flex;
  justify-content: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 800;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
.rb-mob__chips::-webkit-scrollbar { display: none; }

.rb-mob__chip {
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.6px;
  background: #fff;
  color: var(--rb-ink);
  border: 1.5px solid var(--rb-line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: border-color 120ms;
}
.rb-mob__chip[aria-pressed="true"] {
  border-color: var(--rb-chip-color, var(--rb-red));
}
.rb-mob__chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rb-chip-color, var(--rb-red));
}

/* ── Bottom sheet ───────────────────────────────────────── */
.rb-mob__sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--rb-mob-sheet-h, min(46dvh, calc(100dvh - 140px)));
  background: #fff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: height var(--rb-mob-anim);
}
.rb-mob__sheet--dragging { transition: none; }

.rb-mob__handle {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 12px 16px 8px;
  flex: 0 0 auto;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.rb-mob__handle:active { cursor: grabbing; }
.rb-mob__handle::before {
  content: "";
  width: 44px;
  height: 5px;
  border-radius: 4px;
  background: rgba(0,0,0,0.22);
}
.rb-mob__sheet--dragging .rb-mob__handle { cursor: grabbing; }

/* ── Sheet · LIST mode ──────────────────────────────────── */
.rb-mob__list-head {
  padding: 4px 16px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 0 0 auto;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.rb-mob__sheet--dragging .rb-mob__list-head { cursor: grabbing; }
.rb-mob__list-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--rb-red);
  letter-spacing: 0.8px;
}
.rb-mob__list-count {
  font-size: 11px;
  color: var(--rb-mute);
}
.rb-mob__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.rb-mob__sheet--dragging .rb-mob__list {
  overflow: hidden;
  touch-action: none;
}

.rb-mob__row {
  position: relative;
  padding: 12px 16px 12px 20px;
  border-left: 4px solid var(--row-cat-color, var(--rb-red));
  border-bottom: 1px solid var(--rb-line);
  cursor: pointer;
  background: #fff;
  transition: background 120ms;
}
.rb-mob__row:hover { background: var(--rb-paper); }
.rb-mob__row--active {
  background: #fff5f5;
}
.rb-mob__row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.rb-mob__row-name {
  flex: 1;
  font-size: 14px;
  font-weight: 800;
  color: var(--rb-ink);
  letter-spacing: 0.2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
}
.rb-mob__tag {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--rb-tag-color, var(--rb-red));
  background: color-mix(in srgb, var(--rb-tag-color, var(--rb-red)) 12%, white);
  white-space: nowrap;
  text-transform: uppercase;
}
.rb-mob__row-meta {
  font-size: 11px;
  color: var(--text, #0b0b0b);
  line-height: 1.4;
}

/* ── Sheet · EVENT mode ─────────────────────────────────── */
.rb-mob[data-mode="event"] .rb-mob__sheet {
  transition: height var(--rb-mob-anim);
}
.rb-mob[data-mode="event"]:not([data-expanded]) .rb-mob__event {
  flex: 0 0 auto;
}
.rb-mob__event {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}
.rb-mob[data-mode="event"]:not([data-expanded]) .rb-mob__event-scroll {
  flex: 0 0 auto;
  overflow: visible;
  padding: 8px 16px 16px;
}
.rb-mob__event-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  padding: 6px 16px 0;
}
.rb-mob__sheet--dragging .rb-mob__event-scroll {
  overflow: hidden;
  touch-action: none;
}
.rb-mob__event-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  margin-top: 0;
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid var(--rb-line);
}
.rb-mob[data-mode="event"]:not([data-expanded]) .rb-mob__event-actions {
  padding-top: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.rb-mob__event-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.rb-mob__event-cat {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--rb-cat-color, var(--rb-red));
  text-transform: uppercase;
}
.rb-mob__event-cat-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--rb-cat-color, var(--rb-red));
  display: inline-block;
}
.rb-mob__event-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--rb-cream);
  border: none;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rb-mob__admission-badge {
  display: inline-block;
  vertical-align: middle;
  position: relative;
  top: -2px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}
.rb-mob__admission-badge--rsvp {
  background: rgba(200, 60, 60, .15);
  color: #b33;
}
.rb-mob__admission-badge--free {
  background: rgba(34, 197, 94, .15);
  color: #15803d;
}
.rb-mob__admission-badge--unavailable {
  background: rgba(120, 120, 120, .16);
  color: #5c5c5c;
}
.rb-mob__event-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--rb-ink);
  letter-spacing: 0.1px;
  line-height: 1.1;
  text-wrap: pretty;
  margin: 0;
  text-transform: uppercase;
}
.rb-mob__event-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.rb-mob[data-mode="event"]:not([data-expanded]) .rb-mob__event-meta {
  margin-bottom: 0;
}
.rb-mob__event-when {
  font-size: 12px;
  color: var(--rb-ink);
  font-weight: 600;
}
.rb-mob__event-where {
  font-size: 12px;
  color: var(--rb-ink);
}
.rb-mob__event-divider {
  height: 1px;
  background: var(--rb-line);
  margin: 4px 0;
}
.rb-mob__event-section-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--rb-red);
  letter-spacing: 0.8px;
}
.rb-mob__event-desc {
  font-size: 13px;
  color: var(--rb-ink);
  line-height: 1.45;
  text-wrap: pretty;
}
.rb-mob__event-stats {
  display: flex;
  gap: 14px;
  margin-top: 6px;
}
.rb-mob__event-stat-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--rb-mute);
  letter-spacing: 0.6px;
}
.rb-mob__event-stat-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--rb-ink);
}
.rb-mob__event-page-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--rb-red);
  text-decoration: none;
  letter-spacing: 0.3px;
}
.rb-mob__detail-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ff0000;
  text-decoration: none;
  margin-bottom: 12px;
}
.rb-mob__btn--free {
  background: rgba(34, 197, 94, .15);
  color: #15803d;
  cursor: default;
  pointer-events: none;
}
.rb-mob__btn--inert {
  cursor: default;
  pointer-events: none;
  opacity: 0.75;
}
.rb-mob__btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  border: none;
  text-transform: uppercase;
  text-decoration: none;
}
.rb-mob__btn--primary {
  background: var(--rb-ink);
  color: #fff;
}
.rb-mob__btn--secondary {
  background: #fff;
  color: var(--rb-ink);
  border: 1.5px solid var(--rb-line);
}

/* ── Show only relevant content for current mode ───────── */
.rb-mob[data-mode="list"] .rb-mob__event { display: none; }
.rb-mob[data-mode="event"] .rb-mob__list-head,
.rb-mob[data-mode="event"] .rb-mob__list { display: none; }
.rb-mob[data-mode="event"]:not([data-expanded]) .rb-mob__event-expanded { display: none; }

/* ── Custom Leaflet pin ─────────────────────────────────── */
.rb-mob-pin {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: auto;
  overflow: visible;
}
.rb-mob-pin__wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
  vertical-align: bottom;
  overflow: visible;
}
.rb-mob-pin__wrap--stacked {
  overflow: visible;
}
.rb-mob-pin__badge {
  position: absolute;
  top: calc(var(--rb-pin-size, 24px) * -0.05);
  right: calc(var(--rb-pin-size, 24px) * -0.20);
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--rb-pin-size, 24px) * 0.58);
  height: calc(var(--rb-pin-size, 24px) * 0.58);
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
  border: 2px solid #fff;
  font-family: Inter, system-ui, sans-serif;
  font-size: calc(var(--rb-pin-size, 24px) * 0.38);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}
.rb-mob-pin--active .rb-mob-pin__badge {
  display: none;
}
.rb-mob-pin.rb-mob-pin--stacked {
  overflow: visible;
}
.rb-mob-pin__wrap {
  transform-origin: 50% 100%;
  transition: transform 160ms ease;
}
.rb-mob-pin svg {
  overflow: visible;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25));
  display: block;
}
.rb-mob-pin--active .rb-mob-pin__wrap {
  transform: scale(1.2);
}
.rb-mob-pin--active svg {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.35));
}
.rb-mob__venue-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid rgba(11, 11, 11, 0.08);
  border-radius: 12px;
  background: rgba(11, 11, 11, 0.05);
  color: #444;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.rb-mob__venue-note-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.rb-mob__venue-note-action {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #111;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Hide pins when sheet is expanded ───────────────────── */
.rb-mob[data-pins-hidden] .leaflet-marker-pane,
.rb-mob[data-pins-hidden] .leaflet-shadow-pane {
  opacity: 0;
  transition: opacity 200ms;
  pointer-events: none;
}
.leaflet-marker-pane,
.leaflet-shadow-pane {
  transition: opacity 200ms;
}

/* Leaflet attribution toned down */
.rb-mob .leaflet-div-icon,
.rb-mob .leaflet-marker-icon {
  background: transparent !important;
  border: none !important;
  overflow: visible !important;
}
.rb-mob .leaflet-control-attribution {
  font-size: 9px;
  background: rgba(255,255,255,0.7);
}
.rb-mob .leaflet-control-zoom {
  display: none;
}

/* ── FAB “Mappa” (pagina eventi, mappa chiusa) ─────────── */
.btn-map-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  background: var(--rb-red, #ff0000);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
.btn-map-fab[hidden] {
  display: none !important;
}
.btn-map-fab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .btn-map-fab {
    display: none !important;
  }
}
body.mob-map-open .btn-map-fab {
  display: none !important;
}

/* ── Boot deep-link mappa (evita flash lista eventi sotto) ─ */
@media (max-width: 767px) {
  html.rb-map-boot {
    background: #f5f3f0;
  }
  html.rb-map-boot body {
    background: #f5f3f0 !important;
    overflow: hidden !important;
  }
  html.rb-map-boot .skip-link,
  html.rb-map-boot .site-header,
  html.rb-map-boot #scroll-progress-bar,
  html.rb-map-boot .events-main,
  html.rb-map-boot main,
  html.rb-map-boot .site-footer,
  html.rb-map-boot #map-modal-events,
  html.rb-map-boot .btn-map-fab {
    display: none !important;
  }
  html.rb-map-boot #rb-mob {
    display: block !important;
  }
}

/* ── Page integration ────────────────────────────────────── */
/* Hidden by default; shown only when JS adds .is-open */
#rb-mob { display: none; }
#rb-mob.is-open { display: block !important; }

/* When the mobile map is open, hide the rest of the page */
@media (max-width: 767px) {
  body.mob-map-open .site-header,
  body.mob-map-open #scroll-progress-bar,
  body.mob-map-open .events-main,
  body.mob-map-open main,
  body.mob-map-open .site-footer,
  body.mob-map-open #map-modal-events {
    display: none !important;
  }
}
