/* Own font-face fallback for PWA (offline support) */
@font-face {
  font-family: 'Montserrat Alternates';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/montserratalternates/v13/-W_sVQnjV356A9zwKNqOs-gVmxpsvnpHHzrb.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat Alternates';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/montserratalternates/v13/-W_sVQnjV356A9zwKNqOs-gVmxpsvnpH-HYb.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat Alternates';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/montserratalternates/v13/-W_sVQnjV356A9zwKNqOs-gVmxpsvnpH7m8b.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat Alternates';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('https://fonts.gstatic.com/s/montserratalternates/v13/-W_sVQnjV356A9zwKNqOs-gVmxpsvnpHtm4b.woff2') format('woff2');
}
html, body { 
  height: 100%; 
  margin: 0; 
  width: 100%;
  overflow: hidden;
}
#map { 
  height: 100%; 
  width: 100%; 
  position: absolute;
  top: 0;
  left: 0;
}
#panel {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  min-height: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  font-family: sans-serif;
  z-index: 1000;
  pointer-events: auto;
  box-shadow: none;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  box-sizing: border-box;
}

@media (max-width: 600px) {
  /* panel has no padding by default on mobile either */
  #panel { padding: 0; }
}

#panel * {
  font-family: "DIN Next Rounded", sans-serif;
  letter-spacing: -0.02em; /* resserre comme sur l’image */
}

#panel .num,
#panel .eta {
  font-weight: 900;
  font-size: 44px;
  line-height: 1;
}

#panel .meta .dest {
  font-weight: 800;
}

/* removed numeric id box; panel will show stop name + city only */

#panel .info {
  flex: 1;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#panel .info h3 {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  line-height: 1.2;
}

#panel .info p {
  margin: 4px 0 0 0;
  font-size: 13px;
  opacity: 0.95;
  line-height: 1.2;
}

#panel .time {
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
}

#panel .time-value {
  font-size: 32px;
  font-weight: bold;
  color: white;
  line-height: 1;
}

#panel .time-label {
  font-size: 11px;
  font-weight: normal;
  color: white;
  opacity: 0.95;
}

/* bottom panel line cards */
#panel .line-list { display:flex; gap:0; align-items:stretch; overflow:hidden; }
#panel .line-card { display:flex; align-items:center; gap:4px; flex: 1 1 0; padding:12px; border-radius:0; color:white; box-shadow:none; cursor:pointer; border:0; text-align:left; margin:0; }
#panel .line-card:focus { outline: 2px solid rgba(255,255,255,0.6); }
#panel .line-card .num { font-size:36px; font-weight:900; width:auto; min-width:60px; max-width:100px; text-align:center; line-height:1.1; white-space: nowrap; flex-shrink: 0; }
#panel .line-card .meta { flex:1; margin-right: 12px; }
#panel .line-card .meta .dest { font-weight:800; font-size:16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#panel .line-card .meta .stopcity { font-size:12px; opacity:0.95; }
#panel .line-card .eta { font-size:32px; font-weight:900; width:56px; text-align:center; flex-shrink: 0; }
#center-marker {
  position: absolute;
  top: 50%; left: 50%;
  width: 15px; height: 15px;
  margin-left: -10px; margin-top: -10px;
  background: rgb(183, 0, 255);
  border-radius: 50%;
  border: 2px solid white;
  pointer-events: none; /* laisse passer la carte */
  z-index: 1000;
}

#stop-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: white;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.25);
  padding: 16px;
  transform: translateY(100%);
  transition: transform .25s ease;
  z-index: 1000;
  pointer-events: none; /* 👈 CRUCIAL */
}

#stop-panel.open {
  transform: translateY(0);
  pointer-events: auto; /* 👈 réactive quand ouvert */
}

#stop-panel .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative; /* needed for close button */
  padding-right: 56px; /* space for close button */
}

#stop-panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

#close-panel {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

#stop-lines span, #stop-lines button {
  display: inline-block;
  background: #eee;
  border-radius: 6px;
  padding: 4px 8px;
  margin: 4px 4px 0 0;
  font-weight: bold;
  border: 0;
  cursor: pointer;
}

