html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
}

#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

#sidebar {

    position: absolute;

    top: 20px;
    right: 20px;
    left: auto;

    width: clamp(320px, 38vw, 510px);

    max-height: calc(100vh - 40px);

    overflow-y: auto;

    z-index: 6000;

    padding: 0;

    background: transparent;

    border: none;

    box-shadow: none;
}

#search{

width:100%;

padding:10px;

margin-bottom:15px;

font-size:13px;

}

details{

    margin-bottom:12px;

}

summary{

    cursor:pointer;
    font-size:13px;
    margin-bottom:10px;

}

.section{

    margin-top:10px;
    margin-left:5px;

}

.section label{

    display:block;
    margin:6px 0;
    font-size: 13px;

}

.section input[type="text"]{

    width:95%;
    padding:8px;
    border-radius:5px;
    border:1px solid #ccc;

}


/* ======================================================
   BARRE DE CONTRÔLES SUPÉRIEURE
   ====================================================== */

#top-left-stack {

    position: absolute;

    top: 20px;
    left: 20px;

    z-index: 5000;

    display: flex;

    flex-direction: column;

    align-items: flex-start;

    gap: 10px;
}

#top-controls {

    position: relative;

    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

    row-gap: 10px;

    z-index: 5000;

    width: auto;

    max-width: calc(100vw - 40px - clamp(320px, 38vw, 510px));
}




/* ===========================
   Barre de recherche
=========================== */

#search-container {

    position: relative;

    width: clamp(260px, 24vw, 360px);

    z-index: 5000;

    background: rgba(255,255,255,0.82);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    border-radius: 14px;

    box-shadow: 0 4px 12px rgba(0,0,0,0.18);

    padding: 6px;

    box-sizing: border-box;
}

#search {
    width: 100%;
    border: none;
    outline: none;
    font-size: 13px;
    background: transparent;
    padding: 4px;
}


/* ======================================
   bouton reset
====================================== */

#reset-map {

    position: static;

    z-index: 5000;

    border: none;

    padding: 11px 14px;

    border-radius: 11px;

    background: rgba(255,255,255,.88);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    box-shadow: 0 2px 8px rgba(0,0,0,.15);

    cursor: pointer;

    font-weight: bold;

    font-size: 13px;

    transition: .2s;

    white-space: nowrap;

    flex-shrink: 0;
}


#reset-map:hover {

    transform: translateY(-2px);

    box-shadow: 0 4px 15px rgba(0,0,0,.25);

}

/* ======================================
   PANNEAU COUCHES
====================================== */

#layers-panel {

    position: relative;

    width: clamp(280px, 30vw, 380px);

    z-index: 4000;

    background: rgba(255,255,255,.88);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    border-radius: 12px;

    padding: 15px;

    box-shadow: 0 4px 15px rgba(0,0,0,.2);

    font-size: 13px;

    max-height: calc(100vh - 140px);

    overflow-y: auto;
}

#layers-panel hr{

    margin:12px 0;

}

#layers-panel label{

    display:block;

    margin:8px 0;

    cursor:pointer;

    font-size: 13px;

}

.panel-section{

    background:rgba(255,255,255,.82);

    backdrop-filter:blur(10px);

    border-radius:16px;

    padding:14px;

    margin-bottom:12px;

}

.panel-section h3{

    margin:0 0 12px 0;

    font-size:13px;

}

/* ===========================
   FILTRES THEMATIQUES
=========================== */

#theme-filters {

    display: flex;

    align-items: center;

    gap: 8px;

    flex-wrap: wrap;

    row-gap: 8px;

    min-width: 0;

    position: static;
}

.theme-btn,
#reset-filters {
    border: none;

    padding: 11px 13px;

    border-radius: 9px;

    background: rgba(255,255,255,.88);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    box-shadow: 0 2px 8px rgba(0,0,0,.15);

    cursor: pointer;

    font-size: 13px;

    transition: .2s;
}

.theme-btn:hover,
#reset-filters:hover{

    transform:translateY(-2px);

    box-shadow:0 4px 15px rgba(0,0,0,.25);

}

/* ===========================
   COULEUR DES BOUTONS THÉMATIQUES
   =========================== */

