/* Site search (assets/js/search.js): a spotlight-style panel over a dimmed page. */
.site-search-btn {
  /* a search bar: takes the room between the logo and the menu, up to 34rem,
     and sits in the middle of whatever is left over */
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
  flex: 1 1 8rem;
  min-width: 8rem;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--ink-muted);
  font: 500 0.9rem var(--font-sans);
  text-align: left;
  cursor: text;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.site-search-btn:hover,
.site-search-btn:focus-visible {
  color: var(--ink);
  border-color: var(--ink-muted);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.site-search-btn svg {
  flex: none;
}

.site-search-btn__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.site-search-btn__short {
  display: none;
}

.site-search-btn__kbd {
  flex: none;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: 500 0.72rem var(--font-sans);
}

@media (max-width: 720px) {
  .site-header__inner {
    gap: 0.75rem;
  }
  .site-search-btn__kbd {
    display: none;
  }
  /* fill the room between the logo and the menu button */
  .site-search-btn {
    flex-basis: 6rem;
    min-width: 0;
    max-width: none;
    padding: 0.55rem 0.8rem;
  }
}

/* too narrow for the long hint (a phone, or a small window where the menu
   shares the row): say just "검색" */
@media (max-width: 520px), (min-width: 720.02px) and (max-width: 880px) {
  .site-search-btn__long {
    display: none;
  }
  .site-search-btn__short {
    display: inline;
  }
}

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 1rem 2rem;
  background: rgba(12, 10, 8, 0.58);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: search-fade 0.15s ease;
}

.search-overlay[hidden] {
  display: none;
}

@keyframes search-fade {
  from { opacity: 0; }
}

.search-panel {
  width: min(44rem, 100%);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  font-family: var(--font-sans);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.search-field svg {
  flex: none;
  color: var(--ink-muted);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 400 1.15rem var(--font-sans);
}

.search-input::placeholder {
  color: var(--ink-muted);
}

.search-esc {
  flex: none;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
}

.search-results {
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
  list-style: none;
}

.search-results li {
  margin: 0;
}

.search-hit {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  background-image: none !important;
}

.search-hit.is-active {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.search-hit__title {
  display: block;
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.35;
}

.search-hit__meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.search-hit__snip {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--ink-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-hit mark {
  padding: 0 0.1em;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
}

.search-note {
  padding: 1.1rem 1.2rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.search-foot {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1.1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.search-foot kbd {
  padding: 0 0.3rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  font: inherit;
}

body.search-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .search-overlay {
    animation: none;
  }
}
