/* ============================================================
   ARCHIBRON MAP — styles.css
   
   POINTS DE PERSONNALISATION RAPIDE :
   ─────────────────────────────────────────────────────────────
   • Palette de couleurs       → section :root › Colors
   • Typographie               → section :root › Typography
   • Largeur de la sidebar     → --sidebar-width
   • Couleurs de catégorie     → section CATEGORY COLORS
   • Apparence des popups      → section POPUP CARD
   • Apparence des marqueurs   → section MARKERS
   • Responsive (breakpoint)   → @media (max-width: 768px)
   ============================================================ */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  /* ── Typography ── */
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'DM Sans', system-ui, sans-serif;

  --text-xs:   10.5px;
  --text-sm:   12.5px;
  --text-base: 13.5px;
  --text-md:   15px;
  --text-lg:   18px;
  --text-xl:   22px;

  /* ── Colors ── */
  --bg:             #f6f4f1;
  --surface:        #ffffff;
  --surface-raised: #fdfdfc;
  --border:         #e4e1db;
  --border-light:   #edeae5;
  --ink-primary:    #1c1b19;
  --ink-secondary:  #5a5850;
  --ink-muted:      #9a9790;
  --ink-inverse:    #ffffff;
  --accent:         #1c1b19;
  --highlight:      #f0ede7;
  --highlight-warm: #ede8e0;

  /* ── Spacing ── */
  --sp-1:   4px;
  --sp-2:   8px;
  --sp-3:   12px;
  --sp-4:   16px;
  --sp-5:   20px;
  --sp-6:   24px;
  --sp-8:   32px;
  --sp-10:  40px;

  /* ── Layout ── */
  --sidebar-width: 340px;

  /* ── Radius ── */
  --r-sm:   4px;
  --r-md:   8px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-2xl:  20px;
  --r-pill: 999px;

  /* ── Shadows ── */
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.05);
  --shadow-popup: 0 16px 48px rgba(0,0,0,0.14), 0 4px 12px rgba(0,0,0,0.08);

  /* ── Transitions ── */
  --ease:      cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:  cubic-bezier(0.0, 0.0, 0.2, 1);
  --t-fast:    0.12s;
  --t-base:    0.2s;
  --t-slow:    0.3s;

  /* ── Category colors — légèrement assombries pour numéro blanc lisible ── */
  --cat-musee:          #C1121F;   /* rouge */
  --cat-religieux:      #D4793A;   /* orange */
  --cat-traditionnel:   #A8892E;   /* ocre */
  --cat-culture:        #1E7A6E;   /* teal */
  --cat-sport:          #2E8B6F;   /* vert */
  --cat-transport:      #1A9ECC;   /* bleu ciel */
  --cat-civique:        #2F4DD4;   /* bleu */
  --cat-bibliotheque:   #7B3FC5;   /* violet */
  --cat-site:           #D16A00;   /* orange vif */
  --cat-monument:       #1B3A47;   /* ardoise */
  --cat-infrastructure: #5C6878;   /* gris */
  --cat-boutique:       #D94F83;   /* rose */
  --cat-bureau:         #04A882;   /* aqua */
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 20;
  transition: transform var(--t-slow) var(--ease-out);
}

#sidebar-header {
  padding: var(--sp-5) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  background: var(--surface);
}

/* ── Brand ── */
#brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--sp-4);
}

#brand-name,
#brand-name-fallback {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink-primary);
}

/* Fallback texte caché par défaut — affiché si l'image ne charge pas */
#brand-name-fallback { display: none; }

/* Logo image — taille majorée, centre vertical aligné avec "Japon" via align-items:center du parent */
#brand-logo {
  height: 32px;
  width: auto;
  display: block;
  object-fit: contain;
}

#brand-sep {
  color: var(--border);
  font-weight: 300;
}

#brand-sub {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-weight: 400;
  letter-spacing: 0.01em;
}

#progress-counter {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: center;
}

/* ── Search ── */
#search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-3);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

