/* Shared map pieces used by more than one screen (tokens from app.css only):
   the job-site address box (js/site-search.js). Map-host and Leaflet styles live in app.css. */

.site-search {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.site-search__row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.site-search__input {
  flex: 1 1 auto;
  min-width: 0;
}

.site-search__go {
  flex: none;
}

.site-search__msg,
.site-search__note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.site-search__msg[hidden],
.site-search__note[hidden],
.site-search__results[hidden],
.site-search__credit[hidden] {
  display: none;
}

.site-search__msg .icon,
.site-search__note .icon {
  flex: none;
  margin-top: 1px;
}

.site-search__msg.is-error {
  color: var(--bad);
  font-weight: 600;
}

.site-search__note {
  color: var(--accent-ink);
  font-weight: 600;
}

.site-search__results {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  overflow: hidden;
}

.site-search__result {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 400 16px/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.site-search__result:first-child {
  border-top: 0;
}

.site-search__result:hover {
  background: var(--surface-2);
}

.site-search__result:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.site-search__result .icon {
  flex: none;
  color: var(--accent);
}

.site-search__label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.site-search__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
}

.site-search__foot .btn {
  margin-left: -8px;
}

.site-search__credit {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-2);
}

.site-search__credit a {
  color: inherit;
}

/* ---------- Map pieces drawn by js/map.js ---------- */

/* Fixed colors for marks drawn on top of aerial pictures: the pictures look the same in light
   and dark mode, so the white rings and dark labels stay the same too. */
:root {
  --map-ring: #FFFFFF;
  --map-mark-shadow: 0 1px 3px rgb(0 0 0 / 0.45);
}

.map-host {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.map-canvas {
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
}

.map-host--draw .leaflet-container {
  cursor: crosshair;
}

.map-host--draw .leaflet-dragging .leaflet-container,
.map-host--draw .leaflet-container.leaflet-drag-target {
  cursor: grabbing;
}

.map-fence-fill {
  fill: var(--accent);
}

/* Fence corners: the 44 px box is the touch target, the dot is drawn here. */
.leaflet-marker-icon.map-vertex {
  background: transparent;
  border: 0;
  cursor: grab;
}

.map-vertex::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--map-ring);
  box-shadow: var(--map-mark-shadow);
  box-sizing: border-box;
}

.map-vertex.is-dragging::after {
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-width: 4px;
}

.map-vertex:focus-visible {
  outline: none;
}

.map-vertex:focus-visible::after {
  box-shadow: 0 0 0 3px var(--accent), var(--map-mark-shadow);
}

/* Segment lengths: hidden ones keep their size so the layout pass can measure them. */
.leaflet-tooltip.map-seg.is-hidden {
  visibility: hidden;
}

.leaflet-tooltip.map-seg {
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--map-mark-shadow);
}

/* Job-site pin (draggable) */
.leaflet-marker-icon.map-site {
  background: transparent;
  border: 0;
  cursor: grab;
}

.map-site__svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.5));
}

.map-site__body {
  fill: var(--accent);
  stroke: var(--map-ring);
  stroke-width: 2.5;
}

.map-site__dot {
  fill: var(--map-ring);
}

/* "Remove point" popup */
.leaflet-popup.map-pop .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}

.leaflet-popup.map-pop .leaflet-popup-content {
  margin: 0;
  line-height: 1;
}

.leaflet-popup.map-pop .leaflet-popup-tip {
  background: var(--surface);
  box-shadow: none;
}

.map-pop__btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-ctl);
  background: transparent;
  color: var(--bad);
  font: 600 15px/1 var(--font-body);
  white-space: nowrap;
  cursor: pointer;
}

.map-pop__btn:hover {
  background: var(--bad-bg);
}

.map-pop__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Jobs map pins: colored by status; the 40 px box is the touch target. */
.leaflet-marker-icon.map-job {
  background: transparent;
  border: 0;
  cursor: pointer;
}

.map-job::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--ink-2);
  border: 3px solid var(--map-ring);
  box-shadow: var(--map-mark-shadow);
  box-sizing: border-box;
}

.map-job--out::after {
  background: var(--ok);
}

.map-job--booked::after {
  background: var(--info);
}

.map-job--done::after {
  background: var(--ink-2);
}

.map-job.is-selected::after {
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-width: 4px;
  box-shadow: 0 0 0 3px var(--accent), var(--map-mark-shadow);
}

.map-job:focus-visible {
  outline: none;
}

.map-job:focus-visible::after {
  box-shadow: 0 0 0 3px var(--accent), var(--map-mark-shadow);
}

.leaflet-tooltip.map-job-tip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
  font: 600 14px/1.3 var(--font-body);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaflet-tooltip-top.map-job-tip::before {
  border-top-color: var(--surface);
}

/* Designed card over a map that can't show pictures (preview, offline, error) */
.map-overlay {
  background-color: var(--surface-2);
  background-image:
    linear-gradient(color-mix(in srgb, var(--line) 60%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--line) 60%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center;
}

.map-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 300px;
  padding: 18px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-align: center;
}

.map-overlay__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 2px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.map-overlay__title,
.map-overlay__text {
  margin: 0;
}

.map-overlay__action {
  margin-top: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .map-host .leaflet-marker-icon,
  .map-host .leaflet-tooltip {
    transition: none;
  }
}
