/**
 * Moto Pro — panneau d'accueil glissant (3 positions) · v1.0.0
 * Chargé après driver.css, moto-sheet.css, moto-map-tools.css et
 * moto-ergonomie.css : il fixe l'accueil hors course uniquement
 * (#screen-home sans .screen-home-ride).
 *
 * 1. Le panneau recouvre la carte (plus de bande vide sous les onglets) et
 *    la zone sûre du bas n'est comptée qu'une fois, sur la barre d'onglets.
 * 2. Trois crans mesurés par home-sheet.js (hauteur en px) ; le contenu
 *    central défile, Mode en ligne et onglets restent visibles partout.
 * 3. Les outils carte s'accrochent au bord haut du panneau et suivent son
 *    mouvement ; au-delà de 60 % de l'écran ils s'effacent en fondu.
 */

/* ———— 1. Carte plein écran, panneau par-dessus ———— */
#screen-home:not(.screen-home-ride) .uber-map-stage {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 0;
}

#screen-home .uber-dock--home {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  max-height: none;
  /* Zone sûre : uniquement sur la barre d'onglets (plus de double marge). */
  padding-bottom: 0;
  overflow: hidden;
  border-radius: 22px 22px 0 0;
  box-shadow:
    0 -10px 34px rgba(16, 31, 69, 0.14),
    0 -1px 0 rgba(16, 31, 69, 0.05);
  transition: none;
  will-change: height;
}

#screen-home .uber-dock--home .moto-sheet-grip {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  justify-content: flex-start;
  /* Cible tactile 44 px : la zone déborde de 10 px sur l'entête (elle-même
     poignée), sans ajouter de hauteur visible au panneau. */
  min-height: 44px;
  margin-bottom: -10px;
  padding: 0.5rem 0 0.25rem;
  touch-action: none;
  cursor: grab;
}

#screen-home .uber-dock--home .moto-sheet-grip.is-grabbing {
  cursor: grabbing;
}

#screen-home .uber-dock--home .moto-sheet-grip__pill {
  width: 40px;
  height: 5px;
  opacity: 0.55;
}

#screen-home .uber-dock--home[data-snap="peek"] .moto-sheet-grip__hint {
  height: auto;
  opacity: 1;
}

#screen-home .uber-dock--home .moto-sheet-grip__hint {
  height: 0;
  opacity: 0;
}

#screen-home .uber-dock--home .uber-dock-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 1.1rem 0.5rem;
}

/* Partie centrale : défile si besoin, disparaît en position réduite. */
#screen-home .uber-dock--home .home-sheet__scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

#screen-home .uber-dock--home .home-sheet__scroll > * {
  flex: 0 0 auto;
}

/* Plein écran : le contenu (robot, statut) se centre dans la hauteur
   disponible au lieu de laisser un vide sous lui. */
#screen-home .uber-dock--home[data-snap="full"] .home-sheet__scroll {
  justify-content: center;
}

#screen-home .uber-dock--home[data-snap="full"] .home-sheet__scroll > .dock-search {
  margin: auto 0;
}

#screen-home .uber-dock--home .home-sheet__scroll::-webkit-scrollbar {
  display: none;
}

#screen-home .uber-dock--home .home-sheet__scroll .dock-search {
  flex: none;
  overflow: visible;
  margin-top: 0;
}

/* Entêtes = poignées secondaires : le geste vertical pilote le panneau. */
#screen-home .uber-dock--home .dock-search__head,
#screen-home .uber-dock--home .uber-dock-title,
#screen-home .uber-dock--home .dock-stats-row {
  touch-action: none;
}

#screen-home .uber-dock--home .uber-dock-title {
  margin-top: 0.1rem;
}

#screen-home .uber-dock--home .driver-online-box {
  flex: 0 0 auto;
  margin-top: 0.5rem;
}

/* Entête compact : titre serré, statut sous le titre — tient dans le tiers. */
#screen-home .uber-dock--home .dock-search__title {
  line-height: 1.15;
}

#screen-home .uber-dock--home .dock-search__empty-title {
  line-height: 1.25;
}

#screen-home .uber-dock--home .moto-tabbar {
  flex: 0 0 auto;
  /* Marge minimale de la zone sûre (barre de geste), rien de plus. */
  padding-bottom: max(0.15rem, var(--safe-bottom, 0px));
}

/* ———— 2. Crans ————
   · réduit : le panneau se dissout (hauteur 0, fondu) — la carte occupe tout
     l'écran ; seule la capsule flottante « En ligne ˄ » reste, en bas au
     centre, pour le rappeler d'un tap ou d'un glissé ;
   · intermédiaire : robot centré, taille moyenne, bien visible ;
   · plein écran : robot grand, sous-titre affiché, la carte est couverte.
   --home-sheet-reveal (0 → 1 sur les 48 premiers pixels) pilote le fondu. */
#screen-home .uber-dock--home {
  opacity: var(--home-sheet-reveal, 1);
}

#screen-home .uber-dock--home[data-snap="peek"]:not(.home-sheet--dragging):not(.home-sheet--settling) {
  visibility: hidden;
  pointer-events: none;
}

