/* Voir les polices sur Fontsource (Rubik) */
@font-face {
    font-family: 'Roboto';
    src: url('../fonts/webfonts/roboto-latin-300-normal.woff2') format('woff2'),
    url('../fonts/webfonts/roboto-latin-300-normal.woff') format('woff');
    font-weight: 300;
    font-style: normal;
    font-display: swap; /* évite le flash de texte invisible */
}

@font-face {
    font-family: 'Roboto';
    src: url('../fonts/webfonts/roboto-latin-700-normal.woff2') format('woff2'),
    url('../fonts/webfonts/roboto-latin-700-normal.woff') format('woff');
    font-weight: 700;
    font-style: normal;
    font-display: swap; /* évite le flash de texte invisible */
}

:root {
    --max: ;
    --fg: #1f2937;
    --muted: #aaadb2;
    --bg: #ffffff;
    --link: #1d4ed8;
    --border: #e5e7eb;
    --color-light: #f5f5f5;
    --color-grey: #585858;
    --color-dark: #222;
    --background-color-light: #F8F8FFFF;
    --button-color: #2196f3;
    --button-color-hover: #1976d2;
    --line-title-color: #949494;
    --zoomist-wrapper-bg-color: #e5e7eb;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Roboto, sans-serif;
    line-height: 1.5em;
    background: var(--color-light);
    color: var(--color-grey);
}

body {
    display: flex;
    flex-direction: column;
}

h2 {
    font-size: 1.3em;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.site-header {
    background-color: var(--color-dark);
    color: var(--color-light);
    padding: 10px 15px;
    border-bottom: 1px solid #444;
}

/* H1 aligné */
.site-header h1 {
    display: flex;
    align-items: center;
    font-size: 2.5em;
    margin: 0;
}

/* Lien du logo */
.logo-link {
    display: inline-flex;
    align-items: center;
    margin-right: 10px;
    text-decoration: none;
    color: inherit; /* garde le blanc */
    background-color: #f5f5f5;
    border-radius: 45px;
}
.logo-link:visited {
    color: inherit;
}
.logo-link:hover {
    opacity: 0.8; /* petit effet visuel */
}

.site-title {
    white-space: normal;
    font-size: clamp(1rem, 4vw, 1.5rem);
}
.logo {
    height: 40px; /* plus petit sur mobile */
}


main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* éviter les scrollbars parasites */
    height: auto;     /* au lieu de calc(100vh - 120px) */
}


.main-content {
    width: 50vw;
    margin-inline: auto;
    padding: clamp(16px, 3vw, 28px);
    background-color: var(--background-color-light);
}

.main-content h1:after {
    content: '';
    display: block;
    width: 5.125rem;
    height: .125rem;
    background-color: var(--line-title-color);
    margin-top: .625rem;
}

.main-content h2:after {
    content: '';
    display: block;
    width: 2.125rem;
    height: .125rem;
    background-color: var(--line-title-color);
    margin-top: .3rem;
}

.main-content section {
    margin-top: 2rem;
}

.main-content a {
    text-decoration: underline;
}
.main-content a:hover {
    color: #000000;
}

/* Filtres */
.filtres label {
    margin-right: 5px;
    font-weight: bold;
}

.filtres {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background: var(--color-dark);
    color: var(--color-light);
}

.filtre-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

@media (max-width: 600px) {
    .filtres {
        flex-direction: column;
        align-items: flex-start;
    }
    .filtre-group-champ-saisie {
        width: 100%;
    }
}


.filtre-group-champ-saisie {
    padding: 0.2em 0.2em;
    border-radius: 5px;
    font-size: 1.1em;
    font-family: Roboto, sans-serif;
}

.filtre-button {
    padding: 5px 10px;
    border: 1px solid #aaa;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.filtre-button.selected {
    background: var(--button-color);
    color: white;
    border-color: #1976d2;
}

.custom-multiselect {
    position: relative;
    width: 200px;
}

.custom-multiselect-button {
    padding: 0.1em 0.1em;
    background-color: white;
    color: var(--color-dark);
    border: 1px solid #aaa;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    font-weight: bold;
}

