/* Address search (src/search.js): a small box in the top-right corner, above the options panel. On a phone it is a
   magnifier button under "Opcje" that opens a bar across the top. Colours and fonts from style.css. */
.search { position: fixed; z-index: 3; top: calc(var(--gut) + env(safe-area-inset-top, 0px)); right: var(--gut); width: 250px; font: 13px/1.3 var(--sans); }
.search-box { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 4px 0 9px; background: var(--panel); border: 2px solid #050710; box-shadow: 0 0 0 2px var(--line), 4px 4px 0 rgba(0,0,0,.35); backdrop-filter: blur(2px); }
.search-box:focus-within { box-shadow: 0 0 0 2px var(--accent), 4px 4px 0 rgba(0,0,0,.35); }
.search-ico { flex: none; width: 14px; height: 14px; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; padding: 0; font: 13.5px var(--sans); color: var(--ink); background: none; border: 0; outline: none; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input::-webkit-search-cancel-button { display: none; }
.search-x { flex: none; width: 26px; height: 26px; padding: 0; font: 17px/1 var(--sans); color: var(--muted); background: none; border: 0; cursor: pointer; }
.search-x:hover, .search-x:focus-visible { color: var(--ink); outline: none; }
.search-open { display: none; }

.search-list { margin: 6px 0 0; padding: 3px 0; list-style: none; max-height: min(320px, 55dvh); overflow-y: auto; overscroll-behavior: contain; background: #161826; border: 2px solid #050710; box-shadow: 0 0 0 2px var(--line), 4px 4px 0 rgba(0,0,0,.35); }
.search-list li { display: flex; align-items: baseline; gap: 6px; min-height: 34px; padding: 8px 10px; cursor: pointer; color: var(--ink); }
.search-list li[aria-selected="true"], .search-list li:hover { background: rgba(240, 207, 90, .16); }
.search-list li[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--accent); }
.search-list .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-list .n b { color: var(--accent); font-weight: 600; }
.search-list .h { flex: none; font: 400 10.5px/1 var(--pixel); letter-spacing: .06em; color: var(--muted); }
/* a place (an object by name): its name, and under it what it is and the quarter ("Hala, arena · Czyżyny") */
.search-list li.p { flex-wrap: wrap; row-gap: 1px; padding-block: 7px; }
.search-list li.p .n { flex: 1 1 100%; }
.search-list li.p .h { flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 400 11.5px/1.25 var(--sans); letter-spacing: 0; }
.search-list li.msg { cursor: default; color: var(--muted); }
.search-list li.msg:hover { background: none; }
.search-note { margin: 6px 0 0; padding: 7px 10px; font-size: 12.5px; color: var(--ink); background: var(--panel); border: 2px solid #050710; box-shadow: 0 0 0 2px var(--line); }

/* the options panel moves down under the box (ui.js does not know about it) */
@media (min-width: 721px) {
  body.has-search .controls { top: calc(var(--gut) + 52px + env(safe-area-inset-top, 0px)); max-height: calc(100dvh - var(--credits-h, 20px) - 252px - env(safe-area-inset-top, 0px)); }
}
/* wide screens: the note sits left of the box, over the map, not over the panel */
@media (min-width: 1000px) {
  .search-note { position: absolute; top: 0; right: calc(100% + 10px); width: 250px; margin: 0; }
}

/* phone: a magnifier under "Opcje"; tapped, the box opens across the top over the epoch card */
@media (max-width: 720px), (pointer: coarse) and (max-height: 520px) {   /* the phone layout of style.css (a narrow screen, or a phone held sideways) */
  .search { width: auto; top: calc(var(--gut) + 46px + env(safe-area-inset-top, 0px)); }
  .search:not(.open) .search-box, .search:not(.open) .search-list { display: none; }
  /* closed: the note (what was found, or that the street was not there yet) hangs under the magnifier */
  .search:not(.open) .search-note { position: absolute; top: 46px; right: 0; width: max-content; max-width: min(72vw, 300px); margin: 0; }
  .search.open .search-box { background: #161826; backdrop-filter: none; }
  .search-open { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; color: var(--ink); background: var(--panel); border: 2px solid #050710; box-shadow: 0 0 0 2px var(--line), 4px 4px 0 rgba(0,0,0,.35); cursor: pointer; }
  .search-open svg { width: 16px; height: 16px; }
  .search.open { z-index: 6; top: calc(var(--gut) + env(safe-area-inset-top, 0px)); left: var(--gut); right: var(--gut); }
  .search.open .search-open { display: none; }
  .search-box { height: 42px; }
  .search input { font-size: 16px; }   /* 16 px: iOS does not zoom the page into the field */
  .search-list li { min-height: 42px; }
  .controls.open ~ .search-slot .search:not(.open) { display: none; }
}

body.rec .search { visibility: hidden !important; }
@media (prefers-reduced-motion: reduce) { .search-box { backdrop-filter: none; } }
