/* Busca no topo (02/12/2026) — componente comum a todos os modelos (js/busca-topo.js).
   Cada modelo ajusta SÓ por variáveis, com regras pequenas:  html[data-modelo="<id>"] .busca-topo { --bt-fundo: ...; }
   --bt-fundo / --bt-texto / --bt-borda / --bt-raio / --bt-destaque / --bt-destaque-texto: barra e pílula no cabeçalho
   --bt-painel-fundo / --bt-painel-texto / --bt-painel-borda / --bt-painel-raio: caixa (computador) e folha (celular) que abrem ao tocar
   --bt-largura: largura da barra no computador · --bt-tamanho: compacta | completa (padrão do modelo; o construtor pode trocar) */
.busca-topo {
  --bt-texto: currentColor;
  --bt-fundo: color-mix(in srgb, currentColor 7%, transparent);
  --bt-borda: color-mix(in srgb, currentColor 22%, transparent);
  --bt-raio: var(--raio-botao, 999px);
  --bt-destaque: var(--destaque);
  --bt-destaque-texto: var(--destaque-texto);
  --bt-painel-fundo: var(--claro);
  --bt-painel-texto: var(--claro-texto);
  --bt-painel-borda: var(--linha-clara);
  --bt-painel-raio: 18px;
  --bt-fonte: var(--f-texto);
  --bt-largura: 420px;
  position: relative; display: flex; align-items: center; flex: 0 1 var(--bt-largura); min-width: 0;
  color: var(--bt-texto); font-family: var(--bt-fonte);
}
.busca-topo[data-tamanho="completa"] { --bt-largura: 680px; }
.busca-topo[data-tamanho="completa"][data-sem-extras] { --bt-largura: 420px; }
.busca-topo[data-oculta], .busca-topo[hidden] { display: none !important; }
.btopo-so-leitor { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* barra (computador, no alto da página) */
.btopo-barra { width: 100%; }
.busca-topo[data-estado="pilula"] .btopo-barra { display: none; }
.busca-topo .btopo-form { display: flex; align-items: center; gap: 4px; height: 46px; padding: 4px; border: 1px solid var(--bt-borda); background: var(--bt-fundo); border-radius: var(--bt-raio); }
.busca-topo .btopo-form:focus-within { border-color: color-mix(in srgb, var(--bt-destaque) 70%, transparent); }
.btopo-fin { display: flex; gap: 2px; flex: none; }
.btopo-fin button { height: 36px; min-width: 44px; padding: 0 13px; border: 0; border-radius: max(0px, calc(var(--bt-raio) - 4px)); background: none; color: inherit; font: 600 13px/1 var(--bt-fonte); letter-spacing: .01em; cursor: pointer; opacity: .78; transition: background .2s, color .2s, opacity .2s; }
.btopo-fin button:hover { opacity: 1; }
.btopo-fin button[aria-pressed="true"] { background: var(--bt-destaque); color: var(--bt-destaque-texto); opacity: 1; }
.btopo-q { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 100%; padding: 0 6px 0 10px; cursor: text; }
.btopo-fin + .btopo-q { border-left: 1px solid var(--bt-borda); margin-left: 4px; }
.btopo-lupa { display: grid; flex: none; opacity: .6; }
.btopo-lupa svg, .btopo-ir svg, .btopo-pilula svg { width: 17px; height: 17px; }
.btopo-q input { flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; outline: 0; background: none; color: inherit; font: 400 14px/1.2 var(--bt-fonte); -webkit-appearance: none; appearance: none; }
.btopo-q input::placeholder { color: inherit; opacity: .62; }
.btopo-q input::-webkit-search-cancel-button, .btopo-q input::-webkit-calendar-picker-indicator { -webkit-appearance: none; display: none !important; }
.busca-topo .btopo-q input:focus-visible, .btopo-painel .btopo-q input:focus-visible, .btopo-sel select:focus-visible { outline: 0; } /* o contorno vai na caixa inteira (:focus-within) */
.btopo-sel { flex: 0 1 150px; min-width: 0; height: 100%; display: flex; border-left: 1px solid var(--bt-borda); }
.btopo-sel select { width: 100%; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: 500 13px/1 var(--bt-fonte); padding: 0 10px; cursor: pointer; }
.btopo-sel select option { color: #1A1815; background: #fff; }
.busca-topo[data-sem-extras] .btopo-extra { display: none; }
.btopo-ir { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; min-width: 36px; padding: 0 10px; border: 0; border-radius: max(0px, calc(var(--bt-raio) - 4px)); background: var(--bt-destaque); color: var(--bt-destaque-texto); font: 600 13px/1 var(--bt-fonte); cursor: pointer; transition: filter .2s; }
.btopo-ir:hover { filter: brightness(1.08); }
.busca-topo .btopo-ir span { display: none; }

/* pílula (depois de rolar, sem espaço, ou no celular) */
.btopo-pilula { display: none; align-items: center; justify-content: center; gap: 8px; height: 44px; min-width: 44px; padding: 0 16px 0 14px; border: 1px solid var(--bt-borda); border-radius: var(--bt-raio); background: var(--bt-fundo); color: inherit; font: 600 13px/1 var(--bt-fonte); letter-spacing: .01em; cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s; }
.btopo-pilula:hover { border-color: color-mix(in srgb, currentColor 45%, transparent); }
.busca-topo[data-estado="pilula"] { flex: none; }
.busca-topo[data-estado="pilula"] .btopo-pilula { display: inline-flex; }
.busca-topo[data-lupa] .btopo-pilula { width: 44px; padding: 0; }
.busca-topo[data-lupa] .btopo-pilula span { display: none; }
.busca-topo :focus-visible, .btopo-painel :focus-visible { outline: 2px solid var(--bt-destaque); outline-offset: 2px; }
.menu-aberto .busca-topo { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .busca-topo[data-estado="pilula"] .btopo-pilula { animation: btopo-entra .28s cubic-bezier(.22, 1, .36, 1); }
  .busca-topo[data-estado="barra"] .btopo-barra { animation: btopo-entra .28s cubic-bezier(.22, 1, .36, 1); }
}
@keyframes btopo-entra { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* painel: caixa embaixo do cabeçalho (computador) ou folha que desce do topo (celular) */
html.btopo-aberta { overflow: hidden; }
.btopo-painel { position: fixed; inset: 0; z-index: 105; font-family: var(--bt-fonte, var(--f-texto)); }
.btopo-fundo { position: absolute; inset: 0; background: rgba(10, 10, 12, .42); }
.btopo-folha { position: absolute; top: var(--bt-topo, 84px); left: 50%; transform: translateX(-50%); width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - var(--bt-topo, 84px) - 16px); overflow: auto; overscroll-behavior: contain;
  background: var(--bt-painel-fundo, #fff); color: var(--bt-painel-texto, #1A1815); border: 1px solid var(--bt-painel-borda, rgba(0, 0, 0, .1)); border-radius: var(--bt-painel-raio, 18px); padding: 18px 20px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.btopo-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.btopo-cab strong { font: 600 16px/1.2 var(--bt-fonte, var(--f-texto)); letter-spacing: -.005em; }
.btopo-x { width: 44px; height: 44px; margin: -8px -10px -8px 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.btopo-x svg { width: 20px; height: 20px; }
.btopo-x:hover { background: color-mix(in srgb, currentColor 8%, transparent); }
.btopo-form-painel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.btopo-painel[data-tamanho="completa"] .btopo-form-painel { grid-template-columns: auto minmax(0, 1fr) minmax(0, 170px) minmax(0, 170px) auto; }
/* carteira só de venda (ou só de aluguel): sem Comprar | Alugar, o campo de texto fica com a sobra */
@media (min-width: 1025px) {
  .btopo-form-painel:not(:has(> .btopo-fin)) { grid-template-columns: minmax(0, 1fr) auto; }
  .btopo-painel[data-tamanho="completa"] .btopo-form-painel:not(:has(> .btopo-fin)) { grid-template-columns: minmax(0, 1fr) minmax(0, 170px) minmax(0, 170px) auto; }
}
.btopo-form-painel .btopo-fin { padding: 4px; border: 1px solid var(--bt-painel-borda, rgba(0, 0, 0, .12)); border-radius: min(var(--bt-raio, 999px), 14px); }
.btopo-form-painel .btopo-fin button { height: 42px; padding: 0 16px; font-size: 14px; border-radius: max(0px, calc(min(var(--bt-raio, 999px), 14px) - 4px)); }
.btopo-form-painel .btopo-q, .btopo-form-painel .btopo-sel { height: 52px; border: 1px solid var(--bt-painel-borda, rgba(0, 0, 0, .12)); border-radius: min(var(--bt-raio, 999px), 14px); background: color-mix(in srgb, currentColor 3%, transparent); margin: 0; padding: 0 14px; }
.btopo-form-painel .btopo-q:focus-within, .btopo-form-painel .btopo-sel:focus-within { border-color: var(--bt-destaque); }
.btopo-form-painel .btopo-q input { font-size: 16px; } /* 16 px: o iPhone não dá zoom ao tocar */
.btopo-form-painel .btopo-sel select { padding: 0; font-size: 15px; }
.btopo-form-painel .btopo-ir { height: 52px; padding: 0 22px; font-size: 15px; border-radius: min(var(--bt-raio, 999px), 14px); }
.btopo-form-painel .btopo-ir span { display: inline; }
.btopo-todos { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; opacity: .8; }
.btopo-todos:hover { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .btopo-painel .btopo-fundo { animation: btopo-fundo .22s ease-out; }
  .btopo-painel[data-modo="caixa"] .btopo-folha { animation: btopo-caixa .26s cubic-bezier(.22, 1, .36, 1); }
  .btopo-painel[data-modo="folha"] .btopo-folha { animation: btopo-folha .3s cubic-bezier(.22, 1, .36, 1); }
}
@keyframes btopo-fundo { from { opacity: 0; } }
@keyframes btopo-caixa { from { opacity: 0; transform: translate(-50%, -8px); } }
@keyframes btopo-folha { from { transform: translateY(-100%); } }

@media (max-width: 1024px) {
  .busca-topo { flex: none; }
  .busca-topo .btopo-pilula { padding: 0 14px 0 12px; }
  .btopo-painel[data-modo="folha"] .btopo-folha { top: 0; left: 0; right: 0; width: auto; transform: none; max-height: 100dvh; border-radius: 0 0 var(--bt-painel-raio, 18px) var(--bt-painel-raio, 18px); border-width: 0 0 1px; padding: 14px 16px calc(18px + env(safe-area-inset-bottom)); }
  .btopo-form-painel, .btopo-painel[data-tamanho="completa"] .btopo-form-painel { grid-template-columns: 1fr 1fr; }
  .btopo-form-painel .btopo-fin, .btopo-form-painel .btopo-q, .btopo-form-painel .btopo-ir { grid-column: 1 / -1; }
  .btopo-form-painel .btopo-fin { display: grid; grid-template-columns: 1fr 1fr; }
  .btopo-form-painel .btopo-fin button { height: 44px; }
}
@media (max-width: 600px) {
  .busca-topo .btopo-pilula { width: 44px; padding: 0; }
  .busca-topo .btopo-pilula span { display: none; }
}
/* Assinatura (o site de sempre): mais perto do botão do menu no celular, sem mexer no resto */
@media (max-width: 1024px) { html:not([data-modelo]) .busca-topo { margin-right: -24px; } }

/* ---- modelos antigos (vitrine, bairro e lançamentos usam css/site-modelos.css; os novos ajustam no próprio css/modelos/<id>.css) ---- */
/* Lançamentos: cabeçalho em grade (menu | marca | botão). A busca fica na 3ª coluna, colada na marca; no celular, à esquerda (simétrica ao menu). */
html[data-modelo="lancamentos"] .busca-topo { grid-column: 3; grid-row: 1; justify-self: start; --bt-raio: 0px; }
html[data-modelo="lancamentos"] .busca-topo .btopo-pilula, html[data-modelo="lancamentos"] .btopo-fin button { text-transform: uppercase; letter-spacing: .12em; font-size: 11px; }
@media (max-width: 1024px) { html[data-modelo="lancamentos"] .busca-topo { grid-column: 1; justify-self: start; } }
