/* Map page layout. Colors, fonts, .search-box, .search-results and .tile come from styles.css. */
.map-page {
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
}

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: 420px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(16, 16, 20, 0.16);
  overflow-y: auto;
}

.panel-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-top .logo {
  height: 26px;
}

.panel-top .back {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  text-decoration: none;
}

.sheet-handle {
  display: none;
}

.panel .search-box {
  max-width: none;
}

.panel .search-box input {
  padding: 12px 14px;
  font-size: 16px; /* under 16px iOS Safari zooms the page on focus, which shrinks the fixed map */
}

/* ---------- Card ---------- */
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-head h2 {
  margin: 0;
  font-family: "HWT Artz", "Arial Black", Impact, sans-serif;
  font-weight: 400;
  font-size: 30px;
  line-height: 1;
  text-transform: lowercase;
}

.card-head .meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.close {
  flex: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  font: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.close:hover {
  border-color: var(--ink);
}

.tiles-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.tiles-2x2 .tile {
  padding: 12px 14px;
}

.tiles-2x2 .tile .big {
  font-size: 24px;
}

.tiles-2x2 .tile.left-tile .big {
  font-size: 26px;
}

.card h3 {
  margin: 20px 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.groups {
  display: grid;
  gap: 8px;
}

.group {
  display: grid;
  grid-template-columns: 10px 118px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.group .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.group .track {
  height: 8px;
  border-radius: 4px;
  background: var(--silver-bg);
  overflow: hidden;
}

.group .fill {
  height: 100%;
  border-radius: 4px;
}

.group .amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.group .pct {
  width: 44px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Reset the table-page rules from styles.css. */
.grads {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 12px;
}

.grads thead th,
.grads tbody td {
  position: static;
  padding: 6px 4px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--ink);
  text-align: right;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  cursor: default;
  font-variant-numeric: tabular-nums;
}

.grads thead th {
  font-weight: 700;
  color: var(--muted);
}

.grads tbody tr {
  cursor: default;
}

.grads thead th:first-child,
.grads tbody td:first-child {
  text-align: left;
}

.grads tbody td.masked {
  color: var(--muted);
  font-style: italic;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  font-size: 13px;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #c2efdf;
  color: #0b6b47;
}

.pill.minimum {
  background: #feefbe;
  color: #7a5c00;
}

.card-foot a {
  color: var(--blue);
  font-weight: 700;
}

.note {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Legend + metric select (bottom-right, above buttons) ---------- */
.legend {
  padding: 12px 14px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(16, 16, 20, 0.16);
  font-size: 12px;
  width: 210px;
}

.legend select {
  width: 100%;
  margin-bottom: 10px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.legend .row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

.legend .swatch {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.legend .caption {
  margin-top: 8px;
  color: var(--muted);
}

.maplibregl-ctrl-group button {
  width: 34px;
  height: 34px;
}

/* ---------- Mobile bottom sheet ---------- */
@media (max-width: 767px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 45vh;
    border-radius: 14px 14px 0 0;
    padding-top: 6px;
    touch-action: pan-y;
  }

  .sheet-handle {
    display: block;
    flex: none;
    margin: -6px -18px -6px;
    padding: 10px 0;
    touch-action: none;
    cursor: grab;
  }

  .sheet-handle::after {
    content: "";
    display: block;
    width: 44px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: var(--silver);
  }

  .panel.dragging {
    transition: none;
  }

  .panel {
    transition: height 0.2s ease-out;
  }

  .panel-top .back {
    font-size: 12px;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: var(--sheet, 45vh);
  }

  .legend {
    position: fixed;
    top: 12px;
    right: 12px;
    width: auto;
    max-width: 250px;
    padding: 8px 10px;
  }

  .legend .row {
    display: inline-flex;
    margin-right: 8px;
    font-size: 11px;
  }

  .legend .caption {
    display: none;
  }
}
