/* ============================================================
   A&7 · Rota Mágica — HERO + FERRAMENTA + MAPA (o protagonista)
   Layout: texto + busca à ESQUERDA · MAPA à DIREITA (desktop)
   Classes base (tokens.css / base.css): .btn .btn-primary .reveal
   Mobile-first · Tema claro/escuro · Leaflet premium
   ============================================================ */

/* Garante que o atributo [hidden] sempre oculte o elemento,
   mesmo quando uma regra de display (grid/flex) estiver definida. */
[hidden] { display: none !important; }

/* ---------- Hero ---------- */
.hero {
  min-height: auto;
  display: grid;
  align-items: center;
  overflow: hidden;
  padding: calc(var(--header-h) + 24px) 0 32px;
  background:
    radial-gradient(circle at 88% 12%, rgba(75, 91, 255, .16), transparent 34%),
    radial-gradient(circle at 12% 26%, rgba(255, 46, 200, .12), transparent 31%),
    linear-gradient(180deg, var(--hero-bg-1) 0%, var(--hero-bg-2) 100%);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}
.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 40px;
  align-items: start;
}
.hero-col-left { min-width: 0; }

/* Fontes do hero MENORES (coluna esquerda) */
.hero-copy .display {
  max-width: 760px;
  font-size: clamp(2rem, 4.6vw, 3.3rem);
  line-height: 1.02;
  letter-spacing: -.055em;
}
.hero-copy .section-lead {
  max-width: 560px;
  font-size: clamp(1rem, 1.9vw, 1.18rem);
  margin-top: 16px;
}
/* Separador dos chips de longa distância (3 cidades) */
.chip-label-sep {
  margin-left: 6px;
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
}
.hero-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 18px;
}
.hero-trust span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 650;
  color: var(--muted);
}
.hero-trust span::before {
  content: "✓";
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: .6rem;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #1ebe7f);
}
.hero-ctas { margin-top: 22px; }

/* ---------- Coluna direita: MAPA (resultado direto, abaixo do header) ---------- */
.hero-map { min-width: 0; }
.map-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.map-head-spacer { flex: 1; }
.tool-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 850;
  font-size: .96rem;
}
.tool-live .dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(47, 213, 159, .5);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 213, 159, .5); }
  70%  { box-shadow: 0 0 0 9px rgba(47, 213, 159, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 213, 159, 0); }
}
.tool-sub {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 650;
}
.tool-badge {
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--violet-2);
  border: 1px solid var(--line-strong);
  padding: 4px 9px;
  border-radius: 999px;
}
.see-results-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .78rem;
  font-weight: 800;
  color: var(--violet);
  /* Sempre ocupa espaço (evita o mapa "pular" quando aparece no resultado) */
  visibility: hidden;
}
.see-results-link.is-visible { visibility: visible; }
.code-link {
  border: 0;
  background: transparent;
  color: var(--violet);
  font-size: .78rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0;
}

/* ---------- Formulário ---------- */
.tool-form { display: grid; gap: 14px; }
.tool-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: .92rem;
  line-height: 1.6;
  transition: border-color .25s ease, box-shadow .25s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) var(--surface);
}
.tool-textarea::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.tool-textarea::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: 4px;
}
.tool-textarea::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}
.tool-textarea::-webkit-scrollbar-thumb:hover {
  background: var(--violet);
}
.tool-textarea::placeholder { color: var(--muted); }
.tool-textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--glow);
}
.tool-textarea.error { border-color: var(--red); }

.tool-input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.tool-go { min-width: 150px; }

.tool-chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  align-items: center;
  gap: 8px;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.tool-chips::-webkit-scrollbar { height: 5px; }
.tool-chips::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.tool-chips::-webkit-scrollbar-track { background: transparent; }
.chip { flex: none; }
.chip-label { font-size: .74rem; color: var(--muted); font-weight: 650; flex: none; }
.chip {
  font-size: .74rem;
  font-weight: 700;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 7px 12px;
  border-radius: 999px;
  transition: .22s ease;
}
.chip:hover { border-color: var(--violet); color: var(--violet); transform: translateY(-1px); }

