/* Village survey map page, layout only. The map's own chrome is themed in
   styles.css, under .survey-map, and shared with the explorer page. */

/* ── Two stages ───────────────────────────────────────────────────────────
 * The map is the page from the first paint. Step 1 is a card floating over a
 * Telangana overview; picking a village swaps that card for the rail and lets
 * the map take the whole viewport. Nothing about the page changes shape, so
 * there is no jump from "form" to "map".
 */

[data-stage="setup"] [data-stage-only="map"],
[data-stage="map"] [data-stage-only="setup"] {
  display: none;
}

/* In the map stage the shell owns the viewport, so the page behind it must
   not scroll. */
body.is-map-stage {
  overflow: hidden;
}

.map-shell {
  position: relative;
  height: calc(100dvh - var(--header-height, 66px));
  background: var(--brand-dark);
  overflow: hidden;
}

[data-stage="map"] .map-shell {
  position: fixed;
  top: var(--header-height, 66px);
  left: 0;
  right: 0;
  bottom: 0;
  height: auto;
}

/* The phone layout, and every tablet with it: an iPad is a touch device held
   in two hands, not a small desktop, so the second half of these queries hands
   it the phone layout up to the widest iPad there is — 1366px, the 12.9" in
   landscape. `pointer: coarse` is what keeps a laptop out of it, including a
   laptop with a touchscreen, whose primary pointer is still a mouse. */
@media (max-width: 768px), (pointer: coarse) and (max-width: 1366px) {
  .map-shell {
    height: calc(100dvh - var(--header-height, 66px) - 58px - env(safe-area-inset-bottom));
  }
}

/* ── Step 1: the picker, over the map ─────────────────────────────────── */

.map-gate {
  position: absolute;
  inset: 0;
  z-index: 1060;
  display: grid;
  place-items: center;
  padding: 1.25rem 1rem;
  background: rgba(18, 60, 53, 0.42);
  overflow-y: auto;
}

.map-gate-card {
  width: min(440px, 100%);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.5rem 1.6rem;
  box-shadow: var(--shadow-pop);
}

.map-gate-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.map-gate-card h1 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--ink);
  margin-top: 0.15rem;
}

.map-gate-lead {
  margin-top: 0.5rem;
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.map-gate-card .picker-steps {
  margin: 1.2rem 0 1.1rem;
}

.map-gate-card .location-form {
  display: grid;
  gap: 0.9rem;
}

/* A quiet progress rail above the three fields. */
.picker-steps {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
}

.picker-steps li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
}

.picker-steps li::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.picker-steps li:last-child {
  flex: 0 0 auto;
}

.picker-steps li:last-child::after {
  display: none;
}

.picker-steps span {
  width: 23px;
  height: 23px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--paper-sunk);
  color: var(--ink-mute);
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.picker-steps small {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-faint);
  white-space: nowrap;
}

.picker-steps li.is-done span,
.picker-steps li.is-active span {
  background: var(--brand);
  color: var(--paper-raised);
}

.picker-steps li.is-done small,
.picker-steps li.is-active small {
  color: var(--ink);
}

/* ── Loading a village ────────────────────────────────────────────────── */

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 1055;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(18, 60, 53, 0.45);
}

.map-loading.is-hidden {
  display: none;
}

.map-loading-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 22rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1.15rem;
  box-shadow: var(--shadow-pop);
}

.map-loading-card strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.map-loading-card small {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

/* The rail floats over the map rather than taking width from it, so the map
   really is full-page. Only the cards inside it take pointer events; the gaps
   between them stay map. */
.map-rail {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  bottom: 0.9rem;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  /* Above Leaflet's controls (1000) and the sheet (1050), below the site
     header (1100). The survey dropdown opens out of this rail. */
  z-index: 1060;
  pointer-events: none;
}

.map-rail > * {
  pointer-events: auto;
}

.rail-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 0.85rem 1rem;
}

.rail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: 0;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-faint);
}

.rail-back:hover {
  color: var(--brand-dark);
}

.rail-more {
  display: none;
  align-items: center;
  gap: 0.35rem;
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-dark);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.rail-head {
  position: relative;
  padding-right: 6.5rem;
}

.rail-village {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--brand-dark);
  margin-top: 0.25rem;
}

