/* Borey 6A lot map — a field tool for site survey on a phone or tablet.
   The map is the whole screen. On top of it: search, a map-options button, my location, a small key,
   and one card for the picked lot (bottom sheet on a phone, a card on the left under the search from 700px). */
:root {
  --surface: #ffffff;
  --ground: #fbfbfa;
  --raised: #f1f0ee;
  --line: #eaeaea;
  --control: #d9d8d5;
  --text: #191919;
  --muted: #6b6a66;
  --negative: #c4242a;
  --float: 0 2px 10px rgba(0,0,0,.18); /* taste-skill-ignore: everything here floats over the map */
  --r: 12px;
  --edge: 12px;
  --btn: 44px;
  --font: "Geist", system-ui, sans-serif;
  --panel: 400px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 15px/22px var(--font); color: var(--text); -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; font-size: 18px; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
#map { position: fixed; inset: 0; background: #e9ece9; }

/* floating buttons */
/* map buttons: one strip, divided by a 1px step of the ground behind them */
.side { position: fixed; z-index: 5; right: var(--edge); top: calc(var(--edge) + env(safe-area-inset-top)); display: grid; gap: 1px;
  border-radius: var(--r); overflow: hidden; background: var(--control); outline: 1px solid rgba(0,0,0,.16); outline-offset: -1px; }
.fab { display: grid; place-items: center; width: var(--btn); height: var(--btn); border: 0; border-radius: 0; background: var(--surface); }
.fab:active { background: var(--raised); }
@media (hover: hover) { .fab:hover { background: var(--raised); } }
.fab[aria-expanded="true"] { background: var(--raised); }
.fab.on { color: #1d6fe0; }
.fab:focus-visible { outline-offset: -3px; }
@media (pointer: coarse) { :root { --btn: 48px; } .zoom { display: none; } } /* pinch on touch screens */

.top { position: fixed; z-index: 5; top: calc(var(--edge) + env(safe-area-inset-top)); left: var(--edge); right: calc(var(--edge) + var(--btn) + 8px); display: flex; gap: 8px; pointer-events: none; }
.top > * { pointer-events: auto; }
.search { position: relative; flex: 1; max-width: var(--panel); }
.search > svg { position: absolute; left: 15px; top: calc(var(--btn) / 2 - 9px); color: var(--muted); pointer-events: none; }
.search input { width: 100%; height: var(--btn); padding: 0 16px 0 44px; border: 0; border-radius: var(--r); background: var(--surface); outline: 1px solid rgba(0,0,0,.16); outline-offset: -1px; font-size: 16px; }
.search input::placeholder { color: #6b6b6b; }
.results { position: absolute; top: calc(var(--btn) + 6px); left: 0; right: 0; max-height: 50vh; overflow: auto; padding: 6px; background: var(--surface); border-radius: var(--r); box-shadow: var(--float); /* taste-skill-ignore: menu floats */ }
.results[hidden] { display: none; }
.results button { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px; border: 0; background: none; border-radius: 8px; text-align: left; }
.results button:hover, .results button:focus-visible { background: var(--raised); outline: none; }
.results small { color: var(--muted); font-size: 13px; }
.results p { margin: 12px; color: var(--muted); }


/* the key: the count done and what the colours mean; opens the map options */
.panel { display: contents; }
.key { position: fixed; z-index: 4; left: var(--edge); bottom: calc(var(--edge) + env(safe-area-inset-bottom)); max-width: calc(100% - 2 * var(--edge));
  padding: 10px 14px; border: 0; border-radius: var(--r); background: var(--surface); outline: 1px solid rgba(0,0,0,.16); outline-offset: -1px; text-align: left; font-size: 14px; line-height: 20px; }
.key strong { font-weight: 600; }
.key .lead { margin: 0; }
.key .bar { display: none; }
.key ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; }
.key li { display: flex; }
/* each status is a checkbox: the swatch fills when shown, goes hollow when hidden */
.key label { display: flex; align-items: center; gap: 6px; min-height: 28px; color: var(--muted); cursor: pointer; }
.key input { position: absolute; opacity: 0; pointer-events: none; }
.key .dot { background: var(--c); }
.key label:has(input:not(:checked)) { color: #9a9994; text-decoration: line-through; }
.key label:has(input:not(:checked)) .dot { background: none; outline: 1.5px solid var(--c); outline-offset: -1.5px; }
.key label:has(input:not(:checked)) .n { color: inherit; }
.key label:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 2px; }
@media (hover: hover) { .key label:hover { color: var(--text); } }
@media (pointer: coarse) { .key label { min-height: 36px; } }
.key .n { color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 2px; flex: none; outline: 1px solid rgba(0,0,0,.15); outline-offset: -1px; }
body.has-lot .key, body.has-layers .key { display: none; }

/* cards */
.card { position: fixed; z-index: 6; background: var(--surface); box-shadow: var(--float); /* taste-skill-ignore: sheet floats over the map */ overflow: auto; overscroll-behavior: contain; padding: 0 20px 20px; }
.card[hidden] { display: none; }
.card-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 0 8px; background: var(--surface); }
.card h2 { margin: 0; font-size: 18px; line-height: 26px; font-weight: 600; }
.close { display: grid; place-items: center; width: 44px; height: 44px; margin: -10px -12px 0 0; flex: none; border: 0; background: none; border-radius: 50%; color: var(--muted); }
.close:hover { background: var(--raised); color: var(--text); }
.label { margin: 14px 0 8px; font-weight: 500; }
.card-head + .label { margin-top: 4px; }

.seg[hidden], .label[hidden], .switch[hidden] { display: none !important; }
.seg { display: flex; padding: 2px; background: var(--raised); border-radius: 8px; }
.seg label { flex: 1; display: grid; place-items: center; min-height: 40px; padding: 0 8px; border-radius: 6px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--text); outline-offset: -2px; }
.switch { display: flex; align-items: center; justify-content: space-between; min-height: 48px; cursor: pointer; }
.switch input { appearance: none; width: 44px; height: 26px; margin: 0; border-radius: 13px; background: var(--control); position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--text); }
.switch input:checked::after { transform: translateX(18px); }
.sources { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 19px; }
.sources summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; }
.sources ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sources a { color: var(--text); }