.theme-btn {
    color: rgb(0, 0, 0);
    border: none;
    font-weight: 600;
}

/* Forêts */
.theme-btn[data-theme="Forêts"] {
    background: #9AAA81;
}

/* Zones humides */
.theme-btn[data-theme="Zones Humides"] {
    background: #8BAEB3;
}

/* Océans */
.theme-btn[data-theme="Océans"] {
    background: #55718C;
}

/* Renforcement des capacités */
.theme-btn[data-theme="Renforcement des Capacités"] {
    background: #B99657;
}

/* Éducation */
.theme-btn[data-theme="Éducation"] {
    background: #ffc400;
}




/* ===========================
   BOUTON ACTIF
   =========================== */

.theme-btn.active {
    filter: brightness(0.80);

    color: white;

    border: 2px solid rgba(0,0,0,0.35);

    box-shadow:
        0 3px 10px rgba(0,0,0,0.25);
}

/* ========================= */
/* PANNEAU PROJET */
/* ========================= */

#project-info {

    display: flex;

    flex-direction: column;

    font-size: 13px;

}


.info-card {

    background: rgba(255,255,255,.88);

    backdrop-filter: blur(10px);

    border-radius: 18px;

    padding: 18px;

    box-shadow: 0 8px 18px rgba(0,0,0,.18);

    margin-bottom: 18px;

}


/* ========================= */
/* PHOTO */
/* ========================= */

.project-photo {

    position: relative;

    width: 100%;

    margin-bottom: 16px;

}


.project-image {

    width: 100%;

    height: 180px;

    object-fit: cover;

    border-radius: 12px;

    display: block;

}


/* ========================= */
/* LIEN PHOTO */
/* ========================= */

.project-photo-link {

    display: block;

    text-decoration: none;

}


.project-photo-link .project-image {

    cursor: pointer;

    transition:
        transform .2s,
        opacity .2s;

}


.project-photo-link:hover .project-image {

    opacity: .88;

    transform: scale(1.01);

}


/* ========================= */
/* LÉGENDE PHOTO */
/* ========================= */

.photo-caption {

    position: absolute;

    bottom: 0;

    left: 0;

    right: 0;

    padding: 6px 9px;

    box-sizing: border-box;

    background: rgba(255,255,255,.78);

    color: #000;

    font-size: 10px;

    line-height: 1.3;

    text-align: left;

}


/* ========================= */
/* TITRE */
/* ========================= */

.info-card h2 {

    margin: 0 0 18px 0;

    font-size: 19px;

    line-height: 1.3;

    font-weight: bold;

    text-align: center;

    color: #303359;

}


/* ========================= */
/* INFORMATIONS */
/* ========================= */

.info-row {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 15px;

    margin: 10px 0;

    font-size: 13px;

}


.info-row strong {

    flex-shrink: 0;

}


.info-row span {

    text-align: right;

}


.info-row:has(.status-phases-list) {

    align-items: flex-start;

}


.status-phases-list {

    display: flex;

    flex-direction: column;

    gap: 3px;

}


.status-phase {

    white-space: nowrap;

}


.status-phase:first-child {

    font-weight: 600;

}


/* ========================= */
/* BADGE THÉMATIQUE */
/* ========================= */

.theme-badge {

    color: white;

    padding: 4px 10px;

    border-radius: 20px;

    font-weight: 600;

    font-size: 13px;

}


/* ========================= */
/* DESCRIPTION */
/* ========================= */

.project-description {

    margin-top: 20px;

    padding-top: 15px;

    border-top: 1px solid rgba(0,0,0,.12);

}


.project-description h3 {

    margin: 0 0 10px 0;

    font-size: 14px;

    color: #303359;

}


.project-description p {

    margin: 0;

    line-height: 1.6;

    text-align: justify;

    font-size: 13px;

}


/* ========================= */
/* POPUPS MAPLIBRE */
/* ========================= */

.maplibregl-popup-content {

    background: rgba(255,255,255,0.92);

    backdrop-filter: blur(10px);

    border-radius: 14px;

    box-shadow: 0 4px 12px rgba(0,0,0,0.18);

    padding: 13px 15px;

    border: none;

}


.maplibregl-popup-tip {

    border-top-color: rgba(255,255,255,0.92) !important;

}


