﻿/* static/css/popup_theme.css */

/* =========================================================
   Flux Montréal — Leaflet Popup + Legend Theme (2026 FINAL)
   - Popups scoppés: hm-bus-popup / hm-train-popup / hm-bixi-popup / hm-entraves-popup
   - Wrap multi-lignes robuste (pas de "..."), même sans espaces
   - BUS/TRAIN: centré, compact, sans corner icon
   - TRAIN: compact (largeur réduite)
   - ENTRAVES: lien Québec 511 bleu stable
   - LEGEND + SHARE: card theme + z-index safe
   ========================================================= */


/* =========================================================
   1) TOKENS
   ========================================================= */
:root{
  --hm-pop-bg:#283242;
  --hm-pop-surface:#1E293B;
  --hm-pop-text:#E5E7EB;
  --hm-pop-muted:#A7B0BE;
  --hm-pop-border:rgba(255,255,255,.10);
  --hm-pop-divider:rgba(255,255,255,.12);
  --hm-pop-shadow:0 12px 34px rgba(0,0,0,.38);

  --hm-accent-train:#67a7e4;
  --hm-link:#67a7e4;

  --hm-font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* réserve symétrique pour centrer visuellement malgré le X */
  --hm-close-gutter: 28px;
}


/* =========================================================
   2) POPUPS — BASE (SCOPED)
   ========================================================= */
.leaflet-popup.hm-bus-popup .leaflet-popup-content-wrapper,
.leaflet-popup.hm-train-popup .leaflet-popup-content-wrapper,
.leaflet-popup.hm-entraves-popup .leaflet-popup-content-wrapper,
.leaflet-popup.hm-bixi-popup .leaflet-popup-content-wrapper{
  background:var(--hm-pop-bg) !important;
  border:1px solid var(--hm-pop-border) !important;
  border-radius:14px !important;
  box-shadow:var(--hm-pop-shadow) !important;
  padding:0 !important;
}

.leaflet-popup.hm-bus-popup .leaflet-popup-tip,
.leaflet-popup.hm-train-popup .leaflet-popup-tip,
.leaflet-popup.hm-entraves-popup .leaflet-popup-tip,
.leaflet-popup.hm-bixi-popup .leaflet-popup-tip{
  background:var(--hm-pop-bg) !important;
  box-shadow:none !important;
}

/* Close button (Leaflet X) */
.leaflet-popup.hm-bus-popup .leaflet-popup-close-button,
.leaflet-popup.hm-train-popup .leaflet-popup-close-button,
.leaflet-popup.hm-entraves-popup .leaflet-popup-close-button,
.leaflet-popup.hm-bixi-popup .leaflet-popup-close-button{
  display:block !important;
  top:6px !important;
  right:6px !important;
  padding:0 !important;
  width:22px !important;
  height:22px !important;
  line-height:22px !important;
  text-align:center !important;
  color:#CBD5E1 !important;
  opacity:.95 !important;
}
.leaflet-popup.hm-bus-popup .leaflet-popup-close-button:hover,
.leaflet-popup.hm-train-popup .leaflet-popup-close-button:hover,
.leaflet-popup.hm-entraves-popup .leaflet-popup-close-button:hover,
.leaflet-popup.hm-bixi-popup .leaflet-popup-close-button:hover{
  color:#FFFFFF !important;
  opacity:1 !important;
}


/* =========================================================
   3) POPUPS — CONTENT (wrap robuste)
   ========================================================= */
.leaflet-popup.hm-bus-popup .leaflet-popup-content,
.leaflet-popup.hm-train-popup .leaflet-popup-content,
.leaflet-popup.hm-entraves-popup .leaflet-popup-content,
.leaflet-popup.hm-bixi-popup .leaflet-popup-content{
  margin:0 !important;
  padding:10px 12px !important;
  color:var(--hm-pop-text) !important;
  font-family:var(--hm-font) !important;
  font-size:13px !important;
  line-height:1.55 !important;

  white-space:normal !important;
  overflow-wrap:anywhere !important;
  word-break:break-word !important;
  hyphens:auto !important;

  font-weight:400 !important;
  letter-spacing:0 !important;

  max-width:100% !important;
  box-sizing:border-box !important;
}

/* ENTRAVES un peu plus compact */
.leaflet-popup.hm-entraves-popup .leaflet-popup-content{
  padding:8px 10px !important;
}

