:root {
    /* =====================================================
       CORES ATUAIS DA PLATAFORMA
    ====================================================== */

    --marrom-escuro: #361d15;
    --marrom-medio: #6f3928;
    --terracota: #c05a3e;
    --dourado: #e4a853;
    --fundo: #fcfaf7;
    --bege: #f3ede2;
    --branco: #ffffff;
    --texto: #4a3b32;
    --cinza: #6f6863;
    --erro: #a32626;

    /* =====================================================
       TIPOGRAFIA DA GALERIA PROVIDÊNCIA
    ====================================================== */

    --fonte-destaque: "Big Shoulders Display",
        "Arial Narrow",
        Impact,
        sans-serif;

    --fonte-texto: "Faustina",
        Georgia,
        "Times New Roman",
        serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overflow: hidden;

    color: var(--texto);
    background: var(--fundo);

    font-family: var(--fonte-texto);
    font-size: 16px;
    font-weight: 400;
}

/* Campos de formulário utilizam a fonte de leitura */
input,
select,
textarea,
option {
    font-family: var(--fonte-texto);
}

/* Botões utilizam a fonte de destaque */
button {
    font-family: var(--fonte-destaque);
}

/* =========================================================
   MAPA
========================================================= */

#mapa {
    width: 100%;
    height: 100vh;
    z-index: 1;
}

/* =========================================================
   PAINEL PRINCIPAL
========================================================= */

.painel-controle {
    position: absolute;
    z-index: 1000;
    top: 20px;
    left: 20px;

    width: 330px;
    max-height: calc(100vh - 40px);
    padding: 22px;

    overflow-y: auto;

    background: rgba(253, 251, 247, 0.97);
    border-top: 6px solid var(--terracota);
    border-radius: 14px;

    box-shadow: 0 10px 35px rgba(54, 29, 21, 0.2);
    backdrop-filter: blur(8px);
}

.painel-controle h1 {
    margin: 0;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 39px;
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: 0.01em;
}

.subtitulo {
    margin: 9px 0 22px;

    color: var(--terracota);

    font-family: var(--fonte-destaque);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;

    margin-bottom: 22px;
}

.card {
    padding: 15px 8px;

    color: var(--branco);
    text-align: center;

    background: linear-gradient(
        135deg,
        var(--marrom-escuro),
        var(--marrom-medio)
    );

    border-radius: 9px;
}

.card span {
    display: block;
    margin-bottom: 4px;

    color: var(--dourado);

    font-family: var(--fonte-destaque);
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
}

