/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f7f9fa;
    color: #2c3e50;
    line-height: 1.6;
}

/* Color Palette Constants */
:root {
    --primary-color: #1b4d3e; /* Verde Heráldico */
    --secondary-color: #d4af37; /* Ouro Nobre */
    --dark-color: #112a22;
    --light-color: #ffffff;
}

/* Header & Navigation */
header {
    background-color: var(--primary-color);
    border-bottom: 4px solid var(--secondary-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.logo {
    color: var(--secondary-color);
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
    letter-spacing: 2px;
}

/* Mobile Menu Toggle Button */
.menu-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    background: none;
    border: none;
}

.menu-toggle span {
    width: 28px;
    height: 3px;
    background-color: var(--secondary-color);
    margin: 4px 0;
    transition: 0.3s;
}

.nav-menu {
    display: flex;
    list-style: none;
}

.nav-item {
    margin-left: 20px;
}

.nav-link {
    color: var(--light-color);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--dark-color);
    background-color: var(--secondary-color);
}

/* Main Content Sections */
.section {
    padding: 60px 20px;
    max-width: 1200px;
    margin: 0 auto;
    display: none;
	scroll-margin-top: 90px;
}

.section.active-section {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

h2 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 60px;
    height: 4px;
    background-color: var(--secondary-color);
}

/* Page 1: Inicial / Home */
.hero {
    text-align: center;
    padding: 40px 20px;
    background: radial-gradient(circle, #ffffff 0%, #f1f5f2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-top: 20px;
}

/* Container que faz o círculo com a borda dourada */
.brasao-wrapper {
    width: 100%;
    max-width: 320px; /* Limite máximo no desktop */
    aspect-ratio: 1 / 1; /* Garante que sempre seja um círculo perfeito */
    margin: 0 auto 30px auto;
    background: #fff;
    padding: 15px; /* Espaço de segurança entre a imagem e a borda dourada */
    border-radius: 50% 50% 16px 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border: 4px solid var(--secondary-color);
    box-sizing: border-box; /* Garante que o padding não aumente o tamanho do círculo */
    display: flex;
    align-items: center;      
    justify-content: center;   
}

.brasao-container {
    width: 100%;
    height: 100%;
    background-color: transparent; 
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Evita qualquer transbordo acidental */
}

/* Regra de ouro para a imagem redimensionada */
.brasao-image {
    max-width: 95%;    /* Reduzido levemente de 100% para 95% para garantir respiro em todas as laterais */
    max-height: 95%;   /* Reduzido levemente para dar margem de segurança no topo e na base */
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    
    /* Empurra o brasão levemente para baixo, compensando o arco superior do escudo */
    transform: translateY(8px); 
}

.family-title {
    font-size: 42px;
    color: var(--primary-color);
    letter-spacing: 4px;
    margin-bottom: 10px;
    font-weight: 800;
}

.family-subtitle {
    font-size: 18px;
    color: #555;
    font-style: italic;
    margin-bottom: 30px;
}

/* Page 2: Origens */
.origens-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.card {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-left: 5px solid var(--primary-color);
}

.side-card {
    background: var(--dark-color);
    color: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.side-card h3 {
    color: var(--secondary-color);
    margin-bottom: 15px;
}

/* Page 3: Árvore Genealógica */
.tree-container {
    background: white;
    padding: 40px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    text-align: center;
    overflow-x: auto;
}

.tree-node {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    margin: 10px;
    min-width: 150px;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.tree-node.root {
    background: var(--dark-color);
    font-weight: bold;
    font-size: 18px;
}

.tree-level {
    margin-bottom: 30px;
    position: relative;
}

/* Page 4: Fotos - NOVO GRID SIMÉTRICO E RESPONSIVO (SEM PINTEREST) */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.gallery-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}

/* Container da foto - Mantém proporção e define área quadrada/retangular fixa */
.photo-wrapper {
    width: 100%;
    height: 260px; /* Altura fixa confortável para alinhar os blocos horizontalmente */
    background-color: #ffffff; /* Fundo cinza suave preenche as folgas de fotos muito verticais ou horizontais */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px; /* Margem interna sutil de respiro */
    overflow: hidden;
    box-sizing: border-box;
}

/* Ajuste absoluto para a imagem NUNCA cortar */
.gallery-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* REGRA DE OURO: Mostra 100% da foto original intacta */
    cursor: pointer;
    transition: transform 0.4s ease;
    display: block;
}

.gallery-img:hover {
    transform: scale(1.03); /* Efeito sutil para não escapar do wrapper */
}

.gallery-desc {
    padding: 18px;
    font-size: 14px;
    color: #555;
    text-align: center;
    margin-top: -1px; /* Força o bloco a subir 1px e cobrir a fresta */
    position: relative; /* Garante que ele fique na camada de cima */
    background: #ffffff; /* Garante que o fundo seja opaco */
}

.gallery-desc strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 6px;
    font-size: 16px;
}