#search-wrapper:focus-within {
  border-color: var(--ink-secondary);
  box-shadow: 0 0 0 3px rgba(28,27,25,0.06);
}

.search-icon {
  width: 15px;
  height: 15px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

#search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px var(--sp-2);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  outline: none;
  min-width: 0;
}

#search-input::placeholder { color: var(--ink-muted); }

/* Hide browser's native clear button */
#search-input::-webkit-search-cancel-button { display: none; }

#search-clear {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-1);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
  transition: color var(--t-fast);
  flex-shrink: 0;
}
#search-clear:hover { color: var(--ink-primary); }
#search-clear svg { width: 12px; height: 12px; }

/* ── Filters ── */
#filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  margin-bottom: var(--sp-2);
}

/* ── Filter pills ── */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  font-family: var(--font-body);
  letter-spacing: 0.015em;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-secondary);
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Pas de focus persistant après tap (seulement clavier via :focus-visible) */
.filter-pill:focus { outline: none; }
.filter-pill:focus:not(:focus-visible) { outline: none; }

.filter-pill:hover {
  border-color: var(--ink-secondary);
  color: var(--ink-primary);
}

.filter-pill.active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: var(--ink-inverse);
}

.filter-pill.active .pill-dot {
  background: rgba(255,255,255,0.5) !important;
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--category-color, var(--ink-muted));
  flex-shrink: 0;
  transition: background var(--t-fast);
}

/* ── Results count ── */
#results-count {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  margin-top: var(--sp-1);
}

/* ============================================================
   LIST
   ============================================================ */
#list-container {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

#list-container::-webkit-scrollbar { width: 3px; }
#list-container::-webkit-scrollbar-track { background: transparent; }
#list-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--r-pill);
}

/* ── List item ── */
.list-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  padding: 14px var(--sp-4) 14px var(--sp-5);
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background var(--t-fast) var(--ease);
  position: relative;
}

.list-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink-primary);
  transform: scaleY(0);
  transition: transform var(--t-base) var(--ease-out);
}

.list-item:hover { background: var(--bg); }

.list-item.active {
  background: var(--highlight-warm);
}

.list-item.active::before {
  transform: scaleY(1);
}

/* ── List thumbnail — format 3:4 portrait (Instagram natif) ── */
.list-thumb {
  width: 56px;
  height: 75px;
  border-radius: var(--r-md);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
  display: block;
}

.list-thumb-placeholder {
  width: 56px;
  height: 75px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--border);
}

/* ── List info ── */
.list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.list-category {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--category-color, var(--ink-secondary));
}

.list-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.list-area {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.list-meta {
  font-size: 12px;
  color: var(--ink-secondary);
  font-style: italic;
  margin-top: 2px;
}

/* ── List top row (numéro + catégorie) ── */
.list-top-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.list-day-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  flex-shrink: 0;
}

/* ── List empty ── */
.list-empty {
  padding: var(--sp-8) var(--sp-4);
  text-align: center;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* ============================================================
   MAP CONTAINER
   ============================================================ */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ============================================================
   LEAFLET OVERRIDES — contrôles natifs
   ============================================================ */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--r-lg) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 17px !important;
  font-weight: 300 !important;
  color: var(--ink-primary) !important;
  background: var(--surface) !important;
  border: none !important;
  border-bottom: 1px solid var(--border-light) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast) !important;
}

.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: var(--bg) !important; }

.leaflet-control-attribution {
  font-size: 9.5px !important;
  color: var(--ink-muted) !important;
  background: rgba(255,255,255,0.75) !important;
  backdrop-filter: blur(6px);
  border-radius: var(--r-sm) !important;
  padding: 2px 6px !important;
}
.leaflet-control-attribution a { color: var(--ink-secondary) !important; }

/* ============================================================
   MARKERS — Marqueurs numérotés
   Taille 24px ; numéro 8px gras lisible
   ============================================================ */
.marker-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.95);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.32),
    0 0 0 1px rgba(0,0,0,0.10);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast);
}

