/* SPDX-License-Identifier: AGPL-3.0-or-later */

.active-layers-toggle {
  position: absolute;
  z-index: 1010;
  right: 18px;
  bottom: 22px;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 15px;
  background: rgba(8, 31, 45, .94);
  box-shadow: 0 8px 22px rgba(4, 31, 49, .24);
  color: #fff;
  font: inherit;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.active-layers-toggle:hover,
.active-layers-toggle:focus-visible,
.active-layers-toggle[aria-expanded="true"] {
  border-color: #5fc3df;
  background: #075d88;
  outline: none;
}

.active-layers-toggle-icon {
  font-size: 21px;
  line-height: 1;
}

.active-layers-toggle b {
  font-size: 13px;
  white-space: nowrap;
}

.active-layers-toggle-count {
  display: grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff;
  color: #075d88;
  font-size: 12px;
  font-weight: 900;
}

.active-layers-backdrop[hidden],
.active-layers-sheet[hidden] {
  display: none !important;
}

.active-layers-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2140;
  background: rgba(4, 31, 49, .34);
  backdrop-filter: blur(2px);
}

.active-layers-sheet {
  position: fixed;
  z-index: 2160;
  right: 18px;
  bottom: 18px;
  width: min(430px, calc(100vw - 36px));
  max-height: min(760px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid #cbdce5;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 20px 54px rgba(3, 31, 49, .28);
  color: #173e54;
}

.active-layers-sheet-inner {
  display: flex;
  max-height: inherit;
  flex-direction: column;
}

.active-layers-handle {
  display: none;
}

.active-layers-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 18px 13px;
  border-bottom: 1px solid #d8e5eb;
}

.active-layers-head small {
  color: #527486;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.active-layers-head h2 {
  margin: 3px 0 0;
  color: #103f5b;
  font-size: 22px;
  line-height: 1.15;
}

.active-layers-close {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border: 1px solid #cedee6;
  border-radius: 14px;
  background: #edf5f8;
  color: #284e63;
  font-size: 25px;
  cursor: pointer;
}

.active-layers-intro {
  margin: 0;
  padding: 12px 18px;
  background: #f1f7f9;
  color: #506d7c;
  font-size: 12px;
  line-height: 1.45;
}

.active-layers-list {
  display: grid;
  gap: 10px;
  min-height: 110px;
  padding: 13px 14px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.active-layer-empty {
  display: grid;
  min-height: 112px;
  place-items: center;
  padding: 20px;
  border: 1px dashed #b9ced8;
  border-radius: 15px;
  color: #5f7a88;
  text-align: center;
}

.active-layer-card {
  padding: 13px;
  border: 1px solid #ccdde5;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 12px rgba(12, 61, 87, .06);
}

.active-layer-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.active-layer-name {
  margin: 0;
  color: #153f57;
  font-size: 14px;
  line-height: 1.3;
}

.active-layer-kind {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f2f6;
  color: #356176;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.active-layer-kind[data-kind="analysis"] {
  background: #f0e8f7;
  color: #684091;
}

.active-layer-kind[data-kind="evidence"] {
  background: #e5f5f3;
  color: #08766e;
}

.active-layer-opacity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.active-layer-opacity-row input[type="range"] {
  width: 100%;
  min-height: 38px;
  margin: 0;
  accent-color: #087ea4;
  touch-action: pan-x;
}

.active-layer-opacity-value {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 11px;
  background: #e9f4f8;
  color: #075d88;
  font-size: 14px;
  font-weight: 900;
}

.active-layer-presets,
.active-layer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.active-layer-presets {
  margin-top: 5px;
}

.active-layer-presets button,
.active-layer-actions button,
.active-layers-footer button {
  min-height: 40px;
  border: 1px solid #c8d9e2;
  border-radius: 11px;
  background: #f7fafb;
  color: #2c5368;
  font: inherit;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.active-layer-presets button {
  min-width: 45px;
  padding: 6px 9px;
}

.active-layer-presets button[aria-pressed="true"] {
  border-color: #0b7da2;
  background: #dff1f6;
  color: #075d88;
}

.active-layer-actions {
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid #e1eaee;
}

.active-layer-actions button {
  flex: 1 1 120px;
  padding: 7px 10px;
}

.active-layer-actions .remove-layer {
  border-color: #e2bfc2;
  background: #fff7f7;
  color: #9b3e47;
}

.active-layers-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #d6e3e9;
  background: #f7fafb;
}

.active-layers-footer button {
  padding: 9px 10px;
}

.active-layers-footer .primary {
  border-color: #087ea4;
  background: #087ea4;
  color: #fff;
}

.active-layers-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .active-layers-toggle {
    position: fixed;
    z-index: 1880;
    right: auto;
    bottom: calc(var(--mobile-dock) + 10px);
    left: 10px;
    min-height: 48px;
    max-width: calc(100vw - 132px);
    padding: 7px 9px 7px 10px;
    border-radius: 14px;
  }

  .active-layers-toggle b {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
  }

  .mobile-legend-toggle {
    right: 10px !important;
    bottom: calc(var(--mobile-dock) + 10px) !important;
    left: auto !important;
  }

  .active-layers-sheet {
    right: 0;
    bottom: var(--mobile-dock);
    left: 0;
    width: 100%;
    max-height: calc(100dvh - var(--mobile-header) - var(--mobile-dock));
    border: 0;
    border-radius: 24px 24px 0 0;
  }

  .active-layers-handle {
    display: block;
    width: 42px;
    height: 5px;
    margin: 8px auto 1px;
    border-radius: 99px;
    background: #c1d1d9;
  }

  .active-layers-head {
    padding: 10px 14px 12px;
  }

  .active-layers-head h2 {
    font-size: 20px;
  }

  .active-layers-intro {
    padding: 10px 14px;
  }

  .active-layers-list {
    padding: 11px 10px 16px;
  }

  .active-layer-card {
    padding: 12px;
  }

  .active-layer-name {
    font-size: 14px;
  }

  .active-layer-opacity-row input[type="range"] {
    min-height: 46px;
  }

  .active-layer-opacity-value,
  .active-layer-presets button,
  .active-layer-actions button,
  .active-layers-footer button {
    min-height: 44px;
  }

  body.visual-layers-open .active-layers-toggle,
  body.visual-layers-open .mobile-legend-toggle,
  body.visual-layers-open .mobile-more-sheet,
  body.visual-layers-open .mobile-more-backdrop {
    display: none !important;
  }

  body.modal-open .active-layers-toggle,
  body.modal-open .active-layers-sheet,
  body.modal-open .active-layers-backdrop {
    display: none !important;
  }
}

@media (max-width: 380px) {
  .active-layers-toggle b {
    max-width: 90px;
  }

  .active-layers-toggle-icon {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .active-layers-sheet,
  .active-layers-backdrop {
    transition: none !important;
  }
}
