/* ============================================================================
 * CARTE RÉGION — Styles externalisés
 * Fichier : css/hr-carte-region.css
 * Thème enfant : Free-DIVI-Child-Theme-by-Pee-Aye-Creative
 *
 * Convention de classes :
 *   .hr-carte-region          → wrapper principal
 *   .hr-carte-region .hr-map  → conteneur de la carte Leaflet
 *
 * Propriétés dynamiques restant en inline (style="") :
 *   - max-width du wrapper (largeur_carte)
 *   - height + width du .hr-map (hauteur_carte, largeur_carte)
 * ============================================================================ */

/* === WRAPPER PRINCIPAL === */
.hr-carte-region {
    position: relative;
    width: 100%;
    /* max-width: dynamique via style="" */
    margin: 0 auto;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

/* === TITRE INTÉGRÉ === */
.hr-carte-region .map-title-integrated {
    background: #05668d;
    color: #fff;
    padding: 6px 12px;
    margin: 0;
    font-size: 0.95em;
    font-weight: 600;
    text-align: left;
    position: relative;
    z-index: 1;
}

/* === CONTENEUR CARTE === */
.hr-carte-region .hr-map {
    /* height, width : dynamiques via style="" */
    position: relative;
}

/* === CONTRÔLES LEAFLET === */
.hr-carte-region .hr-map .leaflet-control-zoom a,
.hr-carte-region .hr-map .leaflet-control-zoom a:hover {
    text-decoration: none !important;
}

.hr-carte-region .hr-map .leaflet-popup-close-button,
.hr-carte-region .hr-map .leaflet-popup-close-button:hover {
    text-decoration: none !important;
}

/* === INSTRUCTION TACTILE (mobile 2 doigts) === */
.hr-carte-region .hr-map .map-touch-instruction {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    z-index: 10000;
    pointer-events: none;
    text-align: center;
    padding: 30px;
}

.hr-carte-region .hr-map .map-touch-instruction.show {
    display: flex;
}

/* === MARQUEURS === */
.hr-carte-region .hr-map .leaflet-marker-icon {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* === CLUSTERS VERTS === */
.hr-carte-region .hr-map .marker-cluster-small,
.hr-carte-region .hr-map .marker-cluster-medium,
.hr-carte-region .hr-map .marker-cluster-large {
    background-color: transparent !important;
}

.hr-carte-region .hr-map .marker-cluster-small div,
.hr-carte-region .hr-map .marker-cluster-medium div,
.hr-carte-region .hr-map .marker-cluster-large div {
    background-color: #77d242 !important;
    opacity: 0.75;
    color: #333 !important;
    font-weight: bold !important;
    border-radius: 50% !important;
}

/* === BOUTON HOME === */
.hr-carte-region .hr-map .leaflet-control-home {
    background: #fff;
    border: 2px solid rgba(0,0,0,0.35);
    border-radius: 4px;
    width: 33px;
    height: 33px;
    cursor: pointer;
    display: none;
}

.hr-carte-region .hr-map .leaflet-control-home a {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #000;
    font-size: 18px;
    background-image: none !important;
}

.hr-carte-region .hr-map .leaflet-control-home a:hover {
    background-color: #f4f4f4;
    border-radius: 2px;
}

/* === ESPACEMENT CONTRÔLES === */
.hr-carte-region .hr-map .leaflet-top.leaflet-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hr-carte-region .hr-map .leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
}

/* === BOUTON FULLSCREEN === */
.hr-carte-region .hr-map .leaflet-control-fullscreen a {
    background-image: none !important;
    font-size: 18px;
    line-height: 26px !important;
    text-align: center;
}

.hr-carte-region .hr-map .leaflet-control-fullscreen a:before {
    content: '⛶';
}

.hr-carte-region .hr-map .leaflet-fullscreen-on .leaflet-control-fullscreen a:before {
    content: '✕';
}

/* === PLEIN ÉCRAN ===
 * Même système que carte_randonnee : body.hr-fs-active + [data-hr-fs] */

body.hr-fs-active .hr-carte-region[data-hr-fs],
body.hr-fs-active .hr-carte-region[data-hr-fs] * {
    visibility: visible !important;
}

body.hr-fs-active .hr-carte-region[data-hr-fs] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    margin: 0 !important;
    z-index: 2147483647 !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
}

body.hr-fs-active .hr-carte-region[data-hr-fs] .map-title-integrated {
    position: relative !important;
    width: 100% !important;
    flex-shrink: 0 !important;
}

body.hr-fs-active .hr-carte-region[data-hr-fs] .hr-map {
    flex: 1 !important;
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
}

/* Plein écran mobile : carte seule, sans titre */
@media screen and (max-width: 768px) {
    body.hr-fs-active .hr-carte-region[data-hr-fs] .map-title-integrated {
        display: none !important;
    }

    body.hr-fs-active .hr-carte-region[data-hr-fs] .hr-map {
        flex: 1 !important;
        height: 100% !important;
        min-height: 0 !important;
    }
}

