/*
 * Esquina, téléphone d’abord.
 * Page gris clair, cartes blanches, pastilles noires, marche orange, voiture bleue.
 */
:root {
  --page: #ececec;
  --card: #ffffff;
  --ink: #171717;
  --muted: #8d8d8d;
  --line: #ececec;
  --pill: #f2f2f2;
  --orange: #e4570e;
  --blue: #2f6cf6;
  --green: #1f9d55;
  --danger: #a3261b;
  --shadow: 0 8px 28px rgba(20, 20, 20, 0.05);
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --phone: 430px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: #e3e3e3;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

:focus-visible {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.view {
  display: none;
  max-width: var(--phone);
  margin: 0 auto;
  background: var(--page);
  min-height: 100dvh;
}

.view:not([hidden]) {
  display: block;
}

.view--map:not([hidden]) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

.view--home {
  padding: calc(12px + env(safe-area-inset-top)) 16px 104px;
}

.view--sub {
  padding: calc(16px + env(safe-area-inset-top)) 16px 28px;
}

h1,
h2,
p {
  margin: 0;
}

/* ---------- Accueil ---------- */

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.city {
  font-size: 13px;
  font-weight: 650;
  color: #7b7b7b;
  margin-bottom: 2px;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: #fff;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

.icon-btn--ghost {
  width: 40px;
  height: 40px;
  background: transparent;
  box-shadow: none;
  color: #3a6ff0;
}

#swap.icon-btn--ghost {
  color: var(--ink);
}

.banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  background: #fff;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.35;
  color: #444;
}

.route-card {
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 4px;
}

.route-stop {
  position: relative;
  padding: 8px 6px 6px 8px;
  border-radius: 20px;
}

.route-stop + .route-stop {
  box-shadow: inset 0 1px 0 #f1f1f1;
}

.route-stop.is-active {
  z-index: 4;
  background: #fafafa;
}

.route-main {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 40px;
  gap: 6px;
  align-items: center;
}

.mark {
  justify-self: center;
}

.mark--o {
  width: 12px;
  height: 12px;
  border: 2px solid #222;
  border-radius: 50%;
  background: #fff;
}

.mark--d {
  width: 11px;
  height: 11px;
  background: #222;
  border-radius: 2px;
}

.route-copy label {
  display: block;
  font-size: 12px;
  color: #9a9a9a;
  font-weight: 550;
}

.route-copy input {
  width: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  font-weight: 750;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}

.route-copy input::placeholder {
  color: #b0b0b0;
  font-weight: 650;
}

.walk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-left: 28px;
}

.walk-label {
  flex: none;
  width: 58px;
  font-size: 12px;
  color: #9a9a9a;
}

.pills,
.segments,
.track {
  display: flex;
  gap: 6px;
}

.pills {
  flex: 1;
  min-width: 0;
}

.pill,
.seg,
.track-opt {
  position: relative;
  flex: 1;
  min-width: 0;
}

.pill input,
.seg input,
.track-opt input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  appearance: none;
  -webkit-appearance: none;
}

