/* ==========================================================================
   SITE-WIDE SEARCH — header trigger + full-screen overlay palette
   Loaded after site.css / mobile.css on every public page.
   ========================================================================== */

/* ---------- header trigger ---------- */
.search-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 4px;
  background: transparent; color: #cfe0f7; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
  flex: none;
}
.search-btn svg { width: 17px; height: 17px; }
.search-btn:hover { border-color: var(--cyan); color: var(--cyan); background: rgba(56, 200, 255, .10); }
.search-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- overlay shell ---------- */
.sh-search {
  position: fixed; inset: 0; z-index: 10050;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px 20px;
}
.sh-search[hidden] { display: none; }
.sh-search__backdrop {
  position: absolute; inset: 0;
  background: rgba(3, 8, 17, .78);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
}
.sh-search__panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 82vh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0d1a30, #0a1526);
  border: 1px solid rgba(130, 175, 235, .28);
  border-radius: 12px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, .62), 0 0 0 1px rgba(238, 27, 37, .10);
  overflow: hidden;
  animation: shSearchIn .18s ease-out;
}
@keyframes shSearchIn {
  from { opacity: 0; transform: translateY(-12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- input row ---------- */
.sh-search__bar {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
}
.sh-search__ico { display: grid; place-items: center; color: var(--cyan); flex: none; }
.sh-search__ico svg { width: 20px; height: 20px; }
.sh-search__input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text); font-family: inherit; font-size: 16px; font-weight: 500;
  padding: 4px 0;
}
.sh-search__input::placeholder { color: #6f83a6; font-weight: 400; }
.sh-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
.sh-search__close {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 5px;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: .18s;
}
.sh-search__close svg { width: 14px; height: 14px; }
.sh-search__close:hover { color: #fff; border-color: var(--red); background: rgba(238, 27, 37, .14); }

/* ---------- results ---------- */
.sh-search__results {
  flex: 1; min-height: 120px; max-height: 62vh;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px;
}
.sh-search__results::-webkit-scrollbar { width: 8px; }
.sh-search__results::-webkit-scrollbar-thumb { background: rgba(130, 175, 235, .25); border-radius: 4px; }
.sh-search__results::-webkit-scrollbar-track { background: transparent; }

.sh-group + .sh-group { margin-top: 6px; }
.sh-group__t {
  padding: 9px 12px 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #6f83a6;
}
.sh-hit {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 7px;
  transition: background .12s;
}
.sh-hit:hover, .sh-hit.is-active { background: rgba(56, 200, 255, .10); }
.sh-hit.is-active { box-shadow: inset 2px 0 0 var(--red); }
.sh-hit__img {
  width: 40px; height: 40px; flex: none;
  border-radius: 6px; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--line);
}
.sh-hit__img--ico { display: grid; place-items: center; color: var(--cyan); }
.sh-hit__img--ico svg { width: 17px; height: 17px; }
.sh-hit__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sh-hit__title {
  font-size: 14px; font-weight: 600; color: #eaf1ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sh-hit__desc {
  font-size: 12px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Original (English) name — shown when a cross-language hit matched a word
   that is not visible in the translated title. */
.sh-hit__alt {
  font-size: 11.5px; color: #6f83a6;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sh-hit__type {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: #7f92b3; border: 1px solid var(--line); border-radius: 3px;
  padding: 3px 7px;
}
.sh-hit mark {
  background: rgba(238, 27, 37, .26); color: #ffd7d9;
  border-radius: 2px; padding: 0 1px;
}

/* ---------- empty state ---------- */
.sh-search__empty { padding: 26px 18px; text-align: center; }
.sh-search__empty-t { font-size: 14px; color: var(--muted); }
.sh-search__empty-s { font-size: 12.5px; color: #6f83a6; margin-top: 6px; }
.sh-search__chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 18px;
}
.sh-chip {
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .03); color: #b9cbe8;
  font-family: inherit; font-size: 12px; padding: 6px 13px; cursor: pointer;
  transition: .18s;
}
.sh-chip:hover { border-color: var(--cyan); color: var(--cyan); background: rgba(56, 200, 255, .10); }

/* ---------- footer hints ---------- */
.sh-search__foot {
  display: flex; align-items: center; gap: 16px;
  padding: 9px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
  font-size: 11px; color: #6f83a6;
}
.sh-search__foot kbd {
  display: inline-block; min-width: 17px; text-align: center;
  padding: 1px 4px; margin-inline-end: 3px;
  border: 1px solid var(--line); border-radius: 3px;
  background: rgba(255, 255, 255, .04);
  font-family: inherit; font-size: 10px; color: #9fb2d4;
}

/* ---------- page scroll lock ---------- */
html.sh-search-open, html.sh-search-open body { overflow: hidden; }

/* ---------- RTL ---------- */
html[dir="rtl"] .sh-search__panel { text-align: right; }
html[dir="rtl"] .sh-hit.is-active { box-shadow: inset -2px 0 0 var(--red); }
html[dir="rtl"] .sh-search__foot { direction: rtl; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sh-search { padding: 0; }
  .sh-search__panel {
    width: 100%; max-width: none; max-height: 100%; height: 100%;
    border-radius: 0; border: 0;
    animation: shSearchInM .2s ease-out;
  }
  @keyframes shSearchInM {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: none; }
  }
  .sh-search__bar { padding: 12px 14px; }
  .sh-search__input { font-size: 16px; }   /* ≥16px stops iOS zoom-on-focus */
  .sh-search__results { max-height: none; padding: 6px; }
  .sh-search__foot { display: none; }
  .sh-hit { padding: 10px; }
  .sh-hit__img { width: 44px; height: 44px; }
  .sh-hit__type { display: none; }
}
@media (max-width: 620px) {
  .search-btn { width: 34px; height: 34px; }
}