/* ---------- Status / steps animados ---------- */
.tool-status {
  margin-top: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: grid;
  gap: 10px;
  overflow: hidden;
  position: relative;
}
/* Mobile: escondido no idle (não reserva espaço — fluxo natural em coluna única) */
.tool-status.is-ready { display: none; }
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .88rem;
  font-weight: 650;
  color: var(--muted);
  opacity: .45;
  transition: .3s ease;
}
.step::before {
  content: "";
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  flex: none;
  transition: .3s ease;
}
.step.active { color: var(--ink); opacity: 1; }
.step.active::before {
  border-color: var(--violet);
  background: radial-gradient(circle, var(--violet) 0 45%, transparent 50%);
  animation: stepPop .4s ease;
}
.step.done { color: var(--green); opacity: 1; }
.step.done::before {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 3px var(--tool-bg);
}
@keyframes stepPop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

.tool-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(107, 50, 255, .08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  pointer-events: none;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Mapa (o "wow") ---------- */
.tool-map-wrap {
  position: relative;
  margin-top: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--map-frame);
  box-shadow: var(--shadow);
  background: var(--surface-2); /* enquanto os tiles carregam */
}
#map { height: clamp(300px, 52vh, 420px); min-height: 300px; z-index: 0; }
/* Vignette sutil nas bordas para dar profundidade (não bloqueia cliques) */
.tool-map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 30%, transparent 58%, rgba(9, 8, 13, .16) 100%);
}

/* Leaflet adaptado ao tema */
.leaflet-container {
  font-family: var(--font);
  background: var(--surface-2);
}
.leaflet-touch .leaflet-control-zoom a,
.leaflet-control-zoom a {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-weight: 800;
}
.leaflet-control-zoom a:hover { background: var(--surface-2); color: var(--violet); }
.leaflet-control-attribution {
  background: var(--surface);
  color: var(--muted);
  font-size: .6rem;
  border-radius: 8px 0 0 0;
}
.leaflet-control-attribution a { color: var(--violet); }
.leaflet-control-scale-line {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line-strong);
}
.leaflet-tooltip {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  font-size: .74rem;
  font-weight: 650;
  padding: 5px 10px;
}
.leaflet-tooltip-top:before { border-top-color: var(--line-strong); }

/* Marcador numerado premium (gradiente + anel de pulso) */
.rm-marker { background: transparent; border: none; }
.rm-pin {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: .78rem;
  color: #fff;
  background: linear-gradient(135deg, var(--magenta), var(--violet));
  border: 2px solid rgba(255, 255, 255, .9);
  animation: rmPinPulse 2s infinite;
}
@keyframes rmPinPulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 46, 200, .55), 0 6px 16px rgba(107, 50, 255, .45); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 46, 200, 0), 0 6px 16px rgba(107, 50, 255, .45); }
  100% { box-shadow: 0 0 0 0 rgba(255, 46, 200, 0), 0 6px 16px rgba(107, 50, 255, .45); }
}
/* Interação no hover: pin cresce + brilha (a rota vizinha é destacada via JS) */
.rm-marker.is-hover .rm-pin {
  transform: scale(1.32);
  animation: none;
  box-shadow: 0 0 0 5px rgba(255, 46, 200, .4), 0 0 26px rgba(255, 46, 200, .85);
}

/* Dica flutuante da demo (antes de qualquer cálculo) */
.map-demo-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: .72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s ease;
}
.map-demo-hint.is-visible { opacity: 1; }

/* Fallback de rota animada sem o plugin (dash animado via CSS) */
.route-dash {
  stroke-dasharray: 10 14;
  animation: dashmove 1s linear infinite;
}
@keyframes dashmove { to { stroke-dashoffset: -24; } }