.card small {
    font-family: var(--fonte-destaque);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.grupo-filtro {
    margin-bottom: 16px;
}

.grupo-filtro label {
    display: block;
    margin-bottom: 6px;

    color: #555;

    font-family: var(--fonte-destaque);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.input-custom {
    width: 100%;
    padding: 11px 12px;

    color: var(--marrom-escuro);
    background: var(--branco);

    font-family: var(--fonte-texto);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.4;

    border: 1px solid #dfd5c6;
    border-radius: 7px;
}

.input-custom::placeholder {
    color: #817872;
    opacity: 1;

    font-family: var(--fonte-texto);
}

.input-custom:focus {
    outline: none;

    border-color: var(--terracota);
    box-shadow: 0 0 0 3px rgba(192, 90, 62, 0.15);
}

.btn-limpar {
    width: 100%;
    padding: 11px;
    margin-bottom: 15px;

    color: var(--branco);

    font-family: var(--fonte-destaque);
    font-size: 19px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;

    background: var(--marrom-escuro);
    border: 0;
    border-radius: 7px;

    cursor: pointer;

    transition:
        color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.btn-limpar:hover {
    background: var(--terracota);
    transform: translateY(-1px);
}

.btn-limpar:focus-visible {
    outline: 3px solid rgba(228, 168, 83, 0.65);
    outline-offset: 2px;
}

.contador-pontos {
    padding: 11px;

    color: var(--marrom-escuro);

    font-family: var(--fonte-texto);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;

    background: var(--bege);
    border-left: 4px solid var(--dourado);
    border-radius: 7px;
}

.contador-pontos strong,
.contador-pontos b {
    font-family: var(--fonte-destaque);
    font-size: 15px;
    font-weight: 700;
}

.mensagem-erro {
    margin-top: 12px;
    padding: 12px;

    color: #7a1d1d;

    font-family: var(--fonte-texto);
    font-size: 13px;
    line-height: 1.5;

    background: #ffecec;
    border-left: 4px solid #b52a2a;
    border-radius: 6px;
}

/* =========================================================
   PAINEL NARRATIVO
========================================================= */

.painel-detalhes {
    position: fixed;
    z-index: 1300;
    top: 0;
    right: 0;

    width: 440px;
    max-width: 100%;
    height: 100vh;

    overflow: hidden;

    background: var(--fundo);

    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.2);

    transform: translateX(105%);
    visibility: hidden;

    transition:
        transform 0.35s ease,
        visibility 0.35s ease;
}

.painel-detalhes.aberto {
    transform: translateX(0);
    visibility: visible;
}

.btn-fechar-detalhes {
    position: absolute;
    z-index: 3;
    top: 17px;
    right: 17px;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;
    padding: 0;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 31px;
    font-weight: 500;
    line-height: 1;

    background: rgba(243, 237, 226, 0.96);
    border: 0;
    border-radius: 50%;

    cursor: pointer;

    transition:
        color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.btn-fechar-detalhes:hover {
    color: var(--branco);
    background: var(--terracota);

    transform: rotate(5deg) scale(1.05);
}

.btn-fechar-detalhes:focus-visible {
    outline: 3px solid rgba(228, 168, 83, 0.65);
    outline-offset: 2px;
}

.conteudo-detalhes {
    height: 100%;
    padding: 72px 30px 40px;

    overflow-y: auto;
    overscroll-behavior: contain;
}

.estado-inicial-detalhes,
.estado-carregando,
.estado-erro {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    min-height: 70vh;

    text-align: center;
}

.estado-inicial-detalhes h2,
.estado-carregando h2,
.estado-erro h2 {
    margin: 15px 0 8px;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 31px;
    font-weight: 800;
    line-height: 1;
}

.estado-inicial-detalhes p,
.estado-carregando p,
.estado-erro p {
    max-width: 290px;

    color: var(--cinza);

    font-family: var(--fonte-texto);
    font-size: 15px;
    line-height: 1.7;
}

.icone-memoria {
    font-size: 42px;
}

.carregador {
    width: 42px;
    height: 42px;

    border: 4px solid #e9ded1;
    border-top-color: var(--terracota);
    border-radius: 50%;

    animation: girar 0.8s linear infinite;
}

@keyframes girar {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   CONTEÚDO DO VERBETE
========================================================= */

.detalhe-categoria {
    display: inline-block;

    padding: 6px 11px;
    margin-bottom: 15px;

    color: var(--branco);

    font-family: var(--fonte-destaque);
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.05em;
    text-transform: uppercase;

    border-radius: 5px;
}

.detalhe-titulo {
    margin: 0 0 20px;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 43px;
    font-weight: 800;
    line-height: 0.98;
    letter-spacing: 0.005em;
}

.detalhe-galeria {
    display: grid;
    gap: 12px;

    margin-bottom: 22px;
}

.detalhe-foto {
    display: block;

    width: 100%;
    max-height: 320px;

    object-fit: cover;

    background: var(--bege);

    border: 1px solid #ded3c4;
    border-radius: 10px;
}

.detalhe-descricao {
    margin: 0 0 24px;

    color: var(--texto);

    font-family: var(--fonte-texto);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.78;
    text-align: left;

    white-space: normal;
}

.detalhe-secao {
    margin-top: 24px;
    padding-top: 20px;

    border-top: 1px solid #e6ddd2;
}

.detalhe-secao h3 {
    margin: 0 0 12px;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 25px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
}

.detalhe-secao p {
    margin: 0;

    color: var(--texto);

    font-family: var(--fonte-texto);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.75;
}

.detalhe-meta {
    margin-top: 22px;

    overflow: hidden;

    background: #f7f2eb;
    border-radius: 10px;
}

.detalhe-meta-item {
    display: grid;
    grid-template-columns: 125px 1fr;
    gap: 10px;

    padding: 13px 15px;

    font-family: var(--fonte-texto);
    font-size: 13px;
    line-height: 1.55;

    border-bottom: 1px solid #e6ddd2;
}

.detalhe-meta-item:last-child {
    border-bottom: 0;
}

.detalhe-meta-item strong {
    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.15;
}

.detalhe-meta-item span {
    color: var(--cinza);

    font-family: var(--fonte-texto);
    font-weight: 400;

    overflow-wrap: anywhere;
}

.detalhe-fontes,
.detalhe-fontes p {
    font-family: var(--fonte-texto);
}

.detalhe-fontes a {
    color: var(--terracota);

    font-family: var(--fonte-texto);
    font-weight: 600;
    text-decoration: none;

    overflow-wrap: anywhere;
}

.detalhe-fontes a:hover {
    text-decoration: underline;
}

.detalhe-fontes a:focus-visible {
    outline: 2px solid var(--dourado);
    outline-offset: 2px;
}

/* =========================================================
   FUNDO ESCURECIDO — CELULAR
========================================================= */

.fundo-painel {
    position: fixed;
    z-index: 1250;
    inset: 0;

    width: 100%;
    height: 100%;
    padding: 0;

    background: rgba(20, 12, 8, 0.48);
    border: 0;

    cursor: pointer;
}

/* =========================================================
   POPUP E TOOLTIP
========================================================= */

.popup-verbete {
    min-width: 210px;

    font-family: var(--fonte-texto);
}

.popup-verbete h2 {
    margin: 0 0 8px;

    color: var(--marrom-escuro);

    font-family: var(--fonte-destaque);
    font-size: 24px;
    font-weight: 800;
    line-height: 1;
}

.popup-verbete p {
    margin: 5px 0;

    font-family: var(--fonte-texto);
    font-size: 12px;
    line-height: 1.55;
}

/* Textos internos do Leaflet */
.leaflet-popup-content,
.leaflet-tooltip {
    font-family: var(--fonte-texto);
}

.leaflet-control-zoom a {
    font-family: var(--fonte-destaque);
    font-weight: 700;
}

/* =========================================================
   BARRAS DE ROLAGEM
========================================================= */

.painel-controle::-webkit-scrollbar,
.conteudo-detalhes::-webkit-scrollbar {
    width: 8px;
}

.painel-controle::-webkit-scrollbar-track,
.conteudo-detalhes::-webkit-scrollbar-track {
    background: transparent;
}

.painel-controle::-webkit-scrollbar-thumb,
.conteudo-detalhes::-webkit-scrollbar-thumb {
    background: rgba(111, 57, 40, 0.35);
    border-radius: 20px;
}

.painel-controle::-webkit-scrollbar-thumb:hover,
.conteudo-detalhes::-webkit-scrollbar-thumb:hover {
    background: rgba(192, 90, 62, 0.65);
}

/* =========================================================
   RESPONSIVIDADE
========================================================= */

@media (min-width: 701px) {
    .fundo-painel {
        display: none;
    }
}

@media (max-width: 700px) {
    .painel-controle {
        top: 10px;
        left: 10px;

        width: calc(100% - 20px);
        max-height: 43vh;
        padding: 16px;
    }

    .painel-controle h1 {
        font-size: 34px;
    }

    .subtitulo {
        margin-bottom: 16px;
        font-size: 13px;
    }

    .dashboard-cards {
        margin-bottom: 15px;
    }

    .card {
        padding: 12px 6px;
    }

    .card span {
        font-size: 27px;
    }

    .card small {
        font-size: 10px;
    }

    .grupo-filtro label {
        font-size: 14px;
    }

    .painel-detalhes {
        top: auto;
        bottom: 0;

        width: 100%;
        height: 78vh;

        border-radius: 18px 18px 0 0;

        transform: translateY(105%);
    }

    .painel-detalhes.aberto {
        transform: translateY(0);
    }

    .conteudo-detalhes {
        padding: 65px 20px 35px;
    }

    .detalhe-categoria {
        font-size: 14px;
    }

    .detalhe-titulo {
        padding-right: 35px;

        font-size: 36px;
        line-height: 1;
    }

    .detalhe-secao h3 {
        font-size: 23px;
    }

    .detalhe-meta-item {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .detalhe-meta-item strong {
        font-size: 15px;
    }
}

/* =========================================================
   TELAS MUITO PEQUENAS
========================================================= */

@media (max-width: 390px) {
    .painel-controle {
        padding: 14px;
    }

    .painel-controle h1 {
        font-size: 31px;
    }

    .subtitulo {
        font-size: 12px;
        letter-spacing: 0.04em;
    }

    .card span {
        font-size: 24px;
    }

    .card small {
        font-size: 9px;
    }

    .detalhe-titulo {
        font-size: 32px;
    }
}
/* =========================================================
   MENU INSTITUCIONAL DO MAPA
========================================================= */

.menu-plataforma {
    position: fixed;
    z-index: 2000;
    top: 18px;
    right: 18px;

    display: flex;
    align-items: center;
    gap: 5px;

    padding: 6px;

    background: rgba(252, 250, 247, 0.96);
    border: 1px solid rgba(54, 29, 21, 0.16);
    border-radius: 10px;

    box-shadow: 0 8px 24px rgba(54, 29, 21, 0.18);
    backdrop-filter: blur(10px);
}

.menu-plataforma-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 8px 13px;

    color: #361d15;
    font-family: "Big Shoulders Display", sans-serif;
    font-size: 17px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.3px;
    text-decoration: none;

    border-radius: 7px;

    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}

.menu-plataforma-link:hover,
.menu-plataforma-link:focus-visible {
    color: #ffffff;
    background: #c05a3e;
    outline: none;
    transform: translateY(-1px);
}

.menu-plataforma-link.ativo {
    color: #ffffff;
    background: #361d15;
}

@media (max-width: 720px) {
    .menu-plataforma {
        top: 10px;
        right: 10px;
        left: 10px;

        justify-content: center;

        padding: 5px;
    }

    .menu-plataforma-link {
        flex: 1;
        min-width: 0;
        padding: 8px 7px;
        font-size: 15px;
    }
}

@media (max-width: 390px) {
    .menu-plataforma-link {
        font-size: 14px;
    }
}