.marker-num {
  font-family: var(--font-body);
  font-size: 8.5px;
  font-weight: 800;
  color: rgba(255,255,255,1);
  line-height: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 0 1px rgba(0,0,0,0.4);
  user-select: none;
  pointer-events: none;
}

.marker-dot:hover,
.marker-dot.is-active {
  transform: scale(1.35);
  box-shadow:
    0 3px 12px rgba(0,0,0,0.40),
    0 0 0 2.5px rgba(255,255,255,0.85);
  z-index: 999 !important;
}

/* ============================================================
   CATEGORY COLORS — légèrement assombries pour lisibilité
   du numéro blanc. Modifiez ici ET dans CATEGORIES (app.js)
   ============================================================ */
.marker-dot[data-category="musee"]          { background: var(--cat-musee); }
.marker-dot[data-category="religieux"]      { background: var(--cat-religieux); }
.marker-dot[data-category="traditionnel"]   { background: var(--cat-traditionnel); }
.marker-dot[data-category="culture"]        { background: var(--cat-culture); }
.marker-dot[data-category="sport"]          { background: var(--cat-sport); }
.marker-dot[data-category="transport"]      { background: var(--cat-transport); }
.marker-dot[data-category="civique"]        { background: var(--cat-civique); }
.marker-dot[data-category="bibliotheque"]   { background: var(--cat-bibliotheque); }
.marker-dot[data-category="site"]           { background: var(--cat-site); }
.marker-dot[data-category="monument"]       { background: var(--cat-monument); }
.marker-dot[data-category="infrastructure"] { background: var(--cat-infrastructure); }
.marker-dot[data-category="boutique"]       { background: var(--cat-boutique); }
.marker-dot[data-category="bureau"]         { background: var(--cat-bureau); }

/* ============================================================
   CLUSTER — Regroupement de marqueurs
   ============================================================ */
/* Override des couleurs par défaut de MarkerCluster.Default.css */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(28,27,25,0.10) !important;
  border-radius: 50%;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  width: 28px !important;
  height: 28px !important;
  margin: 4px !important;
  background-color: var(--ink-primary) !important;
  border-radius: 50% !important;
  text-align: center !important;
  line-height: 28px !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  color: var(--ink-inverse) !important;
  font-family: var(--font-body) !important;
  letter-spacing: 0 !important;
}

/* ============================================================
   LEAFLET POPUP — Override global
   ============================================================ */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-2xl) !important;
  padding: 0 !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-popup) !important;
  border: 1px solid var(--border-light) !important;
  background: var(--surface) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1 !important;
}

.leaflet-popup-tip {
  box-shadow: none !important;
  background: var(--surface) !important;
}

.leaflet-popup-tip-container { margin-top: -1px; }

.leaflet-popup-close-button {
  top: var(--sp-2) !important;
  right: var(--sp-2) !important;
  width: 26px !important;
  height: 26px !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  color: var(--ink-secondary) !important;
  background: rgba(255,255,255,0.88) !important;
  border-radius: var(--r-pill) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  backdrop-filter: blur(4px);
  transition: background var(--t-fast) !important;
  z-index: 10;
}
.leaflet-popup-close-button:hover {
  background: white !important;
  color: var(--ink-primary) !important;
}

/* ============================================================
   POPUP CARD — Modifiez l'apparence de la fiche lieu ici
   ============================================================ */
.popup-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  width: 280px;
}

/* Image — sur desktop : carré (280×280) pour mettre le thumbnail
   Instagram en valeur. Sur mobile, override en 3:4 portrait. */
.popup-image-wrapper {
  width: 100%;
  height: 240px;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  position: relative;
}

.popup-image-wrapper--clickable {
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.popup-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--t-slow) var(--ease);
}

.popup-image-wrapper:hover .popup-image { transform: scale(1.03); }

/* Body */
.popup-body {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ── Popup category pills (multi-catégorie) ── */
.popup-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.popup-category-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  line-height: 1.6;
  white-space: nowrap;
}

