/* Place search: mobile pill + full-screen sheet, desktop field top left over the panel column. Loaded last. */
:root { --search-h: var(--button); --search-gap: 10px; }
.place-search { position: fixed; z-index: 3; top: var(--top); left: calc(14px + env(safe-area-inset-left));
  right: var(--edge); display: flex; flex-direction: column; color: var(--text); }
.search-field { position: relative; display: flex; align-items: center; height: var(--search-h); padding: 0 4px 0 6px; border-radius: var(--radius-pill); } /* surface: style-controls.css */
.search-glyph { display: grid; place-items: center; width: 36px; height: 36px; color: var(--muted); }
.search-glyph svg { width: var(--icon-sm); height: var(--icon-sm); }
.search-field input { flex: 1; min-width: 0; height: 100%; padding: 0 4px; border: 0; outline: 0; background: transparent; color: var(--text);
  font: var(--fw-medium) max(16px, var(--fs-lg))/1.2 var(--font); text-overflow: ellipsis; -webkit-user-select: text; user-select: text; cursor: text; }
.search-field input::placeholder { color: var(--muted); font-weight: 400; opacity: 1; }
.search-field input::-webkit-search-cancel-button, .search-field input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-field:focus-within { border-color: var(--accent); }
.search-field :focus-visible { outline: 0; }
.search-clear, .search-back, .search-menu { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
@media (hover: hover) { .search-clear:hover, .search-back:hover, .search-menu:hover { background: var(--ctl-bg-hover); color: var(--text); } }
.search-menu { flex-shrink: 0; color: var(--text); }
.search-menu[aria-expanded="true"] { background: var(--ctl-bg-active); }
.search-menu svg { width: var(--icon); height: var(--icon); }
/* Live status: a dot at the left end of the bar; the tap opens the live info bubble. */
.search-live { display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: transparent; }
.search-live:focus-visible, .search-menu:focus-visible { outline: 3px solid var(--ctl-ring); outline-offset: -3px; }
.search-clear:focus-visible, .search-back:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.search-clear svg { width: var(--icon-sm); height: var(--icon-sm); }
.search-back, .search-hint { display: none; }
.search-hint { margin: 0; padding: 18px 22px; color: var(--muted); font-size: var(--fs-md); }
.search-list { margin: 0; padding: 6px 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.search-option { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 16px; cursor: pointer; }
.search-option[aria-selected="true"] { background: var(--accent-soft); }
.search-kind { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); color: var(--muted); flex-shrink: 0; }
.search-kind svg { width: var(--icon-sm); height: var(--icon-sm); }
.search-option[data-kind="parking"] .search-kind { color: var(--accent); }
.search-text { display: flex; flex-direction: column; min-width: 0; }
.search-name, .search-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-name { font-size: var(--fs-lg); font-weight: 400; }
.search-name b { font-weight: var(--fw-semibold); }
.search-detail { font-size: var(--fs-sm); color: var(--muted); }
/* Visible only for "no places" / "unavailable"; counts are read by screen readers only. */
.search-status { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.search-status.is-visible { position: static; width: auto; height: auto; clip-path: none; padding: 14px 18px; color: var(--muted); font-size: var(--fs-md); white-space: normal; }

/* Overlays below the pill: live badge and search-results chip move down one row. */
@media (max-width: 1023px) {
  :root .hits-chip { top: calc(var(--top) + var(--search-h) + var(--search-gap)); }
  /* Mobile and tablet: the pill opens a full-screen sheet with the keyboard and live suggestions. */
  .place-search[data-open] { z-index: 7; inset: 0; padding: var(--top) 0 0; background: var(--bg); }
  .place-search[data-open] .search-field { margin: 0 var(--edge) 0 calc(14px + env(safe-area-inset-left)); box-shadow: none; background: var(--surface);
    border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .place-search[data-open] .search-glyph, .place-search[data-open] .search-live, .place-search[data-open] .search-menu { display: none; }
  .place-search[data-open] .search-back { display: inline-grid; }
  .place-search[data-open]:has(input:placeholder-shown) .search-hint { display: block; }
  .place-search[data-open] .search-list { flex: 1; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  :root[data-search-open] body { overflow: hidden; }
}
/* Tablet: the pill keeps a phone-like width instead of spanning the whole top edge. */
@media (min-width: 600px) and (max-width: 1023px) { .place-search:not([data-open]) { right: auto; width: min(480px, calc(100vw - var(--edge) - 14px)); } }
@media (max-width: 1023px) and (max-height: 500px) { :root { --search-gap: 8px; } }

/* Desktop: a persistent field over the panel column, right next to the rail; the panel slides out beneath it. */
@media (min-width: 1024px) {
  :root { --search-clearance: calc(var(--top) + var(--search-h) + 12px); }
  /* Above the panel (4), below the rail (6) so rail tooltips stay readable. */
  .rail { z-index: 6; }
  .place-search { z-index: 5; top: var(--top); left: calc(var(--rail) + 12px); right: auto; width: calc(var(--sheet-max) - 24px);
    border-radius: 24px; }
  .place-search[data-open]:has(.search-list:not([hidden]), .search-status.is-visible) { overflow: hidden; background: var(--bg); box-shadow: var(--shadow-card); border: 1px solid var(--border); }
  .place-search[data-open]:has(.search-list:not([hidden]), .search-status.is-visible) .search-field { box-shadow: none; border-color: transparent;
    border-bottom: 1px solid var(--border); border-radius: 24px 24px 0 0; background: transparent; }
  .search-list { max-height: min(440px, calc(100dvh - var(--search-clearance) - 24px)); }
  .search-option { min-height: 52px; }
  .search-option:hover { background: var(--surface); }
  .search-option[aria-selected="true"] { background: var(--accent-soft); }
  /* The open panel starts below the field; map overlays start right of the field column. */
  .sheet .sheet-header { padding-top: calc(var(--search-clearance) + 2px); }
  .popover { left: calc(var(--rail) + 12px + 6px); top: calc(var(--top) + var(--search-h) + 4px); }
  :root .hits-chip { left: calc((100% + var(--panel-clearance)) / 2); max-width: calc(100vw - var(--panel-clearance) - 120px); top: calc(var(--top) + (var(--search-h) - 40px) / 2); }
}
