/* --- RESET & BASES --- */
:root {
    --primary: #ecf0f1;
    --accent: #e74c3c;
    --gold: #f1c40f;
    --text: #e0e0e0;
    --light-bg: #2c3e50;
    --white: #1a1a1a;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Roboto', sans-serif;
    --footer-bg: #1a1a1a;
    --header-bg: #1a1a1a;
}

[data-theme="light"] {
    --primary: #2c3e50;
    /* Bleu nuit élégant */
    --accent: #c0392b;
    /* Rouge impérial */
    --gold: #d4af37;
    /* Doré pour les titres */
    --text: #333333;
    --light-bg: #ced6e0;
    --white: #ffffff;
    --footer-bg: #2c3e50;
    --header-bg: #2c3e50;
}

/* Dark Mode Toggle Button */
#theme-toggle {
    background: none;
    border: 1px solid #ffffff;
    color: #ffffff;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    line-height: 1.6;
    background: var(--white);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

ul {
    list-style: none;
}

/* --- HEADER --- */
.header {
    background: var(--header-bg);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 5px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: #ffffff;
    /* Blanc */
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: 30px;
    align-items: center;
}

.nav-links a {
    font-weight: 500;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffffff;
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent);
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--accent);
    transition: width 0.3s;
}

.nav-links a:hover::after {
    width: 100%;
}

.btn-contact {
    border: 1px solid #ffffff;
    padding: 5px 10px;
    border-radius: 5px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-contact:hover {
    background: var(--accent);
    color: white !important;
    border-color: var(--accent);
}

.btn-contact::after {
    display: none;
}

/* --- ARBRE GÉNÉALOGIQUE (GRID SYSTEM) --- */
.gen-tree-container {
    overflow-x: auto;
    padding-bottom: 50px;
}

.gen-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 20px;
    min-width: 900px;
    /* Ensure readability */
    padding: 40px 0;
}

.gen-person {
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 5px;
    padding: 0;
    /* Remove padding to let image fill */
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
    font-size: 1rem;
    color: var(--primary);
    font-family: var(--font-heading);
    transition: 0.3s;
    overflow: hidden;
    /* Clip image */
}

.gen-person:hover {
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.gen-person a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 2;
    padding: 10px;
    /* Text padding */
}

.gen-person img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    /* Focus on top of image */
    z-index: 1;
    opacity: 0.4;
    /* Fade image slightly so text is readable */
    transition: 0.3s;
}

.gen-person:hover img {
    opacity: 0.2;
    transform: scale(1.1);
}

.gen-person a span {
    position: relative;
    z-index: 3;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

/* Connectors Logic */
/* .gen-child is applied to items in Gen 2 and Gen 3 */
.gen-child::before {
    content: '';
    position: absolute;
    top: -30px;
    height: 15px;
    width: 50%;
    left: 25%;
    border-left: 2px solid var(--primary);
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
}

.gen-child::after {
    content: '';
    position: absolute;
    top: -15px;
    height: 15px;
    left: 50%;
    border-left: 2px solid var(--primary);
}

/* Spanning classes */
.span-2 {
    grid-column: span 2;
}

.span-4 {
    grid-column: span 4;
}

/* Specific spacing for rows */
.gen-row-gap {
    grid-column: 1 / -1;
    height: 40px;
    /* Space for connectors */
}

.gen-row-gap-small {
    grid-column: 1 / -1;
    height: 20px;
}

/* Mini parents container for Gen 0 */
.gen-mini-parents {
    display: flex;
    justify-content: space-between;
    gap: 2px;
    width: 140%;
    /* Overflow slightly to fit */
    margin-left: -20%;
    /* Center the overflow */
    position: relative;
}

.gen-mini-parents .gen-person {
    transform: scale(0.85);
    /* Make them slightly smaller */
    padding: 5px;
    min-height: 60px;
    border-radius: 5px;
}

.gen-mini-parents .gen-person img {
    opacity: 0.6;
}

/* Connector for Gen 0 to Gen 1 */
.gen-mini-parents::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: var(--primary);
}

.gen-mini-parents::before {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 25%;
    width: 50%;
    height: 2px;
    border-bottom: 2px solid var(--primary);
    /* Link parents */
    z-index: -1;
}

/* Burger Menu */
.burger {
    display: none;
    cursor: pointer;
}

.burger div {
    width: 25px;
    height: 3px;
    background-color: #ffffff;
    margin: 5px;
    transition: all 0.3s ease;
}

/* --- HERO SECTION --- */
.hero {
    height: 80vh;
    background: #333 url('fond-accueil.jpg') top center/cover no-repeat;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    z-index: 1;
}

.hero-overlay {
    background: rgba(0, 0, 0, 0.5);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content h2 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    margin-bottom: 20px;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    animation: fadeInDown 1s ease-out;
}

