/* ============================================================
   Hero Search Bar — hero-search.css
   Floating search panel below the Hero Section.
   Uses existing design-system variables from style.css.
   ============================================================ */

/* ── Section wrapper ─────────────────────────────────────── */
.hsearch {
  position: relative;
  z-index: 10;
  margin-top: 0;
  padding: 16px 0 16px;
  scroll-margin-top: 100px;
  animation: hs-fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Hero-actions has margin-bottom: -52px by default.
   Reset so the search bar sits cleanly below the cards. */
.hero-actions {
  margin-bottom: 0;
}

@keyframes hs-fadeUp {
  from { opacity: 0.4; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panel card ──────────────────────────────────────────── */
.hsearch__panel {
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 4px 16px rgba(21, 89, 69, 0.07),
    0 20px 60px rgba(21, 89, 69, 0.10);
  padding: 28px 32px 24px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.hsearch__panel:hover {
  box-shadow:
    0 6px 24px rgba(21, 89, 69, 0.10),
    0 28px 72px rgba(21, 89, 69, 0.14);
  transform: translateY(-2px);
}

/* ── Inner row ───────────────────────────────────────────── */
.hsearch__row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

/* ── Each field slot ─────────────────────────────────────── */
.hsearch__field {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hsearch__field--price {
  flex: 1.3;
}

.hsearch__field--btn {
  flex: 0.85;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

/* ── Field label ─────────────────────────────────────────── */
.hsearch__label {
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-light, #787878);
  display: block;
  padding-left: 2px;
  user-select: none;
}

/* ── Shared control height & base styles ─────────────────── */
.hsearch__dd,
.hsearch__price-wrap {
  position: relative;
  height: 52px;
}

/* ── Custom dropdown ─────────────────────────────────────── */
.hsearch__dd-trigger {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  background: #ffffff;
  border: 1.5px solid var(--color-border, #ebebeb);
  border-radius: 12px;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--color-text-main, #000);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  outline: none;
}

.hsearch__dd-trigger:hover {
  border-color: var(--color-primary, #155945);
}

.hsearch__dd-trigger:focus-visible {
  border-color: var(--color-primary, #155945);
  box-shadow: 0 0 0 3px rgba(21, 89, 69, 0.15);
}

.hsearch__dd.is-active .hsearch__dd-trigger {
  border-color: var(--color-primary, #155945);
  color: var(--color-primary, #155945);
  font-weight: 500;
}

.hsearch__dd.is-open .hsearch__dd-trigger {
  border-color: var(--color-primary, #155945);
  box-shadow: 0 0 0 3px rgba(21, 89, 69, 0.12);
}

.hsearch__dd-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Arrow icon */
.hsearch__dd-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--color-text-light, #787878);
  transition: transform 0.22s ease, color 0.22s ease;
}

.hsearch__dd.is-open .hsearch__dd-arrow {
  transform: rotate(180deg);
  color: var(--color-primary, #155945);
}

/* Dropdown menu */
.hsearch__dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #ffffff;
  border: 1.5px solid var(--color-border, #ebebeb);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(21, 89, 69, 0.12);
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px) scaleY(0.96);
  transform-origin: top center;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.hsearch__dd.is-open .hsearch__dd-menu {
  opacity: 1;
  transform: translateY(0) scaleY(1);
  pointer-events: auto;
}

.hsearch__dd-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--color-text-main, #000);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.hsearch__dd-option:hover {
  background: rgba(21, 89, 69, 0.06);
  color: var(--color-primary, #155945);
}

.hsearch__dd-option.is-selected {
  background: rgba(21, 89, 69, 0.08);
  color: var(--color-primary, #155945);
  font-weight: 500;
}

/* ── Price range inputs ──────────────────────────────────── */
.hsearch__price-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--color-border, #ebebeb);
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hsearch__price-wrap:hover {
  border-color: var(--color-primary, #155945);
}

.hsearch__price-wrap:focus-within {
  border-color: var(--color-primary, #155945);
  box-shadow: 0 0 0 3px rgba(21, 89, 69, 0.12);
}

.hsearch__price-wrap.is-active {
  border-color: var(--color-primary, #155945);
}

.hsearch__price-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--color-text-main, #000);
  padding: 0 12px;
  -moz-appearance: textfield;
  text-align: center;
}

.hsearch__price-input::placeholder {
  color: var(--color-text-light, #787878);
  font-weight: 400;
}

.hsearch__price-input:focus {
  color: var(--color-primary, #155945);
}

.hsearch__price-sep {
  flex-shrink: 0;
  color: var(--color-text-light, #787878);
  font-size: 1rem;
  padding: 0 2px;
  user-select: none;
}

/* BYN badge (appended via JS) */
.hsearch__price-currency {
  flex-shrink: 0;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-light, #787878);
  padding-right: 10px;
  user-select: none;
}

/* ── Search button ───────────────────────────────────────── */
.hsearch__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  padding: 0 20px;
  border: none;
  border-radius: 12px;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition:
    background 0.25s ease,
    box-shadow 0.25s ease,
    opacity 0.25s ease,
    transform 0.2s ease;

  /* Inactive state */
  background: #e8ede8;
  color: #9aaa9a;
  box-shadow: none;
}

.hsearch__btn:disabled {
  cursor: default;
  pointer-events: none;
}

.hsearch__btn.is-active {
  background: var(--color-primary, #155945);
  color: #ffffff;
  box-shadow:
    0 4px 14px rgba(21, 89, 69, 0.30),
    0 2px 6px rgba(21, 89, 69, 0.20);
  pointer-events: auto;
  cursor: pointer;
}

.hsearch__btn.is-active:hover {
  background: #1a6d52;
  box-shadow:
    0 6px 20px rgba(21, 89, 69, 0.38),
    0 3px 8px rgba(21, 89, 69, 0.25);
  transform: translateY(-1px);
}

.hsearch__btn.is-active:active {
  transform: translateY(0);
  box-shadow:
    0 2px 8px rgba(21, 89, 69, 0.22);
}

.hsearch__btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(21, 89, 69, 0.25);
}

.hsearch__btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Object counter ──────────────────────────────────────── */
.hsearch__counter {
  margin: 0;
  padding-top: 8px;
  font-family: var(--font-main, "Inter", sans-serif);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-light, #787878);
  text-align: center;
  letter-spacing: 0.01em;
  min-height: 18px;
}

.hsearch__counter-num {
  font-weight: 600;
  color: var(--color-primary, #155945);
  display: inline-block;
  transition: color 0.2s ease;
}

/* ── Shimmer while objects.json is loading ───────────────── */
.hsearch__counter-num.is-loading {
  color: transparent;
  background: linear-gradient(
    90deg,
    #d8e8e3 25%,
    #b0cfc6 50%,
    #d8e8e3 75%
  );
  background-size: 200% 100%;
  border-radius: 4px;
  min-width: 1.6em;
  animation: hs-shimmer 1.4s ease-in-out infinite;
  user-select: none;
}

@keyframes hs-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ── Dividers between fields ─────────────────────────────── */
.hsearch__divider {
  width: 1px;
  background: var(--color-border, #ebebeb);
  align-self: stretch;
  flex-shrink: 0;
  margin: 0 4px;
}

/* ── Responsive ──────────────────────────────────────────── */

/* Tablet */
@media (max-width: 1100px) {
  .hsearch__panel {
    padding: 24px 24px 20px;
  }
  .hsearch__row {
    gap: 8px;
  }
}

@media (max-width: 900px) {
  .hsearch {
    margin-top: -40px;
  }
  .hsearch__panel {
    padding: 20px 20px 18px;
    border-radius: 16px;
  }
  .hsearch__row {
    gap: 6px;
  }
  .hsearch__dd-trigger,
  .hsearch__price-wrap,
  .hsearch__dd,
  .hsearch__price-wrap {
    font-size: 0.875rem;
  }
}

/* Mobile — vertical stack */
@media (max-width: 767px) {
  .hsearch {
    margin-top: -24px;
  }
  .hsearch__panel {
    padding: 20px 18px 18px;
    border-radius: 16px;
  }
  .hsearch__row {
    flex-direction: column;
    gap: 10px;
  }
  .hsearch__field,
  .hsearch__field--price,
  .hsearch__field--btn {
    flex: none;
  }
  .hsearch__divider {
    display: none;
  }
  .hsearch__btn {
    height: 52px;
    font-size: 1rem;
  }
  .hsearch__counter {
    text-align: center;
  }
}
