/* ==============================================================================
   CATÁLOGO DE DADOS ESPACIAIS - LAGEAMB
   ============================================================================== */

/* ------------------------------------------------------------------------------
   0. DESIGN 
   Centraliza cores e curvas de animação para manter tudo consistente.
   ------------------------------------------------------------------------------ */
:root {
    --verde: #6fb048;
    --verde-escuro: #4a8c2a;
    --verde-medio: #5a9638;
    --verde-claro: #f1f8ee;
    --verde-tag-bg: #e9f5e9;
    --cinza-fundo: #f9f9f9;
    --cinza-borda: #dddddd;
    --texto: #444444;
    --texto-forte: #111111;

    /* Curvas de easing: entrada suave e "natural" (sem o ricochete exagerado) */
    --ease-suave: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-padrao: cubic-bezier(0.4, 0, 0.2, 1);

    --sombra-card: 0 4px 15px rgba(0, 0, 0, 0.06);
    --sombra-card-hover: 0 14px 34px rgba(74, 140, 42, 0.16);
    --raio: 10px;
}

/* ------------------------------------------------------------------------------
   1. RESET GLOBAL E FUNDO (SEM BORDAS)
   ------------------------------------------------------------------------------ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    font-family: 'Montserrat', sans-serif;
    background-color: var(--cinza-fundo);
    overflow-x: hidden;
    position: relative;
    color: var(--texto);
}

/* Fundo topográfico com leve zoom para eliminar bordas do arquivo original.
   Adicionamos uma respiração muito sutil e lenta que dá vida sem distrair. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url('../assets/topo-bg.png');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transform: scale(1.5);
    z-index: -1;
    animation: fundoRespira 40s ease-in-out infinite alternate;
}

@keyframes fundoRespira {
    from { transform: scale(1.5); }
    to   { transform: scale(1.55); }
}

/* Barra de rolagem discreta e alinhada à identidade */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(111, 176, 72, 0.4);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(111, 176, 72, 0.65); background-clip: padding-box; }

/* ------------------------------------------------------------------------------
   2. CABEÇALHO (HEADER)
   ------------------------------------------------------------------------------ */
.header {
    background-color: var(--verde);
    color: white;
    padding: 15px 40px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    position: relative;
    z-index: 10;
    animation: descerSuave 0.6s var(--ease-suave) both;
}

.header-container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.logo-container {
    flex-shrink: 0;
    z-index: 2;
}

.logo {
    height: 45px;
    display: block;
    transition: transform 0.4s var(--ease-suave);
}

.logo:hover {
    transform: scale(1.05);
}

.title-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    pointer-events: none;
}

.title-container h1 {
    font-size: 1.8rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* ------------------------------------------------------------------------------
   3. ÁREA PRINCIPAL
   ------------------------------------------------------------------------------ */
.main-content {
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* ------------------------------------------------------------------------------
   4. BARRA DE FILTROS (PESQUISA + DROPDOWNS)
   ------------------------------------------------------------------------------ */
.search-section {
    width: 100%;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    position: relative;
    z-index: 50; /* Mantém a barra de filtros (e os dropdowns abertos) acima do grid de cards */
    animation: subirSuave 0.6s var(--ease-suave) 0.1s both;
}

#searchInput {
    flex: 2;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid var(--cinza-borda);
    border-radius: var(--raio);
    outline: none;
    background: white;
    box-shadow: var(--sombra-card);
    transition: border-color 0.3s var(--ease-padrao),
                box-shadow 0.3s var(--ease-padrao);
}

#searchInput::placeholder { color: #9a9a9a; transition: color 0.3s; }
#searchInput:focus::placeholder { color: #c0c0c0; }

.custom-select {
    flex: 1;
    position: relative;
    user-select: none;
}

.select-box {
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid var(--cinza-borda);
    border-radius: var(--raio);
    background: white;
    cursor: pointer;
    box-shadow: var(--sombra-card);
    transition: border-color 0.3s var(--ease-padrao),
                box-shadow 0.3s var(--ease-padrao);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--texto);
}

.select-box::after {
    content: '▼';
    font-size: 12px;
    color: #888;
    margin-left: 10px;
    transition: transform 0.3s var(--ease-suave), color 0.3s;
}

/* Estados de foco/hover unificados com brilho verde suave */
.select-box:hover,
#searchInput:focus,
.select-box.active {
    border-color: var(--verde);
    box-shadow: 0 0 0 4px rgba(111, 176, 72, 0.12), var(--sombra-card);
}

/* Quando o dropdown está aberto, a seta gira para cima */
.select-box.active::after {
    transform: rotate(180deg);
    color: var(--verde);
}

/* Container de opções: agora animado (fade + deslize) em vez de aparecer seco */
.options-container {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--cinza-borda);
    border-radius: var(--raio);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    padding: 6px 0;

    /* Estado fechado (animável) */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top center;
    pointer-events: none;
    transition: opacity 0.25s var(--ease-padrao),
                transform 0.25s var(--ease-suave),
                visibility 0s linear 0.25s;
}

