/* The field finder's steps inside the .panel shell: the status line, the place summary,
   the locate step (search row, results listbox, the Leaflet map with its CSS pin and the
   controls over it: the satellite toggle and "Use my location", which asks the device again
   after the automatic attempt), the basics step (datalist input, chips, area with a unit)
   and the save step. Mobile first; the map grows at 1025px. */
.finder__status {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-info-bg);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.finder__status:empty { display: none; }

.finder__step {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.finder__step[hidden] { display: none; }

.finder__kicker {
  margin: 0;
  color: var(--color-accent-text);
}

.finder__heading {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.finder__kicker + .finder__heading { margin-top: calc(-1 * var(--space-2)); }

/* The step heading takes focus when a step appears (tabindex -1): a soft ring, not a box. */
.finder__heading:focus { outline: none; }
.finder__heading:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 6px;
  border-radius: var(--radius-sm);
}

/* Search: the input and its button on one row. */
.finder__search {
  display: flex;
  gap: var(--space-2);
}

.finder__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
}

.finder__search-button { flex: 0 0 auto; min-height: 48px; }

/* Results (#place-results): a hint, or a listbox of up to five places. */
.finder__results { display: block; }
.finder__results:empty { display: none; }

.finder__results-hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.finder__options {
  display: grid;
  gap: var(--space-2);
}

.finder__option {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.finder__option:hover { background: var(--color-bg-hover); border-color: var(--color-border-strong); }
.finder__option[aria-selected="true"] { border-color: var(--color-accent); background: var(--color-accent-muted); }

.finder__option-name { font-weight: 600; }

.finder__option-detail {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  overflow-wrap: anywhere;
}

/* The map: at least 45vh on phones, 360px from 1025px. The pin is a CSS div icon. */
.finder__map-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.finder__map {
  width: 100%;
  min-height: 45vh;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  background: var(--color-bg-tertiary);
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
}

.finder__map[hidden] { display: none; }

.finder__map:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.finder__map.leaflet-container { font-family: var(--font-sans); }

/* The controls over the map, stacked at the top right away from Leaflet's zoom (top left)
   and attribution (bottom right): the satellite toggle and "Use my location". */
.finder__map-controls {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1000; /* above Leaflet's panes (400) and controls (800 to 1000) */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.finder__satellite,
.finder__locate {
  min-height: 40px;
  box-shadow: var(--shadow-sm);
}

.finder__satellite[hidden] { display: none; }

.finder__locate svg { width: 18px; height: 18px; }

.finder__locate[aria-busy="true"] { opacity: 0.7; cursor: progress; }

/* The map could not load (field_map_controller.js hides it and its toggle): the location
   button falls back into the flow above the hint, which then carries the failure line. */
.finder__map[hidden] ~ .finder__map-controls {
  position: static;
  align-items: flex-start;
}

.finder__map[hidden] ~ .finder__map-controls .finder__locate { box-shadow: none; }

.finder__map-hint {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* The pin (L.divIcon, iconSize 32x36, anchor at the tip): a teardrop and a dot. */
.finder__pin {
  position: relative;
  width: 32px;
  height: 36px;
  background: none;
  border: 0;
}

.finder__pin::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--color-accent);
  border: 2px solid var(--color-text-inverse);
  box-shadow: var(--shadow-md);
}

.finder__pin::after {
  content: "";
  position: absolute;
  left: 11px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--color-text-inverse);
}

.leaflet-marker-draggable.finder__pin { cursor: grab; }
.leaflet-marker-draggable.finder__pin:active { cursor: grabbing; }

.finder__confirm { display: contents; }

/* The place around the confirmed pin (#place-summary), shown on steps 2 and 3. */
.finder__summary { display: block; margin-bottom: var(--space-4); }
.finder__summary[hidden] { display: none; }

.finder__place {
  display: grid;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-accent-muted);
  border: 1px solid var(--color-border-subtle);
}

.finder__place-name {
  margin: 0;
  font-weight: 600;
}

.finder__place-detail {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.finder__place-coords {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* Save: the "auth" Turbo Frame hosts the two cards (components/auth-choice.css), then the code
   entry or the name step (components/code-input.css). The footer's passkey button shows only
   while the passkey card is the chosen one (finder_controller.js). */
.finder__auth { display: block; }
.finder__save-button[hidden] { display: none; }
.finder__save { display: flex; flex-direction: column; gap: var(--space-3); }

.finder__hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.finder__error { margin: 0; }
.finder__error:empty { display: none; }
.finder__error.auth__status--error {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-danger-bg);
}

.finder__alt {
  margin: 0;
  font-size: var(--text-sm);
  text-align: center;
}

.finder__alt a { color: var(--color-accent-text); }

/* The ceremony is running: the companion breathes. */
.finder--waiting .panel__companion { animation: finder-breathe 1.6s ease-in-out infinite; }

@keyframes finder-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

@media (min-width: 1025px) {
  .finder__map { min-height: 360px; }
}

@media (forced-colors: active) {
  .finder__pin::before { background: Highlight; border-color: CanvasText; }
}
