/* Components: Hero */

/* ---- Hero Section ---- */
.hero {
  position: relative;
  z-index: 10;
  background: var(--color-nav);
  color: #fff;
  padding: var(--space-4xl) 0;
  overflow: visible;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.3;
  overflow: hidden;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  color: #fff;
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-md);
}

.hero p {
  font-size: var(--font-size-lg);
  opacity: 0.85;
  margin-bottom: var(--space-xl);
}

@media (max-width: 768px) {
  .hero {
    padding: var(--space-3xl) 0;
  }
  .hero h1 {
    font-size: var(--font-size-2xl);
  }
}

/* ================================================================
   UNIFIED SEARCH BAR (USB)
   The search "pill" is the entire .usb-input-wrap — a white rounded
   container with the input, GPS button, and submit button inside.
   The submit button has NO border — the pill's white background
   surrounding it creates the visual border effect.
   Two variants: kpdd-search-form[hero] (homepage) and kpdd-search-form:not([hero]) (filter bar)
   ================================================================ */

/* ---- Base ---- */
.usb {
  position: relative;
}

.usb-form {
  margin: 0;
}

/* ---- Input Row ---- */
.usb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Form margin reset — kpdd-search-form is rendered inside layout
   columns that don't want its inherent margin. */
.usb-form {
  margin: 0;
}

/* Visually-hidden radio inputs that drive .usb-tab labels. Display:none
   would yank them from form submission and keyboard nav, so we keep
   them in the DOM but offscreen-style. */
.usb-tab-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Autocomplete host inside the search form is purely structural — no
   layout box. */
.usb-autocomplete { display: contents; }

/* The pill — the whole row IS the search pill */
.usb-input-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  background: #fff;
  border-radius: 100px;
  padding: 4px;
  gap: 10px;
  height: 38px;
  border: 1.5px solid var(--color-border);
}

/* Hero variant sizing — sits on a photo background. Gap / height /
   no-border / shadow values were previously emitted as inline styles
   in `searchForm.js`; moved here so .usb--overlay can cleanly
   override without `!important`. Two more hero rules (`box-shadow`
   + `border-radius`) live further down in the file alongside the
   tab-color rules. */
kpdd-search-form[hero] .usb-input-wrap {
  gap: 14px;
  height: 52px;
  border: none;
}

/* ---- Mirror Input System ---- */
/* The pill looks like an input. The real <input> is invisible on top,
   capturing keystrokes. Below it, mirror divs show typed text (black)
   and autocomplete suggestion (gray). */
.usb-mirror-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Real input — sits on top, fully transparent, captures all events */
.usb-input {
  position: relative;
  z-index: 2;
  width: 100%;
  border: none;
  border-radius: 100px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: normal;
  background: transparent;
  color: transparent; /* real text hidden; mirrors show visible text */
  caret-color: var(--color-text, #1a1a1a);
  outline: none;
  padding: 10px 0 10px 20px;
}

.usb-input::selection {
  background: rgba(59, 130, 246, 0.3);
  color: transparent;
}

/* Mirror layer — typed text + ghost suggestion, positioned under the input */
.usb-mirror {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 10px 0 10px 20px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: normal;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  z-index: 1;
}

.usb-mirror-typed {
  color: #1a1a1a;
}

.usb-mirror-ghost {
  color: #9ca3af;
}

/* Placeholder — shown when input is empty */
.usb-mirror-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 10px 0 10px 20px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: normal;
  color: var(--color-muted);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  z-index: 1;
}

.usb-input::placeholder {
  color: transparent;
}

/* ---- GPS Button (inside pill, before submit) ---- */
.usb-gps-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 16px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.usb-gps-btn:hover {
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 8%, transparent);
}

.usb-gps-btn.locating {
  color: var(--color-primary);
  animation: pulse-gps 1s ease-in-out infinite;
}