.rail-place {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.rail-controls {
  display: grid;
  gap: 0.9rem;
}

/* The records card takes the rest of the rail and scrolls inside itself. */
.map-rail .parcel-results {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-width: none;
  margin: 0;
  padding: 0.95rem 1rem 1.2rem;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ── Survey-number finder ─────────────────────────────────────────────────
 * A village holds thousands of survey numbers, which is far too many for a
 * native select and exactly what a searchable combobox is for. The list is
 * built from the parcels themselves, so anything in it can always be shown
 * on the map.
 */

.survey-finder {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.survey-finder-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-weight: 700;
}

.combo {
  position: relative;
}

.combo-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 2.4rem 0.65rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 0.15s ease;
}

.combo-input::placeholder {
  color: var(--ink-faint);
}

.combo-input:disabled {
  color: var(--ink-faint);
  cursor: not-allowed;
}

.combo-input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.combo-button {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 2.2rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.combo-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.combo-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.combo[data-open="true"] .combo-button svg {
  transform: rotate(180deg);
}

.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1060; /* see .map-picker, this is the root-level value on mobile */
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
}

.combo.is-above .combo-list {
  top: auto;
  bottom: calc(100% + 4px);
}

.combo-option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
}

.combo-option strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.combo-option small {
  color: var(--ink-faint);
  font-size: 0.72rem;
  white-space: nowrap;
}

.combo-option:hover,
.combo-option[aria-selected="true"] {
  background: var(--brand-tint);
}

.combo-note {
  padding: 0.5rem 0.6rem;
  font-size: 0.76rem;
  color: var(--ink-faint);
}

.combo-note.is-more {
  margin-top: 0.25rem;
  border-top: 1px solid var(--line-soft);
}

/* ── Map label toggle ─────────────────────────────────────────────────── */

.map-toggle {
  display: grid;
  gap: 0.15rem;
}

.map-toggle label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.map-toggle input {
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand);
  flex: none;
  cursor: pointer;
}

.map-toggle strong {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}

.map-toggle small {
  padding-left: 1.55rem; /* aligns under the label, clear of the box */
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.map-location-form {
  grid-template-columns: 1fr;
}

.load-strip {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 0.5rem;
}

.load-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.load-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--line);
}

.load-dot[data-state="busy"] {
  background: var(--accent);
  animation: load-pulse 1.1s ease-in-out infinite;
}

.load-dot[data-state="done"] {
  background: var(--brand-light);
}

.load-dot[data-state="warn"] {
  background: var(--accent-dark);
}

.load-dot[data-state="error"] {
  background: var(--danger);
}

@keyframes load-pulse {
  50% {
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .load-dot[data-state="busy"] {
    animation: none;
  }
}

.map-stage-canvas {
  position: absolute;
  inset: 0;
  height: 100%;
}

.map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 2rem;
  text-align: center;
  background: var(--paper);
  color: var(--ink-faint);
  font-size: 0.9rem;
  z-index: 500; /* above Leaflet's panes, below its controls */
}

/* ── Selected parcel ──────────────────────────────────────────────────── */

.parcel-results {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.6rem 1.5rem 2.6rem;
}

.parcel-heading {
  /* Keeps scrollIntoView from parking this under the sticky header, or hard
     against the bottom edge of the viewport. */
  scroll-margin-top: 5.5rem;
  scroll-margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.parcel-heading h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--brand-dark);
  margin: 0.2rem 0 0.35rem;
}

#parcel-subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  max-width: 70ch;
}

.parcel-metrics {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.parcel-metrics div {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.9rem;
  display: grid;
  gap: 0.1rem;
  min-width: 96px;
}

.parcel-metrics span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  font-weight: 700;
}

.parcel-metrics strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--brand-dark);
}

.parcel-note {
  margin: 0.8rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-faint);
  max-width: 78ch;
}

/* ── A parcel's records ───────────────────────────────────────────────────
 * These never sit in a page-width column: on a desktop they are in a 360px
 * rail, on a phone in a bottom sheet. A six-column table in either is a
 * horizontal scrollbar hiding the owner names, so the same markup is laid
 * out as one card per record at every width instead.
 */
.parcel-table {
  overflow-x: visible;
  min-height: 0;
  background: none;
  border: 0;
  border-radius: 0;
}

.parcel-table table,
.parcel-table tbody {
  display: block;
  width: 100%;
  min-width: 0;
}

.parcel-table thead {
  display: none;
}

