/**
 * @file
 * Sticky map layout of the bird observation map page.
 *
 * Used by views-view--sightings--page-1.html.twig (library
 * fkf20/sightings_map). The map stays at the top of the screen and the
 * observation list scrolls under it; the list header (title, count,
 * "Show all", "Hide map") sticks just below the map.
 *
 * - --sos-sticky-top: where the map sticks. Below Drupal's admin toolbar,
 *   whose height core's displace.js publishes as
 *   --drupal-displace-offset-top.
 * - --sos-map-height: the map height. It overrides the inline height that
 *   the Leaflet module sets from the view's Leaflet Map settings.
 *
 * When the visitor hides the map, the sos_observation module adds
 * "sos-map-is-collapsed" to the map element (its own CSS hides it), and the
 * list header moves up to the top.
 */

.sos-map-layout {
  --sos-sticky-top: var(--drupal-displace-offset-top, 0px);
  --sos-map-height: clamp(180px, 38vh, 500px);
}

@supports (height: 1svh) {
  .sos-map-layout {
    --sos-map-height: clamp(180px, 38svh, 500px);
  }
}

@media (min-width: 992px) {
  .sos-map-layout {
    --sos-map-height: clamp(300px, 45vh, 500px);
  }
}

.sos-map-layout:has(.sos-map-is-collapsed) {
  --sos-map-height: 0px;
}

.sos-map-layout__map {
  position: sticky;
  top: var(--sos-sticky-top);
  z-index: 3;
  background-color: var(--bs-body-bg, #fff);
}

.sos-map-layout__map .leaflet-container {
  height: var(--sos-map-height) !important;
}

/*
 * Content wider than a phone screen (e.g. a table format) scrolls sideways
 * in its own box. If it widened the page instead, mobile browsers would zoom
 * out or scroll the page sideways, and the sticky map would no longer stay
 * on screen. The list format (below) fits anyway; this is a safeguard.
 */
.sos-map-layout__list .sos-map-panel__content {
  overflow-x: auto;
}

/*
 * After a click on the map filters the list, observation-map.js scrolls the
 * panel back into view; this makes it stop just below the sticky map.
 */
.sos-map-layout__list .sos-map-panel {
  scroll-margin-top: calc(var(--sos-sticky-top) + var(--sos-map-height));
}

.sos-map-layout__list .sos-map-panel__header {
  position: sticky;
  top: calc(var(--sos-sticky-top) + var(--sos-map-height));
  z-index: 2;
  padding-top: 0.5rem;
  background-color: var(--bs-body-bg, #fff);
}

/*
 * The exposed sort form above the list, when the list is the page display:
 * label and select on one line.
 */
.sos-map-layout__filters .form-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
}

.sos-map-layout__filters .form-select {
  width: auto;
}

/*
 * One observation in the list (views-view-fields--sightings--page-1
 * .html.twig): species, badge and time; scientific name and details; place,
 * observers and icons. On narrow screens the time and the icons wrap to the
 * right of the next line.
 */
.sos-obs {
  line-height: 1.35;
}

.sos-obs__head,
.sos-obs__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.5rem;
}

.sos-obs__species {
  font-weight: 600;
}

.sos-obs__time {
  margin-left: auto;
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875em;
  white-space: nowrap;
}

.sos-obs__meta,
.sos-obs__foot,
.sos-obs__more {
  font-size: 0.875em;
}

.sos-obs__observers,
.sos-obs__sep {
  color: var(--bs-secondary-color, #6c757d);
}

.sos-obs__sep {
  margin: 0 0.25em;
}

.sos-obs__icons {
  display: inline-flex;
  gap: 0.25rem;
  margin-left: auto;
}

.sos-obs__more {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
}
