/* search.css — search overlay, input, results */

/* ── TOPBAR SEARCH BUTTON ── */

.topbar-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.375rem 0.625rem 0.375rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-search:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text-secondary);
  background: var(--color-bg-hover);
}
.topbar-search-label {
  font-family: var(--font-sans);
  line-height: 1;
}
.topbar-search-kbd {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
  font-size: 0.7rem;
  font-family: var(--font-sans);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ── OVERLAY BACKDROP ── */

#search-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 72px 1rem 2rem;
  background: rgba(20, 18, 16, 0.55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
#search-overlay.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ── SEARCH BOX ── */

.search-box {
  width: 100%;
  max-width: 640px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);

  transform: translateY(-10px) scale(0.99);
  transition: transform 0.18s ease;
}
#search-overlay.is-open .search-box {
  transform: translateY(0) scale(1);
}

/* ── INPUT ROW ── */

.search-input-row {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.search-icon-lead {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--color-text);
  font-family: var(--font-sans);
  min-width: 0;
}
.search-input::placeholder { color: var(--color-text-muted); }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { display: none; }

.search-esc-badge {
  flex-shrink: 0;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-bg-secondary);
  font-size: 0.7rem;
  font-family: var(--font-sans);
  color: var(--color-text-muted);
  cursor: pointer;
  line-height: 1.4;
}

/* ── RESULTS LIST ── */

.search-results {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}

.search-status {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.search-result {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
}
.search-result:last-child { border-bottom: none; }
.search-result:hover,
.search-result.is-active {
  background: var(--color-bg-hover);
}

.search-result-top {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.2rem;
}

.search-result-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.search-result-module {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-brand);
  background: var(--color-brand-light);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
}

.search-result-desc {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  line-height: 1.45;
  margin-bottom: 0.2rem;
}

.search-result-snippet {
  font-size: 0.775rem;
  color: var(--color-text-muted);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* highlight marks */
.search-result mark {
  background: rgba(232, 81, 26, 0.14);
  color: var(--color-brand);
  border-radius: 2px;
  padding: 0 1px;
  font-style: normal;
}

/* ── FOOTER HINTS ── */

.search-footer {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}
.search-footer kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-secondary);
  font-size: 0.68rem;
  font-family: var(--font-sans);
  color: var(--color-text-secondary);
  margin-right: 1px;
}

/* ── MOBILE ── */

@media (max-width: 768px) {
  .topbar-search-label,
  .topbar-search-kbd { display: none; }

  .topbar-search {
    padding: 0.4rem 0.5rem;
  }

  #search-overlay {
    padding: 56px 0.5rem 1rem;
    align-items: flex-start;
  }

  .search-box {
    max-height: calc(100dvh - 70px);
  }

  .search-footer { display: none; }
}
