/* ============================================================
   Carte de Libramont — design premium
   Palette tirée du logo : charbon + vert nature / jaune / bleu
   ============================================================ */
:root {
  --ink: #211d18;
  --ink-soft: #6a6157;
  --bg: #f3efe6;
  --panel: #fffdf9;
  --line: #e7e0d3;
  --line-soft: #f0ebe0;

  --green: #6d9a3c;
  --green-deep: #4f7a2c;
  --yellow: #f0be2a;
  --blue: #38a7cf;

  --shadow-sm: 0 2px 8px rgba(40, 32, 22, 0.08);
  --shadow-md: 0 10px 30px rgba(40, 32, 22, 0.13);
  --shadow-lg: 0 22px 60px rgba(30, 24, 16, 0.22);

  --sidebar-w: 384px;
  --r: 14px;

  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--green);
  color: #fff;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------------- Barre latérale ---------------- */
#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 600;
  box-shadow: var(--shadow-md);
}
/* liseré vert (nature) en bordure droite */
#sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(var(--green), var(--blue));
}

#side-header {
  padding: 22px 24px 18px;
  background: radial-gradient(
      120% 120% at 0% 0%,
      rgba(109, 154, 60, 0.08),
      transparent 60%
    ),
    var(--panel);
  border-bottom: 1px solid var(--line);
}
#side-header .logo {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
}
#side-header .subtitle {
  margin: 12px 0 0;
  color: var(--green-deep);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  display: flex;
  align-items: center;
  gap: 8px;
}
#side-header .subtitle::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--green);
  border-radius: 2px;
}

#browse {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

#side-footer {
  flex: 0 0 auto;
  padding: 11px 24px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: #a89f92;
  text-align: center;
}
#side-footer::before {
  content: "✦ ";
  color: var(--green);
}

/* ---------------- Recherche ---------------- */
#search {
  margin: 16px 20px 10px;
  padding: 12px 16px 12px 42px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-family: var(--sans);
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%236a6157' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M16 16l-3.5-3.5'/%3E%3C/svg%3E")
    14px center no-repeat;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search::placeholder {
  color: #a89f92;
}
#search:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(109, 154, 60, 0.14);
}

/* ---------------- Filtres (chips à cocher) ---------------- */
#chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 20px 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent);
}
.chip:hover {
  border-color: var(--c);
  color: var(--ink);
  transform: translateY(-1px);
}
.chip.on {
  color: #fff;
  border-color: var(--c);
  background: var(--c);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--c) 40%, transparent);
}
.chip.on .dot {
  background: #fff;
  box-shadow: none;
}
.chip.tout {
  font-weight: 700;
}
.chip.tout.on {
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: 0 4px 12px rgba(33, 29, 24, 0.35);
}

#count {
  padding: 6px 24px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a89f92;
}

/* ---------------- Liste ---------------- */
#list {
  list-style: none;
  margin: 0;
  padding: 2px 12px 20px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: #d9d2c5 transparent;
}
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.13s, transform 0.13s;
}
.item:hover {
  background: var(--line-soft);
  transform: translateX(3px);
}
.item .ic {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 12%, #fff);
  border: 1.5px solid color-mix(in srgb, var(--c) 45%, #fff);
  font-size: 16px;
}
.item .txt {
  min-width: 0;
}
.item .name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item .type {
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------------- Fiche détail ---------------- */
#detail {
  overflow-y: auto;
  flex: 1;
  animation: slideIn 0.25s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
#detail .back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 16px 20px 0;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  transition: all 0.15s;
}
#detail .back:hover {
  border-color: var(--green);
  color: var(--green-deep);
}
#detail .photo {
  width: calc(100% - 40px);
  height: 210px;
  object-fit: cover;
  margin: 16px 20px 0;
  border-radius: var(--r);
  background: var(--line-soft);
  display: block;
  box-shadow: var(--shadow-sm);
}
#detail .body {
  padding: 18px 24px 32px;
}
#detail .badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--c, var(--green));
}
#detail h2 {
  font-family: var(--display);
  font-optical-sizing: auto;
  margin: 12px 0 8px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
}
#detail .desc {
  color: #3d372f;
  line-height: 1.65;
  font-size: 15px;
}
#detail .desc.empty {
  color: var(--ink-soft);
  font-style: italic;
}
#detail .links {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#detail .links a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-top: 1px solid var(--line-soft);
  transition: color 0.13s, padding-left 0.13s;
}
#detail .links a:hover {
  color: var(--green-deep);
  padding-left: 10px;
}