/* the picked lot */
.lot h2 { font-size: 24px; line-height: 30px; }
.lot .meta { margin: 2px 0 0; color: var(--muted); }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); font-weight: 500; line-height: 18px; white-space: nowrap; transition: background .12s, color .12s; }
.chip .dot { width: 10px; height: 10px; }
@media (hover: hover) { .chip[aria-pressed="false"]:hover { background: var(--raised); } }
.chip:active { transform: scale(.98); }
.chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.chip[aria-pressed="true"] .dot { background: #fff !important; outline: 0; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
textarea { display: block; width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; font-size: 16px; }
textarea::placeholder { color: var(--muted); }
textarea:focus { outline: 0; border-color: var(--text); }
.stamp { min-height: 20px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 20px; }
.stamp.err { color: var(--negative); }
.retry { min-height: 32px; padding: 0 4px; border: 0; background: none; color: var(--text); font-weight: 600; text-decoration: underline; }
.more { margin-top: 4px; color: var(--muted); font-size: 14px; }
.more summary { min-height: 40px; display: flex; align-items: center; cursor: pointer; }
.more dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.more dd { margin: 0; text-align: right; color: var(--text); }

/* photos, videos and PDFs: square tiles, the last one adds more */
.files { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--raised); }
.tile a { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 22px; text-shadow: 0 1px 4px rgba(0,0,0,.6); pointer-events: none; }
.tile .doc { display: grid; place-items: center; align-content: center; gap: 4px; height: 100%; padding: 8px; color: var(--muted); text-align: center; }
.tile .doc small { font-size: 12px; line-height: 15px; overflow-wrap: anywhere; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile.wait { display: grid; place-items: center; padding: 8px; color: var(--muted); font-size: 13px; line-height: 17px; text-align: center; }
.tile.err { color: var(--negative); }
.tile.add { display: grid; place-items: center; align-content: center; gap: 2px; border: 1.5px dashed var(--control); background: none; color: var(--muted); font-weight: 500; }
@media (hover: hover) { .tile.add:hover { background: var(--raised); color: var(--text); } }
.del { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 20px; line-height: 1; }

/* phone: cards are bottom sheets */
@media (max-width: 699px) {
  .card { left: 0; right: 0; bottom: 0; max-height: 82vh; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .chip { padding: 6px; gap: 6px; }
}
/* tablet and up: cards float on the right, the buttons move left of them */
@media (min-width: 700px) {
  :root { --edge: 16px; }
  .card { top: calc(var(--edge) + var(--btn) + 12px); max-height: calc(100% - var(--btn) - 12px - 2 * var(--edge)); border-radius: 16px; }
  .lot { left: var(--edge); width: var(--panel); }
  /* the map options open beside the button strip; nothing moves */
  .layers { top: calc(var(--edge) + env(safe-area-inset-top)); right: calc(var(--edge) + var(--btn) + 8px); width: 320px; max-height: calc(100% - 2 * var(--edge)); }
}
/* wide screens: the map keeps the whole screen. Search and the picked lot float top-left, the legend bottom-left,
   basemap bottom-right with my location and whole site above it. Zoom with the wheel. */
@media (min-width: 1000px) {
  :root { --btn: 36px; }
  .side .zoom, #layersBtn { display: none; }
  .side { top: auto; right: 12px; bottom: calc(12px + 58px + 8px); border-radius: 8px; } /* stacked above the basemap switch and Sources link (58px tall) */
  .panel { position: fixed; z-index: 6; top: 12px; left: 12px; width: 300px; max-height: calc(100% - 132px); display: flex; flex-direction: column;
    overflow: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 10px; box-shadow: var(--float); /* taste-skill-ignore: floats over the map */
    font-size: 13px; line-height: 18px; }
  .panel > * { padding-left: 12px; padding-right: 12px; }
  .panel .top { position: static; padding-top: 10px; padding-bottom: 10px; gap: 6px; }
  .panel .search { max-width: none; }
  .panel .search > svg { top: 9px; left: 10px; width: 16px; height: 16px; }
  .panel .search input { height: 34px; padding-left: 32px; font-size: 14px; background: var(--raised); outline: 0; border: 0; border-radius: 6px; }
  .panel .results { top: 40px; }
  /* the search floats on its own top-left */
  .panel { background: none; box-shadow: none; overflow: visible; }
  .panel .top { padding: 0; }
  .panel .search input { height: 40px; background: var(--surface); box-shadow: var(--float); /* taste-skill-ignore: floats over the map */ }
  .panel .search > svg { top: 12px; }
  .panel .results { top: 46px; }
  /* the picked lot: a card on the right, above the buttons and the basemap switch (12 + 58 + 8 + 72 + 8 + 12) */
  .panel .card.lot { position: fixed; top: 12px; right: 12px; left: auto; width: 320px; max-height: calc(100% - 182px); overflow: auto;
    border-top: 0; border-radius: 10px; background: var(--surface); box-shadow: var(--float); /* taste-skill-ignore: floats over the map */ }
  .panel .card { position: static; width: auto; max-height: none; overflow: visible; border-radius: 0; box-shadow: none; outline: 0;
    background: none; border-top: 1px solid var(--line); }
  .panel .card-head { position: static; padding: 12px 0 4px; background: none; }
  .panel .close { width: 32px; height: 32px; margin: -6px -8px 0 0; }
  .panel .label { margin: 10px 0 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--muted); }
  .panel .card-head + .label { margin-top: 2px; }

  /* progress: one line, a thin bar, the counts in two columns */
  .panel .key { display: block; left: 12px; bottom: 12px; width: max-content; max-width: 340px; padding: 10px 12px 12px; font-size: 13px;
    border-radius: 10px; outline: 0; box-shadow: var(--float); /* taste-skill-ignore: floats over the map */ }
  body.has-lot .key { display: block; }
  .panel .key .lead { color: var(--muted); }
  .panel .key strong { color: var(--text); }
  .panel .key .bar { display: flex; height: 4px; margin: 8px 0; border-radius: 2px; overflow: hidden; background: var(--raised); gap: 1px; }
  .panel .key ul { display: grid; grid-template-columns: auto auto; gap: 0 16px; margin: 0; } /* the card hugs the legend; the bar spans it */
  .panel .key label { gap: 5px; min-height: 24px; }

  /* map options: label left, control right, one row each */
  .layers[hidden] { display: grid; }
  .layers .card-head { display: none; }
  .panel .layers { position: fixed; top: auto; right: 12px; bottom: 12px; width: auto; max-height: none; overflow: visible;
    display: flex !important; flex-direction: column; align-items: flex-end; gap: 2px; padding: 0;
    background: none; border: 0; box-shadow: none; }
  .layers .label { margin: 0; align-self: start; line-height: 28px; }
  .panel .seg { padding: 2px; border-radius: 6px; }
  .panel .seg label { min-height: 24px; font-size: 13px; border-radius: 4px; }
  .layers .switch { grid-column: 2; min-height: 26px; }
  .panel .switch input { width: 28px; height: 16px; border-radius: 8px; }
  .panel .switch input::after { top: 2px; left: 2px; width: 12px; height: 12px; }
  .panel .switch input:checked::after { transform: translateX(12px); }
  /* one row of text links: Satellite  Streets  Sources */
  .layers .label { display: none; }
  .layers .seg { padding: 0 14px; gap: 16px; background: var(--surface); border-radius: 10px; box-shadow: var(--float); /* taste-skill-ignore: floats over the map */ }
  .layers .seg label { min-height: 36px; padding: 0; background: none !important; box-shadow: none !important; color: var(--muted); font-weight: 400; }
  .layers .seg label:hover { color: var(--text); }
  .layers .seg label:has(input:checked) { color: var(--text); font-weight: 500; }
  .layers .sources { position: static; margin: 0; padding: 0; font-size: 13px; } /* the popup anchors to the card */
  .layers .sources summary { min-height: 20px; padding: 0 4px; list-style: none; color: #1a5fd0; font-weight: 500; font-size: 13px; text-decoration: underline; text-underline-offset: 2px;
    text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; } /* taste-skill-ignore: legible on the satellite photo */
  .layers .sources summary::-webkit-details-marker { display: none; }

  .layers .sources-list { position: absolute; right: 0; bottom: calc(100% + 8px); width: 340px; padding: 12px 14px; background: var(--surface);
    border-radius: 10px; box-shadow: var(--float); /* taste-skill-ignore: floats over the map */ }
  .layers .sources-list p { margin: 8px 0 0; }

  /* the picked lot */
  .panel .lot { padding-bottom: 12px; }
  .panel .lot h2 { font-size: 18px; line-height: 24px; }
  .panel .lot .meta { font-size: 13px; }
  .panel .chip { min-height: 34px; font-size: 13px; }
  .panel textarea { min-height: 40px; padding: 8px 10px; font-size: 14px; }
  .panel .stamp { margin-top: 4px; font-size: 13px; }
  .panel .more { font-size: 13px; }
  .panel .more summary { min-height: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