.hero-content p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeInUp 1s ease-out 0.3s backwards;
}

.btn-hero {
    background: var(--accent);
    color: white;
    padding: 15px 30px;
    font-size: 1rem;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.4);
    animation: fadeInUp 1s ease-out 0.6s backwards;
    display: inline-block;
}

.btn-hero:hover {
    background: #a93226;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.6);
}

/* --- SECTIONS COMMUNES --- */
.section {
    padding: 80px 0;
}

.bg-light {
    background: var(--light-bg);
}

.section-title {
    text-align: center;
    margin-bottom: 60px;
}

.section-title span {
    color: var(--accent);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 2px;
    display: block;
    margin-bottom: 10px;
}

.section-title h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary);
    margin: 0;
}

.divider {
    width: 60px;
    height: 3px;
    background: var(--gold);
    margin: 20px auto 0;
}

/* --- GENEALOGIE (GRID) --- */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 30px;
}

.grid-5 {
    display: grid;
    /* Force 5 columns on desktop if space permits, otherwise auto-fit */
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

@media (max-width: 1200px) {
    .grid-5 {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

.card {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s, box-shadow 0.3s;
    text-align: center;
    display: flex;
    flex-direction: column;
}

/* --- SIDE-BY-SIDE SECTIONS --- */
.row-sections {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    align-items: stretch;
    /* Ensure all columns are same height */
}

.half-section {
    width: 50%;
    flex: 0 0 50%;
    padding: 60px 0;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.quarter-section {
    width: 25%;
    flex: 0 0 25%;
    padding: 40px 10px;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.third-section {
    width: 33.333%;
    flex: 0 0 33.333%;
    padding: 50px 10px;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    /* Flex container */
    flex-direction: column;
}

.third-section .container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.third-section .card {
    /* Removed max-width constraint to match standard cards */
    margin: 0 auto;
    height: 100%;
    /* Fill available height */
}

.third-section .card .card-img {
    height: 250px;
    /* Standardized height */
    /* Proportional */
}

.quarter-section .card {
    max-width: 170px;
    /* Constrain width further */
    margin: 0 auto;
    /* Center in column */
}

.quarter-section .card .card-img {
    height: 150px;
    /* Proportional height */
}

@media (max-width: 1200px) {
    .quarter-section {
        width: 50%;
        /* 2 per row on medium screens */
        flex: 0 0 50%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* On Mobile, stack them */
@media (max-width: 768px) {

    .row-sections {
        flex-direction: column;
    }

    .half-section,
    .quarter-section,
    .third-section {
        width: 100%;
        flex: 0 0 100%;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
}

.card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.card-img {
    height: 200px;
    background: #eee;
    overflow: hidden;
    position: relative;
}

.card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform 0.5s ease;
}

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

.card-content {
    padding: 25px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-content h3 {
    font-family: var(--font-heading);
    color: var(--primary);
    margin-bottom: 5px;
    font-size: 1.3rem;
}

.subtitle {
    color: #777;
    font-size: 0.95rem;
    margin-bottom: 15px;
    font-style: italic;
}

.read-more {
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9rem;
    margin-top: auto;
    display: inline-block;
}

.read-more:hover {
    text-decoration: underline;
}

/* --- HISTOIRE (GRID 3 COLONNES) --- */
/* --- Dropdown Menu --- */
.nav-links li {
    position: relative;
    /* For positioning dropdown */
}

/* Light Mode Dropdown (Default) */
.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--white);
    /* Match Header Background */
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    list-style: none;
    padding: 0;
    border-radius: 0 0 8px 8px;
    border-top: 2px solid var(--accent);
    /* Visual separator */
}

.dropdown li a {
    display: block;
    padding: 12px 16px;
    color: var(--text);
    /* Use theme text color */
    text-decoration: none;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    /* Subtle separator */
    transition: color 0.3s;
}

.dropdown li a:hover {
    background-color: transparent;
    /* No background change */
    color: var(--accent);
    /* Accent color on hover */
}

/* Dark Mode Overrides */
[data-theme="dark"] .dropdown {
    background-color: var(--white);
    /* This becomes Dark Grey/Black in Dark Mode */
    border: none;
    border-top: 2px solid var(--accent);
}

[data-theme="dark"] .dropdown li a {
    color: var(--text);
    /* White/Light Grey in Dark Mode */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dropdown li a:hover {
    background-color: transparent;
    color: var(--gold);
    /* Gold on Hover */
}

/* Show Dropdown on Hover */
.nav-links li:hover .dropdown {
    display: block;
}

/* --- Submenu (Nested Dropdown) --- */
.submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    min-width: 220px;
    background-color: var(--white);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    list-style: none;
    padding: 0;
    border-top: 2px solid var(--accent);
    border-radius: 0 8px 8px 8px;
}

.dropdown li:hover>.submenu {
    display: block;
}

.submenu li a {
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    display: block;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.submenu li a:hover {
    background-color: transparent;
    color: var(--accent);
}

/* Dark Mode Submenu */
[data-theme="dark"] .submenu {
    background-color: var(--white);
    /* Dark bg */
    border-top: 2px solid var(--accent);
}

[data-theme="dark"] .submenu li a {
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .submenu li a:hover {
    color: var(--gold);
}

/* Mobile Dropdown */
@media (max-width: 768px) {
    .dropdown {
        position: static;
        box-shadow: none;
        background-color: var(--white);
        /* Match section background */
        display: none;
        margin-left: 20px;
        /* Indent on mobile */
        border-left: 2px solid var(--accent);
        /* Indication of hierarchy */
        /* ... */
        /* display: block; removed to keep it closed by default */
        min-width: 100%;
    }

    .dropdown li a {
        padding-left: 30px;
        font-size: 1.2rem;
    }
}

/* --- BLOG / EVENTS GRID --- */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.blog-post {
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s;
}

.blog-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.blog-img-large {
    height: 350px;
    overflow: hidden;
}

.blog-img-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: 0.5s;
}

.blog-post:hover .blog-img-large img {
    transform: scale(1.05);
}

.blog-content {
    padding: 30px;
}

.blog-content h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin-bottom: 15px;
    color: var(--primary);
    margin: 0;
}

.blog-btn {
    display: inline-block;
    margin-top: 15px;
    color: var(--accent);
    font-weight: bold;
    border-bottom: 2px solid var(--gold);
    padding-bottom: 2px;
}

.blog-btn:hover {
    color: #a93226;
    border-bottom-color: #a93226;
}

/* --- FOOTER --- */
footer {
    background: var(--footer-bg);
    color: white;
    padding: 70px 0 30px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 50px;
    margin-bottom: 50px;
}

.footer-col h4 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--gold);
    margin-bottom: 25px;
    position: relative;
    display: inline-block;
}

.footer-col h4::after {
    content: '';
    display: block;
    width: 30px;
    height: 2px;
    background: var(--gold);
    margin-top: 10px;
}

.footer-links li {
    margin-bottom: 12px;
}

.footer-links a {
    color: #ddd;
    transition: 0.3s;
}

.footer-links a:hover {
    color: white;
    padding-left: 5px;
    color: var(--gold);
}

.copyright {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
    color: #aaa;
}

/* --- MOBILE & ANIMATIONS --- */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .burger {
        display: block;
        position: relative;
        z-index: 2000;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 100%;
        background-color: #2c3e50;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transform: translateX(100%);
        transition: transform 0.4s ease-in-out;
        z-index: 1500;
    }

    .nav-links li {
        margin: 25px 0;
        opacity: 0;
    }

    .nav-links a {
        color: white;
        font-size: 1.5rem;
    }

    .btn-contact {
        border-color: white;
        color: white;
    }

    .nav-active {
        transform: translateX(0%);
    }

    .nav-active li {
        opacity: 1;
    }

    .toggle .line1 {
        transform: rotate(-45deg) translate(-5px, 6px);
        background-color: white;
    }

    .toggle .line2 {
        opacity: 0;
    }

    .toggle .line3 {
        transform: rotate(45deg) translate(-5px, -6px);
        background-color: white;
    }

    @keyframes navLinkFade {
        from {
            opacity: 0;
            transform: translateX(50px);
        }

        to {
            opacity: 1;
            transform: translateX(0px);
        }
    }

    .hero h2 {
        font-size: 2.5rem;
    }

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

    /* Une seule colonne sur mobile */
    .blog-img-large {
        height: 220px;
    }

    /* Moins haut sur mobile */
}

.btn-blue {
    background: #2c3e50;
    color: white;
    box-shadow: none;
}

.btn-blue:hover {
    background: #34495e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4);
}

/* --- SCROLL TO TOP BUTTON --- */
/* --- SCROLL TO TOP BUTTON --- */
#scrollTopBtn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    /* Default (Dark Mode): Red Background, Black Arrow */
    background-color: var(--accent);
    color: #000000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-color: var(--accent);
    /* Hide border in default/dark */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.3s;
    z-index: 9999;
}

#scrollTopBtn.show {
    opacity: 1;
    pointer-events: auto;
}

#scrollTopBtn:hover {
    /* Default (Dark Mean): Menu BG, White Arrow */
    background-color: var(--header-bg);
    color: #ffffff;
    transform: translateY(-3px);
}

/* Light Mode Overrides */
[data-theme="light"] #scrollTopBtn {
    /* Light Mode: Header BG (Dark Blue), White Arrow */
    background-color: var(--header-bg);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="light"] #scrollTopBtn:hover {
    /* Light Mode Hover: Accent BG (Red), Dark Grey Arrow */
    background-color: var(--accent);
    color: #333333;
}