/* Photos anciennes rattachées à un lieu (dans la fiche détail) */
#detail .linked-photos {
  margin-top: 22px;
  border-top: 1px solid var(--line-soft);
  padding-top: 16px;
}
#detail .linked-photos h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 10px;
}
#detail .lp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
#detail .lp-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  border: 1px solid var(--line);
  background-size: cover;
  background-position: center;
  background-color: #eee;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: transform 0.13s, box-shadow 0.13s;
}
#detail .lp-thumb:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(40, 32, 22, 0.18);
}
#detail .lp-thumb span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hidden {
  display: none !important;
}

/* ---------------- Carte ---------------- */
#map {
  flex: 1;
  height: 100%;
  background: #e9e4d8;
}
.leaflet-container {
  font-family: var(--sans);
}

/* Marqueurs — goutte façon carte */
.poi-marker .pin {
  width: 32px;
  height: 32px;
  background: var(--c);
  border: 2.5px solid #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 5px 12px rgba(20, 14, 8, 0.4);
  display: grid;
  place-items: center;
  transition: transform 0.16s ease;
}
.poi-marker .glyph {
  transform: rotate(45deg);
  width: 21px;
  height: 21px;
  background: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
}
.poi-marker:hover {
  z-index: 1000 !important;
}
.poi-marker:hover .pin {
  transform: rotate(-45deg) scale(1.22);
  box-shadow: 0 10px 20px rgba(20, 14, 8, 0.45);
}

/* ---------------- Info-bulle enrichie (survol) ---------------- */
.leaflet-tooltip.poi-tooltip {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  white-space: normal;
}
.leaflet-tooltip.poi-tooltip::before {
  display: none;
}
.tip {
  width: 234px;
  background: #fff;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: tipIn 0.14s ease;
}
@keyframes tipIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.tip-photo {
  height: 118px;
  background: var(--line-soft);
}
.tip-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tip-body {
  padding: 11px 14px 14px;
  border-top: 3px solid var(--c);
}
.tip-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--c);
}
.tip-title {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 3px 0 0;
  line-height: 1.18;
}
.tip-text {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  line-height: 1.45;
}

/* Boutons de zoom Leaflet — plus doux */
.leaflet-bar a {
  border-radius: 0 !important;
  color: var(--ink);
}
.leaflet-bar {
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

/* ---------------- Mobile & tablette (feuille coulissante) ---------------- */
.sheet-handle {
  display: none;
}

@media (max-width: 860px) {
  #app {
    display: block;
    height: 100vh;
    height: 100dvh;
  }

  /* La carte occupe tout l'écran, en fond */
  #map {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  /* La barre latérale devient une feuille qui coulisse depuis le bas */
  #sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    flex: none;
    height: 86vh;
    height: 86dvh;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -12px 36px rgba(30, 24, 16, 0.3);
    transform: translateY(calc(86dvh - 218px)); /* replié : on voit ~218px */
    transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 1000;
  }
  #sidebar.open {
    transform: translateY(0);
  }
  #sidebar::after {
    display: none;
  }

  /* Poignée de préhension */
  .sheet-handle {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    padding: 11px 0 5px;
    cursor: pointer;
  }
  .sheet-handle::before {
    content: "";
    display: block;
    width: 46px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: #d8d1c4;
  }

  #side-header {
    padding: 2px 20px 8px;
    text-align: center;
    border-bottom: none;
    background: none;
  }
  #side-header .logo {
    max-width: 130px;
    margin: 0 auto;
  }
  #side-header .subtitle {
    display: none;
  }

  #search {
    margin: 4px 16px 8px;
  }
  #chips {
    padding: 2px 16px 8px;
    justify-content: center;
  }
  #count {
    padding: 2px 20px 4px;
    text-align: center;
  }
  #side-footer {
    display: none;
  }

  #detail {
    animation: none;
  }
  #detail .photo {
    height: 190px;
  }

  /* Contrôles Leaflet un peu remontés pour ne pas passer sous la feuille */
  .leaflet-bottom {
    bottom: 224px;
  }
}

/* Très petits écrans : feuille un peu plus haute repliée */
@media (max-width: 400px) {
  #chips {
    gap: 5px;
  }
  .chip {
    font-size: 12px;
    padding: 5px 9px;
  }
}

/* ---------------- Voyage dans le temps ---------------- */
.time-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
.time-toggle:hover {
  background: #000;
}