/* === POPUPS === */
.hr-carte-region .hr-map .leaflet-popup-content-wrapper {
    width: 200px !important;
    overflow: hidden !important;
}

.hr-carte-region .hr-map .leaflet-popup-content {
    margin: 0 !important;
    padding: 10px !important;
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    box-sizing: border-box !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
}

.hr-carte-region .hr-map .leaflet-popup-content p {
    margin: 0.2em 0 0;
    line-height: 1.3em;
    font-size: 1.1em;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
}

.hr-carte-region .hr-map .leaflet-popup-content .popup-titre {
    font-size: 1.4em;
    color: #05668d !important;
    margin-bottom: 8px;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    hyphens: auto !important;
    max-width: 100% !important;
    white-space: normal !important;
}

.hr-carte-region .hr-map .leaflet-popup-content .popup-titre a {
    color: #05668d !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    display: inline !important;
    white-space: normal !important;
    max-width: 100% !important;
}

.hr-carte-region .hr-map .leaflet-popup-content a {
    display: block;
    width: 100%;
    overflow: hidden;
}

.hr-carte-region .hr-map .leaflet-popup-content img {
    display: block;
    max-width: 180px !important;
    height: auto !important;
    margin: 8px 0px 0 0px;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    transition: opacity 0.3s ease;
}

/* Hover opacité desktop uniquement */
@media (hover: hover) and (pointer: fine) {
    .hr-carte-region .hr-map .leaflet-popup-content a:hover .popup-rando-img {
        opacity: 0.85;
    }
}

.hr-carte-region .hr-map .leaflet-popup-content .popup-titre a:hover {
    text-decoration: none !important;
}

/* Curseur pointer sur les tracés GPX */
.hr-carte-region .hr-map.leaflet-container .leaflet-interactive {
    cursor: pointer;
}

/* === CERCLE PULSANT (rando active) === */
.pulse-marker-region {
    animation: pulse-region 2s ease-in-out infinite;
}
@keyframes pulse-region {
    0% { opacity: 1; stroke-width: 2; }
    50% { opacity: 0.4; stroke-width: 4; }
    100% { opacity: 1; stroke-width: 2; }
}

/* Bordure pulsante sur le cluster contenant la rando active */
.cluster-has-active div {
    border: 3px solid #e74c3c !important;
    animation: pulse-cluster-region 2s ease-in-out infinite;
}
@keyframes pulse-cluster-region {
    0% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.4); }
    50% { box-shadow: 0 0 12px 4px rgba(231, 76, 60, 0.8); }
    100% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.4); }
}

/* === TOOLTIP === */
.custom-tooltip-region {
    background-color: white !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
    color: #333 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    padding: 5px 9px !important;
    white-space: nowrap !important;
}

/* Flèche bordure (contour gris) */
.custom-tooltip-region::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    z-index: 1;
}

.leaflet-tooltip-right.custom-tooltip-region::before {
    left: 0;
    margin-left: -7px;
    border-width: 7px 7px 7px 0;
    border-color: transparent #ccc transparent transparent;
}

.leaflet-tooltip-left.custom-tooltip-region::before {
    right: 0;
    margin-right: -7px;
    border-width: 7px 0 7px 7px;
    border-color: transparent transparent transparent #ccc;
}

/* Flèche blanche (intérieur) */
.custom-tooltip-region::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    z-index: 2;
}

.leaflet-tooltip-right.custom-tooltip-region::after {
    left: 0;
    margin-left: -6px;
    border-width: 6px 6px 6px 0;
    border-color: transparent white transparent transparent;
}

.leaflet-tooltip-left.custom-tooltip-region::after {
    right: 0;
    margin-right: -6px;
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent white;
}

/* === RESPONSIVE === */
@media screen and (max-width: 768px) {
    .hr-carte-region {
        border-radius: 4px;
        margin: 0;
        /* max-width mobile : dynamique via data-attr ou JS */
    }

    .hr-carte-region .map-title-integrated {
        font-size: 0.9em;
        padding: 5px 10px;
    }

    .hr-carte-region .hr-map .leaflet-popup-content-wrapper {
        width: 180px !important;
    }

    .hr-carte-region .hr-map .leaflet-popup-content {
        width: 180px !important;
        min-width: 180px !important;
        max-width: 180px !important;
    }

    .hr-carte-region .hr-map .leaflet-popup-content img {
        max-width: 160px !important;
    }
}

@media screen and (max-width: 480px) {
    .hr-carte-region .map-title-integrated {
        font-size: 0.85em;
    }

    .hr-carte-region .hr-map .leaflet-control-zoom {
        transform: scale(0.9);
    }
}