/* ==========================================================================
   Carte interactive – structure principale
   ========================================================================== */

/* Conteneur principal de la carte */
.contenu-wrapper {
    max-width: 1160px;
}

@media (min-width: 767px) {
    #texte,
    h1,
    .h1 {
        max-width: 767px;
        margin-left: auto;
        margin-right: auto;
    }
}
@media (min-width: 1200px) {
    main .contenu-wrapper {
        padding-left: 0;
        padding-right: 0;
    }             
}
section {
    max-width: none;
    margin-bottom: 54px;
}
#map-container {
    position: relative;
    max-width: 1160px;
    margin: 1rem auto 0;
}
#texte {
    max-width: 767px;
}

/* Contrôles de zoom, positionnés en bas à droite de la carte */
#map-controls {
    position: absolute;
    right: 0.5rem;
    bottom: 0.5rem;
    z-index: 1000;
}
@media (min-width: 431px) {
    #map-controls {
        right: 1rem;
        bottom: 1rem;
    }
}

/* Boutons des contrôles de zoom */
#map-controls button {
    background-color: rgb(240, 240, 240);
    display: block;
    font-size: 1.5rem;
    margin: 0 0.2rem;
    width: 44px;
    height: 44px;
    cursor: pointer;
}
#map-controls button:disabled {
    background-color: light-dark(rgba(239, 239, 239, 0.6), rgba(19, 1, 1, 0.6));
    color: light-dark(rgba(16, 16, 16, 0.6), rgba(255, 255, 255, 0.6));
    border-color: light-dark(rgba(118, 118, 118, 0.2), rgba(195, 195, 195, 0.2));
    cursor: default;
}
/* Coins arrondis des boutons zoom */
#zoom-in {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

#zoom-out {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* ==========================================================================
   Zone d’affichage de la carte
   ========================================================================== */

/**
 * Zone visible de la carte avec rapport d’aspect
 * Contient les calques positionnés en absolu
 */
#viewport {
    position: relative;
    width: 100%;
    min-height: 500px;
    aspect-ratio: 1 / 1.35;
    overflow: hidden;
    border: 1px solid #ccc;
    cursor: grab;
    touch-action: pan-x pan-y;
}
@media (min-width: 431px) {
    #viewport {
        aspect-ratio: 1 / 1;
    }
}
@media (min-width: 768px) {
    #viewport {
        aspect-ratio: 3360 / 2300;
        min-height: 300px;
    }
}


/* Calques superposés contenant les images */
#map-layers {
    position: absolute;
    top: 0;
    left: 0;
    width: 2150px;
    height: 1487px;
    transform-origin: top left;
    transition: transform 0.1s linear;
}



/* ==========================================================================
   Calques
   ========================================================================== */

/**
 * Calque standard (masqué par défaut)
 * S’affiche en fondu avec pointer-events désactivé sauf s’il est visible
 */
.layer {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.2s linear;
    pointer-events: none;
}

/* Calque activé manuellement */
.layer.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Calque toujours visible, mais non interactif */
.layer.always-visible {
    opacity: 1;
    pointer-events: none;
}

/* Image dans un calque : couvre tout l’espace */
.layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* ==========================================================================
   Boutons
   ========================================================================== */


    .toggle-group-wrapper {
        margin: 1.5rem auto 0;
        text-align: center;
    }
    .toggle-group {
        position: relative;
        display: inline-flex;
        background: #f5f5f5;
        border-radius: 9999px;
        padding: 4px;
        gap: 0;
        box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.05);
        overflow: hidden;
    }

    /* Fond animé */
    .toggle-group::before {
        content: "";
        position: absolute;
        top: 4px;
        left: 0;
        width: calc(100% / 3);
        height: calc(100% - 8px);
        background: #074b98;
        border-radius: 9999px;
        transition: left 0.3s ease, width 0.3s ease;
        z-index: 0;
    }

    .toggle-btn {
        position: relative;
        flex: 1;
        border: none;
        background: none;
        padding: 0.4rem 1.2rem;
        font-weight: 500;
        cursor: pointer;
        color: #000;
        z-index: 0;
        border-radius: 9999px;
        font-size: 1rem;
        font-family: proxima-nova, sans-serif !important;
        transition: color 0.3s ease;
    }
    .toggle-btn.actif {
        color: white;
    }

    /* Position du fond en fonction du bouton actif */
    .toggle-group[data-active="actuel"]::before {
        left: 2%;
        /*width: calc(100% / 3.05);*/
        width: calc(100% / 1.84);
    }

    .toggle-group[data-active="projet"]::before {
        left: 36%;
        width: calc(100% / 3.00);
    }

    .toggle-group[data-active="tout"]::before {
        left: 54%;
        /*width: calc(100% / 3.45);*/
        width: calc(100% / 2.28);
    }


/* =======================
   Structure de la légende
   ======================= */

