/* ================= Carte plein écran ================= */

/* La page entière devient la carte : pas de défilement, pas de pied de page. */
body:has(.screen-map) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body:has(.screen-map) .footer {
  display: none;
}
.container:has(.screen-map) {
  max-width: none;
  padding: 0;
  display: flex;
  min-height: 0;
}
.screen-map {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Fond de carte clair (OpenFreeMap), réchauffé pour s'accorder au crème du site */
.map-canvas {
  position: absolute;
  inset: 0;
  z-index: 0; /* contient les calques Leaflet sous les panneaux */
  background: #efeadf;
}
.map-canvas .leaflet-gl-layer {
  filter: sepia(0.28) saturate(0.85) brightness(0.99);
}

/* ---------- Marqueurs ---------- */
.lawyer-marker {
  display: grid;
  place-items: center;
  cursor: pointer;
}
.lm-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  border: 4px solid var(--black);
  transition: transform 0.15s;
}
.lawyer-marker:hover .lm-dot,
.lawyer-marker:focus-visible .lm-dot {
  transform: scale(1.15);
}
.lawyer-marker.is-selected .lm-dot {
  width: 28px;
  height: 28px;
  border-width: 5px;
}
.lawyer-marker.is-selected {
  z-index: 1000 !important;
}
.me-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--black);
  border: 4px solid var(--field);
  outline: 1px solid var(--black);
}

/* ---------- Commandes posées sur la carte ---------- */
.map-top {
  position: absolute;
  z-index: 2;
  inset-block-start: 12px;
  inset-inline: 12px;
  display: grid;
  gap: 8px;
  pointer-events: none; /* la carte reste manipulable entre les boutons */
}
.map-top > * {
  pointer-events: auto;
}
.map-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
#situation-slot {
  flex: 1;
  min-width: 0;
}
.urgent-btn {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 1.3rem;
  border: none;
  border-radius: var(--pill);
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--urgent);
  cursor: pointer;
  transition: background-color 0.15s;
}
.urgent-btn:hover {
  background: var(--urgent-dark);
}
.situation-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  min-height: 46px;
  padding-inline: 1.2rem 0.35rem;
  border-radius: var(--pill);
  font-weight: 600;
  color: var(--black);
  background: var(--gold);
}
/* Texte long sur petit écran : coupé proprement avec "…" au lieu de pousser les boutons */
.situation-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.situation-pill button {
  flex-shrink: 0;
}
.situation-pill.is-urgent {
  color: #ffffff;
  background: var(--urgent);
}
.situation-pill button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  color: inherit;
  background: rgba(0, 0, 0, 0.12);
  cursor: pointer;
}
.fab {
  flex-shrink: 0;
  margin-inline-start: auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: var(--field);
  color: var(--ink);
  cursor: pointer;
}
.fab:hover {
  background: var(--card);
}
.fab svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* Filtres : une seule bande de pilules qu'on fait défiler du doigt, la sélection en noir.
   Le fondu sur le bord indique qu'il y a d'autres choix à côté. */
.chips {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-inline: -12px; /* la bande va jusqu'aux bords de l'écran */
  padding: 2px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 36px), transparent 100%);
}
:root[dir='rtl'] .chips {
  -webkit-mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to left, #000 0, #000 calc(100% - 36px), transparent 100%);
}
.chips::-webkit-scrollbar {
  display: none;
}
.chips::after {
  content: '';
  flex: 0 0 24px; /* espace en fin de bande pour que le dernier filtre sorte du fondu */
}
.chip-group {
  display: contents;
}
.lang-filter {
  flex-shrink: 0;
}
.chip {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  font: inherit;
  font-size: 0.86rem;
  color: var(--ink);
  background: var(--field);
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  background: var(--card);
}
.chip.is-on {
  color: var(--page);
  background: var(--black);
  border-color: var(--black);
  font-weight: 600;
}
.lang-filter select {
  min-height: 38px;
  width: auto;
  padding: 0 0.9rem;
  font-size: 0.86rem;
  border: 1px solid var(--line);
  background: var(--field);
}
/* Langue choisie : même noir que les pilules sélectionnées */
.lang-filter select:has(option:checked:not([value=''])) {
  color: var(--page);
  background-color: var(--black);
  border-color: var(--black);
}

