/**
 * hr-carte-circuit.css
 * Styles pour le shortcode [carte_circuit]
 * 
 * Les variables CSS dynamiques (--hr-cc-*) sont définies inline par le PHP
 * sur le wrapper .hr-cc-wrapper pour chaque instance.
 */

/* ============================================================
   CONTENEUR GLOBAL
   ============================================================ */

.hr-cc-wrapper {
    position: relative;
    width: 100%;
    max-width: var(--hr-cc-largeur, 100%);
    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é en haut de la carte */
.hr-cc-wrapper .map-title-integrated {
    background: #05668d;
    color: #fff;
    padding: 6px 12px;
    font-size: 0.95em;
    font-weight: 600;
    text-align: left;
    position: relative;
    z-index: 1;
}

/* Conteneur de la carte */
.hr-cc-map {
    height: var(--hr-cc-hauteur, 600px);
    width: 100%;
    position: relative;
}

/* ============================================================
   INSTRUCTION TACTILE MOBILE
   ============================================================ */

.hr-cc-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-cc-map .map-touch-instruction.show {
    display: flex;
}

/* ============================================================
   MARQUEURS LEAFLET
   ============================================================ */

.leaflet-marker-icon {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Personnalisation des clusters verts */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: transparent !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.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-cc-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-cc-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-cc-map .leaflet-control-home a:hover {
    background-color: #f4f4f4;
    border-radius: 2px;
}

/* ============================================================
   BOUTON DE LOCALISATION
   ============================================================ */

.hr-cc-map .leaflet-control-circuit-locate {
    background: #fff;
    border: 2px solid rgba(0,0,0,0.35);
    border-radius: 4px;
    width: 33px;
    height: 33px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.hr-cc-map .leaflet-control-circuit-locate img {
    max-width: 18px !important;
    max-height: 18px !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    object-fit: contain !important;
}

.hr-cc-map .leaflet-control-circuit-locate:hover {
    background-color: #f4f4f4;
}

.hr-cc-map .leaflet-control-circuit-locate.active {
    background: #4CAF50 !important;
    border-color: #4CAF50 !important;
}

.hr-cc-map .leaflet-control-circuit-locate.loading {
    animation: pulse-circuit 1.5s infinite;
}

@keyframes pulse-circuit {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Espacement entre les boutons */
.hr-cc-map .leaflet-top.leaflet-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Cohérence avec les boutons de zoom */
.hr-cc-map .leaflet-control-zoom a {
    width: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
}

/* ============================================================
   BOUTON FULLSCREEN
   ============================================================ */

.hr-cc-map .leaflet-control-fullscreen a {
    background-image: none !important;
    font-size: 18px;
    line-height: 26px !important;
    text-align: center;
}

.hr-cc-map .leaflet-control-fullscreen a:before {
    content: '⛶';
}

.hr-cc-map .leaflet-fullscreen-on .leaflet-control-fullscreen a:before {
    content: '✕';
}

/* ============================================================
   PLEIN ÉCRAN (via classe body dynamique)
   ============================================================ */

body.hr-cc-fullscreen-active {
    overflow: hidden !important;
}

body.hr-cc-fullscreen-active > *:not(script):not(style):not(link) {
    visibility: hidden !important;
}

body.hr-cc-fullscreen-active .hr-cc-wrapper.hr-cc-fullscreen-target,
body.hr-cc-fullscreen-active .hr-cc-wrapper.hr-cc-fullscreen-target * {
    visibility: visible !important;
}

body.hr-cc-fullscreen-active .hr-cc-wrapper.hr-cc-fullscreen-target {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !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-cc-fullscreen-active .hr-cc-wrapper.hr-cc-fullscreen-target .map-title-integrated {
    position: relative !important;
    width: 100% !important;
    flex-shrink: 0 !important;
}

body.hr-cc-fullscreen-active .hr-cc-wrapper.hr-cc-fullscreen-target .hr-cc-map {
    flex: 1 !important;
    height: auto !important;
    min-height: 0 !important;
    position: relative !important;
}

/* ============================================================
   POPUPS
   ============================================================ */

.hr-cc-map .leaflet-popup-content-wrapper {
    width: 200px !important;
}

.hr-cc-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-cc-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-cc-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-cc-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-cc-map .leaflet-popup-content a {
    display: block;
    width: 100%;
    overflow: hidden;
}

.hr-cc-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é uniquement sur desktop (vrai curseur), pas sur tactile */
@media (hover: hover) and (pointer: fine) {
    .hr-cc-map .leaflet-popup-content a:hover .popup-rando-img {
        opacity: 0.85;
    }
}

/* Effets de survol pour les éléments cliquables dans les popups */
.hr-cc-map .leaflet-popup-content .popup-titre a:hover {
    text-decoration: none !important;
}

/* ============================================================
   BADGES DE JOUR (J1, J2, etc.)
   ============================================================ */

.day-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.day-badge {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #0078A8 0%, #005f87 100%);
    border: 3px solid #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.day-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

/* Petit triangle en bas pour l'effet épingle */
.day-badge::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #ffffff;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
}

/* ============================================================
   CURSEUR ET TRACÉS GPX
   ============================================================ */

.hr-cc-map .leaflet-container .leaflet-interactive {
    cursor: pointer;
}

/* ============================================================
   TOOLTIP AU SURVOL
   ============================================================ */

.custom-tooltip-circuit {
    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;
}

/* Bordure de la flèche (contour gris) */
.custom-tooltip-circuit::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    z-index: 1;
}

.leaflet-tooltip-right.custom-tooltip-circuit::before {
    left: 0;
    margin-left: -7px;
    border-width: 7px 7px 7px 0;
    border-color: transparent #ccc transparent transparent;
}

.leaflet-tooltip-left.custom-tooltip-circuit::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-circuit::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    z-index: 2;
}

.leaflet-tooltip-right.custom-tooltip-circuit::after {
    left: 0;
    margin-left: -6px;
    border-width: 6px 6px 6px 0;
    border-color: transparent white transparent transparent;
}

.leaflet-tooltip-left.custom-tooltip-circuit::after {
    right: 0;
    margin-right: -6px;
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent white;
}

/* ============================================================
   MEDIA QUERIES MOBILE
   ============================================================ */

@media screen and (max-width: 768px) {
    .hr-cc-wrapper {
        border-radius: 4px;
        margin: 0;
        max-width: var(--hr-cc-largeur-mobile, 100%);
    }

    .hr-cc-map {
        height: var(--hr-cc-hauteur-mobile, var(--hr-cc-hauteur, 600px));
    }

    .hr-cc-wrapper .map-title-integrated {
        font-size: 0.9em;
        padding: 5px 10px;
    }

    .hr-cc-map .leaflet-popup-content-wrapper {
        width: 180px !important;
    }

    .hr-cc-map .leaflet-popup-content {
        width: 180px !important;
        min-width: 180px !important;
        max-width: 180px !important;
    }

    .hr-cc-map .leaflet-popup-content img {
        max-width: 160px !important;
    }
}

@media screen and (max-width: 480px) {
    .hr-cc-wrapper .map-title-integrated {
        font-size: 0.85em;
    }

    .hr-cc-map .leaflet-control-zoom {
        transform: scale(0.9);
    }
}