/* ---------- Animação comum (usada em lista/análise da seção 2) ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Resultado: lista de paradas ---------- */
.result-list {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}
/* Markup real (Fase 3): li + span.result-num + div > strong/span ·
   e a variante do contrato: .stop .num/.label/.meta */
.result-list li,
.stop {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 10px 13px;
  font-size: .86rem;
  animation: rise .4s ease;
}
.result-num,
.stop .num {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--magenta), var(--violet));
}
.stop.depot .num { background: linear-gradient(135deg, var(--violet), var(--blue)); }
.result-list li > div { flex: 1; min-width: 0; }
.result-list li strong { display: block; font-weight: 650; }
.result-list li div > span { display: block; font-size: .74rem; color: var(--muted); }
.stop .label { flex: 1; font-weight: 650; }
.stop .meta { font-size: .74rem; color: var(--muted); }

/* ---------- Análise do copiloto (typing) ---------- */
.tool-analysis {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: rise .45s ease;
}
.analysis-avatar {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 1.15rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(107, 50, 255, .22), rgba(255, 46, 200, .22));
}
.analysis-bubble {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 16px 16px 16px;
  padding: 14px 16px;
}
.analysis-tag {
  display: block;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--violet-2);
  margin-bottom: 6px;
}
.analysis-text { font-size: .86rem; line-height: 1.6; white-space: pre-line; }
.analysis-text .caret {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--violet);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Erro / Rate limit ---------- */
.tool-error {
  margin-top: 14px;
  border: 1px solid rgba(255, 84, 112, .35);
  background: rgba(255, 84, 112, .12);
  color: var(--red);
  border-radius: var(--radius-xs);
  padding: 13px 15px;
  font-size: .86rem;
  font-weight: 650;
  animation: rise .4s ease;
}
.tool-limit {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: .74rem;
  color: var(--muted);
  font-weight: 650;
}
.tool-limit .limited { color: var(--amber); font-weight: 800; }

/* ---------- Responsivo ---------- */
/* Telas muito pequenas: input e botão empilhados */
@media (max-width: 400px) {
  .tool-input-row { grid-template-columns: 1fr; }
  .tool-go { width: 100%; }
  #map { height: 300px; }
}

/* Desktop: TEXTO + BUSCA à esquerda · MAPA à direita (logo abaixo do header).
   Layout COMPACTO: sem min-height forçado, form logo abaixo do título,
   mapa menor — o hero fica bem abaixo de 100vh. */
@media (min-width: 980px) {
  .hero { min-height: auto; padding: calc(var(--header-h) + 12px) 0 20px; align-items: center; }
  .hero-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 32px; align-items: center; }
  .hero-col-left { max-width: 520px; }

  /* Título menor + form colado logo abaixo (sem o parágrafo section-lead) */
  .hero-copy .display { font-size: clamp(1.7rem, 3.6vw, 2.7rem); }
  .tool-form { margin-top: 12px; gap: 8px; }
  .tool-textarea { min-height: 52px; }
  .tool-limit { margin-top: 0; }

  /* MAPA: protagonista da coluna direita, logo abaixo do header, centralizado */
  .hero-map { min-width: 0; }
  #map { height: clamp(340px, 46vh, 480px); }

  /* FIX (bug do eixo Y): o status sempre ocupa a MESMA altura no desktop,
     então quando o cálculo começa (steps aparecem) o mapa NÃO desce —
     ele permanece centralizado verticalmente. */
  .tool-status { margin-top: 0; height: 96px; padding: 10px 14px; gap: 6px; box-sizing: border-box; }
  .tool-status.is-ready { display: grid; }
  .tool-status.is-ready .step { opacity: .35; }
  .tool-status.is-ready .tool-shimmer { display: none; }
  .tool-status.is-done .step { color: var(--green); opacity: 1; }
  .tool-status.is-done .step::before {
    border-color: var(--green);
    background: var(--green);
    box-shadow: inset 0 0 0 3px var(--tool-bg);
  }
  .tool-status.is-done .tool-shimmer { display: none; }
}