@keyframes pulse-gps {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Submit Button (inside pill, rightmost) ---- */
/* NO border on the button — the pill's white background IS the border */
.usb-submit-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  border: none;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

/* In hero, submit shows label text; in filter, submit shows just the magnifying glass icon */
kpdd-search-form[hero] .usb-submit-icon--filter {
  display: none;
}

.usb-submit-btn:hover {
  background: color-mix(in srgb, var(--color-primary) 85%, #000);
}

.usb-submit-btn i {
  font-size: 13px;
}

/* ================================================================
   HERO VARIANT — centered card with tabs above, dark bg context
   Host layout is in shadow DOM; these rules style light DOM children.
   ================================================================ */

/* Category Tabs (above the pill on hero) — radio inputs */
.usb-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  border-bottom: 2px solid rgba(255,255,255,0.2);
}

.usb-tab {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Jost', 'Jost Fallback', system-ui, sans-serif;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  transition: color 0.15s, border-color 0.15s;
}

.usb-tab input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.usb-tab:hover {
  color: rgba(255,255,255,0.85);
}

.usb-tab:has(input:checked) {
  color: #fff;
  border-bottom-color: #fff;
}

/* Hero pill sizing */
kpdd-search-form[hero] .usb-input-wrap {
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

kpdd-search-form[hero] .usb-input {
  font-size: 16px;
  padding: 14px 0 14px 24px;
  caret-color: #1a1a1a;
}

kpdd-search-form[hero] .usb-mirror,
kpdd-search-form[hero] .usb-mirror-placeholder {
  font-size: 16px;
  padding: 14px 0 14px 24px;
}

kpdd-search-form[hero] .usb-gps-btn {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

kpdd-search-form[hero] .usb-submit-btn {
  padding: 0 28px;
  font-size: 15px;
  height: 44px;
  line-height: 25px;
}

@media (max-width: 575px) {
  kpdd-search-form[hero] .usb-input {
    font-size: 14px;
    padding: 10px 0 10px 16px;
  }

  kpdd-search-form[hero] .usb-mirror,
  kpdd-search-form[hero] .usb-mirror-placeholder {
    font-size: 14px;
    padding: 10px 0 10px 16px;
  }

  kpdd-search-form[hero] .usb-submit-label {
    display: none;
  }

  kpdd-search-form[hero] .usb-submit-btn {
    padding: 10px 14px;
    height: auto;
  }
}

/* ================================================================
   GOOGLE-STYLE OVERLAY — hero search expands on focus
   Search bar pins to top, white bg, results fill below.
   ================================================================ */

/* Sizing / scroll-lock / safe-area / animation are owned by the
   <kpdd-overlay-host> shadow-root CSS — see
   public/js/components/kpdd-overlay-host.js. The autocomplete just
   slots the search form into a host element on _enterOverlay. */

kpdd-search-form.usb--overlay {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* min-height:0 is the magic flex incantation — without it, the
     dropdown's `flex:1; overflow-y:auto` resolves against an
     unbounded parent and the whole column scrolls instead of just
     the results list. */
  min-height: 0;
  max-width: none;
  margin: 0;
  /* Edge-to-edge layout (matches Google's mobile search). Only the
     search pill itself gets a small inset (added in the
     `.usb-input-wrap` rule below) so it doesn't kiss the screen
     edge — section headers and result rows run full width. */
  padding: var(--space-md) 0 0;
  background: #fff;
}

/* Tabs in overlay: re-themed for the white background. Sits above the
   flat search row so the visitor can switch contexts (Residential /
   Rental / Commercial / Land) before typing. The hero variant's
   white-on-dark tab styles don't apply here — they were authored
   against a hero photo background. */
kpdd-search-form.usb--overlay .usb-tabs {
  display: flex;
  gap: 0;
  margin: 0;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  overflow-x: auto;
  scrollbar-width: none;
}
kpdd-search-form.usb--overlay .usb-tabs::-webkit-scrollbar { display: none; }

kpdd-search-form.usb--overlay .usb-tab {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-muted, #6b7280);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  flex: 0 0 auto;
  white-space: nowrap;
}
kpdd-search-form.usb--overlay .usb-tab:hover {
  color: var(--color-text, #1a1a1a);
}
kpdd-search-form.usb--overlay .usb-tab:has(input:checked) {
  color: var(--color-primary, #003366);
  border-bottom-color: var(--color-primary, #003366);
  font-weight: 600;
}

/* In overlay mode, the search bar is a flat 100%-wide row that
   buttts directly against the BEDS/PRICE chip row below. No pill
   chrome, no shadow, no side margins — the input IS the top of the
   panel. Only a bottom border separates it from the filters.
   Inline `border-radius` was stripped from the SSR template so this
   wins without `!important`. */
kpdd-search-form.usb--overlay .usb-input-wrap {
  box-shadow: none;
  border: none;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
  border-radius: 0;
  flex-shrink: 0;
  margin: 0;
  width: 100%;
}

/* Drop the blue circular submit button on the overlay — it competes
   with the result list for "primary action" attention. Replace with
   a quiet icon-only button. Submit still works on Enter or by tapping
   a result, which is the natural flow inside the overlay anyway. */
kpdd-search-form.usb--overlay .usb-submit-btn {
  background: transparent;
  color: var(--color-muted, #6b7280);
  padding: 8px;
  border-radius: var(--radius-md, 10px);
}
kpdd-search-form.usb--overlay .usb-submit-btn:hover {
  background: var(--color-bg-alt, #f3f4f6);
  color: var(--color-text, #1a1a1a);
}
kpdd-search-form.usb--overlay .usb-submit-label {
  display: none;
}

/* Input text dark in overlay — font-size must match mirror exactly */
kpdd-search-form.usb--overlay .usb-input {
  color: var(--color-text, #1a1a1a);
  font-size: 16px;
  padding: 12px 0;
}

/* Mirror layers must match input font-size and padding in overlay */
kpdd-search-form.usb--overlay .usb-mirror,
kpdd-search-form.usb--overlay .usb-mirror-placeholder {
  font-size: 16px;
  padding: 12px 0;
}

kpdd-search-form.usb--overlay .usb-input::placeholder {
  color: var(--color-muted, #9ca3af);
}

/* (search icon removed from pill — kept in submit button only) */

/* GPS button dark in overlay */
kpdd-search-form.usb--overlay .usb-gps-btn {
  color: var(--color-muted, #6b7280);
}

/* Dropdown in overlay: not absolute, flows in column, fills remaining
   space. No top border / margin — the search row above already has
   its own bottom border, and we want the BEDS/PRICE chip row to butt
   directly against the input. */
kpdd-search-form.usb--overlay .omni-dropdown {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin-top: 0;
  max-height: none;
  flex: 1;
  overflow-y: auto;
}

/* Close button for overlay */
kpdd-search-form.usb--overlay::before {
  content: '';
}

kpdd-search-form.usb--overlay .usb-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

kpdd-search-form.usb--overlay .usb-input-row {
  flex-shrink: 0;
}

/* Back/close button in overlay — flex child so it always sits at the
   start of the input row and never overlaps the input. */
.usb-overlay-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-muted, #6b7280);
  cursor: pointer;
  padding: 8px;
  margin-left: 4px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.usb-overlay-close:hover {
  background: var(--color-bg-alt, #f3f4f6);
  color: var(--color-text, #1a1a1a);
}

/* ================================================================
   FILTER VARIANT — same pill look, slightly smaller, in the filter bar
   Uses same colors and shape as hero for visual consistency.
   ================================================================ */

/* Host layout (flex, min/max-width, responsive order) handled by shadow DOM CSS */

kpdd-search-form:not([hero]) .usb-input-wrap {
  background: #fff;
  border: 1.5px solid var(--color-border);
  padding: 3px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

kpdd-search-form:not([hero]) .usb-input-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent);
}

kpdd-search-form:not([hero]) .usb-input {
  font-size: 14px;
  padding: 8px 0 8px 16px;
}

kpdd-search-form:not([hero]) .usb-mirror,
kpdd-search-form:not([hero]) .usb-mirror-placeholder {
  font-size: 14px;
  padding: 8px 0 8px 16px;
}

kpdd-search-form:not([hero]) .usb-gps-btn {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

kpdd-search-form:not([hero]) .usb-submit-btn {
  padding: 11px 14px;
  font-size: 12px;
}

kpdd-search-form:not([hero]) .usb-submit-label {
  display: none;
}

/* Submit button spinner animation */
.omni-spin {
  animation: omni-spin 0.8s linear infinite;
}
@keyframes omni-spin {
  to { transform: rotate(360deg); }
}

/* Responsive filter layout handled by shadow DOM CSS */