/* Capsule flottante (cran réduit) */
#screen-home .home-sheet-chip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom, 0px) + 14px);
  z-index: 13;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1rem 0 0.9rem;
  border: 1px solid rgba(16, 31, 69, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  color: var(--ink, #101f45);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow:
    0 12px 30px rgba(16, 31, 69, 0.22),
    0 2px 6px rgba(16, 31, 69, 0.1);
  transform: translateX(-50%) translateY(calc(var(--home-sheet-reveal, 1) * 18px));
  opacity: calc(1 - var(--home-sheet-reveal, 1));
  pointer-events: none;
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow 0.18s ease;
}

#screen-home[data-home-snap="peek"] .home-sheet-chip {
  pointer-events: auto;
}

#screen-home .home-sheet-chip:active {
  box-shadow:
    0 8px 20px rgba(16, 31, 69, 0.2),
    0 1px 4px rgba(16, 31, 69, 0.1);
}

#screen-home .home-sheet-chip__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--uber-gray-500, #8a93a8);
  box-shadow: 0 0 0 3px rgba(138, 147, 168, 0.18);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

#screen-home .home-sheet-chip.is-online .home-sheet-chip__dot {
  background: #2b62d9;
  box-shadow: 0 0 0 3px rgba(43, 98, 217, 0.2);
  animation: driver-online-dot 1.8s ease infinite;
}

#screen-home .home-sheet-chip__chevron {
  width: 16px;
  height: 16px;
  margin-left: -0.15rem;
  opacity: 0.7;
}

/* Bloc « On cherche » : une colonne, robot centré. */
#screen-home .uber-dock--home .dock-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "hello"
    "title"
    "sub"
    "robot"
    "status"
    "queue";
  align-items: center;
}

#screen-home .uber-dock--home .dock-search__head,
#screen-home .uber-dock--home .dock-search__titles,
#screen-home .uber-dock--home .dock-search__empty {
  display: contents;
}

#screen-home .uber-dock--home .dock-search__empty[hidden] {
  display: none;
}

#screen-home .uber-dock--home .dock-search__hello {
  grid-area: hello;
  margin-bottom: 0.1rem;
  touch-action: none;
}

#screen-home .uber-dock--home .dock-search__title {
  grid-area: title;
  line-height: 1.15;
  touch-action: none;
}

#screen-home .uber-dock--home .dock-search__sub {
  grid-area: sub;
  max-height: 3.2em;
  overflow: hidden;
  opacity: 1;
  transition: max-height 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.2s ease, margin 0.3s ease;
}

#screen-home .uber-dock--home:not([data-snap="full"]) .dock-search__sub,
#screen-home .uber-dock--home.home-sheet--measure-half .dock-search__sub {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

/* Robot centré, taille moyenne à mi-hauteur. */
#screen-home .uber-dock--home .moto-robot {
  grid-area: robot;
  display: block;
  justify-self: center;
  width: 96px;
  margin: 0.55rem 0 0.35rem;
  overflow: visible;
  opacity: 1;
  transition: width 0.34s cubic-bezier(0.32, 0.72, 0, 1), margin 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  animation: moto-robot-appear 0.32s cubic-bezier(0.22, 1, 0.36, 1) both, moto-empty-float 3.6s ease-in-out 0.32s infinite;
}

#screen-home .uber-dock--home .moto-robot__svg {
  width: 100%;
  height: auto;
}

#screen-home .uber-dock--home .dock-search__empty-title {
  grid-area: status;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.25;
  text-align: center;
}

#screen-home .uber-dock--home .dock-search__queue {
  grid-area: queue;
}

/* Écran trop court pour le robot moyen : robot compact, marges serrées. */
#screen-home .uber-dock--home.home-sheet--dense:not([data-snap="full"]) .moto-robot,
#screen-home .uber-dock--home.home-sheet--dense.home-sheet--measure-half .moto-robot {
  width: 72px;
  margin: 0.3rem 0 0.2rem;
}

/* Plein écran : robot grand, sous-titre visible. */
#screen-home .uber-dock--home[data-snap="full"]:not(.home-sheet--measure-half) .moto-robot {
  width: 150px;
  margin: 1.4rem 0 0.9rem;
  /* Autre nom = l'apparition rejoue à chaque changement de taille. */
  animation-name: moto-robot-appear-full, moto-empty-float;
}

@keyframes moto-robot-appear {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes moto-robot-appear-full {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mesures (home-sheet.js) : hauteur naturelle, sans transition ni sous-titre. */
#screen-home .uber-dock--home.home-sheet--measuring {
  height: auto !important;
  opacity: 1 !important;
  visibility: visible !important;
  transition: none !important;
}

#screen-home .uber-dock--home.home-sheet--measuring .dock-search__sub {
  display: none;
}

/* Une transition en cours (marge du robot, sous-titre) fausserait la
   mesure : on lit les valeurs finales. */
#screen-home .uber-dock--home.home-sheet--measuring * {
  transition: none !important;
}

