/* ==========================================================================
   SEÇÃO DA GALERIA - ESTRUTURA E CORREÇÃO DE FLUXO
   ========================================================================== */
section#gallery {
    padding: 90px 8%;
    width: 100%;
    height: auto !important;
    min-height: 100vh;
    display: block;
    position: relative;
    overflow: visible;
    background: linear-gradient(45deg,rgba(70, 96, 136, 1) 0%, rgba(255, 255, 255, 1) 100%, rgba(255, 255, 255, 1) 100%);
}

.gallery-header {
    display: flex;
    flex-direction: column;
    text-align: center;
    gap: 20px;
    margin-bottom: 70px;

}

.gallery-header p {
    color: #414955;
}

.gallery-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* --- FILTROS ESTILIZADOS --- */
.gallery-filters {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 50px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 12px 25px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #64748b;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.filter-btn:hover {
    border-color: #f59e0b;
    color: #f59e0b;
}

.filter-btn.active {
    background: #466088;
    border-color: #466088;
    color: #fff;
    /* box-shadow: 0 10px 20px -5px rgba(245, 158, 11, 0.4); */
}

/* --- GRID BENTO PADRONIZADA --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 280px;
    grid-auto-flow: dense;
    gap: 25px;
}

.grid-big {
    grid-column: span 2;
    grid-row: span 2;
}

/* ==========================================================================
   CARDS DA GALERIA - ANIMAÇÕES E HOVER
   ========================================================================== */
.gallery-card {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    background: #0f172a;
    cursor: pointer;
    opacity: 0; 
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.gallery-card.show {
    opacity: 1;
    transform: translateY(0);
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
}

.gallery-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.5s ease;
}

.gallery-card:hover img {
    transform: scale(1.1);
    opacity: 0.6;
}

/* ==========================================================================
   MÚLTIPLAS TAGS - MHL PORTFÓLIO
   ========================================================================== */

.card-tags-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap; /* Permite que as tags pulem de linha se houver muitas */
    gap: 8px;        /* Espaço exato entre uma tag e outra */
    z-index: 5;
}

.card-tag {
    /* Removido o top e left fixos para não sobrepor */
    position: relative !important; 
    display: inline-block;
    padding: 6px 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    color: #f59e0b;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
    white-space: nowrap; /* Garante que o texto da tag não quebre */
}

.card-zoom-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    opacity: 0;
    transition: 0.3s;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-card:hover .card-zoom-icon {
    opacity: 1;
}

.card-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 35px 25px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
    color: #fff;
    z-index: 4;
}

.card-info h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    transition: transform 0.8s ease;
}

.card-info p {
    font-size: 0.9rem;
    color: #cbd5e1;
    margin-top: 10px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.8s ease;
    transform: translateY(10px);
}

.gallery-card:hover .card-info h4 { transform: translateY(-5px); }
.gallery-card:hover .card-info p {
    opacity: 1;
    max-height: 100px;
    transform: translateY(0);
}

/* ==========================================================================
   LIGHTBOX - REFINAMENTO DE HIERARQUIA VERTICAL
   ========================================================================== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.98);
    z-index: 5000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
}

.lightbox.active {
    display: flex;
}

/* BOTÃO FECHAR - TOPO DIREITO */
.lightbox-close {
    align-self: flex-end;
    color: #fff;
    font-size: 2.8rem;
    cursor: pointer;
    z-index: 5011;
    padding: 10px;
    margin-top: 5px;
}

.lightbox-close:hover {
    color: #f59e0b;
}

/* ÁREA DA IMAGEM */
.lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 1000px;
    flex-grow: 1;
}

.lightbox-content img {
    display: block;
    max-height: 60vh; /* Reduzido levemente para garantir espaço do texto */
    max-width: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
}

.lightbox-caption {
    width: 100%;
    text-align: center;
    color: #ffffff;
    padding-top: 20px;
    padding-bottom: 90px; /* RESERVA ESPAÇO PARA AS SETAS NO MOBILE */
    margin-top: auto;
}

.lightbox-caption h3 {
    font-size: 1.4rem;
    color: #f59e0b;
    margin-bottom: 5px;
}

.lightbox-caption p {
    font-size: 0.95rem;
    color: #cbd5e1;
    max-width: 650px;
    margin: 0 auto;
}

/* NAVEGAÇÃO - POSIÇÃO PADRÃO (DESKTOP) */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #fff;
    font-size: 3rem;
    cursor: pointer;
    padding: 20px;
    border-radius: 50%;
    transition: 0.3s;
    z-index: 5010;
}

.lightbox-nav:hover {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.prev { left: 40px; }
.next { right: 40px; }

/* ==========================================================================
   RESPONSIVIDADE E CORREÇÃO DE SOBREPOSIÇÃO (MOBILE)
   ========================================================================== */
@media (max-width: 1100px) {
    .prev { left: 15px; }
    .next { right: 15px; }
}

@media (max-width: 850px) {
    /* SETAS DESCEM PARA A ÁREA RESERVADA */
    .lightbox-nav {
        top: auto;
        bottom: 20px; /* Ficam no pé da tela */
        transform: none;
        background: rgba(0, 0, 0, 0.7);
        font-size: 1.8rem;
        padding: 12px;
    }

    /* Centralização horizontal das setas no rodapé */
    .prev { left: calc(50% - 65px); }
    .next { right: calc(50% - 65px); }

    .lightbox-content img {
        max-height: 50vh; 
    }

    .lightbox-close {
        font-size: 2.3rem;
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 280px;
    }
    .grid-big {
        grid-column: span 1;
        grid-row: span 1;
    }
}

@media (max-width: 480px) {
    .lightbox-caption h3 { font-size: 1.1rem; }
    .lightbox-caption p { font-size: 0.85rem; padding: 0 15px; }
    .lightbox-nav { font-size: 1.6rem; padding: 10px; }
    .prev { left: calc(50% - 55px); }
    .next { right: calc(50% - 55px); }
}