/* ======================================================
   RÉSULTATS DE RECHERCHE
   ====================================================== */

#search-results {

    display: none;

    position: absolute;

    top: calc(100% + 8px);

    left: 0;

    width: clamp(400px, 35vw, 600px);

    max-height: 400px;

    overflow-y: auto;

    background: rgba(255,255,255,0.94);

    backdrop-filter: blur(10px);

    -webkit-backdrop-filter: blur(10px);

    border-radius: 12px;

    box-shadow: 0 4px 15px rgba(0,0,0,0.18);

    box-sizing: border-box;

    z-index: 6000;
}


/* Résultat */

.search-result {

    padding: 12px 14px;

    cursor: pointer;

    border-bottom: 1px solid rgba(0,0,0,0.08);

}


.search-result:last-child {

    border-bottom: none;

}


.search-result:hover {

    background: rgba(0,0,0,0.06);

}


/* Titre */

.search-result-title {

    font-size: 13px;

    font-weight: bold;

    color: #222;

    line-height: 1.3;

}


/* Partenaire / pays */

.search-result-details {

    margin-top: 4px;

    font-size: 13px;

    color: #666;

}


/* Aucun résultat */

.search-no-result {

    padding: 15px;

    font-size: 13px;

    color: #666;

}


#faw-logo {
    position: absolute;

    top: 20px;
    right: 20px;

    width: 160px;
    height: auto;

    z-index: 5000;

    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.15));
}


/* ======================================================
   ADAPTATION AUX ÉCRANS PLUS PETITS
   ====================================================== */

@media (max-width: 1150px) {

    #theme-filters {
        gap: 5px;
    }

    #theme-filters .theme-btn {
        padding: 10px 10px;
        font-size: 13px;
    }

    #search-container {
        width: clamp(220px, 22vw, 300px);
    }

    #reset-map {
        padding: 10px 12px;
        font-size: 13px;
    }

    #faw-logo {
        width: 120px;
        top: 15px;
        right: 15px;
    }
}

/* ======================================================
   NOM DES PAYS AU SURVOL
   ====================================================== */

.country-popup .maplibregl-popup-content {

    padding: 8px 12px;

    border-radius: 8px;

    background: rgba(255, 255, 255, 0.92);

    backdrop-filter: blur(8px);

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);

    font-family: Arial, sans-serif;

    font-size: 13px;

    font-weight: bold;

    color: #333;
}

.country-popup .maplibregl-popup-tip {
    display: none;
}





/* ========================================= */
/* LÉGENDE CARTOGRAPHIQUE */
/* ========================================= */

.map-legend {

    position: absolute;

    bottom: 25px;
    left: 15px;

    background: rgba(255, 255, 255, 0.95);

    padding: 14px 16px;

    border-radius: 10px;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);

    font-family: Arial, sans-serif;
    font-size: 13px;

    z-index: 10;

    display: none;
}


/* Titre */

.legend-title {

    font-weight: bold;

    margin-bottom: 10px;

}


/* Ligne de légende */

.legend-item {

    display: flex;

    align-items: center;

    margin-bottom: 7px;

}


/* Carrés de couleur */

.legend-color {

    width: 16px;
    height: 16px;

    margin-right: 8px;

    border-radius: 3px;

    display: inline-block;

}


/* Rouge */

.legend-color.conflict {

    background-color: #d7191c;

}


/* Orange */

.legend-color.high-risk {

    background-color: #f28e2b;

}


/* Source */

.legend-source {

    margin-top: 10px;

    padding-top: 8px;

    border-top: 1px solid #ddd;

    font-size: 11px;

    color: #666;

}


.legend-source a {

    color: #555;

    text-decoration: underline;

}




/* ========================================================= */
/* RESPONSIVE - TÉLÉPHONE EN MODE PAYSAGE */
/* ========================================================= */

