/* The map: count pins, the user position dot, the desaturated tiles, the
   rink peek sheet, the floating Map/List pill and the phone's full map
   view. DESIGN.md > Component conventions > Map; specs/api.yaml >
   x-listing-ui2 > map. The desktop layout (the sticky map beside the
   list) is in layout.css; the peek row's two columns and the selected
   row's ring are in components.css with the other row rules. */

/* ---- Tiles: desaturated so the pins carry the colour ------------------- */
#map {
  background: #dde6ee;
}
#map .leaflet-tile-pane {
  filter: grayscale(0.85) contrast(0.9) brightness(1.06);
}

/* ---- Count pins: a 30px circle inside a 44px hit area ------------------ */
.map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.map-pin:focus {
  outline: none;
}
.map-pin-count {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--color-boards-deep);
  border: 2px solid #fff;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: 0 3px 8px -2px rgba(12, 24, 48, 0.55);
  transition: transform 150ms ease-out;
}
.map-pin.is-selected .map-pin-count {
  background: #fff;
  color: var(--color-boards-deep);
  border: 3px solid var(--color-boards-deep);
  transform: scale(1.2);
}
.map-pin:focus-visible .map-pin-count {
  outline: 2px solid var(--color-ice-blue);
  outline-offset: 2px;
}

/* The user position, once the locate-me control has found it. */
.map-user-dot {
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--color-ice-blue);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(12, 24, 48, 0.4);
}

/* ---- The rink peek sheet: a non-modal region at the foot of the map ---- */
.peek-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000; /* above Leaflet's panes, inside .map-container's own stacking context */
  display: flex;
  flex-direction: column;
  max-height: 60%;
  padding: 0 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--color-fresh-sheet);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px -12px rgba(12, 24, 48, 0.35);
}
.peek-sheet[hidden] {
  display: none;
}
.peek-sheet-head {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 12px;
  padding: 0 36px 10px 2px;
  cursor: pointer;
  touch-action: none; /* a vertical drag picks a detent */
  user-select: none;
  -webkit-user-select: none;
}
.peek-sheet-detent {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 100%;
  height: 28px;
  margin-right: -36px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.peek-sheet-detent:focus-visible {
  outline: 2px solid var(--color-ice-blue);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}
.peek-sheet-grab {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-blue-line);
}
.peek-sheet-title {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-boards);
}
.peek-sheet-meta {
  margin: 0 0 0 auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--color-text-secondary);
}
.peek-sheet-close {
  position: absolute;
  top: 0;
  right: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.peek-sheet-close:focus-visible {
  outline: 2px solid var(--color-ice-blue);
  outline-offset: -4px;
  border-radius: var(--radius-md);
}
.peek-sheet-rows {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-fresh-sheet);
}
.peek-sheet-rows:empty {
  min-height: 60px;
}
.peek-sheet-rows[hidden] {
  display: none;
}
.peek-sheet-empty {
  margin: 0;
  padding: 14px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ---- The floating Map/List pill and the phone map view ----------------- */
.map-view-toggle {
  display: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

@media (max-width: 1023px) {
  .map-view-toggle {
    position: fixed;
    left: 50%;
    bottom: 22px;
    z-index: 200;
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--color-boards-deep);
    border-radius: var(--radius-pill);
    background: var(--color-boards-deep);
    color: #fff;
    font-family: var(--font-body);
    font-size: 14.5px;
    font-weight: 600;
    box-shadow: 0 10px 24px -8px rgba(12, 24, 48, 0.55);
    transform: translateX(-50%);
    cursor: pointer;
  }
  .map-view-toggle:focus-visible {
    outline: 2px solid var(--color-ice-blue);
    outline-offset: 2px;
  }
  .map-view-toggle-map,
  .map-view-toggle-list {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  .map-view-toggle-list,
  .is-map-view .map-view-toggle-map {
    display: none;
  }
  .is-map-view .map-view-toggle-list {
    display: inline-flex;
  }
  .is-map-view.is-peek-open .map-view-toggle {
    bottom: calc(var(--peek-sheet-height) + 14px);
  }

  .map-container {
    display: none;
  }
  .session-list-container {
    padding-bottom: 88px; /* room for the pill under the last row */
  }

  body.is-map-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  .is-map-view .main-layout {
    flex: 1 1 auto;
    min-height: 0;
  }
  .is-map-view .session-list-container {
    display: none;
  }
  .is-map-view .day-strip,
  .is-map-view .compact-strip {
    display: none;
  }
  .is-map-view .map-container {
    display: block;
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    height: auto;
  }
}
