/* SpaceSick — Search + Tour Launcher.
   Reuses the app's tokens (--serif, --sans, --accent, --text*, --bg) so the
   search entry button, its top-sheet panel, the empty-state journey launcher,
   and the live world results all sit inside the existing quiet aesthetic.
   Loaded after css/tours.css. Adds only new selectors — touches nothing else. */

/* ---------- search entry button (corner, left of #journey-btn) ---------- */
/* Inherits the .corner pill (background, border, blur, radius, transition).
   Base top/right here are a fallback only — js/search.js glues it to the left
   edge of #journey-btn so the two read as a matched pair at any width. */
#search-btn {
  top: max(20px, env(safe-area-inset-top));
  right: 84px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  padding: 10px;
}
#search-btn .search-glyph { display: block; width: 15px; height: 15px; }
#search-btn.active { color: var(--text-dim); border-color: rgba(160, 160, 200, 0.35); }

/* ---------- overlay shell (a calm top sheet) ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 47;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(70px, 11vh, 118px) 20px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.search-overlay.open { opacity: 1; pointer-events: auto; }
.search-scrim {
  position: absolute;
  inset: 0;
  background: rgba(1, 3, 9, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---------- panel ---------- */
.search-panel {
  position: relative;
  width: min(480px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* the body scrolls; the field row stays put */
  background: rgba(10, 14, 28, 0.94);
  border: 1px solid rgba(120, 130, 180, 0.22);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  transform: translateY(-14px) scale(0.99);
  transition: transform 0.55s cubic-bezier(0.22, 0.8, 0.35, 1);
}
.search-overlay.open .search-panel { transform: translateY(0) scale(1); }

.search-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.4s ease, background 0.4s ease;
}
.search-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

/* field row — leading icon + input; right padding clears the close button */
.search-field {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 21px 58px 21px 22px;
  border-bottom: 1px solid rgba(140, 150, 220, 0.12);
}
.search-field .sf-icon { flex-shrink: 0; width: 17px; height: 17px; color: var(--text-faint); }
.search-input {
  flex: 1;
  min-width: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
  background: transparent;
  border: none;
}
.search-input::placeholder { color: var(--text-faint); font-style: italic; }
.search-input:focus { outline: none; }

/* ---------- body (tours in the empty state, or live world results) ---------- */
.search-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-body::-webkit-scrollbar { display: none; }

.search-label {
  flex: 0 0 auto;
  padding: 6px 8px 2px;
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.search-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(140, 150, 200, 0.14);
  border-radius: 13px;
  cursor: pointer;
  transition: border-color 0.4s ease, background 0.4s ease;
}
.search-row:hover {
  border-color: rgba(140, 150, 240, 0.5);
  background: rgba(67, 97, 238, 0.1);
}
.search-row:hover .sr-arrow { transform: translateX(4px); color: var(--text); }
.sr-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.sr-title {
  font-family: var(--serif);
  font-size: clamp(19px, 4.6vw, 21px);
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  text-wrap: pretty;
}
.sr-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--text-dim);
  text-wrap: pretty;
}
.sr-meta {
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.sr-arrow {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-faint);
  transition: transform 0.4s ease, color 0.4s ease;
}

.search-empty {
  padding: 34px 18px 30px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-faint);
  text-wrap: pretty;
}

/* ---------- empty-state subscribe (a quiet coda below the journeys) ---------- */
/* Only rendered by renderTours() — so it exists in the empty state and vanishes
   the moment a query filters the body to results. Mirrors the end-of-tour
   capture's look; its submit reuses that same handler. */
.search-sub {
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 22px 8px 6px;
  border-top: 1px solid rgba(140, 150, 220, 0.14);
  display: flex;
  flex-direction: column;
}
.search-sub-copy {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  line-height: 1.5;
  color: #9aa6e8;
  text-wrap: pretty;
}
.search-sub-form {
  margin-top: 14px;
  display: flex;
  gap: 10px;
}
.search-sub-input {
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(140, 150, 200, 0.28);
  border-radius: 999px;
  padding: 12px 20px;
  min-height: 48px;
  transition: border-color 0.4s ease, background 0.4s ease;
}
.search-sub-input::placeholder { color: var(--text-faint); }
.search-sub-input:focus {
  outline: none;
  border-color: rgba(140, 150, 240, 0.7);
  background: rgba(67, 97, 238, 0.08);
}
.search-sub-btn {
  flex-shrink: 0;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(67, 97, 238, 0.18);
  border: 1px solid rgba(120, 130, 220, 0.5);
  border-radius: 999px;
  padding: 0 24px;
  min-height: 48px;
  cursor: pointer;
  transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease, opacity 0.4s ease;
}
.search-sub-btn:hover {
  border-color: rgba(140, 150, 240, 0.8);
  background: rgba(67, 97, 238, 0.28);
  box-shadow: 0 0 26px rgba(67, 97, 238, 0.22);
}
.search-sub-btn:disabled { opacity: 0.5; cursor: default; }
.search-sub-confirm {
  margin-top: 14px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.7s ease;
}
.search-sub-confirm.visible { opacity: 1; }
.search-sub-error {
  margin-top: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: rgba(232, 176, 176, 0.82); /* the same quiet rose the tour capture uses */
  opacity: 0;
  transition: opacity 0.5s ease;
}
.search-sub-error.visible { opacity: 1; }
.search-sub-form.sent { display: none; } /* on confirm, retire the field; the message stands in */

/* ---------- small screens ---------- */
@media (max-width: 460px) {
  .search-panel { border-radius: 18px; }
  .search-field { padding: 19px 54px 19px 20px; }
  .search-input { font-size: 20px; }
  .search-row { padding: 13px 14px; gap: 12px; }
  .search-sub-form { flex-direction: column; }
  .search-sub-input, .search-sub-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .search-overlay,
  .search-panel,
  .search-sub-confirm,
  .search-sub-error,
  .sr-arrow { transition: none; }
}