/* ── List category pills ── */
.list-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  min-width: 0;
}

.list-cat-pill {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.list-cat-pill + .list-cat-pill::before {
  content: '·';
  margin-right: 3px;
  opacity: 0.4;
  color: var(--ink-muted);
}

.popup-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.popup-description {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: 1.58;
  margin-top: 1px;
}

.popup-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: 2px;
}

.popup-architect {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-primary);
}

.popup-year {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  padding-left: var(--sp-2);
  border-left: 1px solid var(--border);
}

.popup-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-day-number {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  flex-shrink: 0;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-primary);
  text-decoration: none;
  padding: 6px 12px;
  background: #fafaf9;
  border: 1px solid var(--border-light);
  border-radius: var(--r-pill);
  transition:
    background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.popup-link svg { width: 13px; height: 13px; flex-shrink: 0; }
.popup-link:hover {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: white;
}

/* Variant icône seule (utilisé sur la card mobile)
   Icône noire pleine, fond clair, bordure visible pour bon contraste */
.popup-link--icon-only {
  padding: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  justify-content: center;
  gap: 0;
  font-size: 0;
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink-primary);
}
.popup-link--icon-only svg {
  width: 18px;
  height: 18px;
  color: var(--ink-primary);
}
/* Le bouton partage en icône utilise stroke-width plus marqué */
.popup-link--share.popup-link--icon-only svg {
  stroke-width: 1.6;
}

.popup-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
}

.popup-link--insta:hover {
  background: #c13584;
  border-color: #c13584;
  color: white;
}

/* Bouton partage (button element, pas <a>) */
button.popup-link {
  cursor: pointer;
  font-family: inherit;
}
.popup-link--share:hover {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: white;
}
.popup-link--copied {
  background: #2a9d8f !important;
  border-color: #2a9d8f !important;
  color: white !important;
}

/* Bouton "Lire la suite" / "Réduire" — affiché sous la description sur mobile */
.popup-desc-expand {
  display: block;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-primary);
  background: none;
  border: none;
  padding: 6px 0 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.popup-desc-expand:active { opacity: 0.6; }

/* ============================================================
   "FIT ALL" BUTTON — Contrôle personnalisé de la carte
   ============================================================ */
.fit-all-control {
  background: var(--surface) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden;
}

.fit-all-btn {
  width: 34px !important;
  height: 34px !important;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  font-size: 14px;
}
.fit-all-btn:hover {
  background: var(--bg);
  color: var(--ink-primary);
}
.fit-all-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================================
   SIDEBAR TOGGLE — Desktop uniquement
   ============================================================ */
#sidebar-toggle {
  display: none;
  position: absolute;
  top: var(--sp-4);
  left: var(--sp-4);
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 40px;
  height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: background var(--t-fast);
}
#sidebar-toggle:hover { background: var(--bg); }
#sidebar-toggle svg { width: 18px; height: 18px; color: var(--ink-primary); }



/* ============================================================
   MOBILE CARD — Card d'info qui apparaît au clic d'un marqueur
   
   Approche ULTRA-SIMPLE pour fiabilité iOS Chrome dans iframe :
   • position: fixed (relative à la viewport, pas au parent)
   • display: none/block selon data-state (pas de transform)
   • Aucune transition (cause connue de bugs iOS dans iframe)
   ============================================================ */
#mobile-card {
  display: none;
}

#mobile-card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.18);
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
#mobile-card-close svg {
  width: 13px;
  height: 13px;
  color: var(--ink-primary);
}

/* ============================================================
   MOBILE CARD CONTENT — Layout horizontal compact
   
   Image en format 3:4 portrait (Instagram natif) à gauche,
   contenu textuel à droite. La hauteur s'adapte au contenu.
   ============================================================ */
#mobile-card-content {
  width: 100%;
  display: block;
  padding: 12px 12px 10px;
}

