/* =====================================================================
   Module "Sur le terrain" — carte des interventions (Leaflet + tuiles).
   Herite de --c-* du site (accent, texte...). Marqueurs en divIcon (pas
   d'image), popup avec carrousel + lightbox plein ecran (style galerie).
   ===================================================================== */
.terrain {
    --tr-radius: 16px;
    --tr-ink: var(--c-text, #1f2430);
    --tr-muted: var(--c-muted, #5b6472);
    --tr-accent: var(--c-accent, #1b6ec2);
    --tr-surface: var(--c-surface, #f4f6fa);
    --tr-line: var(--c-border, #e6e9f0);
    max-width: var(--container, 1140px);
    margin-inline: auto;
    color: var(--tr-ink);
}
.terrain *, .terrain *::before, .terrain *::after { box-sizing: border-box; }

/* ---- En-tete ---- */
.terrain-head { text-align: center; max-width: 720px; margin: 0 auto clamp(22px, 4vw, 36px); }
.terrain-title { margin: 0 0 12px; font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.terrain-desc { margin: 0; color: var(--tr-muted); font-size: 1.05rem; line-height: 1.65; }
.terrain-count {
    display: inline-flex; align-items: center; gap: 7px; margin-top: 16px;
    padding: 7px 15px; border-radius: 999px; background: var(--tr-surface);
    font-size: .9rem; font-weight: 700; color: var(--tr-ink);
}
.terrain-count svg { width: 16px; height: 16px; color: var(--tr-accent); }

/* ---- Cadre de la carte ---- */
.terrain-map-wrap {
    position: relative; border-radius: var(--tr-radius); overflow: hidden;
    box-shadow: 0 1px 2px rgba(20, 28, 55, .05), 0 24px 48px -32px rgba(20, 28, 55, .35);
}
#terrain-map { width: 100%; height: clamp(440px, 64vh, 700px); background: var(--tr-surface); z-index: 0; }
.terrain-empty { text-align: center; color: var(--tr-muted); padding: 60px 20px; font-size: 1.05rem; }

.terrain .leaflet-container { font-family: inherit; }
.terrain .leaflet-container a { color: var(--tr-accent); }

/* Controles (zoom + selecteur de fond) : arrondis, ombre douce, propres */
.terrain .leaflet-bar { border: 0; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 18px rgba(20, 28, 55, .16); }
.terrain .leaflet-bar a { border-bottom-color: var(--tr-line); color: var(--tr-ink); }
.terrain .leaflet-control-layers {
    border: 0; border-radius: 12px; overflow: hidden; background: #fff;
    box-shadow: 0 6px 18px rgba(20, 28, 55, .16);
}
.terrain .leaflet-control-layers-expanded { padding: 8px 12px; color: var(--tr-ink); }
.terrain .leaflet-control-layers label { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: .9rem; font-weight: 600; cursor: pointer; }
.terrain .leaflet-control-layers-selector { width: 15px; height: 15px; margin: 0; accent-color: var(--tr-accent); }

/* ---- Marqueur "pin" (divIcon) ---- */
.terrain-pin-wrap { background: none; border: 0; }
.terrain-pin {
    display: block; width: 28px; height: 28px; background: var(--tr-accent);
    border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    box-shadow: 0 4px 10px rgba(20, 28, 55, .35); border: 2px solid #fff;
    transition: transform .18s cubic-bezier(.16, 1, .3, 1);
}
.terrain-pin::after { content: ""; position: absolute; top: 50%; left: 50%; width: 9px; height: 9px; border-radius: 50%; background: #fff; transform: translate(-50%, -50%); }
.terrain-pin-wrap:hover .terrain-pin { transform: rotate(-45deg) scale(1.15); }

/* ---- Regroupement de points (clustering) : pastille a la couleur d'accent ---- */
.terrain-cluster { background: none; }
.terrain-cluster span {
    display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    background: var(--tr-accent, #1b6ec2); color: #fff; border-radius: 999px;
    font-weight: 700; font-size: .88rem; font-variant-numeric: tabular-nums;
    border: 3px solid #fff; box-shadow: 0 4px 12px rgba(20, 28, 55, .35);
}

/* ---- Popup ---- */
.terrain-popup .leaflet-popup-content-wrap { border-radius: 16px; padding: 0; overflow: hidden; box-shadow: 0 16px 44px rgba(20, 28, 55, .30); }
.terrain-popup .leaflet-popup-content { margin: 0; width: 300px !important; line-height: 1.5; }
.terrain-popup .leaflet-popup-tip { box-shadow: 0 16px 44px rgba(20, 28, 55, .30); }

/* Bouton fermer : croix dessinee en CSS -> parfaitement centree */
.terrain-popup a.leaflet-popup-close-button {
    width: 30px; height: 30px; top: 8px; right: 8px; padding: 0; font-size: 0;
    background: rgba(17, 24, 39, .5); border-radius: 999px; z-index: 3;
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); transition: background .18s ease;
}
.terrain-popup a.leaflet-popup-close-button::before,
.terrain-popup a.leaflet-popup-close-button::after {
    content: ""; position: absolute; top: 50%; left: 50%; width: 12px; height: 2px; background: #fff; border-radius: 2px;
}
.terrain-popup a.leaflet-popup-close-button::before { transform: translate(-50%, -50%) rotate(45deg); }
.terrain-popup a.leaflet-popup-close-button::after { transform: translate(-50%, -50%) rotate(-45deg); }
.terrain-popup a.leaflet-popup-close-button:hover { background: rgba(17, 24, 39, .82); }

.tp-card { color: var(--tr-ink); }

/* Carrousel : coins hauts arrondis, cliquable pour agrandir */
.tp-carousel { position: relative; aspect-ratio: 4 / 3; background: var(--tr-surface); overflow: hidden; border-radius: 16px 16px 0 0; cursor: zoom-in; }
.tp-track { display: flex; height: 100%; transition: transform .35s cubic-bezier(.16, 1, .3, 1); }
.tp-slide { flex: 0 0 100%; height: 100%; }
.tp-slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* voile + loupe au survol : indique qu'on peut ouvrir en grand */
.tp-carousel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .30), transparent 42%); opacity: 0; transition: opacity .2s ease; pointer-events: none; }
.tp-carousel:hover::after { opacity: 1; }
.tp-zoom { position: absolute; top: 10px; left: 10px; z-index: 2; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 999px; background: rgba(17, 24, 39, .5); color: #fff; opacity: 0; transform: scale(.9); transition: opacity .2s ease, transform .2s ease; pointer-events: none; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.tp-zoom svg { width: 15px; height: 15px; }
.tp-carousel:hover .tp-zoom { opacity: 1; transform: scale(1); }
.tp-counter { position: absolute; bottom: 10px; right: 10px; z-index: 2; font-size: .72rem; font-weight: 700; color: #fff; background: rgba(17, 24, 39, .55); padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

.tp-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
    width: 32px; height: 32px; border: 0; cursor: pointer; border-radius: 999px;
    background: rgba(17, 24, 39, .5); color: #fff; display: flex; align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); transition: background .18s ease;
}
.tp-arrow:hover { background: rgba(17, 24, 39, .82); }
.tp-arrow svg { width: 17px; height: 17px; }
.tp-prev { left: 8px; }
.tp-next { right: 8px; }
.tp-dots { position: absolute; left: 0; right: 0; bottom: 10px; z-index: 2; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.tp-dot { width: 6px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .55); border: 0; padding: 0; cursor: pointer; pointer-events: auto; transition: background .18s ease, transform .18s ease; }
.tp-dot.is-active { background: #fff; transform: scale(1.3); }
.tp-carousel.is-single .tp-arrow, .tp-carousel.is-single .tp-dots, .tp-carousel.is-single .tp-counter { display: none; }

/* Corps texte */
.tp-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.tp-place { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--tr-accent); }
.tp-place svg { width: 13px; height: 13px; flex: 0 0 auto; }
.tp-title { margin: 0; font-size: 1.1rem; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; color: var(--tr-ink); }
.tp-text { margin: 4px 0 0; font-size: .92rem; line-height: 1.55; color: var(--tr-muted); }
.tp-date { font-size: .78rem; color: var(--tr-muted); font-variant-numeric: tabular-nums; }

/* ---- Lightbox plein ecran (calquee sur la galerie Realisations) ---- */
.glx { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(12, 15, 22, .62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; }
.glx.is-open { opacity: 1; visibility: visible; }
.glx-fig { margin: 0; max-width: min(1100px, 94vw); display: flex; align-items: center; justify-content: center; }
.glx-img { max-width: 100%; max-height: 84vh; object-fit: contain; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); background: #0b0d12; transform: scale(.96); transition: transform .3s cubic-bezier(.16, 1, .3, 1); }
.glx.is-open .glx-img { transform: scale(1); }
.glx-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 52px; height: 52px; border: 0; cursor: pointer; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); transition: background .2s ease, transform .2s ease; }
.glx-btn:hover { background: rgba(0, 0, 0, .72); }
.glx-btn:active { transform: translateY(-50%) scale(.92); }
.glx-btn svg { width: 26px; height: 26px; }
.glx-prev { left: 20px; }
.glx-next { right: 20px; }
.glx-close { position: absolute; top: 20px; right: 20px; z-index: 2; width: 46px; height: 46px; border: 0; cursor: pointer; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); transition: background .2s ease; }
.glx-close:hover { background: rgba(0, 0, 0, .72); }
.glx-close svg { width: 22px; height: 22px; }
.glx-count { position: absolute; top: 22px; left: 20px; z-index: 2; color: #fff; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; background: rgba(0, 0, 0, .5); padding: 6px 13px; border-radius: 999px; box-shadow: 0 4px 18px rgba(0, 0, 0, .35); }

@media (max-width: 560px) {
    #terrain-map { height: clamp(380px, 72vh, 580px); }
    .terrain-popup .leaflet-popup-content { width: 250px !important; }
    .glx-btn { width: 42px; height: 42px; }
    .glx-prev { left: 8px; }
    .glx-next { right: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    .tp-track, .terrain-pin, .glx-img { transition: none; }
}