.custom-multiselect-options {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background-color: white;
    color: var(--color-dark);
    border: 1px solid #ccc;
    border-radius: 5px;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.custom-multiselect.open .custom-multiselect-options {
    display: block;
}

.custom-multiselect-options label {
    display: block;
    padding: 6px 10px;
    cursor: pointer;
}

.custom-multiselect-options input {
    margin-right: 5px;
}

/*Onglets*/
.onglets {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #333;
    color: white;
}

.onglets-gauche button {
    margin-right: 10px;
    padding: 8px 15px;
    cursor: pointer;
    background: #555;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: bold;
}

@media (max-width: 600px) {
    .onglets {
        flex-direction: column;
        gap: 10px;
    }
    .onglets-gauche button,
    #pagination button {
        flex: 1; /* occupe toute la largeur */
    }
}


.onglets-gauche button:disabled {
    background: #999;
    cursor: not-allowed;
}

.onglets-droite {
    display: flex;
    align-items: center;
    gap: 15px;
}

#compteur-photos {
    font-weight: bold;
    font-size: 14px;
}

#reset-filtres {
    background: var(--button-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;

    /* taille responsive du bouton */
    width: clamp(25px, 4vw, 38px);
    height: clamp(25px, 4vw, 38px);

    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#reset-filtres svg {
    /* taille relative au bouton */
    width: 60%;
    height: 60%;
    fill: currentColor;  /* hérite de color: white */
    display: block;           /* supprime l’espace blanc sous le svg */
    margin: auto;
    transform: translateX(1px) translateY(-1px);
}

#reset-filtres:hover {
    background: var(--button-color-hover);
    transform: rotate(180deg);
}


.contenu-onglet {
    display: none !important;
}

.contenu-onglet.active {
    display: flex !important;
    flex: 1;
    overflow: hidden;
}

#carte {
    height: 100%;
}

/* L’onglet liste doit occuper l’espace et permettre le scroll */
#onglet-liste {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;       /* important en flexbox pour autoriser le scroll */
    overflow: hidden;
}

/* La grille des photos doit scroller si nécessaire */
#resultats-liste {
    flex: 1;
    overflow-y: auto;    /* 🔑 permet le scroll vertical */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1em;
    padding: 0.7em;
    box-sizing: border-box;
    grid-auto-rows: auto;  /* laisser les vignettes définir leur hauteur */
}

/* Assurer ratio paysage */
.photo-item {
    position: relative;
    background-color: var(--background-color-light);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 100%;

    /* 🔑 Forcer vignettes paysage */
    aspect-ratio: 4 / 3; /* largeur > hauteur */
}

/* Tablet ~ 1024px : 3 colonnes */
@media (max-width: 1200px) {
    #resultats-liste {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 1fr;
    }
}

/* Smartphone paysage ~ 768px : 2 colonnes */
@media (max-width: 900px) {
    #resultats-liste {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 1fr;
    }
}

/* Smartphone portrait ~ 480px : 1 colonne */
@media (max-width: 600px) {
    #resultats-liste {
        grid-template-columns: repeat(1, 1fr);
        grid-auto-rows: 1fr;
    }
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* évite de couper l'image */
    border-radius: 5px;
    cursor: zoom-in;
}

.photo-item img:hover {
    filter: brightness(0.9);
    transition: filter 0.2s;
}

.photo-title-small {
    font-weight: bold;
    font-size: 1.3em
}

.photo-title-large {
    padding: 5px;
    font-size: 26px;
}

.photo-overlay {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.overlay-header {
    width: fit-content;
    margin-left: auto;
    background: rgba(0, 0, 0, 0.2);
    color: #333;
    padding: 5px;
    text-align: right;
    font-weight: bold;
    transition: background 0.3s, color 0.3s;
    border-top-left-radius: 10px;
    cursor: pointer;
}

/* Quand l'overlay est ouvert, header prend la couleur foncée */
.photo-overlay.open .overlay-header {
    background: rgba(0, 0, 0, 0.6);
    color: white;
}

.overlay-infos {
    width: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 5px;
    box-sizing: border-box;
    text-align: left;
}


/*Pagination*/
#pagination {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    align-items: center;
    padding: 10px;
    background: #333;
    color: white;
}


#pagination button {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    background: var(--button-color);
    color: white;
    cursor: pointer;
    transition: background 0.2s;
}

#pagination button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#pagination button:hover:not(:disabled) {
    background: #1976d2;
}

/*Lightbox*/
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.lightbox.hidden {
    display: none;
}

.lightbox-content {
    position: relative;
    background: var(--border);
    width: 90%;
    height: 90%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) clamp(60px, 5%, 120px);
    /* 1ère ligne = image, se réduit si besoin (minmax(0,1fr))
       2ème ligne = infos, vise 15% avec bornes 60–120px */
    overflow: hidden;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 10px;
    border-radius: 8px;
}