/* ---------- Panneau du bas ---------- */
.sheet {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 54%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color: var(--ink);
  background: var(--page);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: max-height 0.25s ease;
}
.sheet.is-collapsed {
  max-height: 128px;
}
.sheet-handle {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 30px;
  border: none;
  background: none;
  cursor: pointer;
}
.grab {
  width: 42px;
  height: 5px;
  border-radius: 5px;
  background: var(--line);
}
.sheet-body {
  overflow-y: auto;
  padding: 0 20px 12px;
  display: grid;
  gap: 14px;
  align-content: start;
}
.sheet-foot {
  margin: 0;
  padding: 8px 20px 12px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.sheet-head {
  display: grid;
  gap: 2px;
}
.sheet-title {
  margin: 0;
  font-size: 1.45rem;
}
.sheet-hero {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.1;
}
.sheet-sub,
.sheet-text.small {
  font-size: 0.82rem;
  color: var(--ink-muted);
}
.sheet-text {
  margin: 0;
  color: var(--ink-muted);
}
.sheet-actions {
  display: grid;
  gap: 8px;
}

.active-request {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  padding: 0 0.6rem 0 1.2rem;
  border-radius: var(--pill);
  color: var(--page);
  text-decoration: none;
  background: var(--black);
}
.active-request strong {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 1rem;
  border-radius: var(--pill);
  font-size: 0.85rem;
  color: var(--black);
  background: var(--gold);
}

.lawyer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.lawyer-row {
  width: 100%;
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px 10px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--card);
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
:root[dir='rtl'] .lawyer-row {
  padding: 10px 10px 10px 16px;
}
.lawyer-row:hover {
  background: var(--card-hover);
}
.lawyer-main {
  display: grid;
  min-width: 0;
}
.lawyer-main strong {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lawyer-main small {
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gold);
  background: var(--black);
}
.avatar-lg {
  width: 58px;
  height: 58px;
  font-size: 1rem;
}
.distance {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.back-link {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.back-link::before {
  content: '‹';
  font-size: 1.4rem;
  line-height: 1;
}
:root[dir='rtl'] .back-link::before {
  content: '›';
}
.detail-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
}
.verified {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  min-height: 28px;
  padding: 0 0.75rem;
  border-radius: var(--pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--black);
  background: var(--gold);
}
/* Fiche : lignes "libellé · valeur" séparées par un filet (comme "Overview") */
.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  margin: 0;
  font-size: 0.92rem;
}
.detail-list dt,
.detail-list dd {
  padding-block: 0.7rem;
  border-block-end: 1px solid var(--line);
}
.detail-list dd {
  margin: 0;
  text-align: end;
  color: var(--ink-muted);
}
.detail-list dt:last-of-type,
.detail-list dd:last-of-type {
  border-block-end: none;
}

/* ---------- Fenêtre "Que se passe-t-il ?" ---------- */
.urgent-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.urgent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 31, 28, 0.45);
}
.urgent-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  display: grid;
  gap: 12px;
  padding: 26px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--page);
  color: var(--ink);
}
.urgent-dialog h2 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
}
.muted-dark {
  margin: 0;
  color: var(--ink-muted);
}
.situations {
  display: grid;
  gap: 8px;
}
.situation {
  display: grid;
  gap: 2px;
  min-height: 66px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.situation strong {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 500;
}
.situation small {
  color: var(--ink-muted);
}
.situation.is-urgent {
  background: #f3dfd9;
}
.situation:hover {
  border-color: var(--gold-deep);
}
.emergency-numbers {
  margin: 0;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  background: var(--gold-soft);
}

/* Grand écran : le panneau devient une colonne à gauche (à droite en arabe). */
@media (min-width: 900px) {
  .sheet {
    inset-block: 12px;
    inset-inline: 12px auto;
    bottom: 12px;
    width: 400px;
    max-height: none;
    border-radius: var(--radius);
  }
  .sheet.is-collapsed {
    max-height: none;
  }
  .sheet-handle {
    display: none;
  }
  .sheet-body {
    padding-top: 22px;
    flex: 1;
  }
  .map-top {
    inset-inline-start: 424px;
  }
  .chips {
    margin-inline: 0;
    padding-inline: 0;
  }
  .urgent-panel {
    align-items: center;
  }
  .urgent-dialog {
    border-radius: var(--radius);
  }
}

/* ---------- Version application ---------- */
/* Commandes du haut sous l'encoche de l'iPhone quand la carte occupe tout l'écran */
body.is-fullscreen .map-top {
  inset-block-start: calc(12px + env(safe-area-inset-top, 0px));
}
/* Avec la barre d'onglets, c'est elle qui gère la zone du bas de l'iPhone */
body.has-tabbar .sheet {
  padding-bottom: 0;
}
/* Pas de rebond de page sur la carte */
body:has(.screen-map) {
  overscroll-behavior: none;
}
/* Langue, pour les visiteurs (téléphone : la barre du haut est masquée sur la carte) */
.map-lang {
  flex-shrink: 0;
  min-height: 46px;
  padding: 0 1rem;
  border: none;
  border-radius: var(--pill);
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
}
.map-lang + .fab {
  margin-inline-start: 0;
}
#situation-slot + .map-lang {
  margin-inline-start: auto;
}
@media (min-width: 900px) {
  .map-lang {
    display: none;
  }
  .map-lang + .fab {
    margin-inline-start: auto;
  }
}

