/* ============================================================================
   Nuvari Blog Search — Premium Search Styles
   Typeahead, answer cards, people-also-ask, mobile overlay, animations
   ============================================================================ */

/* ── Search wrapper (must be position:relative for typeahead) ────────────── */
.blog-search-wrap {
  position: relative;
  z-index: 50;
}

/* ── Typeahead dropdown ──────────────────────────────────────────────────── */
.search-typeahead {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  -webkit-overflow-scrolling: touch;
}

.search-typeahead.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.search-typeahead::-webkit-scrollbar { width: 6px; }
.search-typeahead::-webkit-scrollbar-track { background: transparent; }
.search-typeahead::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Typeahead sections (popular, topics) ────────────────────────────────── */
.typeahead-section { padding: 8px 0; }
.typeahead-section + .typeahead-section { border-top: 1px solid var(--border); }

.typeahead-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--mute);
  padding: 8px 20px 4px;
}

/* ── Typeahead items ─────────────────────────────────────────────────────── */
.typeahead-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.typeahead-item:hover,
.typeahead-item.active {
  background: rgba(0, 180, 198, 0.05);
}

.typeahead-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--cream);
  color: var(--mute);
}

.typeahead-icon-question {
  background: rgba(0, 180, 198, 0.1);
  color: var(--teal);
}

.typeahead-icon-heading {
  background: rgba(10, 22, 40, 0.06);
  color: var(--navy);
}

.typeahead-icon-popular {
  background: rgba(0, 180, 198, 0.08);
  color: var(--tealD);
}

.typeahead-text-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.typeahead-main {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typeahead-sub {
  font-size: 11px;
  color: var(--mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.typeahead-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--tealL);
  color: var(--tealD);
  padding: 2px 8px;
  border-radius: 100px;
  flex-shrink: 0;
}

/* ── Category chips (empty state) ────────────────────────────────────────── */
.typeahead-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 20px 12px;
}

.typeahead-chip {
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  color: var(--sub);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'DM Sans', sans-serif;
}

.typeahead-chip:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(0, 180, 198, 0.04);
}

/* ── Featured answer cards — animations ──────────────────────────────────── */
#featured-answers {
  margin-bottom: 28px;
}

#featured-answers .answer-card {
  opacity: 0;
  transform: translateY(12px);
  animation: answerSlideIn 0.35s ease forwards;
}

@keyframes answerSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Improved answer card styles */
.answer-card {
  display: block;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.25s ease;
}

.answer-card:hover {
  border-left-color: var(--tealD);
  box-shadow: 0 4px 20px rgba(0, 180, 198, 0.1);
  transform: translateY(-2px);
}

.answer-source { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.answer-cat {
  background: var(--tealL);
  color: var(--tealD);
  padding: 2px 10px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.answer-title { font-size: 12px; color: var(--mute); font-weight: 500; }
.answer-heading {
  font-family: 'DM Serif Display', serif;
  font-size: 17px;
  margin-bottom: 6px;
  color: var(--navy);
}
.answer-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--sub);
}
.answer-text mark {
  background: rgba(0, 180, 198, 0.15);
  color: var(--text);
  padding: 1px 2px;
  border-radius: 3px;
}
.answer-read {
  font-size: 12px;
  color: var(--teal);
  font-weight: 600;
  margin-top: 8px;
}
.answers-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--teal);
  margin-bottom: 12px;
}

/* ── People Also Ask ─────────────────────────────────────────────────────── */
#people-also-ask {
  margin-bottom: 28px;
}

#people-also-ask.visible .paa-item {
  opacity: 0;
  animation: paaSlideIn 0.3s ease forwards;
}

@keyframes paaSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.paa-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--navy);
  margin-bottom: 12px;
  opacity: 0.6;
}

.paa-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.paa-item {
  border-bottom: 1px solid var(--border);
}

.paa-item:last-child {
  border-bottom: none;
}

.paa-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.15s ease;
  gap: 12px;
}

.paa-question:hover {
  background: rgba(0, 180, 198, 0.03);
}

.paa-q-text {
  flex: 1;
  line-height: 1.4;
}

.paa-chevron {
  font-size: 12px;
  color: var(--mute);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.paa-item.open .paa-chevron {
  transform: rotate(180deg);
}

.paa-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 20px;
}

.paa-item.open .paa-answer {
  max-height: 500px;
  padding: 0 20px 16px;
}

.paa-answer p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--sub);
  margin-bottom: 8px;
}

.paa-source {
  font-size: 12px;
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.paa-source:hover {
  color: var(--tealD);
}

/* ── Mobile full-screen search overlay ───────────────────────────────────── */
.search-mobile-back {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  border-radius: 50%;
  transition: background 0.15s;
}

.search-mobile-back:hover {
  background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  /* Full-screen search overlay when focused */
  body.search-focused::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(250, 250, 247, 0.97);
    z-index: 49;
    animation: fadeIn 0.2s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  body.search-focused .blog-search-wrap {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 51;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    max-width: 100%;
    margin: 0;
  }

  body.search-focused .blog-search input {
    padding-left: 52px;
    font-size: 16px; /* Prevents iOS zoom */
    border-radius: 12px;
  }

  body.search-focused .search-mobile-back {
    display: flex;
  }

  body.search-focused .search-typeahead {
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    max-height: calc(100vh - 68px);
    box-shadow: none;
  }

  /* Larger touch targets on mobile */
  .typeahead-item {
    padding: 14px 20px;
    min-height: 48px;
  }

  .paa-question {
    padding: 18px 20px;
    min-height: 52px;
  }

  .typeahead-chip {
    padding: 8px 16px;
    font-size: 13px;
  }
}

/* ── Smooth transition for search count ──────────────────────────────────── */
.search-count {
  transition: opacity 0.2s ease;
}

/* ── No results state animation ──────────────────────────────────────────── */
.no-results {
  animation: fadeIn 0.3s ease;
}
