/* TVDE+ · Viagem partilhada (ride.tvdemais.pt) — mesmas cores e letras do site www */
:root {
  --ink: #0f0f10;
  --ink-soft: #3d3d42;
  --muted: #6b6b72;
  --line: #e6e6e9;
  --paper: #ffffff;
  --cream: #f4f1ec;
  --hairline: #d9d5cd;
  --topbar: #222226;
  --brand: #ff9019;
  --brand-dark: #8a4a00;
  --brand-soft: #fff1e2;
  --ok: #1e8e4e;
  --pickup: #159a3c;
  --trip: #1b3fa0;
  --danger: #c62828;
  --font: "General Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --topbar-h: 64px;
  --panel-w: 420px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, p { margin: 0; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.muted { color: var(--muted); }

.eyebrow {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand-dark);
}
.headline {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.04em;
}
.label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.btn-ghost { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn-ghost:hover { background: var(--cream); }

/* ---------- Barra de topo ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  background: var(--topbar);
  color: var(--cream);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.topbar-logo { display: block; line-height: 0; }
.logo { height: 34px; width: auto; aspect-ratio: 420 / 171; stroke: none; }
/* Botões de download da app (iguais aos do site www, versão escura) */
.stores { display: flex; gap: 8px; }
.store {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
a.store[href]:hover { background: rgba(255, 255, 255, 0.1); }
.store svg { flex: none; width: 20px; height: 20px; fill: currentColor; stroke: none; }
.store-text { display: flex; flex-direction: column; line-height: 1.15; }
.store-pre { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.7; }
.store-name { font-size: 14px; font-weight: 600; white-space: nowrap; }
/* Ecrãs estreitos: só o ícone e o nome da loja */
@media (max-width: 420px) {
  .topbar { padding: 0 12px; }
  .logo { height: 30px; }
  .stores { gap: 6px; }
  .store { padding: 6px 9px; gap: 6px; }
  .store svg { width: 17px; height: 17px; }
  .store-pre { display: none; }
  .store-name { font-size: 13px; }
}

/* ---------- Layout ---------- */
/* Mobile: mapa em cima, painel logo por baixo (sem sobrepor o mapa, para os links da HERE ficarem visíveis) */
.layout { display: flex; flex-direction: column; min-height: calc(100% - var(--topbar-h)); }
.map-wrap { position: relative; height: 56vh; height: 56svh; min-height: 300px; background: #e8ecef; }
.map-canvas { position: absolute; inset: 0; }
.panel {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 16px calc(20px + env(safe-area-inset-bottom));
  background: var(--cream);
  border-top: 1px solid var(--hairline);
}

/* Desktop: painel à esquerda, mapa a ocupar o resto do ecrã */
@media (min-width: 900px) {
  body { overflow: hidden; }
  .layout { flex-direction: row-reverse; height: calc(100% - var(--topbar-h)); min-height: 0; }
  .map-wrap { flex: 1; height: auto; min-height: 0; }
  .panel {
    flex: 0 0 var(--panel-w);
    padding: 28px 24px 20px;
    border-top: 0;
    border-right: 1px solid var(--hairline);
    overflow-y: auto;
  }
  .headline { font-size: 34px; }
}

/* ---------- Estado da ligação (sobre o mapa) ---------- */
.map-overlay { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 8px; pointer-events: none; z-index: 2; }
.live, .demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  font-weight: 600;
}
.demo-badge { background: var(--brand); color: var(--ink); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-ok .live-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(30, 142, 78, 0.22); animation: pulse 1.8s ease-in-out infinite; }
.live-wait .live-dot { background: var(--brand); }
.live-bad .live-dot { background: var(--danger); }
.live-off .live-dot { background: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(30, 142, 78, 0.08); } }

.recenter {
  position: absolute;
  left: 12px;
  bottom: 36px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 600 14px var(--font);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.recenter svg { width: 18px; height: 18px; }
@media (min-width: 900px) { .recenter { bottom: 36px; } }

/* ---------- Marcadores ---------- */
/* O HERE posiciona o elemento exterior (tamanho 0) na coordenada; o interior desloca a imagem para a âncora certa */
.mk { position: relative; width: 0; height: 0; }
.mk > img { position: absolute; left: 0; top: 0; display: block; pointer-events: none; user-select: none; }
/* Motorista: GIF centrado na coordenada */
.mk-driver > img { width: 52px; height: 52px; transform: translate(-50%, -50%); border-radius: 50%; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28); }
/* Destino (marker.png, 375×440; ponta do pino a 49 % da largura e 87,5 % da altura) */
.mk-dest > img { width: 40px; height: 47px; transform: translate(-49%, -87.5%); }

/* ---------- Painel ---------- */
/* ---------- Ecrã inicial (a carregar / mensagens) ---------- */
.start {
  display: grid;
  place-items: center;
  min-height: calc(100% - var(--topbar-h));
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
}
.start-box { display: grid; justify-items: center; gap: 14px; width: 100%; max-width: 440px; text-align: center; }
.start-loading-text { color: var(--ink-soft); }
.start-message {
  padding: 32px 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
}
.start-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); }
.start-icon svg { width: 28px; height: 28px; stroke-width: 2; }
.start-message .headline { font-size: 28px; }
.start-text { color: var(--ink-soft); font-size: 16px; }
.start-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.btn-dark { border: 0; background: var(--ink); color: #fff; font: 600 15px var(--font); cursor: pointer; }
.btn-dark:hover { background: #26262a; }

@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255, 144, 25, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

#state-trip { display: flex; flex-direction: column; gap: 12px; }
.status { display: grid; gap: 8px; padding: 0 4px 6px; }
.status-sub { font-size: 16px; }
.status-sub strong { color: var(--ink); }
.progress { height: 6px; margin-top: 4px; border-radius: 999px; background: var(--hairline); overflow: hidden; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--pickup); transition: width 0.6s ease; }
.is-trip .progress-bar { background: var(--trip); }
.is-trip #status-eyebrow { color: var(--trip); }
.is-pickup #status-eyebrow { color: var(--pickup); }

.card {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
}

.driver { display: flex; align-items: center; gap: 14px; }
.driver-photo { flex: none; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #d9e4ec; }
.driver-info { min-width: 0; }
.driver-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.driver-rating { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; font-weight: 600; }
.driver-rating svg { width: 16px; height: 16px; fill: var(--brand); stroke: var(--brand); stroke-width: 1; }

.vehicle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vehicle-info { display: grid; gap: 2px; min-width: 0; }
.vehicle-name { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
.vehicle-photo { flex: none; width: 128px; height: 80px; object-fit: contain; }
/* Matrícula portuguesa (faixa azul da UE) */
.plate {
  display: inline-flex;
  align-items: stretch;
  justify-self: start;
  margin-top: 6px;
  border: 1.5px solid var(--ink);
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
  font: 500 16px/1 var(--mono);
  letter-spacing: 0.06em;
}
.plate-eu { display: grid; place-items: center; width: 18px; background: #1b3fa0; color: #fff; font: 600 10px var(--font); padding-top: 10px; }
.plate-text { padding: 6px 10px; }

.route { list-style: none; display: grid; gap: 0; }
.route-stop { position: relative; display: flex; gap: 14px; padding: 6px 0; }
.route-dot { flex: none; width: 14px; height: 14px; margin-top: 4px; border-radius: 50%; border: 3.5px solid var(--ink); background: #fff; }
.route-to .route-dot { border-color: #e2342b; }
/* Linha vertical entre recolha e destino */
.route-from::after { content: ""; position: absolute; left: 6px; top: 24px; bottom: -10px; border-left: 2px dashed var(--hairline); }
.route-address { font-weight: 500; line-height: 1.35; }
.route-street { margin-top: 2px; font-size: 14px; line-height: 1.35; color: var(--muted); }

.safety { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0; font-size: 14px; color: var(--ink-soft); }
.safety svg { flex: none; width: 20px; height: 20px; color: var(--brand-dark); }
.safety a { font-weight: 600; }

.panel-foot { margin-top: auto; padding: 14px 4px 0; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--muted); }
.panel-foot a { text-decoration: none; border-bottom: 1px solid var(--hairline); }

/* Mapa sem chave ou indisponível */
.map-missing { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; padding: 24px; text-align: center; color: var(--ink-soft); }