.parcel-table tbody tr {
  display: grid;
  /* Two even halves. The right half is right-aligned so khata and land type
     sit on the card's edge instead of trailing dead space beside a label
     that is wider than its value. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.5rem 0.9rem;
  align-items: start;
  margin-bottom: 0.5rem;
  padding: 0.65rem 0.8rem;
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
}

.parcel-table tbody tr:last-child {
  margin-bottom: 0;
}

.parcel-table tbody tr:hover {
  border-color: var(--line);
  background: var(--brand-tint);
}

.parcel-table tbody td {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  padding: 0;
  border: 0;
}

/* The header row is gone, so the short values carry their own labels. The
   name and the button do not: a bold Telugu name over a father's name, and
   an arrow in the corner, are already unambiguous, and two fewer label lines
   is a card that fits more records in the rail. */
.parcel-table tbody .owner-cell[data-label]::before,
.parcel-table tbody .record-action[data-label]::before {
  content: none;
}

.parcel-table tbody td[data-label]::before {
  content: attr(data-label);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--ink-faint);
}

.parcel-table td[data-label="Survey no."] {
  grid-area: 1 / 1;
}

.parcel-table td[data-label="Khata"],
.parcel-table td[data-label="Land type"] {
  align-items: flex-end;
  text-align: right;
}

.parcel-table td[data-label="Khata"] {
  grid-area: 1 / 2;
}

/* The name is what the row is read for, so it gets the full card width and
   wraps rather than being cut off at an ellipsis. */
.parcel-table .owner-cell {
  grid-column: 1 / -1;
  grid-row: 2;
}

.parcel-table .owner-cell strong,
.parcel-table .owner-cell small {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.parcel-table .owner-cell strong {
  font-size: 0.86rem;
  line-height: 1.35;
}

.parcel-table td[data-label="Extent (Ac.Gts)"] {
  grid-area: 3 / 1;
}

.parcel-table td[data-label="Land type"] {
  grid-area: 3 / 2;
}

.parcel-table .pill {
  align-self: flex-end;
  max-width: 100%;
  white-space: normal;
}

/* The action closes the card off: a full-width bar under the values, in the
   same place on every card, rather than a small target hunted for in a
   corner. */
.parcel-table .record-action {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 0.15rem;
}

/* Squared off and heavily bordered rather than the table's bare circle, so a
   rail this narrow still says what the button does and is easy to hit. */
.parcel-table .view-record {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  width: 100%;
  height: auto;
  padding: 0.5rem 0.7rem;
  border: 2px solid var(--brand);
  border-radius: var(--radius-sm);
  color: var(--brand-dark);
  font-size: 0.76rem;
  font-weight: 600;
}

.parcel-table .view-record:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--paper-raised);
  transform: none;
}

.parcel-table .view-record .view-label {
  position: static;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
}

/* On wide screens the affordances are meaningless, the results are just the
   next section down the page. */
.sheet-grip,
.sheet-close {
  display: none;
}

/* Two lines in one tooltip: the survey number, then how many records sit
   under it. */
.survey-map.leaflet-container .parcel-tooltip small {
  display: block;
  font-weight: 500;
  color: rgba(247, 245, 238, 0.72);
}

/* ── Survey numbers drawn on the parcels ──────────────────────────────────
 * The marker itself is a zero-size anchor dropped on the parcel's centre;
 * the span inside it is what is seen, translated back over that point.
 * Leaflet drives the marker's own transform to position it, so the centring
 * has to happen on a child element or it would be overwritten every pan.
 */
.survey-map.leaflet-container .survey-label {
  width: 0;
  height: 0;
  margin: 0;
  overflow: visible;
}

.survey-map.leaflet-container .survey-label span {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: #fff8e7;
  /* No box: a fill behind every number would hide the imagery the boundaries
     are being read against. An outline keeps them legible over both dark
     fields and bright rooftops. */
  text-shadow:
    0 0 3px rgba(11, 42, 37, 0.95),
    0 1px 2px rgba(11, 42, 37, 0.9);
}

.survey-map.leaflet-container .survey-label.is-selected span {
  color: var(--accent);
  font-size: 11px;
}