.lightbox-body {
    /* plus besoin de flex ici, juste conteneur */
    min-height: 0;      /* évite débordement des enfants à 100% */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    cursor: pointer;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.8);
    border: none;
    color: #333;
    font-size: 40px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    z-index: 100;
}

.lightbox-nav:hover {
    filter: brightness(0.8);
    transition: filter 0.2s;
}

.lightbox-nav svg {
    fill: currentColor;
    display: block;
    width: clamp(24px, 5vw, 48px);
    height: clamp(24px, 5vw, 48px);
}

#lightbox-prev {
    left: 10px;
}

#lightbox-next {
    right: 10px;
}

.lightbox-overlay .overlay-header {
    font-size: 1.4em;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    width: 5%;
}

.lightbox-overlay .overlay-infos {
    font-size: 1.2em;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s ease;
    background: rgba(0, 0, 0, 0.6);
}

.lightbox-overlay.open .overlay-infos,
.lightbox-overlay .overlay-header:hover + .overlay-infos {
    max-height: 500px; /* plus grand pour le contenu étendu */
}

.lightbox-topbar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    z-index: 10000;
}

.lightbox-button {
    background: rgba(255, 255, 255, 0.8);
    color: #333;
    cursor: pointer;
    border-radius: 5px;
    text-align: center;
}

.lightbox-button svg {
    fill: currentColor;
    display: block;
    width: clamp(18px, 2.5vw, 24px);
    height: clamp(18px, 2.5vw, 24px);
}

.lightbox-button:hover {
    filter: brightness(0.8);
    transition: filter 0.2s;
}

#lightbox-menu-popup {
    position: absolute;
    top: 40px; /* en dessous de la topbar */
    right: 40px; /* sous le bouton ⋮ */
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10002;
}


#lightbox-menu-popup ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#lightbox-menu-popup li {
    padding: 8px 15px;
    cursor: pointer;
}

#lightbox-menu-popup li:hover {
    background: #f0f0f0;
}

#lightbox-description {
    overflow-y: auto;
    padding: 5px 15px;
    border-top: 1px solid var(--border);
    box-sizing: border-box;
}

.lightbox-info {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    height: 100%;
    align-items: center;
}

.info-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-date-desc {
    color: var(--color-dark);
    font-weight: 700;
}

.info-source {
    font-size: 0.9em;
    color: var(--color-dark);
}

.info-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--color-dark);
    border-left: 1px solid var(--border);
    min-width: 60px;
}


.hidden {
    display: none;
}


/* Responsive pour petits écrans */
@media (max-width: 768px) {
    #resultats-liste {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }
}

/* Timeline */
.timeline-container {
    background: #222;
    padding: 10px clamp(10px, 5vw, 50px);
    z-index: 1;
}

.timeline-wrapper {
    position: relative;
    height: 60px;
    margin-bottom: 0;
}

.timeline-bar {
    position: absolute;
    top: 75%;
    left: 0;
    right: 0;
    height: 4px;
    background: #ccc;
    transform: translateY(-50%);
}

.timeline-highlight {
    position: absolute;
    top: 75%;
    height: 4px;
    background: #2196f3;
    transform: translateY(-50%);
    z-index: 0;
}

.handle {
    position: absolute;
    top: 75%;
    width: 0;
    height: 0;
    cursor: pointer;
    transform: translateY(-50%);
    z-index: 10;
    /* 🔑 Important pour le mobile */
    touch-action: none;   /* empêche le scroll quand on glisse */
    user-select: none;    /* empêche la sélection de texte au passage */
}

.handle.range-left {
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-left: 20px solid #2196f3;
}

.handle.range-right {
    border-top: 14px solid transparent;
    border-bottom: 14px solid transparent;
    border-right: 20px solid #2196f3;
}

.handle.explore {
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-top: 24px solid #ffc107;
}

.label {
    position: absolute;
    font-size: 1.1em;
    font-weight: bold;
    border-radius: 5px;
    padding: 0.3em;
    background-color: #333;
}

.label.right {
    transform: translate(-15%, -140%);
    color: #2196f3;
    border: 2px solid #2196f3;
}

.label.left {
    transform: translate(-80%, -140%);
    color: #2196f3;
    border: 2px solid #2196f3;
}

.label.explore {
    transform: translate(-50%, -160%);
    color: #ffc107;
    border: 2px solid #ffc107;
}

