/*
 * Lifehack Method — Blog Enhance v0.1.0
 * Sticky "Ask anything" search bar with featured-articles dropdown.
 *
 * All classes prefixed `lhm-` to avoid collisions with Divi or other plugins.
 * Brand tokens scoped to the search elements so this CSS does not affect
 * the rest of the site.
 */

.lhm-search,
.lhm-search-panel {
  --lhm-ink:           oklch(0.21 0.020 195);
  --lhm-ink-2:         oklch(0.32 0.030 195);
  --lhm-paper:         oklch(0.985 0.005 195);
  --lhm-paper-2:       oklch(0.96 0.008 195);
  --lhm-rule:          oklch(0.86 0.012 195);
  --lhm-muted:         oklch(0.55 0.010 195);
  --lhm-teal-deep:     oklch(0.49 0.085 192);
  --lhm-teal:          oklch(0.66 0.105 192);
  --lhm-teal-wash:     oklch(0.93 0.025 188);
  --lhm-teal-mist:     oklch(0.98 0.012 188);
  --lhm-gold-soft:     oklch(0.93 0.10 95);
  --lhm-gold:          oklch(0.86 0.14 95);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--lhm-ink);
}

/* ============================================================
   STICKY BAR
   - On scroll, the bar sticks to the top of the viewport.
   - top:0 means it'll appear above Divi's main header. If Divi's
     header is taller than expected, JS auto-detects and shifts.
   ============================================================ */
.lhm-search {
  position: sticky;
  top: 0;
  z-index: 9000;
  background: var(--lhm-paper);
  padding: 14px 0 14px;
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.lhm-search[data-state="open"] {
  border-bottom-color: var(--lhm-rule);
  box-shadow: 0 8px 24px -16px oklch(0.20 0.02 195 / 0.30);
}

.lhm-search__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

.lhm-search__input-wrap {
  background: var(--lhm-paper);
  border: 1.5px solid var(--lhm-rule);
  border-radius: 100px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  cursor: text;
}
.lhm-search[data-state="open"] .lhm-search__input-wrap {
  border-color: var(--lhm-teal-deep);
  box-shadow: 0 0 0 4px var(--lhm-teal-mist);
}

.lhm-search__sparkle {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--lhm-teal-deep);
}

.lhm-search__input {
  flex: 1;
  border: 0 !important;
  outline: 0;
  background: transparent !important;
  font: inherit;
  font-size: 1rem;
  color: var(--lhm-ink);
  padding: 0 !important;
  box-shadow: none !important;
  height: auto;
  line-height: 1.5;
}
.lhm-search__input:focus {
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}
.lhm-search__input::placeholder {
  color: var(--lhm-muted);
  font-family: inherit;
}
/* hide the browser's built-in clear button on Safari/Chrome */
.lhm-search__input::-webkit-search-cancel-button,
.lhm-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

.lhm-search__submit {
  background: var(--lhm-ink) !important;
  color: var(--lhm-paper) !important;
  border: 0 !important;
  border-radius: 100px !important;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 200ms ease;
  flex-shrink: 0;
}
.lhm-search__submit:hover { background: var(--lhm-teal-deep) !important; }
.lhm-search__submit svg { width: 18px; height: 18px; }

.lhm-search__close {
  display: none;
  background: transparent !important;
  border: 0 !important;
  cursor: pointer;
  padding: 4px !important;
  color: var(--lhm-muted);
}
.lhm-search[data-state="open"] .lhm-search__close { display: inline-flex; }

/* Topic chips row (collapsed state only) */
.lhm-search__chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-top: 12px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.lhm-search__chips::-webkit-scrollbar { display: none; }
.lhm-search[data-state="open"] .lhm-search__chips { display: none; }

.lhm-chip {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 100px;
  background: var(--lhm-paper-2);
  color: var(--lhm-ink);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: border-color 150ms ease, background 150ms ease;
  white-space: nowrap;
}
.lhm-chip:hover {
  border-color: var(--lhm-teal-deep);
  background: var(--lhm-paper);
  color: var(--lhm-ink);
}

/* ============================================================
   DROPDOWN PANEL
   ============================================================ */
.lhm-search-panel {
  position: sticky;
  top: 70px; /* sits below the search bar; JS will adjust if Divi header changes height */
  z-index: 8999;
  background: var(--lhm-paper);
  border-bottom: 1px solid var(--lhm-rule);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.lhm-search-panel[hidden] { display: none !important; }

.lhm-search-panel__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 20px 24px;
}

.lhm-search-panel__section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}
.lhm-search-panel__section-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--lhm-paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lhm-ink-2);
  flex-shrink: 0;
}
.lhm-search-panel__section-title {
  font-family: 'Fraunces', Georgia, serif !important;
  font-weight: 600 !important;
  font-size: 1.15rem !important;
  color: var(--lhm-ink) !important;
  line-height: 1.2 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.lhm-search-panel__msg {
  padding: 24px 0;
  text-align: center;
  color: var(--lhm-muted);
  font-size: 0.95rem;
}
.lhm-search-panel__msg strong { color: var(--lhm-ink); }

/* ============================================================
   RESULT CARDS (used in featured + search results)
   ============================================================ */
.lhm-result {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--lhm-rule);
  text-decoration: none !important;
  color: inherit;
  transition: background 150ms ease;
}
.lhm-result:hover { background: var(--lhm-paper-2); }
.lhm-result:last-child { border-bottom: 0; }

.lhm-result__thumb {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  background: var(--lhm-paper-2);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--lhm-teal-deep);
}
.lhm-result__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.lhm-result__thumb-fallback {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--lhm-teal-deep);
}

.lhm-result__body {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
}
.lhm-result__title {
  font-family: 'Fraunces', Georgia, serif !important;
  font-weight: 600 !important;
  font-size: 1.02rem !important;
  line-height: 1.3 !important;
  color: var(--lhm-ink) !important;
  margin: 0 0 6px !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lhm-result__meta {
  font-size: 0.78rem;
  color: var(--lhm-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.lhm-result__meta-sep::before {
  content: "·";
  margin: 0 6px 0 2px;
}

/* ============================================================
   DESKTOP
   ============================================================ */
@media (min-width: 720px) {
  .lhm-search { padding: 18px 0; }
  .lhm-search__inner { padding: 0 32px; }
  .lhm-search-panel__inner { padding: 24px 32px 36px; }
  .lhm-result__thumb { width: 120px; height: 90px; }
  .lhm-result__title { font-size: 1.1rem !important; }
}
