/* =========================================================
   Client-side search — Cmd+K modal + nav button
   Panel positioned ~15vh from top; backdrop dims the page.
   Matches the site's design tokens.
   ========================================================= */

/* Nav trigger button */
.v2-search-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: transparent;
  border: 1px solid var(--bone-400, #b3a589);
  border-radius: 999px;
  color: var(--ink-800, #2a2720);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
  margin-right: 0.6rem;
}
.v2-search-btn:hover {
  border-color: var(--amethyst-600, #8c6aa0);
  color: var(--amethyst-700, #6f4b82);
}
.v2-search-btn svg { display: block; }
.v2-search-btn__kbd {
  background: var(--bone-100, #f8f3eb);
  color: var(--bone-600, #5d5440);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
@media (max-width: 640px) {
  .v2-search-btn__label,
  .v2-search-btn__kbd { display: none; }
  .v2-search-btn { padding: 0.35rem 0.5rem; }
}

/* Modal overlay */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 15vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.search-modal[hidden] { display: none; }

.search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.search-modal__panel {
  position: relative;
  width: min(640px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bone-50, #fdfaf5);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform: scale(0.98);
  opacity: 0;
  transition: transform 150ms ease-out, opacity 150ms ease-out;
}
.search-modal.is-visible .search-modal__panel {
  transform: scale(1);
  opacity: 1;
}

.search-modal__input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--bone-200, #ede5d5);
}
.search-modal__icon {
  width: 18px;
  height: 18px;
  color: var(--bone-500, #857962);
  flex-shrink: 0;
}
.search-modal__input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--ink-900, #1c1a14);
}
.search-modal__input::placeholder { color: var(--bone-500, #857962); }
.search-modal__esc {
  background: var(--bone-100, #f8f3eb);
  color: var(--bone-600, #5d5440);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

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

.search-result {
  padding: 0.6rem 1rem;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.search-result[aria-selected="true"] {
  background: var(--amethyst-100, #f5eff8);
  border-left-color: var(--amethyst-600, #8c6aa0);
}
.search-result__page {
  font-size: 0.75rem;
  color: var(--bone-600, #5d5440);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}
.search-result__section {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--forest-800, #2d5a3d);
  line-height: 1.3;
}
.search-result__snippet {
  font-size: 0.85rem;
  color: var(--ink-800, #2a2720);
  line-height: 1.45;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result__snippet mark {
  background: var(--amethyst-200, #eae0f0);
  color: var(--forest-800, #2d5a3d);
  padding: 0 0.1em;
  border-radius: 2px;
}

.search-modal__empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--bone-600, #5d5440);
  font-size: 0.9rem;
}

.search-modal__footer {
  display: flex;
  gap: 1.25rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--bone-200, #ede5d5);
  background: var(--bone-100, #f8f3eb);
  font-size: 0.75rem;
  color: var(--bone-600, #5d5440);
}
.search-modal__footer kbd {
  background: var(--bone-50, #fdfaf5);
  border: 1px solid var(--bone-300, #d9cdb8);
  border-radius: 3px;
  padding: 0 0.35rem;
  margin-right: 0.3rem;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.7rem;
}

@media (prefers-reduced-motion: reduce) {
  .search-modal__panel {
    transition: opacity 100ms ease-out;
    transform: none;
  }
}