/* No bold absolu: tout à 400 */
.leaflet-popup.hm-bus-popup *,
.leaflet-popup.hm-train-popup *,
.leaflet-popup.hm-entraves-popup *,
.leaflet-popup.hm-bixi-popup *{
  font-family:var(--hm-font) !important;
  font-weight:400 !important;
  box-sizing:border-box !important;
}


/* =========================================================
   4) COMPONENTS (structure commune)
   ========================================================= */
.hm-popup-wrap{
  position:relative;
  display:block;
  max-width:100%;
}

/* Header (par défaut) */
.hm-popup-head{
  padding-left:40px;
}

.hm-title{
  font-size:13.5px;
  line-height:1.2;
  color:var(--hm-pop-text);
  white-space:normal;
  overflow-wrap:anywhere;
}

.hm-sub{
  margin-top:3px;
  font-size:12px;
  color:var(--hm-pop-muted);
  white-space:normal;
  overflow-wrap:anywhere;
}

/* Pills */
.hm-status-row{
  margin-top:10px;
  display:flex;
  gap:8px;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
}

.hm-status-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:7px 12px;
  border-radius:999px;
  background:var(--hm-pop-surface);
  border:1px solid var(--hm-pop-border);
  color:var(--hm-pop-text);
  font-size:12px;
  white-space:nowrap;

  max-width:none;
  overflow:visible;
  text-overflow:clip;
}

/* Divider utilitaire */
.hm-divider{
  height:1px;
  background:var(--hm-pop-divider);
  margin:10px 0;
}


/* =========================================================
   5) REMIXICON safe
   ========================================================= */
.hm-ri{
  font-family:"remixicon" !important;
  font-style:normal !important;
  font-weight:normal !important;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  line-height:1;
  opacity:.95;
}

.leaflet-popup.hm-bixi-popup i[class^="ri-"],
.leaflet-popup.hm-bixi-popup i[class*=" ri-"],
.leaflet-popup.hm-train-popup i[class^="ri-"],
.leaflet-popup.hm-train-popup i[class*=" ri-"],
.leaflet-popup.hm-bus-popup i[class^="ri-"],
.leaflet-popup.hm-bus-popup i[class*=" ri-"],
.leaflet-popup.hm-entraves-popup i[class^="ri-"],
.leaflet-popup.hm-entraves-popup i[class*=" ri-"]{
  font-family:"remixicon" !important;
  font-style:normal !important;
  font-weight:normal !important;
}


/* =========================================================
   6) BUS — FINAL (compact + centré, sans corner icon)
   ========================================================= */
.leaflet-popup.hm-bus-popup{
  max-width:360px !important;
}
.leaflet-popup.hm-bus-popup .leaflet-popup-content-wrapper{
  min-width:260px !important;
}
.leaflet-popup.hm-bus-popup .leaflet-popup-content{
  min-width:260px !important;
  padding:10px 12px !important;
}

/* Header: centré + réserve symétrique (centrage visuel parfait) */
.leaflet-popup.hm-bus-popup .hm-popup-wrap{
  width:100% !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  text-align:center !important;
}
.leaflet-popup.hm-bus-popup .hm-popup-head{
  width:100% !important;
  padding-left:var(--hm-close-gutter) !important;
  padding-right:var(--hm-close-gutter) !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  text-align:center !important;
  margin:0 !important;
}
.leaflet-popup.hm-bus-popup .hm-title,
.leaflet-popup.hm-bus-popup .hm-sub{
  width:100% !important;
  text-align:center !important;
  margin:0 auto !important;
  display:block !important;
}

/* Accent titre bus */
.leaflet-popup.hm-bus-popup .hm-title{
  color:var(--hm-accent-train) !important;
}

/* Pills empilées (1 par ligne) */
.leaflet-popup.hm-bus-popup .hm-status-row{
  width:100% !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  gap:8px !important;
  flex-wrap:nowrap !important;
}
.leaflet-popup.hm-bus-popup .hm-status-pill{
  width:fit-content !important;
  max-width:100% !important;
  margin:0 auto !important;
  white-space:nowrap !important;
}

/* Leaflet content: pas de shrink */
.leaflet-popup.hm-bus-popup .leaflet-popup-content{
  width:auto !important;
  display:block !important;
}

/* No corner icon */
.leaflet-popup.hm-bus-popup .hm-corner-icon{
  display:none !important;
}


/* =========================================================
   7) TRAIN — FINAL (centré + plus étroit)
   ========================================================= */
.leaflet-popup.hm-train-popup{
  max-width:220px !important;   /* ajuste ici si besoin (210–240) */
}

.leaflet-popup.hm-train-popup .leaflet-popup-content-wrapper{
  max-width:220px !important;
  min-width:0 !important;
}