/* Override de la structure popup-card pour mobile */
#mobile-card-content .popup-card {
  width: 100%;
  background: transparent;
  display: grid;
  grid-template-columns: 95px 1fr;
  grid-auto-rows: auto;
  gap: 10px 12px;
  padding: 0;
  margin: 0;
}

/* Image thumbnail à gauche — format 3:4 portrait (Instagram natif) */
#mobile-card-content .popup-image-wrapper {
  grid-column: 1;
  grid-row: 1;
  width: 95px;
  height: 127px;                  /* 95 × 4/3 ≈ 127 */
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
#mobile-card-content .popup-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Body à droite */
#mobile-card-content .popup-body {
  grid-column: 2;
  grid-row: 1;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* Titre */
#mobile-card-content .popup-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin: 0;
}

/* Catégories en pills */
#mobile-card-content .popup-category-pills {
  flex-wrap: wrap;
  gap: 3px;
}
#mobile-card-content .popup-category-pill {
  font-size: 8.5px;
  padding: 2px 6px;
}

/* Header row : numéro + catégories */
#mobile-card-content .popup-header-row {
  gap: 6px;
}

/* Métadonnées (architecte / année) — collées en bas du body */
#mobile-card-content .popup-meta {
  margin-top: auto;
  font-size: 12px;
}
#mobile-card-content .popup-architect { font-size: 12px; }
#mobile-card-content .popup-year      { font-size: 12px; }

/* Description sur les 2 colonnes, sous l'image+texte
   Pas de line-clamp : le tronquage est fait en JS. */
#mobile-card-content .popup-description {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0;
  color: var(--ink-secondary);
}

/* Bouton "Lire la suite" — ligne dédiée */
#mobile-card-content .popup-desc-expand {
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: -2px;
  padding-top: 0;
}

/* Liens en icônes, tout en bas — gap réduit pour éviter trou */
#mobile-card-content .popup-links {
  grid-column: 1 / -1;
  grid-row: 4;
  margin-top: 4px;
}

/* Si pas d'image, le contenu prend toute la largeur */
#mobile-card-content .popup-card:not(:has(.popup-image-wrapper)) {
  grid-template-columns: 1fr;
}
#mobile-card-content .popup-card:not(:has(.popup-image-wrapper)) .popup-body {
  grid-column: 1;
}

/* ============================================================
   MOBILE — Bouton "Liste" flottant
   ============================================================ */
#mobile-list-btn {
  display: none;
}

/* ============================================================
   MOBILE — Panneau de liste
   ============================================================ */
#mobile-list-panel {
  display: none;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
#empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  pointer-events: all;
}
#empty-state-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-8) var(--sp-6);
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 220px;
  max-width: 260px;
}
#empty-state svg {
  width: 40px; height: 40px;
  color: var(--ink-muted);
  margin-bottom: var(--sp-3);
}
#empty-state p {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: 1.55;
  margin-bottom: var(--sp-4);
}
#reset-filters {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-primary);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 7px 18px;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
#reset-filters:hover {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: white;
}

/* ============================================================
   RESPONSIVE DESKTOP — > 768px
   La card mobile est strictement cachée
   ============================================================ */
@media (min-width: 769px) {
  #sidebar-toggle { display: flex; }
  #mobile-card    { display: none !important; }
}

/* ============================================================
   MOBILE — < 768px
   
   Layout simple, sans drag :
   • Top bar sticky : brand + recherche + filtres
   • Carte plein écran dessous
   • Card d'info en bas qui apparaît au tap d'un marqueur
   ============================================================ */