.tick {
    flex: 1;
    text-align: center;
    position: relative;
}

.tick::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 10px;
    background: #aaa;
}

.handle.disabled {
    opacity: 0.3;
    pointer-events: auto;
}

.timeline-highlight.disabled {
    opacity: 0.2;
}

#timeline-heatmap {
    display: flex;
    height: 5px;
    margin-top: 1px;
    background-color: #333333;
}

#report-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6); /* fond sombre */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001; /* au-dessus de la lightbox */
}

#report-container.hidden {
    display: none;
}

.report-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
}

.report-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}


.btn-report {
    margin-left: 10px;
    font-size: 0.9em;
    background: #ff5555;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
}

.btn-report:hover {
    background: #cc0000;
}

.muted {
    color: var(--muted)
}

.notice {
    background: var(--color-light);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 12px
}

.grid {
    display: grid;
    gap: 8px
}

.list {
    padding-left: 1.25rem
}

.zoomist-container {
    width: 100%;
    height: 100%;
    cursor: grab;
    background-color: var(--zoomist-wrapper-bg-color);
}

.zoomist-container:active {
    cursor: grabbing;
}

.zoomist-wrapper {
    background-color: var(--zoomist-wrapper-bg-color);
}

.zoomist-image {
    width: 100%;
    height: 100%;
}

.zoomist-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* <-- pour voir l'image entière */
    object-position: center;
}

.external-only {
    display: none; !important;
}

/* Popup mobile (hérite déjà de .lightbox) */
#mobile-popup .popup-content {
    position: relative;
    background: var(--background-color-light);
    color: var(--color-dark);
    max-width: 90vw;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    text-align: center;
    animation: popup-fade-in 0.3s ease;
}

/* Animation */
@keyframes popup-fade-in {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* Bouton de fermeture */
#mobile-popup .popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-grey);
}
#mobile-popup .popup-close:hover {
    color: var(--color-dark);
}

/* Bouton principal */
#mobile-popup .popup-button {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--button-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
#mobile-popup .popup-button:hover {
    background: var(--button-color-hover);
}

/* === PATCH RESPONSIVE V2 === */

/* 1. Layout global : flex pour footer collé sur desktop */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto; /* éviter les scrollbars parasites */
    height: auto;
}

/* 2. Galerie : grid flexible qui s’adapte à la hauteur disponible */
/* === Grille fixe avec ratios === */

/* Par défaut : desktop (≥1200px) → 4 x 3 */
/* === Grille fixe avec ajustement auto === */

/* Conteneur prend toute la hauteur disponible */
#resultats-liste {
    display: grid;
    gap: 1em;
    padding: 0.7em;
    height: 100%; /* occupe toute la zone */
    box-sizing: border-box;
}

/* Vignettes paysage */
.photo-item {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 5px;
    background: var(--background-color-light);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* === Grille selon la taille d’écran === */

/* Desktop ≥1200px : 4 colonnes x 3 lignes */
@media (min-width: 1200px) {
    #resultats-liste {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(3, 1fr);
    }
}

/* Laptop / grand tablet 900–1199px : 3 colonnes x 4 lignes */
@media (min-width: 900px) and (max-width: 1199px) {
    #resultats-liste {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(4, 1fr);
    }
}

/* Tablette 600–899px : 2 colonnes x 6 lignes */
@media (min-width: 600px) and (max-width: 899px) {
    #resultats-liste {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(6, 1fr);
    }
}

/* Mobile <600px : 1 colonne x 12 lignes */
@media (max-width: 599px) {
    #resultats-liste {
        grid-template-columns: repeat(1, 1fr);
        grid-template-rows: repeat(12, 1fr);
    }
}



/* 3. Carte Leaflet : occupe l’espace mais sans forcer de scrollbar */
#carte {
    flex: 1;
    min-height: 300px;
}

/* 4. Filtres + timeline s’adaptent */
.filtres {
    flex-wrap: wrap;
    gap: 0.5em;
}
.filtre-group-champ-saisie {
    max-width: 100%;
    flex: 1 1 auto;
}

.timeline-container {
    padding: 10px clamp(20px, 14vw, 60px);
}

/* 5. Footer sur mobile */
@media (max-width: 768px) {
    body {
        display: block; /* 🔑 repasse en flux normal pour scroll global */
    }

    main {
        min-height: auto;
    }

    #carte {
        height: 60vh;
    }

    .site-footer {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
}



