/* Shared ⌘K place-search modal (search-modal.js).
 *
 * SINGLE SOURCE OF TRUTH for the search dialog across the whole site — the
 * Explore board (/weather), the weather-events detail SPA, and every static
 * page with the search header all load THIS file. Do not re-declare these
 * rules elsewhere; that drift is exactly what this consolidation removed.
 *
 * Colours read the host page's design tokens when present and fall back to a
 * light palette otherwise, so the dialog matches whatever page mounts it.
 * z-index sits above the topnav (z-index:100) and every in-page overlay
 * (the SPA's forecast drawer is 60, its NWS modal 70) — a search dialog is a
 * top-level surface, so it must win. */

.search-modal { position: fixed; inset: 0; z-index: 200; }
.search-modal[hidden] { display: none; }

.search-backdrop {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--page-bg, #f5f5f7) 70%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}

.search-box {
  position: absolute; top: 14vh; left: 50%; transform: translateX(-50%);
  width: min(600px, calc(100vw - 32px));
  background: var(--sheet-bg, #ffffff); border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden; display: flex; flex-direction: column;
  max-height: min(72vh, 660px);
}
@media (prefers-reduced-motion: no-preference) {
  .search-box { animation: gc-search-in 160ms cubic-bezier(0.32, 0.72, 0, 1); }
  @keyframes gc-search-in { from { opacity: 0; transform: translate(-50%, -8px); } }
}

.search-field {
  flex: none; display: flex; align-items: center; gap: 11px;
  padding: 15px 16px; border-bottom: 1px solid var(--hair, rgba(23, 23, 23, 0.09));
}
.search-field .i-search { width: 18px; height: 18px; flex: none; color: var(--ink-3, rgba(23, 23, 23, 0.38)); }
.search-field input {
  flex: 1; min-width: 0; appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 17px; font-weight: 600; color: var(--ink, #171717);
}
.search-field input::placeholder { color: var(--ink-3, rgba(23, 23, 23, 0.38)); font-weight: 500; }
.search-field input:focus { outline: none; }
.search-close {
  flex: none; appearance: none; border: 0; cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--seg-bg, rgba(23, 23, 23, 0.06)); color: var(--ink-2, rgba(23, 23, 23, 0.55));
}
.search-close svg { width: 15px; height: 15px; }
.search-close:hover { background: var(--hair, rgba(23, 23, 23, 0.09)); color: var(--ink, #171717); }

.search-results { margin: 0; padding: 6px; list-style: none; overflow-y: auto; }
.search-result {
  display: flex; align-items: center; gap: 13px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.search-result.is-active, .search-result:hover { background: var(--card-2, rgba(23, 23, 23, 0.035)); }
.search-result .wx {
  flex: none; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-2, rgba(23, 23, 23, 0.55));
}
.search-result .wx svg { width: 30px; height: 30px; display: block; }
.search-result.search-use-location .wx { color: var(--sev-minor, #2563eb); }
.search-result.search-use-location .wx svg { width: 20px; height: 20px; }
.search-result.search-use-location .primary { color: var(--sev-minor, #2563eb); }
.search-result .wx-temp {
  flex: none; margin-inline-start: auto; min-width: 40px; text-align: right;
  font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink, #171717);
}
.search-result .body { min-width: 0; flex: 1; }
.search-result .primary {
  font-size: 15.5px; font-weight: 700; color: var(--ink, #171717);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result .secondary {
  font-size: 13px; font-weight: 600; color: var(--ink-3, rgba(23, 23, 23, 0.38));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-empty {
  padding: 22px 16px; text-align: center;
  color: var(--ink-3, rgba(23, 23, 23, 0.38)); font-size: 14px; font-weight: 600;
}
/* Failure state (network/rate-limit) — stronger ink than the muted empty
   state so it reads as "something went wrong", not "no such place". */
.search-empty.search-error {
  color: var(--ink-2, rgba(23, 23, 23, 0.62));
}
.search-section {
  padding: 12px 14px 6px; font-size: 11px; font-weight: 800;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3, rgba(23, 23, 23, 0.38));
}

/* Mobile: lift the dialog higher so the on-screen keyboard doesn't cover the
   results. The full-width edge insets already come from the box's width clamp. */
@media (max-width: 720px) {
  .search-box { top: 8vh; }
}
