/*
 * Live search results — one look for the catalog search (catalog_search.js, .kms)
 * and the home page search (home_map.js, .hs-ac-*). Tiles, no extra headings.
 */

/* ============ Catalog panel (.kms) ============ */

html body .catalog-search-dropdown.kms:not(#kms-a):not(#kms-b) {
  position: absolute !important;
  top: calc(100% + 10px) !important;
  left: 0 !important;
  right: 0 !important;
  width: auto !important;
  max-width: none !important;
  display: flex !important;
  flex-direction: column !important;
  max-height: min(600px, var(--suggestions-available-height, 600px)) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  border: 1px solid rgba(22, 122, 63, 0.14) !important;
  border-radius: 22px !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(17, 54, 33, 0.06), 0 18px 40px -12px rgba(17, 54, 33, 0.22), 0 40px 70px -40px rgba(17, 54, 33, 0.3) !important;
  z-index: 9999 !important;
  animation: none !important;
  transform-origin: top center;
}

html body .catalog-search-dropdown.kms[hidden]:not(#kms-a):not(#kms-b) {
  display: none !important;
}

html body .catalog-search-dropdown.kms.is-in {
  animation: kms-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
}

@keyframes kms-pop {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

/* Thin progress line while the next answer loads (results stay visible). */
html body .kms .kms-progress {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

html body .kms .kms-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, #4cc38a, #167a3f, transparent);
  animation: kms-progress 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

html body .kms.is-loading .kms-progress {
  opacity: 1;
}

html body .kms.is-loading .kms-grid:not(:has(.kms-tile--skeleton)) {
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

@keyframes kms-progress {
  from { left: -40%; }
  to { left: 100%; }
}

html body .kms .kms-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 122, 63, 0.25) transparent;
}

/* Categories / organisations as chips */
html body .kms .kms-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 2px 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid #edf2ee;
}

html body .kms .kms-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  max-width: 100%;
  padding: 0 13px 0 11px;
  border: 1.5px solid #dbe7df;
  border-radius: 999px;
  background: #fff;
  color: #2a3d31;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  animation: kms-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: border-color 0.16s ease, background-color 0.16s ease, color 0.16s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html body .kms .kms-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
}

html body .kms .kms-chip svg {
  flex: 0 0 auto;
  color: #167a3f;
}

html body .kms .kms-chip--org svg {
  color: #6a5ad1;
}

html body .kms .kms-chip:is(:hover, .is-selected) {
  border-color: #167a3f;
  background: #e9f6ee;
  color: #0e5f30;
  transform: translateY(-1px);
}

/* Tiles */
html body .kms .kms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 8px;
}

html body .kms .kms-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 10px 8px 8px;
  border: 1px solid #edf2ee;
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  animation: kms-in 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 30ms);
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes kms-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

html body .kms .kms-tile:is(:hover, .is-selected) {
  border-color: #bfe0cb;
  background: #f7fbf8;
  box-shadow: 0 8px 18px -10px rgba(17, 54, 33, 0.35);
  transform: translateY(-2px);
}

html body .kms .kms-tile.is-selected {
  outline: 2px solid rgba(22, 122, 63, 0.35);
  outline-offset: 1px;
}

html body .kms .kms-tile:active {
  transform: scale(0.985);
}

