/*
 * search.css — Drop-in search modal styles
 * -----------------------------------------
 * Uses CSS custom properties so it inherits your site's existing colours.
 * Override any variable in your own stylesheet if needed.
 *
 * Assumed variables from your site (fallbacks provided):
 *   --bg, --text, --border, --accent
 *
 * All px values converted to rem (base 16px = 1rem) for responsive scaling.
 */

/* ── Local fallbacks (used only if site variables are absent) ───────────── */
.search-overlay {
  --_bg:      var(--bg,      #ffffff);
  --_text:    var(--text,    #1a1a1a);
  --_border:  var(--border,  #e0e0e0);
  --_accent:  var(--accent,  #0057ff);
  --_muted:   var(--muted,   #6b6b6b);
  --_surface: var(--surface, #f5f5f5);
  --_radius:  var(--radius,  0.5rem);
}

/* ── Overlay / backdrop ─────────────────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(0.1875rem);                  /* was 3px */
  -webkit-backdrop-filter: blur(0.1875rem);

  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(3rem, 10vh, 6rem);
  padding-inline: 1rem;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.search-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Modal box ──────────────────────────────────────────────────────────── */
.search-modal {
  background: var(--_bg);
  color: var(--_text);
  border: 0.0625rem solid var(--_border);            /* was 1px */
  border-radius: var(--_radius);
  box-shadow: 0 0.5rem 2.5rem rgba(0, 0, 0, 0.18);  /* was 8px 40px */
  width: 100%;
  max-width: 40rem;                                  /* was 640px */
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  transform: translateY(-0.5rem);                    /* was -8px */
  transition: transform 0.18s ease;
}

.search-overlay.is-open .search-modal {
  transform: translateY(0);
}

/* ── Header row ─────────────────────────────────────────────────────────── */
.search-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 0.0625rem solid var(--_border);
  flex-shrink: 0;
}

/* Search icon */
.search-icon {
  flex-shrink: 0;
  color: var(--_muted);
  display: flex;
  align-items: center;
}

.search-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

/* Input */
.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--_text);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  padding: 0.15rem 0;
  /* Reset browser search input extras */
  -webkit-appearance: none;
  appearance: none;
}

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

/* Remove the browser-native ✕ clear button */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* Close button */
.search-close-btn {
  flex-shrink: 0;
  background: var(--_surface);
  border: 0.0625rem solid var(--_border);
  border-radius: 0.25rem;                            /* was 4px */
  color: var(--_muted);
  font-size: 0.7rem;
  font-family: inherit;
  padding: 0.15rem 0.45rem;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.12s;
}

.search-close-btn:hover {
  background: var(--_border);
}

/* ── Status message ─────────────────────────────────────────────────────── */
.search-status {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--_muted);
  /*color: red;*/
  margin: 0;
}

/* ── Results list ───────────────────────────────────────────────────────── */
.search-results {
  list-style: none;
  margin: 0;
  padding: 0.4rem 0;
  overflow-y: auto;
  flex: 1;
  /* Smooth scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--_border) transparent;
}

.search-results::-webkit-scrollbar {
  width: 0.25rem;                                    /* was 4px */
}
.search-results::-webkit-scrollbar-track {
  background: transparent;
}
.search-results::-webkit-scrollbar-thumb {
  background: var(--_border);
  border-radius: 0.125rem;                           /* was 2px */
}

/* ── Single result ──────────────────────────────────────────────────────── */
.search-result-item {
  padding: 0;
}

.search-result-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
  border-radius: 0;
}

.search-result-link:hover,
.search-result-item.is-active .search-result-link {
  background: var(--_surface);
  /*border-color: red; border-style: ridge; border-width: 0.05rem;*/
  /*padding-left: 2.2rem;*/ 
  /*margin-left: 2.2rem;*/   
  box-sizing: border-box; padding-left: 1rem; border-left: 0.15rem ridge red;
}

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

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--_muted);
}

.search-result-category {
  background: var(--_surface);
  border: 0.0625rem solid var(--_border);
  border-radius: 0.1875rem;                          /* was 3px */
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--_muted);
}

.search-result-date {
  color: var(--_muted);
}

.search-result-snippet {
  font-size: 0.8125rem;
  color: var(--_muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Highlight marks */
.search-result-title mark,
.search-result-snippet mark {
  background: color-mix(in srgb, var(--_accent) 18%, transparent); /*18%*/
  color: inherit;
  border-radius: 0.125rem;                           /* was 2px */
  padding: 0 0.0625rem;                              /* was 1px */
  font-style: inherit;
}

/* No-results state */
.search-no-results {
  padding: 1.25rem 1rem;
  color: var(--_muted);
  font-size: 0.875rem;
  text-align: center;
}

/* ── Keyboard hint footer ───────────────────────────────────────────────── */
.search-hint {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-top: 0.0625rem solid var(--_border);
  font-size: 0.7rem;
  color: var(--_muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.search-hint kbd {
  display: inline-block;
  background: var(--_surface);
  border: 0.0625rem solid var(--_border);
  border-radius: 0.1875rem;                          /* was 3px */
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
  font-family: inherit;
  line-height: 1.6;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 30rem) {                          /* was 480px */
  .search-overlay {
    padding-top: 0;
    align-items: flex-end;
  }

  .search-modal {
    max-width: 100%;
    max-height: 85vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
    transform: translateY(0.75rem);                  /* was 12px */
  }

  .search-overlay.is-open .search-modal {
    transform: translateY(0);
  }

  .search-hint {
    display: none;
  }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .search-overlay,
  .search-modal {
    transition: none;
  }
}