/* Pendant le glissement : aucune animation interne, le doigt fait loi. */
#screen-home .uber-dock--home.home-sheet--dragging *,
#screen-home .uber-dock--home.home-sheet--dragging {
  transition-duration: 0s !important;
}

/* ———— 3. Outils carte accrochés au panneau ———— */
#screen-home:not(.screen-home-ride) .moto-maptype-fab,
#screen-home:not(.screen-home-ride) .moto-map-zoom,
#screen-home:not(.screen-home-ride) .uber-map-stage .moto-locate-fab,
#screen-home:not(.screen-home-ride) .moto-map-compass,
#screen-home:not(.screen-home-ride) .moto-maptype-pop {
  top: auto;
  right: max(0.875rem, env(safe-area-inset-right));
}

#screen-home:not(.screen-home-ride) .moto-maptype-fab,
#screen-home:not(.screen-home-ride) .moto-map-zoom,
#screen-home:not(.screen-home-ride) .uber-map-stage .moto-locate-fab {
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

/* Pile, de bas en haut : calques · zoom · ma position (· boussole). */
#screen-home:not(.screen-home-ride) .moto-maptype-fab {
  bottom: calc(max(var(--home-sheet-h, 280px), var(--safe-bottom, 0px)) + 14px);
}

#screen-home:not(.screen-home-ride) .moto-maptype-pop {
  bottom: calc(max(var(--home-sheet-h, 280px), var(--safe-bottom, 0px)) + 14px + 56px);
  transform-origin: bottom right;
}

#screen-home:not(.screen-home-ride) .moto-map-zoom {
  bottom: calc(max(var(--home-sheet-h, 280px), var(--safe-bottom, 0px)) + 14px + var(--home-maptype-h, 56px));
}

#screen-home:not(.screen-home-ride) .uber-map-stage .moto-locate-fab {
  right: max(0.875rem, env(safe-area-inset-right));
  bottom: calc(max(var(--home-sheet-h, 280px), var(--safe-bottom, 0px)) + 14px + var(--home-maptype-h, 56px) + 98px);
}

#screen-home:not(.screen-home-ride) .moto-map-compass {
  bottom: calc(max(var(--home-sheet-h, 280px), var(--safe-bottom, 0px)) + 14px + var(--home-maptype-h, 56px) + 98px + 56px);
}

html[dir="rtl"] #screen-home:not(.screen-home-ride) .moto-maptype-fab,
html[dir="rtl"] #screen-home:not(.screen-home-ride) .moto-map-zoom,
html[dir="rtl"] #screen-home:not(.screen-home-ride) .uber-map-stage .moto-locate-fab,
html[dir="rtl"] #screen-home:not(.screen-home-ride) .moto-map-compass,
html[dir="rtl"] #screen-home:not(.screen-home-ride) .moto-maptype-pop {
  right: auto;
  left: max(0.875rem, env(safe-area-inset-left));
}

/* Carte couverte (au-delà de 60 % de l'écran, et en plein écran) :
   les outils s'effacent en fondu et ne captent plus le toucher. */
#screen-home.home-sheet-covering:not(.screen-home-ride) .moto-maptype-fab,
#screen-home.home-sheet-covering:not(.screen-home-ride) .moto-map-zoom,
#screen-home.home-sheet-covering:not(.screen-home-ride) .uber-map-stage .moto-locate-fab,
#screen-home.home-sheet-covering:not(.screen-home-ride) .moto-map-compass,
#screen-home.home-sheet-covering:not(.screen-home-ride) .moto-demand-legend {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
}

#screen-home.home-sheet-covering:not(.screen-home-ride) .moto-maptype-pop {
  opacity: 0;
  pointer-events: none;
}

/* La bande « Position en direct » du haut et la légende restent au-dessus
   de la carte, jamais sous le panneau. */
#screen-home:not(.screen-home-ride) .moto-demand-legend {
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* ———— Thème sombre ———— */
html[data-theme="dark"] #screen-home .home-sheet-chip {
  background: rgba(16, 22, 38, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
  color: #eef2fb;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] #screen-home .uber-dock--home {
  box-shadow:
    0 -12px 36px rgba(0, 0, 0, 0.5),
    0 -1px 0 rgba(255, 255, 255, 0.06);
}

/* ———— Mouvement réduit : positions sans ressort, robot sans fondu ———— */
@media (prefers-reduced-motion: reduce) {
  #screen-home .uber-dock--home .moto-robot,
  #screen-home .home-sheet-chip.is-online .home-sheet-chip__dot {
    animation: none;
  }
  #screen-home .uber-dock--home .moto-robot,
  #screen-home .uber-dock--home .dock-search__sub,
  #screen-home:not(.screen-home-ride) .moto-maptype-fab,
  #screen-home:not(.screen-home-ride) .moto-map-zoom,
  #screen-home:not(.screen-home-ride) .uber-map-stage .moto-locate-fab,
  #screen-home:not(.screen-home-ride) .moto-map-compass {
    transition: none;
  }
}