.leaflet-popup.hm-train-popup .leaflet-popup-content{
  max-width:220px !important;
  min-width:0 !important;
  width:auto !important;
  padding:10px 12px !important;
}

/* Wrap/header centré + réserve symétrique (centrage visuel parfait) */
.leaflet-popup.hm-train-popup .hm-popup-wrap{
  width:100% !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  text-align:center !important;
}
.leaflet-popup.hm-train-popup .hm-popup-head{
  width:100% !important;
  padding-left:var(--hm-close-gutter) !important;
  padding-right:var(--hm-close-gutter) !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  text-align:center !important;
  margin:0 !important;
}

/* Accent titre train seulement */
.leaflet-popup.hm-train-popup .hm-title{
  color:var(--hm-accent-train) !important;
  width:100% !important;
  text-align:center !important;
  margin:0 auto !important;
  display:block !important;
}
.leaflet-popup.hm-train-popup .hm-sub{
  color:var(--hm-pop-muted) !important;
  font-size:12px !important;
  line-height:1.15 !important;
  width:100% !important;
  text-align:center !important;
  margin:0 auto !important;
  display:block !important;
}

/* Pills empilées */
.leaflet-popup.hm-train-popup .hm-status-row{
  width:100% !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  gap:8px !important;
  flex-wrap:nowrap !important;
}
.leaflet-popup.hm-train-popup .hm-status-pill{
  width:fit-content !important;
  max-width:100% !important;
  margin:0 auto !important;
  white-space:nowrap !important;
}

/* No corner icon */
.leaflet-popup.hm-train-popup .hm-corner-icon{
  display:none !important;
}


/* =========================================================
   8) ENTRAVES — cohérence + lien Québec 511
   ========================================================= */
.leaflet-popup.hm-entraves-popup{
  max-width:420px !important;
}

.leaflet-popup.hm-entraves-popup a,
.leaflet-popup.hm-entraves-popup a:visited,
.leaflet-popup.hm-entraves-popup a:hover,
.leaflet-popup.hm-entraves-popup a:active,
.leaflet-popup.hm-entraves-popup a:focus{
  color:var(--hm-link) !important;
  text-decoration:none !important;
  outline:none !important;
}

.leaflet-popup.hm-entraves-popup a:hover{
  color:var(--hm-link) !important;
  text-decoration:none !important;
  opacity:1 !important;
}

/* Optionnel: look “CTA” */
.leaflet-popup.hm-entraves-popup .hm-entraves-link,
.leaflet-popup.hm-entraves-popup a.hm-entraves-link{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:8px !important;
  padding:8px 12px !important;
  border-radius:10px !important;
  background:rgba(30,41,59,.55) !important;
  border:1px solid rgba(255,255,255,.12) !important;
  color:var(--hm-link) !important;
  cursor:pointer !important;
  user-select:none !important;
}

.leaflet-popup.hm-entraves-popup .hm-entraves-link:hover,
.leaflet-popup.hm-entraves-popup a.hm-entraves-link:hover{
  color:var(--hm-link) !important;
  border-color:rgba(103,167,228,.55) !important;
  background:rgba(30,41,59,.62) !important;
}


/* =========================================================
   9) BIXI — placement icône coin + spacing header
   ========================================================= */
.leaflet-popup.hm-bixi-popup{
  max-width:380px !important;
}

.leaflet-popup.hm-bixi-popup .hm-popup-wrap{
  position:relative !important;
  padding-top:2px !important;
}

.leaflet-popup.hm-bixi-popup .hm-corner-icon{
  position:absolute !important;
  left:12px !important;
  top:12px !important;
  width:30px !important;
  height:30px !important;
  border-radius:12px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;

  background:rgba(30,41,59,.55) !important;
  border:1px solid rgba(255,255,255,.10) !important;
  color:#E5E7EB !important;
}

.leaflet-popup.hm-bixi-popup .hm-popup-head{
  padding-left:52px !important;
  padding-right:28px !important;
  min-height:34px !important;
  text-align:left !important;
}

.leaflet-popup.hm-bixi-popup .hm-corner-icon i{
  display:block !important;
  line-height:1 !important;
  font-size:16px !important;
  opacity:.95 !important;
  transform:translateY(0.5px);
}


/* =========================================================
   10) LEAFLET CONTROLS — safe z-index (ne pas casser Leaflet)
   ========================================================= */
.leaflet-control-container{
  pointer-events:none;
}
.leaflet-control-container .leaflet-control{
  pointer-events:auto;
}

