/**
 * @file
 * Styles of the observation panel next to an SOS observation map.
 *
 * The layout of map and panel (side by side or below, sticky or not) is not
 * set here but in the theme's views-view template for the map view
 * (Bootstrap grid classes) and its CSS. A theme can follow the hidden map
 * with the class sos-map-is-collapsed on the map element, or
 * is-map-collapsed on the panel.
 * The panel header uses Bootstrap utility classes in the template. Colours
 * come from Bootstrap's CSS variables, so they follow the theme's palette;
 * the values after the variable names are fallbacks.
 */

.sos-map-panel {
  display: flex;
  flex-direction: column;
  margin-top: 1rem;
}

.sos-map-panel__show-all[hidden],
.sos-map-panel__toggle-map[hidden] {
  display: none;
}

/* The map hidden with "Hide map" (observation-map.js). */
.sos-map-is-collapsed {
  display: none !important;
}

/* A click on a row shows its location on the map (observation-map.js). */
.sos-map-panel.is-interactive [data-location-key] {
  cursor: pointer;
}

.sos-map-panel__content table {
  width: 100%;
  margin-bottom: 0;
  font-size: 0.875rem;
}

/*
 * Cell spacing comes from the table format (Bootstrap "Condensed",
 * table-sm). Cells with several lines (species, place) align at the top.
 */
.sos-map-panel__content th,
.sos-map-panel__content td {
  vertical-align: top;
}

/* Rows filtered out by a click on the map. */
.sos-map-panel [data-location-key][hidden] {
  display: none;
}

/* The row whose marker is highlighted on the map. */
.sos-map-panel [data-location-key]:hover,
.sos-map-panel [data-location-key]:focus-within {
  background-color: rgba(var(--bs-emphasis-color-rgb, 0, 0, 0), 0.05);
}

/* Bootstrap tables paint the cells, so tint them through its variables. */
.sos-map-panel tr[data-location-key]:hover > *,
.sos-map-panel tr[data-location-key]:focus-within > * {
  --bs-table-bg-state: var(--bs-table-hover-bg, rgba(0, 0, 0, 0.075));
  --bs-table-accent-bg: var(--bs-table-hover-bg, rgba(0, 0, 0, 0.075));
}

.sos-map-panel__locality {
  font-size: 0.875rem;
  color: var(--bs-secondary-color, #6c757d);
}

/*
 * Map badges: one per location (L.DivIcon, see ObservationMapGrouper) and
 * one per cluster (observation-map-cluster.js), showing the number of
 * observations. Override these in the theme to change the look.
 *
 * Leaflet positions the icon element (.sos-map-count) with an inline
 * transform, so the visible circle is the inner __number element: transforms
 * on the icon element itself would move the badge.
 */
.sos-map-count {
  background: none;
  border: 0;
}

.sos-map-count__number {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  border: 2px solid #fff;
  border-radius: 50%;
  background-color: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.1s ease-in-out;
}

.sos-map-count--cluster {
  cursor: zoom-in;
}

.sos-map-count--cluster .sos-map-count__number {
  background-color: var(--bs-danger-text-emphasis, #58151c);
  box-shadow:
    0 0 0 3px rgba(var(--bs-danger-rgb, 220, 53, 69), 0.45),
    0 1px 3px rgba(0, 0, 0, 0.4);
}

.sos-map-count.is-hovered,
.sos-map-count.is-selected,
.sos-map-count:focus-visible {
  z-index: 1000 !important;
  outline: none;
}

.sos-map-count.is-hovered .sos-map-count__number,
.sos-map-count:focus-visible .sos-map-count__number {
  transform: scale(1.2);
  outline: 2px solid var(--bs-emphasis-color, #1d1d1b);
  outline-offset: 1px;
}

.sos-map-count.is-selected .sos-map-count__number {
  border-color: var(--bs-emphasis-color, #1d1d1b);
  outline: 3px solid var(--bs-emphasis-color, #1d1d1b);
  outline-offset: 0;
}

/* The list while a sort change loads (observation-list-sort.js). */
.sos-map-panel__content[aria-busy="true"] {
  opacity: 0.5;
  transition: opacity 0.15s ease-in;
}