#timebar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 901;
  width: 300px;
  max-width: calc(100vw - 28px);
  background: rgba(20, 16, 12, 0.93);
  color: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
}
#timebar .tb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#timebar .tb-year {
  font-size: 14px;
}
#timebar .tb-year b {
  font-family: var(--display);
  font-size: 22px;
  color: var(--yellow);
}
#timebar .tb-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.7;
}
#tbSlider {
  width: 100%;
  margin: 12px 0 8px;
  accent-color: var(--yellow);
  cursor: pointer;
}
#timebar .tb-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: #d8d1c4;
}
#tbUndated {
  background: rgba(255, 255, 255, 0.14);
  border: none;
  color: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  cursor: pointer;
}

/* Cases à cocher du voyage dans le temps */
#timebar .tb-opts {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
#timebar .tb-check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: #efe9dd;
  cursor: pointer;
  user-select: none;
}
#timebar .tb-check input {
  width: 17px;
  height: 17px;
  accent-color: var(--yellow);
  cursor: pointer;
  flex: none;
}
#timebar .tb-check small {
  color: #b3aa9a;
  font-size: 11.5px;
}
/* Quand « toutes les photos » est coché, le curseur d'année est désactivé */
#timebar.all-on #tbSlider {
  opacity: 0.35;
  pointer-events: none;
}
#timebar.all-on .tb-year b {
  font-size: 15px;
}

.photo-marker .pm {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.55);
  background-size: cover;
  background-position: center;
  background-color: #ccc;
  cursor: pointer;
  transition: transform 0.15s;
}
.photo-marker:hover .pm {
  transform: scale(1.16);
}

/* Plusieurs photos au même endroit : effet de pile + badge du nombre */
.photo-marker.multi .pm {
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.55), 4px -4px 0 -1px #fff,
    5px -5px 0 0 rgba(0, 0, 0, 0.28);
}
.photo-marker .pm-count {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--yellow);
  color: #2b2205;
  border: 2px solid #fff;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 12, 8, 0.93);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 24px 40px;
  overflow-y: auto; /* le panneau sous la photo doit rester atteignable */
  overscroll-behavior: contain;
}
#lightbox figure {
  margin: auto;
  max-width: 92vw;
  text-align: center;
}
#lightbox img {
  max-width: 92vw;
  max-height: 62vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
#lightbox figcaption {
  color: #f3efe6;
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.5;
  max-width: 640px;
}
#lightbox .lb-year {
  font-family: var(--display);
  font-size: 20px;
  color: var(--yellow);
  display: block;
  margin-bottom: 4px;
}
#lightbox .lb-credit {
  font-size: 12.5px;
  color: #b7b0a4;
  margin-top: 6px;
}

#lbClose {
  position: fixed;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
}

/* ============================================================
   Compléments responsive — confort mobile (ajoutés en fin de
   fichier, ne modifient pas le rendu desktop).
   Cible : recherche, filtres, « voyage dans le temps » et
   lightbox parfaitement lisibles et sans débordement à 375px.
   ============================================================ */
@media (max-width: 760px) {
  /* Recherche : police >= 16px pour éviter le zoom auto iOS */
  #search {
    font-size: 16px;
  }

  /* Filtres à cocher : espacements resserrés, boutons compacts */
  #chips {
    gap: 6px;
  }
  .chip {
    padding: 6px 11px;
    font-size: 12.5px;
  }

  /* Voyage dans le temps : paddings resserrés, cases lisibles */
  #timebar {
    padding: 13px 14px;
  }
  #timebar .tb-check {
    align-items: flex-start; /* propre si le libellé passe sur 2 lignes */
  }

  /* Lightbox : aucune photo ne dépasse de l'écran */
  #lightbox {
    padding: 52px 12px 34px;
  }
  #lightbox figure {
    max-width: calc(100vw - 24px);
  }
  #lightbox img {
    max-width: calc(100vw - 24px);
    max-height: 58vh;
  }
  #lightbox figcaption {
    font-size: 14px;
  }
  #lightbox .lb-year {
    font-size: 18px;
  }
}

@media (max-width: 460px) {
  /* Voyage dans le temps : pleine largeur avec petites marges */
  #timebar {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
  }
  #timebar .tb-year {
    font-size: 13px;
  }
  #timebar .tb-year b {
    font-size: 19px;
  }
  #timebar .tb-check {
    font-size: 13px;
  }

  /* Filtres encore plus compacts sur très petits écrans */
  #chips {
    gap: 5px;
  }
  .chip {
    padding: 5px 9px;
    font-size: 12px;
  }

  /* Lightbox : hauteur d'image ajustée, fermeture bien visible */
  #lightbox {
    padding: 48px 10px 30px;
  }
  #lightbox img {
    max-width: calc(100vw - 20px);
    max-height: 54vh;
  }
  #lbClose {
    top: 10px;
    right: 12px;
    font-size: 28px;
  }
}

