/* Seguimiento del pedido (ver track.js): mapa a pantalla completa y la hoja de abajo que se arrastra.
   --trk-peek (px) lo pone track.js: lo que se ve de la hoja cerrada (el mapa deja ese espacio abajo). */
body.trk-on { overflow: hidden; overscroll-behavior: none; }
.trk { --trk-peek: 300px; position: fixed; inset: 0; z-index: 5; background: var(--bg); overflow: hidden; }
.trk-map { position: absolute; inset: 0; }
.trk-map .tm-canvas { position: absolute; inset: 0; }
/* Créditos del mapa (obligatorios), pequeños y justo encima de la hoja */
.trk .mapboxgl-ctrl-bottom-left, .trk .mapboxgl-ctrl-bottom-right,
.trk .maplibregl-ctrl-bottom-left, .trk .maplibregl-ctrl-bottom-right, .trk .leaflet-bottom {
  bottom: calc(var(--trk-peek) - 4px); transition: bottom .25s ease;
}
.trk .mapboxgl-ctrl-attrib, .trk .maplibregl-ctrl-attrib, .trk .leaflet-control-attribution { font-size: 10px; line-height: 1.3; }
.trk .mapboxgl-ctrl-logo { transform: scale(.8); transform-origin: left bottom; }

/* Volver: botón redondo flotante arriba a la izquierda */
.trk-back {
  position: absolute; z-index: 3; top: calc(12px + env(safe-area-inset-top)); left: 12px;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); color: var(--text); box-shadow: 0 2px 10px rgb(0 0 0 / .22);
}
.trk-back svg { width: 22px; height: 22px; }