@media screen and (max-width: 1000px) and (max-height: 500px) {

    /* =============================== */
    /* PILE HAUT-GAUCHE */
    /* =============================== */

    #top-left-stack {

        top: 10px;
        left: 10px;
        right: 10px;

        gap: 8px;

    }


    /* =============================== */
    /* CONTROLES DU HAUT */
    /* =============================== */

    #top-controls {

        position: relative;

        width: 100%;

        max-width: 100%;

        display: flex;

        align-items: flex-start;

        gap: 8px;

        z-index: 5000;

    }


    /* =============================== */
    /* FILTRES THÉMATIQUES */
    /* =============================== */

    #theme-filters {

        display: flex;

        flex-wrap: wrap;

        row-gap: 6px;

        gap: 6px;

        flex: 1;

        min-width: 0;

    }


    .theme-btn {

        flex-shrink: 0;

        padding: 8px 12px;

        font-size: 12px;

    }


    /* =============================== */
    /* RÉINITIALISER */
    /* =============================== */

    #reset-map {

        flex-shrink: 0;

        padding: 8px 12px;

        font-size: 12px;

        white-space: nowrap;

    }


    /* =============================== */
    /* BARRE DE RECHERCHE */
    /* =============================== */
    /* Passe sur sa propre ligne (width:100% dans un
       conteneur flex-wrap) plutôt que d'être repositionnée
       en absolu — reste ainsi cohérente avec le reste
       de la pile #top-left-stack. */

    #search-container {

        position: relative;

        order: 10;

        width: 100%;

        max-width: none;

    }


    /* =============================== */
    /* PANNEAU DE GAUCHE (COUCHES) */
    /* =============================== */

    #layers-panel {

        width: 100%;

        max-width: none;

        max-height: calc(100vh - 130px);

    }


    /* =============================== */
    /* PANNEAU DE GAUCHE (FICHE PROJET) */
    /* =============================== */
    /* Passe en panneau plein-écran ancré en bas plutôt qu'à
       droite : à cette largeur, cohabiter horizontalement avec
       #top-left-stack n'est plus tenable quel que soit le
       nombre de lignes que celui-ci occupe. */

    #sidebar {

        top: auto;

        bottom: 0;

        left: 0;

        right: 0;

        width: 100%;

        max-width: 100%;

        max-height: 65vh;

        overflow-y: auto;

    }

    #sidebar .info-card {

        border-radius: 16px 16px 0 0;

        margin-bottom: 0;

    }


    /* =============================== */
    /* INFOS PROJET */
    /* =============================== */

    #project-info {

        width: min(380px, 42vw);

        max-height: calc(100vh - 80px);

        overflow-y: auto;

    }


    /* =============================== */
    /* CARTE INFO PROJET */
    /* =============================== */

    .info-card {

        padding: 12px;

    }


    .project-image {

        height: 140px;

    }


    .info-card h2 {

        font-size: 17px;

    }


    .info-row {

        font-size: 12px;

    }


    .theme-badge {

        font-size: 12px;

        padding: 3px 8px;

    }


    .project-description p {

        font-size: 12px;

        line-height: 1.45;

    }

}


/* ================================================= */
/* LÉGENDE BIOMES TERRESTRES */
/* ================================================= */

#legend-ecoregions {

    width: 1050px;
    max-width: calc(100vw - 40px);

    box-sizing: border-box;

    padding: 7px 10px;
}


/* 5 colonnes */

#legend-ecoregions .legend-grid {

    display: grid;

    grid-template-columns: repeat(5, 1fr);

    column-gap: 14px;

    row-gap: 1px;
}


/* Éléments */

#legend-ecoregions .legend-item {

    margin: 0;

    min-width: 0;

    line-height: 1.15;
}


/* Titre */

#legend-ecoregions .legend-title {

    margin-bottom: 4px;

    font-size: 13px;
}


/* Source */

#legend-ecoregions .legend-source {

    margin-top: 4px;

}


.info-icon {

    width: 16px;
    height: 16px;

    object-fit: contain;

    vertical-align: middle;

    margin-right: 7px;
}




/* ================================================= */
/* SÉLECTEUR DE LANGUE */
/* ================================================= */

#language-switcher {

    display: flex;

    gap: 4px;

}


.language-btn {

    border: none;

    background: rgba(255,255,255,0.85);

    color: #303359;

    font-size: 12px;

    font-weight: 600;

    padding: 5px 8px;

    border-radius: 6px;

    cursor: pointer;

}


.language-btn.active {

    background: #303359;

    color: white;

}


.language-btn:hover {

    opacity: 0.85;

}

.theme-icon {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
    object-fit: contain;
}