@media (max-width: 1000px), (pointer: coarse) and (max-width: 1366px) {
  .map-gate {
    place-items: start center;
    padding: 0.9rem;
  }

  .map-gate-card {
    padding: 1.15rem 1.15rem 1.25rem;
  }

  .map-gate-card h1 {
    font-size: 1.45rem;
  }

  /* Three labels do not fit beside three dots on a phone. */
  .picker-steps small {
    display: none;
  }

  .picker-steps li.is-active small {
    display: inline;
  }

  /* No room for a full-height rail beside the map: the head and controls
     become a bar across the top, and the records go back to being a sheet. */
  .map-rail {
    top: 0.6rem;
    left: 0.6rem;
    right: 0.6rem;
    bottom: auto;
    width: auto;
    gap: 0.5rem;
  }

  .rail-card {
    padding: 0.7rem 0.85rem;
  }

  .rail-village {
    font-size: 1.15rem;
  }

  /* The controls card is the one thing that would swallow the map, so it
     opens only on demand. */
  .rail-controls {
    display: none;
  }

  .map-rail.is-expanded .rail-controls {
    display: grid;
  }

  .rail-more {
    display: inline-flex;
  }

  /* ── Bottom sheet ──────────────────────────────────────────────────────
   * Tapping a survey number on a phone should not scroll the map out from
   * under the finger that just tapped it. The same markup the desktop lays
   * out inline becomes a sheet here: parked off-screen, slid up on selection,
   * and scrolling inside itself so the map behind it stays put and stays
   * usable. It stops short of the header rather than covering the whole
   * screen, so there is always somewhere to look back to.
   */
  .map-rail .parcel-results {
    position: fixed;
    left: 0;
    right: 0;
    /* Sits on top of the bottom nav rather than under it. */
    bottom: calc(58px + env(safe-area-inset-bottom));
    z-index: 1050; /* over Leaflet's controls (1000), under the header (1100) */
    max-width: none;
    /* Roughly half the screen. Enough to read a couple of records without
       reducing the map above it to a sliver, the sheet is there to keep the
       map, not replace it. Scrolling inside it reaches the rest. */
    max-height: min(56vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.4rem 1rem 1.6rem;
    background: var(--paper-raised);
    border: none;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px -12px rgba(27, 67, 50, 0.45);
    /* Park it fully off-screen, past its own height plus the nav offset. */
    transform: translateY(calc(101% + 58px + env(safe-area-inset-bottom)));
    visibility: hidden;
    transition:
      transform 0.28s cubic-bezier(0.32, 0.72, 0, 1),
      visibility 0.28s;
  }

  .map-rail .parcel-results.is-open {
    transform: translateY(0);
    visibility: visible;
  }

  /* While a drag is in progress the transform is driven from JS. */
  .map-rail .parcel-results.is-dragging {
    transition: none;
  }

  .sheet-grip {
    display: block;
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -1rem 0.2rem;
    padding: 0.55rem 0 0.7rem;
    background: var(--paper-raised);
    cursor: grab;
    touch-action: none; /* the drag handler owns vertical gestures here */
  }

  .sheet-grip span {
    display: block;
    width: 42px;
    height: 4px;
    margin: 0 auto;
    border-radius: 999px;
    background: var(--line);
  }

  .sheet-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 0.5rem;
    right: 0.8rem;
    z-index: 3;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
  }

  .parcel-heading {
    /* Inside a sheet there is nothing to scroll into view. */
    scroll-margin-top: 0;
    scroll-margin-bottom: 0;
    padding-right: 2.4rem; /* clear of the close button */
  }

  .parcel-metrics {
    width: 100%;
  }

  /* Three tiles across a phone is tight; trimming the type keeps a value like
     "41 ac 31.60 gts" on two lines instead of three. */
  .parcel-metrics div {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.6rem;
  }

  .parcel-metrics strong {
    font-size: 0.92rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .parcel-results {
    transition: none;
  }
}

/* ── Leaflet chrome on the full-page map ─────────────────────────────────
 * Zoom and layers both sit bottom-right, clear of the floating rail. On a
 * phone they also have to clear the bottom nav and the attribution line.
 */

.map-shell .leaflet-bottom.leaflet-right {
  margin-bottom: 1.6rem;
}

@media (max-width: 1000px), (pointer: coarse) and (max-width: 1366px) {
  .map-shell .leaflet-bottom.leaflet-right {
    margin-bottom: 2rem;
  }

  /* Once the sheet is up it owns the lower half; keep the controls above it. */
  .map-shell:has(.parcel-results.is-open) .leaflet-bottom.leaflet-right {
    margin-bottom: min(56vh, 520px);
  }
}