html body .kms .kms-thumb {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 13px;
  background: linear-gradient(140deg, #eef7f1, #e1f0e7);
  color: #6aa585;
}

html body .kms .kms-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

html body .kms .kms-tile:hover .kms-thumb img {
  transform: scale(1.06);
}

html body .kms .kms-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

html body .kms .kms-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: #17251d;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

html body .kms mark {
  padding: 0 1px;
  border-radius: 4px;
  background: #d9f2e2;
  color: #0e5f30;
}

html body .kms .kms-meta {
  overflow: hidden;
  color: #6a7d71;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html body .kms .kms-meta i {
  margin: 0 5px;
  font-style: normal;
  opacity: 0.6;
}

html body .kms .kms-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

html body .kms .kms-price,
html body .kms .kms-rating {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

html body .kms .kms-price {
  background: #e9f6ee;
  color: #0e5f30;
}

html body .kms .kms-rating {
  background: #fff6e0;
  color: #9a6400;
}

html body .kms .kms-rating svg {
  color: #f2a50c;
}

html body .kms .kms-go {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f6f3;
  color: #167a3f;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html body .kms .kms-tile:is(:hover, .is-selected) .kms-go {
  opacity: 1;
  transform: none;
}

/* Footer: open the full list with the same filters */
html body .kms .kms-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 48px;
  margin: 0;
  border-top: 1px solid #edf2ee;
  background: #fbfdfb;
  color: #0e5f30;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  transition: background-color 0.16s ease;
}

html body .kms .kms-all svg {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html body .kms .kms-all:is(:hover, .is-selected) {
  background: #e9f6ee;
}

html body .kms .kms-all:is(:hover, .is-selected) svg {
  transform: translateX(4px);
}

/* Skeleton while the very first answer loads */
html body .kms .kms-tile--skeleton {
  pointer-events: none;
}

html body .kms .kms-tile--skeleton .kms-thumb,
html body .kms .kms-line {
  background: linear-gradient(90deg, #eef3ef 25%, #f7faf8 45%, #eef3ef 65%);
  background-size: 300% 100%;
  animation: kms-shimmer 1.1s linear infinite;
}

html body .kms .kms-line {
  display: block;
  height: 12px;
  width: 80%;
  border-radius: 6px;
}

html body .kms .kms-line--short {
  width: 50%;
  margin-top: 6px;
}

@keyframes kms-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* Empty / error */
html body .kms .kms-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px 28px;
  text-align: center;
  color: #6a7d71;
  font-size: 13px;
  animation: kms-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

html body .kms .kms-empty strong {
  color: #17251d;
  font-size: 15px;
}

html body .kms .kms-empty__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: #eef7f1;
  color: #167a3f;
}

html body .kms .kms-retry {
  margin-top: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: #167a3f;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

/* Phones: one column, bigger targets, panel fits above the keyboard */
@media (max-width: 760px) {
  html body .catalog-search-dropdown.kms:not(#kms-a):not(#kms-b) {
    top: calc(100% + 8px) !important;
    border-radius: 18px !important;
    max-height: var(--suggestions-available-height, 70vh) !important;
  }

  html body .kms .kms-scroll {
    padding: 8px;
  }

  html body .kms .kms-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  html body .kms .kms-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -8px 8px;
    padding: 2px 8px 10px;
    scrollbar-width: none;
  }

  html body .kms .kms-chips::-webkit-scrollbar {
    display: none;
  }

  html body .kms .kms-thumb {
    flex-basis: 56px;
    width: 56px;
    height: 56px;
    border-radius: 12px;
  }

  html body .kms .kms-go {
    display: none;
  }

  html body .kms .kms-tile:hover {
    transform: none;
  }
}

/* ============ Home page panel (.hs-ac-*) — same tiles ============ */

html body .home-search-autocomplete:not(#kms-a) .hs-ac-header {
  display: none !important;
}

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) {
  border: 1px solid rgba(22, 122, 63, 0.14) !important;
  border-radius: 22px !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(17, 54, 33, 0.06), 0 18px 40px -12px rgba(17, 54, 33, 0.22) !important;
  padding: 10px !important;
  max-height: min(600px, var(--suggestions-available-height, 600px)) !important;
}

html body .home-search-autocomplete:not([hidden]):not(#kms-a) {
  animation: kms-pop 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-list {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  align-content: start !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)) !important;
  gap: 8px !important;
  margin: 0 !important;
  padding: 0 !important;
}

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 8px 10px 8px 8px !important;
  text-align: left !important;
  border: 1px solid #edf2ee !important;
  border-radius: 16px !important;
  background: #fff !important;
  cursor: pointer !important;
  animation: kms-in 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

html body .home-search-autocomplete .hs-ac-item:nth-child(2) { animation-delay: 30ms; }
html body .home-search-autocomplete .hs-ac-item:nth-child(3) { animation-delay: 60ms; }
html body .home-search-autocomplete .hs-ac-item:nth-child(4) { animation-delay: 90ms; }
html body .home-search-autocomplete .hs-ac-item:nth-child(5) { animation-delay: 120ms; }
html body .home-search-autocomplete .hs-ac-item:nth-child(6) { animation-delay: 150ms; }
html body .home-search-autocomplete .hs-ac-item:nth-child(7) { animation-delay: 180ms; }

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-item:is(:hover, [aria-selected="true"], .is-selected, .is-active) {
  border-color: #bfe0cb !important;
  background: #f7fbf8 !important;
  box-shadow: 0 8px 18px -10px rgba(17, 54, 33, 0.35) !important;
  transform: translateY(-2px) !important;
}

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-item-cover {
  position: relative !important;
  display: grid !important;
  place-items: center !important;
  flex: 0 0 60px !important;
  width: 60px !important;
  height: 60px !important;
  overflow: hidden !important;
  border-radius: 13px !important;
  background: linear-gradient(140deg, #eef7f1, #e1f0e7) !important;
  color: #6aa585 !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-photo {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-content {
  padding: 0 !important;
  align-items: flex-start !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-top {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 4px !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-name {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  overflow: hidden !important;
  color: #17251d !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  line-height: 1.3 !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-name b {
  padding: 0 1px;
  border-radius: 4px;
  background: #d9f2e2;
  color: #0e5f30;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-price {
  display: inline-flex !important;
  align-items: center !important;
  height: 20px !important;
  padding: 0 7px !important;
  border-radius: 999px !important;
  background: #e9f6ee !important;
  color: #0e5f30 !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-meta {
  display: block !important;
  max-width: 100% !important;
  overflow: hidden !important;
  color: #6a7d71 !important;
  font-size: 12px !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-footer {
  margin: 10px -10px -10px !important;
  border-top: 1px solid #edf2ee !important;
}

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-show-all-btn {
  width: 100% !important;
  min-height: 48px !important;
  border: 0 !important;
  border-radius: 0 0 22px 22px !important;
  background: #fbfdfb !important;
  color: #0e5f30 !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  box-shadow: none !important;
}

html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-show-all-btn:hover {
  background: #e9f6ee !important;
}

@media (max-width: 760px) {
  html body .home-search-autocomplete:not(#kms-a) .hs-ac-list {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  html body .home-search-autocomplete:not(#kms-a):not(#kms-b) {
    padding: 8px !important;
    border-radius: 18px !important;
  }

  html body .home-search-autocomplete:not(#kms-a):not(#kms-b) .hs-ac-item-cover {
    flex-basis: 54px !important;
    width: 54px !important;
    height: 54px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .kms,
  html body .kms *,
  html body .home-search-autocomplete,
  html body .home-search-autocomplete * {
    animation: none !important;
    transition: none !important;
  }
}

html body .home-search-autocomplete:not(#kms-a) .hs-ac-item-sep {
  margin: 0 5px !important;
  opacity: 0.6;
}
