/* Rastreio do pedido: o visual próprio da consulta e do resultado. Fontes,
   cores, cabeçalho, rodapé, .card e .btn vêm do CSS do site institucional
   (o HTML é src/pages/rastreio/index.astro do repo gruporko-site).

   Tudo fica sob .rastreio para não vazar no cabeçalho e no rodapé do site.
   As cores são os tokens do site (src/styles/global.css), com o valor ao lado
   para não depender de o Tailwind ter emitido a variável.
   Mobile primeiro; contraste AA e alvos de 48 px ou mais (seção 4 do plano).
   Nada aqui pode virar estilo inline: a CSP do /rastreio não aceita. */
.rastreio {
  --rt-navy: var(--color-navy-900, #0b1a3b);
  --rt-texto: var(--color-ink-900, #0d1526);
  --rt-texto-2: var(--color-ink-700, #33415c);
  --rt-texto-3: var(--color-ink-500, #5b6b87);      /* 5,3:1 sobre branco */
  --rt-borda: #dbe3ee;
  --rt-fundo-suave: var(--color-surface-soft, #f6f9fd);
  --rt-feita: #1d6b3a;                               /* 6,5:1 sobre branco */
  --rt-feita-fundo: #e7f4ec;
  --rt-atual: var(--color-accent-500, #f59313);      /* marcador e barra */
  --rt-atual-texto: var(--color-accent-text, #8a4a03); /* 6,9:1: texto laranja */
  --rt-atual-fundo: #fff3e3;
  --rt-futura: var(--color-ink-300, #64748b);        /* 4,8:1 */
  --rt-whatsapp: #0f7a3f;                            /* branco sobre ele: 5,5:1 */
  --rt-erro: #a8231b;
  --rt-erro-fundo: #fdecea;
}

/* ── Cartões e cabeçalho do formulário ─────────────────────────────────── */
.rastreio .rt-cartao { padding: 1.5rem 1.25rem; }
.rastreio .rt-cab { display: flex; gap: 1rem; align-items: flex-start; }
.rastreio .rt-cab-icone {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  background: var(--rt-atual-fundo);
  color: var(--rt-atual-texto);
}

/* 18 px: legível no celular e acima dos 16 px que fazem o iOS dar zoom. */
.rastreio .rt-campo { min-height: 3.5rem; font-size: 1.125rem; }
.rastreio #campo-codigo { text-transform: uppercase; }
.rastreio .rt-dica {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--rt-texto-3);
}
.rastreio .rt-dica svg { flex: none; margin-top: 0.15rem; }

/* ── Botões grandes ────────────────────────────────────────────────────── */
.rastreio .rt-botao {
  min-height: 3.25rem;
  justify-content: center;
  font-size: 1rem;
  line-height: 1.3;
  text-align: center;
}
.rastreio .rt-botao-leve { background: transparent; color: var(--rt-texto-2); }
.rastreio .rt-botao-leve:hover { background: #fff; color: var(--rt-navy); }
.rastreio .rt-whatsapp { background: var(--rt-whatsapp); color: #fff; }
.rastreio .rt-whatsapp:hover { background: #0b6233; }
.rastreio button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.rastreio .captcha { min-height: 65px; }

/* Botão da nota: desabilitado até a área do cliente entrar no ar. Não é
   espera, então sem o cursor de "carregando" dos outros botões. */
.rastreio #botao-nota:disabled { cursor: not-allowed; }
.rastreio .rt-aviso-nota {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--rt-texto-3);
  text-align: center;
}

.rastreio .mensagem { min-height: 1.5em; margin: 0; color: var(--rt-erro); font-weight: 600; }
.rastreio .mensagem:empty { min-height: 0; }
.rastreio #msg-resultado:not(:empty) {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--rt-erro-fundo);
}

/* ── Carregando ────────────────────────────────────────────────────────── */
.rastreio .rt-carregando { display: flex; gap: 1rem; align-items: center; }
.rastreio .rt-carregando[hidden] { display: none; }
.rastreio .rt-girando {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid var(--rt-borda);
  border-top-color: var(--rt-atual);
  border-radius: 50%;
  animation: rt-girar 0.8s linear infinite;
}
@keyframes rt-girar { to { transform: rotate(360deg); } }

/* ── Resultado ─────────────────────────────────────────────────────────── */
.rastreio .rt-resultado > * + * { margin-top: 1.25rem; }
.rastreio .rt-titulo-cartao { font-size: 1.125rem; color: var(--rt-navy); }

/* Situação: ícone, número do pedido, situação em destaque e progresso. */
.rastreio .rt-status-topo { display: flex; gap: 1rem; align-items: center; }
.rastreio .rt-status-icone {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--rt-atual-fundo);
  color: var(--rt-atual-texto);
}
.rastreio .rt-rotulo {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rt-texto-3);
}
.rastreio .rt-situacao {
  margin-top: 0.125rem;
  font-size: 1.5rem;
  line-height: 1.2;
  color: var(--rt-navy);
}
.rastreio .rt-situacao:focus { outline: none; }
.rastreio .rt-situacao:focus-visible { outline: 3px solid var(--rt-navy); outline-offset: 4px; }

/* Um ícone por situação; o rastreio.js põe o código em data-situacao. */
.rastreio .rt-ic { display: none; }
[data-situacao="recebido"] .rt-ic-recebido,
[data-situacao="em_separacao"] .rt-ic-pacote,
[data-situacao="separado"] .rt-ic-pacote,
[data-situacao="faturado"] .rt-ic-faturado,
[data-situacao="saiu"] .rt-ic-saiu,
[data-situacao="entregue"] .rt-ic-entregue,
[data-situacao="cancelado"] .rt-ic-encerrado,
[data-situacao="devolvido"] .rt-ic-encerrado { display: inline-flex; }
[data-situacao="entregue"] .rt-status-icone { background: var(--rt-feita-fundo); color: var(--rt-feita); }
[data-situacao="cancelado"] .rt-status-icone,
[data-situacao="devolvido"] .rt-status-icone { background: var(--rt-erro-fundo); color: var(--rt-erro); }

.rastreio .rt-progresso-bloco { margin-top: 1.25rem; }
.rastreio .rt-progresso {
  display: flex;
  gap: 0.375rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rastreio .rt-progresso li {
  flex: 1;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--rt-borda);
}
.rastreio .rt-progresso li.feita { background: var(--rt-feita); }
.rastreio .rt-progresso li.atual { background: var(--rt-atual); }
.rastreio .rt-progresso-texto { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--rt-texto-3); }

.rastreio .rt-linha-info {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--rt-fundo-suave);
  color: var(--rt-texto);
  font-weight: 600;
}
.rastreio .rt-linha-info + .rt-linha-info { margin-top: 0.5rem; }

/* ── Linha do tempo vertical ───────────────────────────────────────────────
   Marcador à esquerda: concluída (verde com ✓), atual (laranja com anel) e
   próxima (vazada). O traço entre marcadores fica verde até a etapa atual. */
.rastreio .linha-tempo { list-style: none; margin: 1.25rem 0 0; padding: 0; }
.rastreio .linha-tempo li {
  position: relative;
  min-height: 3.25rem;
  padding: 0 0 1.25rem 2.75rem;
}
.rastreio .linha-tempo li:last-child { min-height: 0; padding-bottom: 0; }
.rastreio .linha-tempo li::before {
  content: "";
  position: absolute;
  left: calc(0.875rem - 1px);
  top: 1.75rem;
  bottom: 0;
  width: 2px;
  background: var(--rt-borda);
}
.rastreio .linha-tempo li.feita::before { background: var(--rt-feita); }
.rastreio .linha-tempo li:last-child::before { display: none; }

.rastreio .lt-marca {
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--rt-futura);
  background: #fff;
}
.rastreio li.feita .lt-marca { border-color: var(--rt-feita); background: var(--rt-feita); }
/* ✓ desenhado com bordas: sem imagem nem fonte de ícone. */
.rastreio li.feita .lt-marca::after {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0.25rem;
  width: 0.4rem;
  height: 0.75rem;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.rastreio li.atual .lt-marca {
  /* Borda escura: o laranja sozinho dá 2,3:1 sobre branco (WCAG 1.4.11 pede 3:1). */
  border-color: var(--rt-atual-texto);
  background: var(--rt-atual);
  box-shadow: 0 0 0 6px rgba(245, 147, 19, 0.2);
  animation: rt-pulsar 2s ease-out infinite;
}
.rastreio li.atual .lt-marca::after {
  content: "";
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  bottom: 0.4rem;
  left: 0.4rem;
  border-radius: 50%;
  background: #fff;
}
@keyframes rt-pulsar {
  0% { box-shadow: 0 0 0 0 rgba(245, 147, 19, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(245, 147, 19, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 147, 19, 0); }
}

.rastreio .lt-corpo { padding-top: 0.125rem; }
.rastreio .lt-linha { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: center; }
.rastreio .linha-tempo .etapa { font-size: 1rem; color: var(--rt-texto-3); }
.rastreio li.feita .etapa { color: var(--rt-texto); }
.rastreio li.atual .etapa { font-weight: 700; color: var(--rt-navy); }
.rastreio .lt-agora {
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--rt-atual-fundo);
  color: var(--rt-atual-texto);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.rastreio .linha-tempo .quando {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.9375rem;
  color: var(--rt-texto-2);
  font-variant-numeric: tabular-nums;
}

.rastreio .rt-tentativas { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rt-borda); }
.rastreio .tentativas { margin: 0.5rem 0 0; padding-left: 1.25rem; list-style: disc; color: var(--rt-texto-2); }

/* ── Seu pedido: blocos de dado ────────────────────────────────────────── */
.rastreio .rt-dados {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0 0;
}
.rastreio .rt-dado {
  min-width: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: var(--rt-fundo-suave);
}
.rastreio .rt-dado dt { font-size: 0.8125rem; color: var(--rt-texto-3); }
.rastreio .rt-dado dd {
  margin: 0.125rem 0 0;
  font-weight: 600;
  color: var(--rt-texto);
  overflow-wrap: anywhere;
}

/* ── Contato do vendedor ───────────────────────────────────────────────── */
.rastreio .rt-pessoa { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.rastreio .rt-avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--rt-navy);
  color: #fff;
  font-family: var(--font-display, inherit);
  font-size: 1.25rem;
  font-weight: 700;
}
.rastreio .rt-pessoa-nome { margin: 0; font-size: 1.125rem; font-weight: 700; color: var(--rt-navy); }
.rastreio .rt-pessoa-fone { margin: 0; color: var(--rt-texto-2); font-variant-numeric: tabular-nums; }
.rastreio .rt-contato-botoes { display: grid; gap: 0.75rem; margin-top: 1.25rem; }

@media (min-width: 640px) {
  .rastreio .rt-cartao { padding: 2rem; }
  .rastreio .rt-situacao { font-size: 1.875rem; }
  .rastreio .rt-contato-botoes { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 359px) {
  .rastreio .rt-dados { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .rastreio li.atual .lt-marca { animation: none; }
  .rastreio .rt-girando { animation-duration: 2s; }
}