.pill > span {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 40px;
  border-radius: 999px;
  background: var(--pill);
  font-weight: 750;
  font-size: 14px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pill .u {
  margin: 0;
  min-height: 0;
  border-radius: 0;
  background: none;
  font-size: 10px;
  font-weight: 650;
  line-height: 1;
}

.pill input:checked + span,
.seg input:checked + span,
.track-opt input:checked + span {
  background: #171717;
  color: #fff;
}

.pill input:focus-visible + span,
.seg input:focus-visible + span,
.track-opt input:focus-visible + span {
  outline: 3px solid #111;
  outline-offset: 2px;
}

.block {
  margin-top: 14px;
}

.block h2,
.set-card h2 {
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.segments span {
  display: block;
  text-align: center;
  padding: 11px 8px;
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
}

.hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.hint--block {
  margin-top: 16px;
}

.quiet-link {
  display: inline-flex;
  margin-top: 8px;
  font-weight: 700;
  font-size: 14px;
  color: #444;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px 0 14px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid #e6e6e6;
  font-weight: 700;
  font-size: 15px;
}

.chip svg {
  display: block;
}

.chip.is-selected {
  border: 2px solid #171717;
}

.chip.is-empty {
  color: #666;
}

.chip-add {
  width: 44px;
  padding: 0;
  justify-content: center;
  border-style: dashed;
  color: #888;
}

.recent {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 8px;
  row-gap: 1px;
  width: 100%;
  text-align: left;
  padding: 8px 0 4px;
  border-top: 1px solid #e1e1e1;
  color: var(--ink);
}

.recent svg {
  margin-top: 2px;
  color: #9a9a9a;
}

.recent-title {
  font-weight: 750;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.recent-sub {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.status {
  min-height: 0;
  margin-top: 10px;
  font-size: 14px;
  color: #555;
}

.status:empty {
  display: none;
}

.status.is-error {
  color: var(--danger);
  font-weight: 650;
}

.dock {
  position: fixed;
  z-index: 5;
  left: 50%;
  transform: translateX(-50%);
  width: min(var(--phone), 100%);
  bottom: 0;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(236, 236, 236, 0), var(--page) 28%);
}

.dock--stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 56px;
  border-radius: 16px;
  background: #1c1c1c;
  color: #fff;
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.cta--small {
  height: 48px;
  width: auto;
  padding: 0 18px;
}

.cta:disabled {
  background: #a3a3a3;
  cursor: not-allowed;
}

.arr {
  color: #3ddc84;
  font-weight: 700;
}

.cta:disabled .arr {
  color: #dedede;
}

/* ---------- Réglages ---------- */

.nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.nav h1 {
  font-size: 30px;
}

.set-card {
  background: #fff;
  border-radius: 22px;
  padding: 16px 16px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.set-card h2 {
  margin-bottom: 4px;
}

.set-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.set-card--flat p {
  margin-bottom: 0;
}

.set-card--links {
  padding: 4px 12px;
}

.track {
  background: var(--pill);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.track-opt span {
  display: block;
  text-align: center;
  padding: 10px 4px;
  border-radius: 11px;
  font-weight: 750;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.plat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.uber-badge {
  background: #171717;
  color: #fff;
  font-weight: 750;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  flex: none;
}

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 4px;
  text-align: left;
  font-weight: 700;
  font-size: 15.5px;
  border-top: 1px solid #f0f0f0;
}

.link-row:first-child {
  border-top: 0;
}

.chev {
  color: #b0b0b0;
  font-size: 22px;
  line-height: 1;
}

/* ---------- Favoris / historique ---------- */

.fav-card {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.fav-card strong {
  display: block;
  font-size: 16px;
}

.fav-card p {
  color: var(--muted);
  font-size: 14px;
  margin: 2px 0 8px;
}

.fav-actions {
  display: flex;
  gap: 14px;
}

.fav-list .quiet-link,
.fav-actions .quiet-link {
  margin-top: 0;
}

.trips {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.trips li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
}

.trips input {
  width: 76px;
  height: 40px;
  padding: 0 8px;
  border: 1.5px solid #e4e4e4;
  border-radius: 10px;
  background: #fff;
}

/* ---------- Suggestions ---------- */

.suggestions {
  position: absolute;
  z-index: 6;
  left: 8px;
  right: 8px;
  top: calc(100% - 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 240px;
  overflow: auto;
}

.suggestions--flow {
  position: static;
  margin-top: 6px;
  box-shadow: none;
  border: 1px solid #eee;
}

.suggestions[hidden] {
  display: none;
}

.suggestions li {
  display: grid;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.suggestions li:hover,
.suggestions li:focus {
  background: var(--page);
}

.suggestions span {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Carte + résultats ---------- */

.map-stage {
  position: relative;
  flex: 0 0 36dvh;
  min-height: 220px;
  background: #d7d7d7;
  overflow: hidden;
}

.map-stage--full {
  flex: 1;
  min-height: 0;
}

.map {
  position: absolute;
  inset: 0;
  background: #d7d7d7;
}

/* Carte plein écran : le dock recouvre le coin bas-droit. Le bouton info
   (crédit replié) doit rester au-dessus. */
#view-carte .maplibregl-ctrl-bottom-right {
  bottom: 136px;
}

.map--off {
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  color: #555;
}

.map-legend {
  position: absolute;
  z-index: 2;
  left: 10px;
  bottom: 22px;
  max-width: calc(100% - 20px);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.map-legend[hidden] {
  display: none;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key {
  display: inline-block;
  width: 16px;
  height: 4px;
  border-radius: 3px;
}

.key--direct {
  background: #5c6770;
}

.key--ride {
  background: var(--blue);
}

.key--walk {
  height: 0;
  border-top: 3px dotted var(--orange);
  background: none;
}

.map-float {
  position: absolute;
  z-index: 3;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view--map .map-float {
  left: 12px;
  right: 12px;
}

.route-pill {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 12px 16px;
  background: #fff;
  border-radius: 999px;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.sheet {
  position: relative;
  z-index: 1;
  flex: 1;
  margin-top: -18px;
  background: var(--page);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px 132px;
  overflow: auto;
}

.sheet h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.priority {
  margin-bottom: 14px;
}

.priority .segments span {
  background: #fff;
}

.results {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.opt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'top badge'
    'legs price';
  gap: 4px 10px;
  width: 100%;
  text-align: left;
  background: #fff;
  border-radius: 18px;
  border: 2px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 14px 14px 12px;
}

.opt.is-selected {
  border-color: #171717;
}

.opt-top {
  grid-area: top;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.opt-dur,
.detail-dur {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.opt-name {
  font-weight: 700;
  font-size: 14px;
  color: #6d6d6d;
}

.badge {
  grid-area: badge;
  align-self: center;
  justify-self: end;
  background: #171717;
  color: #3dcc6e;
  font-weight: 750;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.is-ref,
.badge.is-loss {
  background: transparent;
  color: #8d8d8d;
  font-weight: 600;
  padding-right: 0;
}

.opt-legs {
  grid-area: legs;
  font-size: 13.5px;
  font-weight: 700;
  min-width: 0;
}

.opt-price {
  grid-area: price;
  align-self: end;
  color: #8a8a8a;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.w {
  color: var(--orange);
}

.r {
  color: var(--blue);
}

.sep {
  color: #b5b5b5;
  font-weight: 500;
}

.note {
  margin-top: 12px;
  background: #f6f6f6;
  border-radius: 16px;
  padding: 12px 14px;
  color: #444;
  font-size: 14px;
}

.note[hidden] {
  display: none;
}

/* ---------- Détail ---------- */

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  color: var(--blue);
  font-weight: 750;
  font-size: 14px;
  margin-bottom: 2px;
}

.detail-dur {
  font-size: 40px;
}

#detail-badge {
  margin-top: 18px;
}

.timeline {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  position: relative;
  padding-bottom: 14px;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: #ddd;
}

.timeline li.is-walk::before {
  background: var(--orange);
}

.timeline li.is-ride::before {
  background: var(--blue);
}

.timeline li:last-child::before {
  display: none;
}

.pin {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 2px;
  justify-self: center;
  position: relative;
  z-index: 1;
}

.pin--origin {
  background: #fff;
  box-shadow: inset 0 0 0 2px #171717;
}

.pin--pickup {
  background: var(--blue);
}

.pin--dropoff,
.pin--destination {
  background: #171717;
}

.pin--destination {
  border-radius: 2px;
  width: 12px;
  height: 12px;
}

.stop-title {
  font-weight: 750;
  letter-spacing: -0.02em;
}

.leg-walk,
.leg-ride {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
}

.leg-walk {
  color: var(--orange);
}

.leg-ride {
  color: var(--blue);
}

.text-btn {
  width: 100%;
  padding: 8px;
  font-weight: 750;
  font-size: 15px;
}

.copy-status {
  text-align: center;
  font-size: 13px;
  color: var(--green);
  min-height: 1em;
}

.copy-status:empty {
  display: none;
}

/* ---------- Dialogue favori ---------- */

dialog {
  border: 0;
  border-radius: 22px;
  padding: 18px 16px 14px;
  width: min(360px, calc(100% - 32px));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

dialog h2 {
  font-size: 22px;
  margin-bottom: 12px;
}

.stack-field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #666;
}

.stack-field input {
  height: 48px;
  padding: 0 12px;
  border: 1.5px solid #e4e4e4;
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  font-weight: 650;
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.dialog-bar .text-btn {
  width: auto;
  padding: 10px 12px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
