/* ========================================================================
   HorusFinder Results — Unified Responsive
   ======================================================================== */

/* ---- Desktop header visibility ---- */
@media (min-width: 992px) {
  .hf-results-header {
    flex: 1;
  }
  .hf-filter-header {
    display: none;
  }
}

/* ---- Results container ---- */
#hf-results {
  position: absolute;
  top: 100%;                /* anchor right below the searchbar */
  z-index: var(--hf-z-results, 9002);
  max-height: 80vh;
  overflow: hidden;
  background: var(--hf-color-surface, #fff);
  border: 1px solid var(--hf-color-border);
  display: none;
  /* left + width set by JS to center on viewport (clientWidth, no scrollbar shift) */
}

#hf-results .hf-right-column {
  display: flex;
  flex-direction: column;
  width: 75%;
  max-height: inherit;       /* inherit parent's max-height so children scroll */
  min-height: 0;
  box-sizing: border-box;
  background-color: var(--hf-color-surface, #fff);
}

/* Suggest-only mode: no results grid, only keyword suggestions */
#hf-results.hf-suggest-only .hf-left-column,
#hf-results.hf-suggest-only .shadow-overlay {
  display: none !important;
}

#hf-results.hf-suggest-only .hf-right-column {
  width: 100%;
}

#hf-results.hf-suggest-only .results-container {
  display: block;
}

#hf-results .hf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;            /* never squeeze the header row */
  font-size: 14px;
  text-align: center;
  font-weight: normal;
  color: var(--hf-color-text, #333);
  background-color: #e9e9e9;
  border-bottom: 1px solid var(--hf-color-border);
  border-left: 1px solid var(--hf-color-border);
  padding: 5px;
  margin: 0;
}

#hf-results .results-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 10px;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;             /* allow grid to shrink within flex column */
}

#hf-results .search-result-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  text-align: center;
  background-color: var(--hf-color-surface, #fff);
  min-height: 250px;
  max-width: 250px;
  color: inherit;
  padding: 0.8em;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  height: 100%;
  box-sizing: border-box;
  position: relative;
}

@media (hover: hover) {
  #hf-results .search-result-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
}

#hf-results .search-result-image {
  height: 120px;
  width: 100%;
  object-fit: contain;
  background: transparent;
  margin-bottom: 8px;
}

#hf-results .search-result-image-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

#hf-results .hf-badge-out-of-stock {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--hf-color-danger);
  opacity: 0.85;
  color: var(--hf-color-surface);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1.3;
  z-index: 10;
}

#hf-results .search-result-title {
  font-size: 13px;
  line-height: 19px;
  font-weight: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--hf-color-text, #333);
  text-align: center;
  word-wrap: break-word;
  margin-bottom: auto;
  flex-grow: 1;
}

#hf-results .search-result-price {
  font-size: 15px;
  font-weight: bold;
  color: var(--hf-color-text, #333);
  text-align: center;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
}

#hf-results .no-results {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: var(--hf-color-muted);
  padding: 40px 20px;
  width: 100%;
}

#hf-results .hf-bold {
  font-weight: bold;
}

#hf-results .results-separator {
  grid-column: 1 / -1;
  height: 1px;
  background-color: var(--hf-color-border);
  margin: 15px 0;
}

/* Recent searches block: span the full grid width so the inner header
   (title + clear) doesn't get squashed into a single 150px column */
#hf-results .results-container .hf-recent-searches {
  grid-column: 1 / -1;
}

/* High-resolution desktop breakpoints: width + left now computed by JS
   using clientWidth (excludes scrollbar) — see positionResultsBox(). */

/* ========================================================================
   Results — Mobile / Tablet portrait (≤991.98px)
   ======================================================================== */

@media (max-width: 991.98px) {
  /* Inside the fullscreen overlay, #hf-results is a static flex child.
     No more fixed positioning — the overlay container handles layout. */
  #hf-results {
    position: static;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;           /* allow nested scroll containers */
    display: flex;
    overflow: hidden;        /* children scroll */
    z-index: auto;
    background: var(--hf-color-surface, #fff);
    border: 0;
    box-sizing: border-box;
    padding: 0;
  }

  /* When overlay is closed, #hf-results shouldn't block the hidden state */
  body:not(.hf-mobile-open) #hf-results {
    display: none;
  }

  #hf-results .hf-right-column {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;           /* critical for nested scroll */
    display: flex;
    flex-direction: column;
  }

  #hf-results .hf-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: var(--hf-color-surface-alt, #f0f0f0);
    border-bottom: 0;
    border-left: 0;
    flex-shrink: 0;
  }

  #hf-results .hf-results-header {
    text-align: left;
    flex: 1;
  }

  #hf-results .hf-filter-header {
    display: block;
    text-align: right;
  }

  #hf-results .hf-suggestions-container {
    flex-shrink: 0;
  }

  #hf-results .results-container {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    border-left: 0;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #hf-results .hf-powered-by {
    flex-shrink: 0;
  }

  #hf-results .search-result-item {
    min-height: 220px;
    padding: 10px;
    border: 1px solid var(--hf-color-border, #ccc);
    border-radius: 4px;
  }

  #hf-results .search-result-title {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  #hf-results .search-result-price {
    font-size: 14px;
    bottom: 5px;
  }

  #hf-results .results-separator {
    height: 2px;
    margin: 10px 0;
    min-height: 2px;
  }

  #hf-results .filter-svg {
    height: 12px;
    margin-top: -3px;
  }
}

/* ========================================================================
   Reduced Motion
   ======================================================================== */

@media (prefers-reduced-motion: reduce) {
  #hf-results *, #hf-results *::before, #hf-results *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
