/*
 * Sidebar layout for the map page — replaces the fragile percentage/JS
 * sizing of the D7 page with a fixed-width flex column.
 * Loads after qriver-map.css (the ported D7 mapbox.css).
 */

.filter-group {
  width: 300px;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: #546d7a;
}

.dkl {
  flex: 0 1 auto;
  max-height: 60%;
  overflow-y: auto;
  height: auto !important; /* the D7 page set heights from JS */
}

.map_my_layer,
.fltr_sctn {
  float: none;
}

.ac-custom {
  float: none;
  max-width: none;
  margin: 0;
  padding: 8px 10px 8px 38px;
}

.ac-custom li {
  width: 100%;
  float: none;
}

.sidebar_popup {
  flex: 1 1 auto;
  float: none;
  height: auto !important;
  overflow-y: auto;
  padding: 10px 16px;
}

.map_btmimg {
  flex: 0 1 auto;
  max-height: 34%;
  overflow: hidden;
  background: #f1efe2;
  height: auto !important;
}

.map_btmimg img {
  width: 100%;
  display: block;
}

#map {
  left: 300px;
  width: auto;
  right: 0;
}

#mapview {
  position: fixed;
  top: 180px;
  right: 12px;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  padding: 6px 12px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

@media screen and (max-width: 900px) {
  .filter-group {
    width: 240px;
  }
  #map {
    left: 240px;
  }
}

/* --- Grouped layer list --------------------------------------------- */

.layer-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 10px 0 2px;
  padding: 4px 10px 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #cfe0e8;
}

/* The list is inside .ac-custom, which indents rows to clear the custom
   checkmark; headings are not rows, so pull them back to the edge. */
.ac-custom li.layer-group-heading {
  margin-left: -28px;
  padding-left: 0;
}

.ac-custom li.layer-group-heading:first-child {
  margin-top: 0;
}

.layer-group-toggle {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  color: #cfe0e8;
  cursor: pointer;
  font: inherit;
  font-size: 10px;
  padding: 1px 7px;
  text-transform: lowercase;
}

.layer-group-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* --- Selected feature card ------------------------------------------ */

.sidebar_popup .feature-kind {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7d8f99;
}

.sidebar_popup .feature-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

.sidebar_popup .feature-actions button {
  background: #546d7a;
  border: 0;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
}

.sidebar_popup .feature-actions button:hover {
  background: #41555e;
}

.sidebar_popup .feature-actions .feature-clear {
  background: none;
  border: 1px solid #b6bfc4;
  color: #546d7a;
}

.sidebar_popup .feature-actions .feature-clear:hover {
  background: #e4e1d2;
}

/* --- Mobile: the panel is a drawer, not display:none ----------------- */

.map-panel-toggle {
  display: none;
}

@media screen and (max-width: 640px) {
  .map-panel-toggle {
    display: block;
    position: fixed;
    /* Anchored below the site header at the top of the map, not to the
       bottom edge, where mobile browser chrome overlaps a fixed control. */
    left: 10px;
    top: 123px;
    z-index: 6;
    background: #546d7a;
    border: 0;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
    color: #fff;
    cursor: pointer;
    font: 700 13px/1 Arial, Helvetica, sans-serif;
    padding: 11px 16px;
  }

  /* The D7 stylesheet hid the panel outright on phones, which lost both the
     layer list and every feature detail. Slide it in instead. */
  #filter-group.filter-group {
    display: flex;
    width: 100%;
    max-width: 340px;
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.35);
  }

  #filter-group.filter-group.is-open {
    transform: translateX(0);
  }

  #map {
    left: 0;
  }
}

/* --- Feature detail dialog ------------------------------------------- */

/*
 * Sized to the viewport rather than to its content: the picture is a fixed
 * band and the description is line-clamped, so the dialog never scrolls.
 * Anything longer lives on the feature's own page behind "Full details".
 */
.map-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.map-modal[hidden] {
  /* An author-level display value outranks the UA rule for [hidden], so the
     closed dialog would otherwise sit invisibly over the whole map and
     swallow every click. */
  display: none;
}

.map-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 35, 0.6);
}

.map-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

.map-modal__close {
  position: absolute;
  top: 6px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.map-modal__close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.map-modal__figure {
  margin: 0;
  flex: 0 0 auto;
  height: 210px;
  background: #dedad0;
}

.map-modal__figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.map-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 22px 20px;
}

.map-modal__kind {
  margin: 0 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7d8f99;
}

.map-modal__title {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
  color: #41555e;
}

.map-modal__text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #444;
  /* Clamp rather than scroll; the full text is one click away. */
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.map-modal__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.map-modal__link {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid #b6bfc4;
  border-radius: 3px;
  color: #41555e;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.map-modal__link:hover {
  background: #eef1f2;
}

.map-modal__link.is-primary {
  background: #546d7a;
  border-color: #546d7a;
  color: #fff;
}

.map-modal__link.is-primary:hover {
  background: #41555e;
}

.map-modal__share {
  background: none;
  border: 0;
  color: #7d8f99;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  padding: 0;
  text-decoration: underline;
}

.map-modal__share:hover {
  color: #41555e;
}

body.map-modal-open {
  overflow: hidden;
}

@media screen and (max-width: 640px) {
  .map-modal {
    padding: 12px;
  }

  .map-modal__figure {
    height: 150px;
  }

  .map-modal__title {
    font-size: 17px;
  }

  .map-modal__text {
    -webkit-line-clamp: 4;
  }
}

.sidebar_popup .feature-details {
  background: #546d7a;
}