@media (max-width: 768px) {

  /* Layout vertical : top bar + map */
  #app {
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }

  /* La sidebar devient une top bar compacte */
  #sidebar {
    position: relative;
    width: 100%;
    height: auto;
    flex-shrink: 0;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    z-index: 100;
    overflow: visible;
    /* Empêche le pinch-zoom natif sur la top bar (seule la carte zoome) */
    touch-action: pan-x pan-y;
  }
  #search-input {
    font-size: 16px;                /* ≥16px évite l'auto-zoom iOS au focus */
    padding: 9px var(--sp-2);
  }
  #sidebar-header {
    padding: 10px var(--sp-3) 8px;
    border-bottom: none;
  }
  #brand { margin-bottom: 8px; }
  #brand-name,
  #brand-name-fallback { font-size: 13.5px; }
  #brand-sub  { font-size: 11px; }
  #brand-logo { height: 26px; }

  /* Le bouton liste en haut-droite occupe cette zone — cacher le compteur */
  #progress-counter { display: none; }

  #search-wrapper { margin-bottom: 8px; }

  /* Filtres : scroll horizontal, plus de wrap */
  #filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-bottom: 0;
    padding-bottom: 3px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #filter-bar::-webkit-scrollbar { display: none; }

  /* La liste dans la sidebar est cachée sur mobile */
  #sidebar > #list-container { display: none; }

  /* Le compteur de résultats inline n'a plus sa place ici */
  #results-count { display: none; }

  /* La carte prend tout le reste */
  #map-container {
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    position: relative;
  }

  /* MOBILE CARD — visible UNIQUEMENT quand data-state="visible"
     position: fixed + height: fit-content pour coller au contenu exact. */
  #mobile-card[data-state="visible"] {
    display: block;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 9999;
    background: var(--surface);
    border-radius: var(--r-2xl);
    box-shadow: 0 6px 28px rgba(0,0,0,0.25), 0 2px 6px rgba(0,0,0,0.10);
    height: fit-content;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* Cacher les popups Leaflet sur mobile (on utilise notre propre card) */
  .leaflet-popup { display: none !important; }

  /* Cacher le bouton sidebar-toggle desktop */
  #sidebar-toggle { display: none !important; }

  /* ─── MOBILE : Bouton flottant "Liste" ─── 
     Positionné dans le coin haut-droit DU MAP (pas de l'écran),
     calculé via --top-bar-height (hauteur réelle de la sidebar). */
  #mobile-list-btn {
    display: flex;
    position: fixed;
    top: calc(var(--top-bar-height, 160px) + 10px);
    right: 12px;
    z-index: 1500;
    background: var(--ink-primary);
    color: white;
    border: none;
    border-radius: var(--r-pill);
    padding: 9px 14px;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.30);
    font-family: var(--font-body);
    font-size: 12.5px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  #mobile-list-btn:active { opacity: 0.85; }
  #mobile-list-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
  #mobile-list-btn-count {
    background: rgba(255,255,255,0.22);
    border-radius: var(--r-pill);
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
  }

  /* Quand le panel est ouvert : icône X au lieu des barres (toggle close) */
  #app:has(#mobile-list-panel[data-state="visible"]) #mobile-list-btn .icon-list,
  #mobile-list-btn .icon-close {
    display: none;
  }
  #app:has(#mobile-list-panel[data-state="visible"]) #mobile-list-btn .icon-close {
    display: block;
  }
  #app:has(#mobile-list-panel[data-state="visible"]) #mobile-list-btn #mobile-list-btn-count {
    display: none;
  }

  /* Le bouton reste visible même quand la card d'info est ouverte
     (conserve l'état de la liste filtrée affichée) */

  /* ─── MOBILE : Panneau de liste (visible quand data-state="visible") ───
     Flush sous la top bar via --top-bar-height. */
  #mobile-list-panel[data-state="visible"] {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--top-bar-height, 160px);
    bottom: 0;
    z-index: 1400;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
  }

  /* Header du panel et bouton close internes : cachés
     (le bouton flottant en haut à droite fait office de toggle) */
  #mobile-list-panel-header,
  #mobile-list-panel-close {
    display: none;
  }

  #mobile-list-panel-container {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================
   ACCESSIBILITÉ — focus clavier
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--ink-primary);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* ============================================================
   UTILITAIRES
   ============================================================ */
[hidden] { display: none !important; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.list-item {
  animation: fade-up var(--t-base) var(--ease-out) both;
}