.options-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
    transition: opacity 0.25s var(--ease-padrao),
                transform 0.28s var(--ease-suave),
                visibility 0s;
}

.options-container label {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--texto);
    transition: background 0.2s var(--ease-padrao), padding-left 0.2s var(--ease-padrao);
}

.options-container label:hover {
    background-color: var(--verde-claro);
    padding-left: 20px;
}

.options-container input[type="checkbox"] {
    margin-right: 12px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--verde);
    transition: transform 0.15s var(--ease-suave);
}

.options-container input[type="checkbox"]:checked {
    transform: scale(1.15);
}

.btn-clear-filters {
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    color: var(--verde-medio);
    background: white;
    border: 2px solid var(--cinza-borda);
    border-radius: var(--raio);
    cursor: pointer;
    box-shadow: var(--sombra-card);
    transition: border-color 0.3s var(--ease-padrao),
                color 0.3s var(--ease-padrao),
                box-shadow 0.3s var(--ease-padrao),
                transform 0.2s var(--ease-suave);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1;
}

.btn-clear-filters:hover {
    border-color: var(--verde);
    color: var(--verde-escuro);
    box-shadow: 0 0 0 4px rgba(111, 176, 72, 0.12), var(--sombra-card);
}

.btn-clear-filters:active {
    transform: scale(0.98);
}

/* ------------------------------------------------------------------------------
   5. CONTADOR DE RESULTADOS
   ------------------------------------------------------------------------------ */
.results-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    padding-left: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    -webkit-text-stroke: 3px white;
    paint-order: stroke fill;
    animation: subirSuave 0.6s var(--ease-suave) 0.15s both;
}

.results-bar strong {
    -webkit-text-stroke: 0;
    display: inline-flex;
    align-items: center;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--verde-escuro);
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(74, 140, 42, 0.3);
}

/* ------------------------------------------------------------------------------
   6. GRID DO CATÁLOGO E CARDS
   ------------------------------------------------------------------------------ */
.catalog-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: var(--raio);
    padding: 25px;
    box-shadow: var(--sombra-card);
    border-top: 5px solid var(--verde);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;

    /* Entrada escalonada (o delay é definido inline pelo JS via --ordem).
       fill-mode "backwards" garante que o hover continue funcionando depois. */
    animation: cardEntra 0.55s var(--ease-suave) backwards;
    animation-delay: calc(var(--ordem, 0) * 55ms);
    transition: transform 0.35s var(--ease-suave),
                box-shadow 0.35s var(--ease-padrao),
                border-top-color 0.35s var(--ease-padrao);
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--sombra-card-hover);
    border-top-color: var(--verde-escuro);
}

.card-content {
    flex-grow: 1;
}

.card p.card-arquivo-fonte {
    display: inline-block;
    background: #f0f0f0;
    color: #555;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 15px;
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
}

.card h3 {
    color: var(--verde);
    margin-bottom: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    overflow-wrap: break-word;
    word-break: break-word;
    transition: color 0.3s var(--ease-padrao);
}

.card:hover h3 {
    color: var(--verde-escuro);
}