/* ================= Panneau de la carte : fond sombre, contenu clair ================= */
.sheet {
  --sheet-text: #f4f0e6;
  --sheet-muted: #bdb5a6;
  --sheet-line: rgba(244, 240, 230, 0.12);
  --sheet-block: rgba(244, 240, 230, 0.07);
  --sheet-block-hover: rgba(244, 240, 230, 0.12);
  background: var(--black);
  color: var(--sheet-text);
}
.sheet .grab {
  background: rgba(244, 240, 230, 0.25);
}
.sheet :is(h2, h3, .sheet-title, .sheet-hero) {
  color: var(--sheet-text);
}
.sheet :is(.sheet-text, .sheet-sub, .eyebrow, .muted) {
  color: var(--sheet-muted);
}
.sheet .sheet-foot {
  color: var(--sheet-muted);
  border-block-start: 1px solid var(--sheet-line);
}
.sheet a:not(.btn) {
  color: var(--gold);
}
/* Boutons inversés sur fond sombre */
.sheet .btn-primary {
  background: var(--page);
  color: var(--black);
}
.sheet .btn-primary:hover:not(:disabled) {
  background: #ffffff;
}
.sheet .btn-light {
  background: var(--sheet-block-hover);
  color: var(--sheet-text);
}
.sheet .btn-light:hover:not(:disabled) {
  background: rgba(244, 240, 230, 0.18);
}
/* Demande en cours */
.sheet .active-request {
  background: var(--sheet-block);
  color: var(--sheet-text);
  border: 1px solid rgba(226, 180, 58, 0.45);
}
/* Liste des avocats */
.sheet .lawyer-row {
  background: var(--sheet-block);
  color: var(--sheet-text);
}
.sheet .lawyer-row:hover {
  background: var(--sheet-block-hover);
  border-color: rgba(226, 180, 58, 0.5);
}
.sheet .lawyer-main small {
  color: var(--sheet-muted);
}
.sheet .avatar {
  background: var(--sheet-block-hover);
  color: var(--gold);
}
.sheet .distance {
  color: var(--sheet-text);
}
/* Fiche d'un avocat */
.sheet .back-link {
  color: var(--sheet-text);
}
.sheet .detail-list :is(dt, dd) {
  border-block-end-color: var(--sheet-line);
}
.sheet .detail-list dt {
  color: var(--sheet-text);
}
.sheet .detail-list dd {
  color: var(--sheet-muted);
}
@media (min-width: 900px) {
  .sheet {
    border: none;
  }
}
