/* Feature search (feature-search.js): the search button in the app bar, the search dialog, feature rows in the
   map's search box and the highlight on a setting opened from a search. Colours, type and motion come from
   design/tokens.css. */

/* ---------- The button in the app bar (resort.js) ---------- */
/* A round button beside the page links (an icon only, so the resort pill stays centred; the shortcut is in its
   tooltip); up to 960 px a row at the top of the ☰ menu instead. */
.app-search {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 999px;
  background: var(--fill-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.app-search svg { width: 21px; height: 21px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.app-search:hover { background: var(--fill-hover); }
.app-search:active { transform: scale(.96); }
.fs kbd {
  padding: 1px 6px; border-radius: 6px;
  background: rgb(255 255 255 / .8); box-shadow: 0 0 0 1px var(--separator);
  font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--muted);
}

/* Up to 960 px the bar has no room: Search is the first row of the ☰ menu (profile-menu.js) */
@media (max-width: 960px) {
  .app-search { display: none; }
}

/* ---------- The search dialog ---------- */

.fs {
  width: min(620px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 24vh));
  margin: 12vh auto auto;
  padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--glass-solid);
  box-shadow: var(--shadow);
  color: var(--text); font-family: var(--font); font-size: 15px;
}
.fs[open] { display: flex; flex-direction: column; animation: fs-in var(--dur) var(--ease-out); }
.fs::backdrop { background: rgb(var(--navy-rgb) / .35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fs-fade var(--dur) var(--ease); }
@keyframes fs-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }

.fs-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--separator);
}
.fs-bar > svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.fs-bar input {
  flex: 1; min-width: 0; height: 44px;
  border: 0; background: none; outline: none;
  font: inherit; font-size: 18px; color: var(--text);
}
.fs-bar input::placeholder { color: var(--muted); }
.fs-bar input::-webkit-search-cancel-button { cursor: pointer; }
.fs-cancel {
  display: none;
  height: 44px; padding: 0 6px; border: 0; background: none;
  font: inherit; font-size: 16px; font-weight: 500; color: var(--accent); cursor: pointer;
}

/* flex: 1 1 auto, not flex: 1: with a 0% basis Safari gave the results no height in the content-sized dialog (resort.css .rp-body) */
.fs-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px 8px 8px; scroll-padding-bottom: var(--kb-bar, 0px);
}
.fs-body::after { content: ""; display: block; height: var(--kb-bar, 0px); }   /* iOS's form bar (feature-search.js fit; resort.css .app-rs-results::after) */
.fs-group { margin: 12px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fs-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 6px 10px; border-radius: 12px;
  cursor: pointer;
}
/* The tint alone is too faint to see (1.15:1) and the input has no outline: a ring marks the row the arrow keys are on */
.fs-row[aria-selected="true"] { background: rgb(var(--accent-rgb) / .1); box-shadow: inset 0 0 0 2px var(--accent); }
@media (forced-colors: active) { .fs-row[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; } }
.fs-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.fs-text strong { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-text strong:has(> .resort-aka) { white-space: normal; }   /* a resort's other name isn't cut off (resort.css) */
.fs-text small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-icon {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--fill-2); color: var(--navy);
}
.fs-icon svg, .search-results .fs-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fs-icon.safety { background: rgb(var(--sos-rgb) / .12); color: var(--sos-dark); }
.fs-icon.resort { border-radius: 50%; }
.fs-note { margin: 16px 10px; color: var(--muted); font-size: 14px; }
.fs-status { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.fs-foot {
  display: flex; gap: 16px; margin: 0; padding: 8px 18px;
  border-top: 1px solid var(--separator);
  font-size: 12px; color: var(--muted);
}
.fs-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* Phones: a sheet at the top, only as tall as its results, never over 75% of the screen and always ending above the
   keyboard (--fs-top and --fs-bottom, the visual viewport, feature-search.js), so the page shows under it (owner's
   report 2026-10-27: it took the whole screen); Cancel instead of the keyboard hints, and a tap on the page closes it */
@media (max-width: 600px) {
  .fs {
    width: auto; max-width: none;
    margin: 0; inset: calc(var(--fs-top, 0px) + max(8px, env(safe-area-inset-top))) 8px auto;
    max-height: min(75vh, calc(100vh - 16px));
    max-height: min(75dvh, calc(var(--fs-bottom, 100dvh) - var(--fs-top, 0px) - max(8px, env(safe-area-inset-top)) - 8px));
  }
  .fs-bar { padding: 8px 10px 8px 16px; }
  .fs-bar input { font-size: 17px; }
  .fs-cancel { display: block; }
  .fs-foot { display: none; }
}
/* A phone on its side (2026-11-05, iOS Safari: with the keyboard up 78 px of the page showed, and the dialog 12vh down
   had its field under the keyboard): the same top sheet as on phones, at the visual viewport's top, its own width */
@media (min-width: 601px) and (max-height: 500px) and (pointer: coarse) {
  .fs {
    margin: calc(var(--fs-top, 0px) + 8px) auto auto;
    max-height: calc(100vh - 16px);
    max-height: calc(var(--fs-bottom, 100dvh) - var(--fs-top, 0px) - 16px);
    min-height: 53px;   /* the field's row, whole: Safari's word suggestions can leave 50 px of visual viewport */
  }
  .fs-bar { padding-top: 4px; padding-bottom: 4px; }
  .fs-cancel { display: block; }
  .fs-foot { display: none; }
}
@keyframes fs-fade { from { opacity: 0; } }

/* ---------- Feature rows in the map's search box (map.js) ---------- */

.search-results li.search-feature { flex-direction: row; align-items: center; gap: 10px; }
.search-results li.search-feature .fs-icon { width: 32px; height: 32px; border-radius: 9px; color: var(--navy); }   /* not map.css's muted span colour */
.search-results li.search-feature .fs-icon.safety { color: var(--sos-dark); }
.search-results li.search-feature .fs-text strong { font-size: 15px; color: var(--text); }
.search-results li.search-feature .fs-text span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-results .search-heading {
  padding: 8px 12px 2px; cursor: default;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}

/* ---------- A setting opened from a search (settings.html and the map's settings dialog) ---------- */

@keyframes fs-flash {
  0%, 60% { background: rgb(var(--accent-rgb) / .14); box-shadow: inset 0 0 0 2px rgb(var(--accent-rgb) / .35); }   /* inset: the card clips outside */
  100% { background: transparent; box-shadow: inset 0 0 0 2px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .fs[open] { animation: fs-fade var(--dur-fast) linear; }
  .app-search:active { transform: none; }
}