/* Mobile layout: stack lines vertically and allow scrolling after 3 items */
@media (max-width: 600px) {
  /* panel adapts to its content height up to 3 stacked cards */
  #panel { display:block; bottom:0; left:0; right:0; }
  #panel .line-list { display:flex; flex-direction:column; gap:0; max-height: calc(3 * 68px); overflow-y: auto; -webkit-overflow-scrolling: touch; width:100%; }
  /* each card takes full width and fixed height so panel grows naturally up to 3 cards */
  #panel .line-card { flex: 0 0 auto; width: 100%; height: 68px; padding: 8px 12px; border-radius: 0; margin: 0; }
  #panel .line-card .num { font-size:28px; width:auto; min-width:50px; max-width:90px; white-space: nowrap; }
  #panel .line-card .eta { width:56px; font-size:22px; text-align:right; }
  #panel .line-list, #panel .line-card { box-sizing: border-box; }

  /* stop panel lines (popup) styled similarly and flush */
  #stop-lines { display:flex; flex-direction:column; gap:0; max-height: calc(3 * 48px); overflow-y:auto; -webkit-overflow-scrolling: touch; }
  #stop-lines span, #stop-lines button { display:block; width:100%; text-align:left; padding:12px; margin:0; border-radius:0; background:#f2f2f2; }
}

/* uniform line button styling inside popups */
.line-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 6px;
  margin: 3px 4px 3px 0;
  font-weight: bold;
  border: 0;
  cursor: pointer;
  box-sizing: border-box;
}

/* small helper for stop panel line buttons */
.stop-line-btn { border: 0; padding: 8px 12px; border-radius: 8px; background: #f6f6f6; cursor: pointer; }

/* Route panel mirrors stop panel styles */
#route-panel { position: absolute; right: 12px; top: 70px; width: 360px; background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.2); border-radius: 8px; overflow: hidden; z-index: 600; font-family: sans-serif; }
#route-panel.hidden { display: none; }
#route-panel.open { display: block; }
#route-panel .header { display:flex; justify-content:space-between; align-items:center; padding:8px; }
#route-panel h2 { margin:0; font-size:18px; font-weight:600; }
#route-panel #close-route-panel { border-radius:8px; padding:2px 8px; font-size:16px; margin-left:8px; border:0; cursor:pointer; }
#route-stops { padding: 8px; max-height: 420px; overflow:auto; }
#route-meta { padding: 8px; font-size: 13px; color:#444; }
#route-stops .route-stop { padding:6px 4px; border-bottom: 1px solid #eee; display:flex; justify-content:space-between; align-items:center; }
#route-stops .route-stop .stop-name { font-weight:600 }
#route-stops .route-stop .eta { color:#666; font-size:13px }

/* layout for traced route panel columns */
#route-panel .col-left { width:48px; }
#route-panel .col-middle { flex:1; }
#route-panel .col-right { width:120px; }
#route-panel .stop-row { display:flex; gap:8px; align-items:center; padding:6px 4px; border-bottom:1px solid #fafafa; }
#route-panel .stop-dot { width:12px; height:12px; border-radius:50%; border:2px solid #fff; box-shadow:0 0 0 2px rgba(0,0,0,0.06); }
#route-panel .stop-name { font-weight:600 }
#route-panel .stop-meta { font-size:12px; color:#666; margin-bottom:4px }
#route-panel .route-badge { min-width:36px; height:22px; border-radius:6px; display:inline-flex; align-items:center; justify-content:center; padding:0 8px; margin-right:8px; font-weight:700; color:#fff; flex:0 0 auto; }
#route-panel .stop-times { color:#333; font-size:13px }
#route-eta { display:flex; gap:10px; }
#route-eta .eta-card { background:#fff; border-radius:12px; padding:12px 14px; min-width:80px; text-align:center; box-shadow:0 6px 20px rgba(0,0,0,0.06); }
#route-eta .eta-card .eta-number { font-size:28px; font-weight:700 }
#route-eta .eta-card .eta-label { font-size:12px; color:#666 }
#route-panel .col-left { width:58px; }
#route-panel .col-left .stop-dot { width:14px; height:14px }