/* Conteneur de la légende (même largeur que la carte) */
#legend-container {
    position: relative;
    max-width: 1160px;
    margin: 1rem auto;
}
#legend-container.open #legend-controls {
    transform: translateX(0);
}

#legend-container.open #legend-overlay {
    display: block;
}
@media (max-width: 767px) {
    #legend-details-container {
        margin-top: 3rem;
    }
}
@media (min-width: 768px) {
    #legend-details-container {
        column-count: 2;
    }
}
@media (min-width: 1024px) {
    #legend-details-container {
        column-count: 3;
    }
}

/* Groupe de légende */
.legend-group {
    margin-bottom: 1rem;
    overflow: hidden;
    background: white;
    transition: all 0.3s ease;
}

.legend-group[open] {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Titre de chaque groupe */
.legend-group summary {
    padding: 0.25rem 0;
    font-weight: bold;
    position: relative;
}

/* Cases à cocher */
.legend-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    margin: 0.2rem 0;
    user-select: none;
}


.legend-group input[type="checkbox"] {
    margin: 0;
}
.legend-group .vh {
    visibility: hidden;
}
.legend-item-description {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1.8rem;
    user-select: none;
}
.legend-item-sub-description {
    padding: 0 0 0.25rem 1.8rem;
    font-size: 0.9rem;
    line-height: 1.25;
}

.legend-marker {
    display: inline-block;
    width: 24px;
    height: 8px;
    flex-shrink: 0;
}

.legend-item--hidden {
    display: none !important;
}


/* =======================
   Styles personnalisés pour chaque couche
   ======================= */

.legend-marker.flexibus {
    background-color: #ede1d4;
    border: 1px solid #949494;
}
.legend-marker.flexibus-projet {
    background-color: #eddac5;
    border: 1px solid #949494;
}
.legend-marker.velo-actuel {
    background-color: #ed1c24;
}
.legend-marker.velo-dame {
    background-color: #14c0f3;
}
.legend-marker.velo-deneige {
    background-image: repeating-linear-gradient(90deg,
                #007db6,
                #007db6 3px,
                white 3px,
                white 6px);
    height: 3px;
}

.legend-marker.avelo-actuel {
    background-color: #98d4c3;
}

.legend-marker.avelo-projet {
    background-color: #d4ece4;
    border: 1px solid #949494;
}

.legend-marker.rtc-actuel {
    background-color: #ccb291;
    border: 1px solid #949494;
}

.legend-marker.rtc-projet {
    background-image: repeating-linear-gradient(90deg,
                #aa6d2b,
                #aa6d2b 3px,
                white 3px,
                white 4px);
        height: 6px;
}

.legend-marker.tramway {
    background-image: repeating-linear-gradient(90deg,
                #7d256e,
                #7d256e 10px,
                white 10px,
                white 14px);
    height: 6px;
}
.legend-marker.tramway-souterrain {
    background-image: repeating-linear-gradient(90deg,
            #231f20,
            #231f20 10px,
            white 10px,
            white 14px);
    height: 6px;
}

.legend-marker.cvc-actuel {
    background-color: #00285e;
}

.legend-marker.cvc-projet {
    background-color: #00539f;
}

.legend-marker.boulevards {
    background-color: #00909e;
}


/* =======================
   Boutons d'action
   ======================= */
/*
#legend-controls .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

#legend-controls .actions button {
    padding: 0.25rem 0.75rem;
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

#toggle-all-layers {
    margin-bottom: 0.5rem;
}
@media (min-width: 768px) {
    #toggle-all-layers {
        display: block;
        margin: 0 0 0.5rem auto;
    }
}
    */

/* =======================
   Responsive : panneau mobile
   ======================= */

@media (min-width: 768px) {
    #legend-toggle-button {
        display: none;
    }
    #close-legend {
        display: none;
    }
}

@media (max-width: 767px) {

    #legend-controls {
        position: fixed;
        top: 0;
        right: 0;
        width: 80%;
        height: 100%;
        background-color: white;
        box-shadow: -2px 0 5px rgba(0, 0, 0, 0.3);
        padding: 1rem;
        overflow-y: auto;
        z-index: 1020;
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
    }

    #legend-controls.open {
        transform: translateX(0);
    }

    /* Overlay pour permettre de fermer le panneau mobile au clic */
    #legend-overlay {
        position: fixed;
        inset: 0;
        display: none;
        z-index: 1010;
    }

    #legend-controls.open~#legend-overlay {
        display: block;
    }

    /* Bouton de fermeture */
    #close-legend {
        display: block;
        position: absolute;
        top: 1rem;
        right: 1rem;
    }
    #legend-toggle-button {
        position: absolute;
        bottom: 1rem;
        left: 1rem;
        z-index: 1005;
    }
}
@media (max-width: 430px) {
    #legend-toggle-button {
        bottom: 0.5rem;
        left: 0.5rem;
    }
}


/* =======================
   Loader
   ======================= */

#map-loader {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    /* ou transparent selon ton style */
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #ccc;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}