.gallery-desc p {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Estilização para o item que ainda não possui foto fixa */
.placeholder-item .photo-placeholder {
    width: 100%;
    height: 100%;
    min-height: 236px; /* Desconta o padding relativo */
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    color: #475569;
    font-weight: 600;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* Page 5: Estrutura da Página de Eventos */
.eventos-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.event-card {
    display: flex;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border-left: 4px solid var(--secondary-color);
}

.event-date {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
    font-weight: bold;
    font-size: 18px;
    min-width: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.event-date small {
    font-size: 12px;
    color: var(--secondary-color);
}

.event-details {
    padding: 20px;
}

.event-details h4 {
    color: var(--dark-color);
    margin-bottom: 8px;
}

/* Page 6: Contato */
.contact-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-submit {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}

.btn-submit:hover {
    background-color: var(--dark-color);
}

.contact-info h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.contact-info p {
    margin-bottom: 10px;
}

/* Footer */
footer {
    background-color: var(--dark-color);
    color: #a0b0a8;
    text-align: center;
    padding: 20px;
    margin-top: 60px;
    font-size: 14px;
    border-top: 3px solid var(--secondary-color);
}

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 968px) {
    .origens-grid, .contact-container, .eventos-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background-color: var(--primary-color);
        border-bottom: 3px solid var(--secondary-color);
        padding: 10px 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }

    .nav-menu.mobile-open {
        display: flex;
    }

    .nav-item {
        margin: 10px 0;
        text-align: center;
        width: 100%;
    }

    .nav-link {
        display: block;
        padding: 12px;
        width: 90%;
        margin: 0 auto;
    }

    .family-title {
        font-size: 32px;
    }

    .section {
        padding: 40px 15px;
    }
	
    .brasao-wrapper {
        max-width: 240px; /* Reduz o círculo em telas menores */
        padding: 10px;    /* Reduz levemente o recuo para aproveitar a tela do celular */
    }

    .photo-wrapper {
        height: 220px; /* Suave redução da caixinha nos celulares */
    }
}

@media (max-width: 480px) {
    .family-title {
        font-size: 26px;
        letter-spacing: 2px;
    }
    .card, .side-card, .contact-container {
        padding: 20px;
    }
}

/* ==========================================================================
   Nova Página: Seção do Brasão Responsivo
   ========================================================================== */
.brasao-page-container {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 40px;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    align-items: center;
}

.brasao-display-card {
    background-color: #ffffff;
    padding: 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    justify-content: center;
}

/* Garante a responsividade da imagem sem distorção */
.brasao-main-img {
    max-width: 100%;
    height: auto;
    max-height: 550px; /* Evita que fique gigante em monitores ultra-wide */
    object-fit: contain;
    border-radius: 4px;
}

.brasao-text-card h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 22px;
}

.historical-text {
    font-style: italic;
    color: #4a5568;
    line-height: 1.8;
    text-align: justify;
}

/* Botão elegante para download da imagem */
.btn-download {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.3s ease;
    text-align: center;
}

.btn-download:hover {
    background-color: var(--dark-color);
    color: var(--secondary-color);
}

/* Ajuste de responsividade para tablets e celulares */
@media (max-width: 868px) {
    .brasao-page-container {
        grid-template-columns: 1fr; /* Transforma o layout em uma coluna única */
        gap: 20px;
        padding: 20px;
    }
    
    .brasao-main-img {
        max-height: 400px; /* Diminui a altura limite em telas menores */
    }
}

/* --- ESTILOS DO LIGHTBOX (FOTOS EM TAMANHO MAIOR) --- */
.lightbox {
    display: none; /* Escondido por padrão */
    position: fixed;
    z-index: 2000; /* Fica por cima do menu fixo */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9); /* Fundo preto semi-transparente */
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

/* Imagem ampliada na tela */
.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh; /* Limita a altura para sobrar espaço para a legenda */
    object-fit: contain;
    border: 3px solid var(--secondary-color);
    box-shadow: 0 0 25px rgba(0,0,0,0.5);
    animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Legenda da foto ampliada */
#lightbox-caption {
    margin: 15px auto;
    width: 80%;
    text-align: center;
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Botão Fechar (X) */
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.lightbox-close:hover {
    color: var(--secondary-color);
}

/* Ajustes finos de responsividade para telas pequenas */
@media (max-width: 768px) {
    .lightbox-close {
        top: 15px;
        right: 20px;
        font-size: 35px;
    }
    #lightbox-caption {
        font-size: 14px;
    }
}

/* ==========================================================================
   Nova Árvore Genealógica Responsiva e Expansível
   ========================================================================== */