/* La hoja: misma forma que las hojas de Tatigo, pero siempre abierta (no se cierra; se sube o se baja) */
.trk-sheet {
  position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 680px;
  height: calc(100dvh - 72px - env(safe-area-inset-top)); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border-radius: var(--r-lg, 20px) var(--r-lg, 20px) 0 0;
  box-shadow: var(--shadow-lg, 0 -8px 30px rgb(0 0 0 / .18));
  transition: transform .32s cubic-bezier(.2, .8, .2, 1); will-change: transform; touch-action: pan-x;
}
.trk-sheet.no-anim { transition: none; }
.trk-handle { flex: none; display: flex; justify-content: center; padding: 8px 0 6px; cursor: grab; touch-action: none; outline: none; }
.trk-handle:focus-visible .trk-grab { box-shadow: 0 0 0 3px var(--focus-ring); }
.trk-grab { width: 40px; height: 5px; border-radius: 999px; background: var(--line-strong); }
.trk-body { flex: 1; min-height: 0; overflow: hidden; padding: 0 20px calc(20px + env(safe-area-inset-bottom)); }
.trk-sheet.is-open .trk-body { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.trk-peek { touch-action: none; }
.trk-sheet.is-open .trk-peek { touch-action: pan-y; }

/* Tiempo estimado y estado */
.trk-eta { margin: 2px 0 2px; font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.trk-status { margin: 0 0 14px; color: var(--muted); font-size: 16px; }

/* Barra de progreso: un tramo por estado, con su color y su icono (ver progressBar en track.js) */
.trk { --c-confirmed: #5B6470; --c-preparing: #E59A00; --c-way: #3E63DD; --c-arrived: #8E4EC6; --c-ready: #1C9B96; --c-done: #2E7D32; }
:root[data-theme="dark"] .trk { --c-confirmed: #A3A9B0; --c-preparing: #F2C14E; --c-way: #7F9BFF; --c-arrived: #B98CF0; --c-ready: #4EC5C1; --c-done: #6FD08C; }
.trk-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.trk-steps.n5 { grid-template-columns: repeat(5, 1fr); }
.trk-step { --c: var(--c-confirmed); display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.trk-step.c-preparing { --c: var(--c-preparing); }
.trk-step.c-way { --c: var(--c-way); }
.trk-step.c-arrived { --c: var(--c-arrived); }
.trk-step.c-ready { --c: var(--c-ready); }
.trk-step.c-done { --c: var(--c-done); }
.trk-step-ico {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line-strong); background: var(--surface); color: var(--muted);
}
.trk-step-ico svg { width: 16px; height: 16px; }
.trk-step.is-done .trk-step-ico { background: var(--c); border-color: var(--c); color: #fff; }
.trk-step.is-now .trk-step-ico { width: 34px; height: 34px; margin-top: -4px; border-color: var(--c); color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.trk-step.is-now .trk-step-ico svg { width: 19px; height: 19px; }
.trk-step.is-done.is-now .trk-step-ico { background: var(--c); color: #fff; }
.trk-bar { position: relative; align-self: stretch; height: 7px; border-radius: 999px; background: var(--line); overflow: hidden; }
.trk-bar i { position: absolute; inset: 0 auto 0 0; width: calc(var(--fill, 0) * 100%); border-radius: inherit; background: var(--c); transition: width .8s ease; }
.trk-step.is-now .trk-bar i::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .55), transparent);
  animation: trk-shine 1.6s ease-in-out infinite;
}
/* Nunca se corta una palabra ("Confirmad / o"): solo entre palabras ("Listo para / recoger"). Con 5 pasos a 360 px,
   letra un poco más pequeña y sin saltos. */
.trk-step-name { max-width: 100%; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.15; overflow-wrap: normal; hyphens: none; }
.trk-steps.n5 { gap: 4px; }
.trk-steps.n5 .trk-step-name { font-size: 10.5px; letter-spacing: -.02em; white-space: nowrap; }
@media (max-width: 340px) { .trk-steps.n5 .trk-step-name { font-size: 9.5px; } }
.trk-step.is-done .trk-step-name { color: var(--text); font-weight: 700; }
.trk-step.is-now .trk-step-name { color: var(--c); font-weight: 800; }
@keyframes trk-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.trk-coming { margin-bottom: 12px; }

/* ---------- "Tu Tati llegó": pantalla completa tipo llamada entrante (ver arrival.js) ---------- */
body.ac-open { overflow: hidden; }
/* Paleta de Tatigo: gris casi negro (#3E4146 -> #1E2126) con un brillo rojo suave detrás de la foto. Igual en los dos
   temas (es una pantalla de llamada: oscura siempre). */
.arrive-call {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(48px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% calc(48px + env(safe-area-inset-top) + 130px), rgb(214 0 28 / .42) 0, rgb(214 0 28 / .16) 130px, transparent 230px),
    linear-gradient(180deg, #3E4146 0%, #2A2D32 45%, #1E2126 100%);
  color: #fff; text-align: center; outline: none;
  animation: ac-in .3s ease-out;
}
.ac-top { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ac-label { font-size: 15px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .9; }
.ac-face {
  position: relative; display: grid; place-items: center; width: 150px; height: 150px; margin: 22px 0 8px; border-radius: 50%;
  background: #D6001C; color: #fff; font-size: 60px; font-weight: 800; overflow: visible; box-shadow: 0 0 0 4px rgb(255 255 255 / .9);
}
.ac-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ac-face::before, .ac-face::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 3px solid rgb(214 0 28 / .55); animation: ac-ring 1.8s ease-out infinite; }
.ac-face::after { animation-delay: .9s; }
.arrive-call.is-quiet .ac-face::before, .arrive-call.is-quiet .ac-face::after { animation: none; opacity: 0; }
.ac-top h2 { margin: 0; font-size: 38px; font-weight: 800; letter-spacing: -.02em; }
.ac-top p { margin: 0; font-size: 19px; opacity: .92; }
.ac-actions { display: flex; justify-content: space-around; gap: 16px; }
.ac-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 120px; padding: 0; border: 0;
  background: none; color: #fff; font: inherit; font-size: 17px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.ac-round { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; box-shadow: 0 8px 24px rgb(0 0 0 / .35); }
.ac-round svg { width: 38px; height: 38px; }
.ac-call .ac-round { background: #fff; color: #3E4146; }
.ac-go .ac-round { background: #D6001C; color: #fff; box-shadow: 0 8px 24px rgb(214 0 28 / .45); }
/* Marco de foco solo con teclado (al volver a la app no aparece un recuadro alrededor de "Ya voy"). */
.ac-btn:focus { outline: none; }
.ac-btn:focus-visible .ac-round { outline: 4px solid #fff; outline-offset: 4px; }
@keyframes ac-in { from { opacity: 0; transform: scale(1.04); } }
@keyframes ac-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.45); opacity: 0; } }
@media (prefers-reduced-motion: no-preference) {
  .arrive-call:not(.is-quiet) .ac-go .ac-round { animation: ac-bounce 1.2s ease-in-out infinite; }
  @keyframes ac-bounce { 0%, 100% { transform: none; } 50% { transform: translateY(-8px); } }
}

/* Avisos (cancelado, sin Tati, pago por verificar) */
.trk-notice { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r-md, 14px); border: 1px solid var(--line); }
.trk-notice > svg { flex: none; width: 24px; height: 24px; margin-top: 2px; }
.trk-notice p { margin: 0 0 10px; font-size: 15px; }
.trk-notice.is-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.trk-notice.is-warn > svg { color: var(--warn); }
.trk-notice.is-danger { background: var(--danger-soft); border-color: var(--danger-line); }
.trk-notice.is-danger > svg { color: var(--danger); }
.trk-notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tarjeta del Tati */
.trk-tati { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; padding: 12px; border-radius: var(--r-md, 14px); background: var(--surface-2); }
.trk-face {
  flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
  background: var(--brand); color: var(--on-brand); font-size: 22px; font-weight: 800;
}
.trk-face img { width: 100%; height: 100%; object-fit: cover; }
.trk-tati-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trk-tati-txt strong { font-size: 17px; }
.trk-tati-txt span { color: var(--muted); font-size: 14px; }
.trk-plate { align-self: flex-start; margin-top: 3px; display: inline-block; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); font-size: 13px; letter-spacing: .04em; }
.trk-round {
  flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); text-decoration: none;
}
.trk-round svg { width: 22px; height: 22px; }
.trk-round:active { transform: scale(.95); }

.trk-more { margin-top: 2px; }
.trk-more svg { width: 18px; height: 18px; vertical-align: -3px; }

/* Detalle (al subir la hoja) */
.trk-detail { padding-top: 6px; border-top: 1px solid var(--line); margin-top: 8px; }
.trk-detail .card { margin-bottom: 12px; }
.trk-h { margin: 16px 0 4px; font-size: 18px; font-weight: 800; }
.trk-detail > p { margin: 0 0 12px; }
.trk-detail .btn { margin-bottom: 10px; }

/* "¡Entregado!": un círculo que aparece y el visto que se dibuja (una vez por pedido) */
.trk-done { width: 56px; height: 56px; margin: 4px 0 6px; }
.trk-done svg { width: 100%; height: 100%; }
.trk-done circle { fill: var(--ok); }
.trk-done path { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; }
.trk-done.is-new { animation: trk-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.trk-done.is-new path { stroke-dashoffset: 40; animation: trk-check .35s .3s ease-out forwards; }
@keyframes trk-pop { from { transform: scale(.3); opacity: 0; } }
@keyframes trk-check { to { stroke-dashoffset: 0; } }

/* Para el seguimiento en vivo (todavía no se usa): la moto del Tati en el mapa */
.trk-moto { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff; border: 3px solid #fff; box-shadow: 0 2px 8px rgb(0 0 0 / .3); }
.trk-moto svg { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
  .trk-sheet, .trk .mapboxgl-ctrl-bottom-left, .trk .mapboxgl-ctrl-bottom-right { transition: none; }
  .trk-step.is-now .trk-bar i::after, .ac-face::before, .ac-face::after { animation: none; }
  .arrive-call { animation: none; }
  .trk-done.is-new, .trk-done.is-new path { animation: none; stroke-dashoffset: 0; }
  .trk-round:active { transform: none; }
}