.leaflet-top,
.leaflet-bottom{
  z-index:1000 !important;
}


/* =========================================================
   11) LEGEND THEME (hm_dynamic_legend.js)
   ========================================================= */
.hm-legend.leaflet-control{
  position:relative;
  z-index:1200 !important;
}

.hm-legend-card{
  background:var(--hm-pop-bg);
  border:1px solid var(--hm-pop-border);
  border-radius:14px;
  box-shadow:var(--hm-pop-shadow);
  padding:10px 10px;
  color:var(--hm-pop-text);
  font-family:var(--hm-font);
}

.hm-legend-title{
  font-size:11px;
  letter-spacing:.14em;
  text-transform:uppercase;
  color:rgba(229,231,235,.92);
  margin:0 0 8px 2px;
  font-weight:400;
}


/* =========================================================
   12) Share button (PARTAGER CETTE VUE) — style legend
   ========================================================= */
.th-map-share-btn{
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  font-size:10px !important;
  font-weight:600 !important;
  letter-spacing:.18em !important;
  text-transform:uppercase !important;

  background:#283242 !important;
  color:rgba(229,231,235,.92) !important;
  border:1px solid rgba(255,255,255,.10) !important;
  border-radius:999px !important;
  box-shadow:0 16px 40px rgba(0,0,0,.55) !important;

  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;

  padding:7px 18px !important;
  line-height:1 !important;
  white-space:nowrap !important;

  cursor:pointer !important;
  outline:none !important;
  -webkit-tap-highlight-color:transparent;
}

.th-map-share-btn:hover,
.th-map-share-btn:focus{
  background:#2f3b4f !important;
  border-color:rgba(255,255,255,.14) !important;
  color:rgba(241,245,249,.96) !important;
}

.th-map-share-btn:active{
  transform: translateY(1px);
  box-shadow:0 12px 30px rgba(0,0,0,.55) !important;
}

.th-map-share-btn:focus-visible{
  box-shadow:
    0 16px 40px rgba(0,0,0,.55),
    0 0 0 3px rgba(56,189,248,.25) !important;
}


/* =========================================================
   13) MOBILE — hide legend + share
   ========================================================= */
@media (max-width: 768px){
  .hm-legend.leaflet-control,
  .hm-legend-card{
    display:none !important;
    visibility:hidden !important;
    opacity:0 !important;
    pointer-events:none !important;
  }

  .th-map-share-btn{
    display:none !important;
    visibility:hidden !important;
    opacity:0 !important;
    pointer-events:none !important;
  }
}

/* =========================================================
   TRAIN — title split (Exo Train / number)
   ========================================================= */
.leaflet-popup.hm-train-popup .hm-title{
  white-space:nowrap !important;   /* Exo Train reste sur 1 ligne */
}

/* =========================================================
   ✅ BUS — WIDTH COMPACT (n'affecte rien d'autre)
   ========================================================= */

.leaflet-popup.hm-bus-popup{
  max-width: 200px !important;   /* ajuste ici si besoin (190–220) */
}

.leaflet-popup.hm-bus-popup .leaflet-popup-content-wrapper{
  max-width: 200px !important;
  min-width: 0 !important;
}

.leaflet-popup.hm-bus-popup .leaflet-popup-content{
  max-width: 200px !important;
  min-width: 0 !important;
  width: auto !important;
}

/* =========================================================
   ✅ TRAIN — text size -1px (title + number)
   ========================================================= */

/* Exo Train */
.leaflet-popup.hm-train-popup .hm-title{
  font-size: 12.5px !important;   /* -1px */
}

/* Numéro du train (3000, 2051, etc.) */
.leaflet-popup.hm-train-popup .hm-sub{
  font-size: 11px !important;     /* -1px */
  line-height: 1.15 !important;
}

/* =========================================================
   ✅ BUS — FORCE WIDTH (override du min-width 260)
   ========================================================= */

.leaflet-popup.hm-bus-popup{
  max-width: 220px !important; /* ajuste ici */
}

/* Leaflet met souvent la vraie largeur ici */
.leaflet-popup.hm-bus-popup .leaflet-popup-content-wrapper,
.leaflet-popup.hm-bus-popup .leaflet-popup-content{
  width: 220px !important;     /* force la largeur réelle */
  max-width: 220px !important;
  min-width: 0 !important;     /* casse le verrou 260px */
}

/* Optionnel: si le contenu pousse encore (rare) */
.leaflet-popup.hm-bus-popup .hm-popup-wrap{
  max-width: 100% !important;
}