.genealogia-container {
    background: #ffffff;
    padding: 35px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    max-width: 1000px;
    margin: 0 auto;
}

.gen-block {
    position: relative;
    margin-bottom: 40px;
    text-align: center;
}

.gen-label {
    display: inline-block;
    background-color: var(--dark-color);
    color: var(--secondary-color);
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

/* Cartões de Casais */
.couple-card {
    display: inline-flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.central-couple {
    border: 2px solid var(--primary-color);
    background: #f0fdf4;
}

.person {
    text-align: left;
    padding: 0 10px;
}

.person strong {
    display: block;
    color: var(--dark-color);
    font-size: 15px;
}

.person small {
    color: #64748b;
}

.parent-origin {
    display: block;
    font-size: 11px;
    color: var(--primary-color);
    font-style: italic;
}

.marriage-sign {
    font-weight: bold;
    color: var(--secondary-color);
    background: white;
    border: 1px solid #cbd5e1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin: 0 10px;
    flex-shrink: 0;
}

/* Linhas de conexão vertical simuladas */
.connect-line {
    width: 2px;
    height: 20px;
    background-color: var(--secondary-color);
    margin: 0 auto 5px auto;
}

/* Listagem de Filhos e Subgerações (Cascata Responsiva) */
.children-list-container {
    text-align: left;
    max-width: 800px;
    margin: 0 auto;
}

.children-tier, .sub-generation {
    list-style: none;
    padding-left: 0;
}

.children-tier > li {
    background: #ffffff;
    border-left: 3px solid #cbd5e1;
    padding: 10px 15px;
    margin-bottom: 12px;
    border-radius: 0 6px 6px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    font-size: 15px;
}

.children-tier > li.has-descendants {
    border-left: 3px solid var(--secondary-color);
    background: #fffdf5;
    padding-bottom: 20px;
}

.couple-inline {
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
}

.couple-inline strong {
    color: var(--primary-color);
}

.m-status {
    font-size: 13px;
    color: #64748b;
    margin: 0 5px;
}

/* Estilo para as Gerações Aninhadas (Prontas para mais 4 camadas) */
.sub-generation {
    margin-top: 10px;
    padding-left: 25px; /* Cria o efeito visual de árvore/hierarquia */
    border-left: 1px dotted var(--secondary-color);
}

.sub-gen-title {
    display: block;
    font-size: 12px;
    font-weight: bold;
    color: #78350f;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.sub-generation li {
    padding: 6px 12px;
    background: #f8fafc;
    margin-bottom: 6px;
    border-radius: 4px;
    font-size: 14px;
    border-left: 2px solid var(--primary-color);
}

.branch-ready {
    position: relative;
}

.gen-seed {
    font-size: 11px;
    color: #059669;
    font-weight: 600;
    margin-left: 6px;
}

/* Bloco Informativo de Ajuda técnica */
.genealogy-guide-box {
    margin-top: 40px;
    background-color: #f1f5f9;
    border-radius: 6px;
    padding: 15px 20px;
    text-align: left;
    border-left: 4px solid var(--dark-color);
}

.genealogy-guide-box h4 {
    color: var(--dark-color);
    margin-bottom: 5px;
    font-size: 14px;
}

.genealogy-guide-box p {
    font-size: 12px;
    color: #475569;
    line-height: 1.5;
}

/* ==========================================================================
   Responsividade Estrita para Telas Menores (Celulares)
   ========================================================================== */
@media (max-width: 768px) {
    .couple-card {
        flex-direction: column; /* Transforma o casal horizontal em vertical no celular */
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        padding: 12px;
    }
    
    .person {
        text-align: center;
        padding: 5px 0;
    }
    
    .marriage-sign {
        margin: 8px auto;
    }
    
    .couple-inline {
        display: flex;
        flex-direction: column;
        text-align: left;
        gap: 4px;
    }
    
    .m-status {
        margin: 2px 0;
        font-style: italic;
    }
    
    .sub-generation {
        padding-left: 12px; /* Diminui o recuo em telas pequenas para poupar espaço */
    }
}

/* Formatação dos ícones de nascimento e falecimento */
.sub-generation small {
    font-size: 12px;
    color: #64748b;
    margin-left: 5px;
    word-spacing: 2px;
}

/* Estilo para garantir apenas uma mídia por linha e centralizada */
.midia-bloco {
    display: block;          /* Força o elemento a se comportar como um bloco (uma linha por elemento) */
    max-width: 100%;         /* Garante que a mídia não ultrapasse a largura da tela */
    height: auto;            /* Mantém a proporção original da imagem ou vídeo */
    margin: 20px auto;       /* Adiciona um espaçamento de 20px acima/abaixo e centraliza horizontalmente */
    border-radius: 4px;      /* Opcional: um leve arredondamento nos cantos para combinar com o layout */
}