/*
 * Estilo único do site. As páginas normais carregam este arquivo; as AMP o
 * embutem em <style amp-custom> (ver `setup_static_assets` em application.py), então
 * nada aqui pode usar !important nem @import, que o AMP rejeita.
 */

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-hover: #eef3ff;
    --border: #e1e6ef;
    --text: #172033;
    --muted: #5b6678;
    --accent: #2350d8;
    --accent-hover: #1a3fb0;
    --accent-soft: #e8eeff;
    --warn-bg: #fff4e0;
    --warn-border: #f2c879;
    --warn-text: #6b4300;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141d;
        --surface: #171e2a;
        --surface-hover: #1f2939;
        --border: #2a3446;
        --text: #e6ebf3;
        --muted: #9aa6b8;
        --accent: #7c9cff;
        --accent-hover: #a3bbff;
        --accent-soft: #1f2a45;
        --warn-bg: #33270f;
        --warn-border: #6e5320;
        --warn-text: #ffd88f;
        --shadow: none;
        color-scheme: dark;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    line-height: 1.25;
}

img {
    max-width: 100%;
}

.hide {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Topo */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 760px;
    margin: 0 auto;
    padding: 12px 16px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo:hover {
    color: var(--text);
    text-decoration: none;
}

.logo img,
.logo amp-img {
    width: 32px;
    height: 32px;
}

/* O ícone é claro e some no fundo branco; no escuro ele fica como está. */
@media (prefers-color-scheme: light) {
    .logo img,
    .logo amp-img {
        filter: brightness(0.35);
    }
}

.search {
    display: flex;
    flex: 1;
    min-width: 0;
}

.search input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 10px 0 0 10px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.search input:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--surface);
}

.search button {
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 0 10px 10px 0;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.search button:hover {
    background: var(--accent-hover);
}

@media (prefers-color-scheme: dark) {
    .search button {
        color: #0f141d;
    }
}

/* Corpo: coluna central com os anúncios laterais nas margens. */

.layout {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 0 16px;
}

.content {
    flex: 0 1 760px;
    min-width: 0;
    padding: 16px 0 32px;
}

.rail {
    flex: 0 0 160px;
    align-self: flex-start;
    padding-top: 16px;
}

@media (max-width: 1120px) {
    .rail {
        display: none;
    }
}

#top-global-ad {
    margin-bottom: 16px;
    text-align: center;
}

.ad-incontent {
    margin: 24px 0;
    text-align: center;
}

/*
 * Espaço reservado para os anúncios, para o conteúdo não pular quando eles
 * carregam (CLS, que conta no Core Web Vitals). Os tamanhos vêm da configuração
 * da Publift (breakpoints de 600px e 960px): a partir de 600px o topo e o
 * in-content são até 728x90; abaixo, o topo é 320x50 ou 320x100 e o in-content
 * vai até 300x250/336x280. Reserva-se o tamanho mais comum, não o maior, para
 * não deixar buraco quando vem o menor.
 *
 * Só onde o slot existe de fato: sem `data-fuse` (páginas de DDD) não há
 * anúncio, e a reserva viraria espaço em branco.
 */
#top-global-ad[data-fuse],
.ad-incontent[data-fuse] {
    min-height: 90px;
}

@media (max-width: 599px) {
    #top-global-ad[data-fuse] {
        min-height: 50px;
    }

    .ad-incontent[data-fuse] {
        min-height: 250px;
    }
}

.page-title {
    margin: 8px 0 20px;
    font-size: 28px;
    letter-spacing: -0.02em;
}

.section-title {
    margin: 28px 0 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Breadcrumbs */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0 0 16px;
    padding: 0;
    color: var(--muted);
    font-size: 14px;
    list-style: none;
}

.breadcrumb li + li::before {
    content: "›";
    margin-right: 4px;
    color: var(--border);
}

.breadcrumb .active {
    color: var(--muted);
}

/* Cartão principal */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 24px;
    padding: 24px;
}

.hero-text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.hero h1 {
    font-size: 36px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.hero h2 {
    color: var(--muted);
    font-size: 18px;
    font-weight: 500;
}

.hero-map {
    overflow: hidden;
    border-radius: 10px;
    background: var(--bg);
    aspect-ratio: 1;
}

.hero-map iframe,
.hero-map amp-iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 16px;
    margin: 4px 0 0;
}

.details div {
    min-width: 0;
}

.details dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

@media (prefers-color-scheme: dark) {
    .btn-primary,
    .btn-primary:hover {
        color: #0f141d;
    }
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* Aviso de CEP inativo */

.notice {
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--warn-border);
    border-radius: 10px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 15px;
}

.notice a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.tag {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--warn-bg);
    color: var(--warn-text);
    font-size: 12px;
    font-weight: 600;
}

/* Listas de resultados */

.results {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.results-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.box {
    display: block;
    min-width: 0;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
}

.box:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}

.box .title {
    color: var(--accent);
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.box p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 14px;
    overflow-wrap: anywhere;
}

.box-inativo .title {
    color: var(--muted);
}

/* Carregamento dos relacionados, que vêm por XHR depois da página. */

.related[aria-busy="true"] {
    min-height: 240px;
    border-radius: var(--radius);
    background: var(--surface);
    animation: pulse 1.4s ease-in-out infinite;
}

/* Só opacity: é o que o AMP aceita dentro de @keyframes. */
@keyframes pulse {
    50% {
        opacity: 0.5;
    }
}

@media (prefers-reduced-motion: reduce) {
    .related[aria-busy="true"] {
        animation: none;
    }
}

/* Facetas da busca */

.facets {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 8px;
    padding: 16px;
}

.facets h2 {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 14px;
}

.chip:hover {
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.chip .count {
    color: var(--muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.chip:hover .count {
    color: inherit;
}

.empty {
    padding: 32px 16px;
    color: var(--muted);
    text-align: center;
}

/* Rodapé */

.site-footer {
    padding: 24px 16px 32px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.site-footer nav {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

/* Anúncios fixos no rodapé. O breakpoint de 550px é o mesmo de antes do
   redesign: ele decide qual slot da Publift aparece. */

.sticky-top {
    position: -webkit-sticky;
    position: sticky;
    top: 16px;
}

.sticky-bottom {
    position: -webkit-sticky;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

#footer-desktop {
    display: block;
    width: 100%;
}

#footer-mobile {
    display: none;
    width: 100%;
}

@media (max-width: 550px) {
    #footer-desktop {
        display: none;
    }

    #footer-mobile {
        display: block;
    }
}

/* Telas estreitas */

@media (max-width: 640px) {
    .topbar-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px 12px;
    }

    .logo {
        justify-content: center;
    }

    .layout {
        padding: 0 12px;
    }

    .content {
        padding-top: 12px;
    }

    .page-title {
        font-size: 22px;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 18px;
    }

    .hero h1 {
        font-size: 30px;
    }

    .hero h2 {
        font-size: 16px;
    }

    .hero-map {
        aspect-ratio: 16 / 10;
    }

    .results,
    .results-compact {
        grid-template-columns: 1fr;
    }

    .facets {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 641px) and (max-width: 760px) {
    .results-compact {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