/* Tags de Projeto e Categoria */
.tags-container {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.card-tag {
    display: inline-block;
    background: var(--verde-tag-bg);
    color: var(--verde-escuro);
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    transition: transform 0.25s var(--ease-suave), background 0.25s;
}

.card:hover .card-tag {
    transform: translateY(-1px);
}

.card-tag.categoria {
    background: #f0f0f0;
    color: #555;
}

.card p {
    font-size: 0.92rem;
    line-height: 1.6;
    margin-bottom: 8px;
    color: var(--texto);
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.card strong {
    color: var(--texto-forte);
    font-weight: 600;
}

/* Trunca o resumo em até 3 linhas */
.resumo-texto.resumo-curto {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 15px;
}

.detalhes-extras {
    margin-top: 15px;
    animation: fadeIn 0.3s ease-in-out;
}

/* Botão Saiba Mais */
.btn-ver-mais {
    background: none;
    border: none;
    color: var(--verde);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    margin-top: 15px;
    padding: 4px 0;
    width: fit-content;
    position: relative;
    transition: color 0.25s var(--ease-padrao), gap 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Sublinhado que cresce a partir da esquerda (mais elegante que underline fixo) */
.btn-ver-mais::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: var(--verde-escuro);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s var(--ease-suave);
}

/* Seta indicativa */
.btn-ver-mais::before {
    content: "→";
    order: 2;
    transition: transform 0.3s var(--ease-suave);
    display: inline-block;
}

.btn-ver-mais:hover {
    color: var(--verde-escuro);
}

.btn-ver-mais:hover::after {
    transform: scaleX(1);
}

.btn-ver-mais:hover::before {
    transform: translateX(4px);
}

/* ------------------------------------------------------------------------------
   7. ESTADO DE CARREGAMENTO E MENSAGENS
   ------------------------------------------------------------------------------ */
.grid-status {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #777;
    animation: fadeIn 0.4s ease-in-out;
}

.spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 18px;
    border: 4px solid rgba(111, 176, 72, 0.2);
    border-top-color: var(--verde);
    border-radius: 50%;
    animation: girar 0.8s linear infinite;
}

.grid-status.erro { color: #d9534f; font-weight: 600; }

/* ------------------------------------------------------------------------------
   8. KEYFRAMES
   ------------------------------------------------------------------------------ */
@keyframes cardEntra {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes subirSuave {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes descerSuave {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes girar {
    to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------------------
   9. RESPONSIVIDADE (MOBILE)
   ------------------------------------------------------------------------------ */
@media (max-width: 768px) {
    .header { padding: 15px 20px; }

    .header-container {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .logo { height: 38px; }

    .title-container {
        position: static;
        left: auto;
        transform: none;
    }

    .title-container h1 { font-size: 1.35rem; }
    .search-section {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 18px;
    }

    #searchInput, .custom-select, .btn-clear-filters { width: 100%; }

    .select-box { padding: 12px 15px; font-size: 15px; }

    .main-content { padding: 20px 10px; }

    .catalog-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 15px;
        width: 100%;
    }

    .card { padding: 20px; min-width: 0; width: 100%; }
}

/* ------------------------------------------------------------------------------
   10. MODAL (POP-UP) DE DETALHES
   ------------------------------------------------------------------------------ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);

    /* Estado fechado animável (sem depender de display:none, o que trava a transição) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s var(--ease-padrao),
                visibility 0s linear 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s var(--ease-padrao), visibility 0s;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 850px;
    border-radius: var(--raio);
    padding: 35px 40px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    border-top: 5px solid var(--verde);
    max-height: 90vh;
    overflow-y: auto;

    /* Entrada do card do modal */
    opacity: 0;
    transform: scale(0.94) translateY(16px);
    transition: opacity 0.3s var(--ease-padrao),
                transform 0.4s var(--ease-suave);
}

.modal-overlay.active .modal-content {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.fechar-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 32px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.25s var(--ease-padrao),
                background 0.25s var(--ease-padrao),
                transform 0.3s var(--ease-suave);
}

.fechar-modal:hover {
    color: #d9534f;
    background: #fdecea;
    transform: rotate(90deg);
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 25px;
}

.detalhes-tecnicos {
    background: #f4f9f1;
    padding: 20px;
    border-radius: var(--raio);
    border: 1px solid #e1eedb;
    margin-bottom: 20px;
}

/* --- Cabeçalho e textos corridos do modal --- */
.modal-titulo {
    color: var(--verde);
    margin-bottom: 5px;
    font-size: 1.6rem;
}

.modal-secao {
    margin-top: 25px;
}

.modal-titulo-secao {
    margin-bottom: 12px;
    color: #333;
    font-size: 1rem;
    border-bottom: 2px solid var(--verde);
    display: inline-block;
    padding-bottom: 3px;
}

.modal-texto {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
    text-align: justify;
}

/* --- Blocos de responsáveis / licença / restrições --- */
.bloco-info {
    background: #f4f9f1;
    padding: 20px;
    border-radius: var(--raio);
    border: 1px solid #e1eedb;
}

.lista-info {
    display: grid;
    gap: 14px;
}

.lista-info.duas-colunas {
    grid-template-columns: 1fr 1fr;
    gap: 14px 30px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0; /* impede que textos longos estourem a coluna do grid */
}

.info-item.largura-total {
    grid-column: 1 / -1;
}

.info-rotulo {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7a63;
}

.info-valor {
    font-size: 0.92rem;
    line-height: 1.5;
    color: #222;
    overflow-wrap: anywhere;
}

.info-valor.vazio {
    color: #9a9a9a;
    font-style: italic;
}

.info-valor a {
    color: #4d8a2e;
    text-decoration: none;
    border-bottom: 1px solid rgba(77, 138, 46, 0.35);
    transition: color 0.2s var(--ease-padrao), border-color 0.2s var(--ease-padrao);
}

.info-valor a:hover {
    color: #3b6b22;
    border-bottom-color: #3b6b22;
}

/* Selo colorido conforme o nível de restrição do dado */
.selo-restricao {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.45;
}

.selo-restricao.ok {
    background: #e6f4dd;
    color: #3f6d22;
    border: 1px solid #c8e4b4;
}

.selo-restricao.alerta {
    background: #fdecea;
    color: #a93226;
    border: 1px solid #f5c6c0;
}

.selo-restricao.neutro {
    background: #eef1f4;
    color: #4a5560;
    border: 1px solid #dbe1e7;
}

@media (max-width: 768px) {
    .modal-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .modal-content { padding: 25px 20px; }
    .lista-info.duas-colunas { grid-template-columns: 1fr; }
    .bloco-info { padding: 16px; }
}

/* ------------------------------------------------------------------------------
   11. ACESSIBILIDADE: FOCO VISÍVEL + RESPEITO A "REDUZIR MOVIMENTO"
   ------------------------------------------------------------------------------ */
#searchInput:focus-visible,
.select-box:focus-visible,
.btn-clear-filters:focus-visible,
.btn-ver-mais:focus-visible,
.fechar-modal:focus-visible {
    outline: 3px solid rgba(111, 176, 72, 0.45);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    body::before { animation: none; }
}