/* diagnostico.css — complementa os estilos do guia. Tokens e fontes vêm de
   tokens.css. Regras herdadas do DESIGN.md: sem emoji, amarelo nunca como
   texto sobre fundo claro, números fiscais em tabular-nums.

   Ajuste de nomes: o CSS de referência usava --superficie/--texto/--borda/
   --trilho/--data-chave/--fonte-display/--texto-secundario/--fundo/
   --interativo, que não existem em tokens.css. Mapeados para os tokens
   reais: --surface, --text, --border, --rail, --progress (barra) /
   --viggo-yellow (destaque e botão, via --btn-bg/--btn-ink), --font-display,
   --muted, --bg, --interactive. */

/* O trilho é a espinha do mundo Agenda Tributária (DESIGN.md §4): linha
   vertical contínua com um nó por etapa. Aqui cada pergunta é um marco da
   sequência, então o diagnóstico ganha a mesma estrutura do guia em vez de
   uma coluna centrada — assimetria estrutural, headings à esquerda. */
.dg-palco {
  position: relative;
  max-width: 1080px;
  margin-inline: auto;
  padding: clamp(2rem, 6vw, 3.5rem) clamp(18px, 4vw, 56px) 3rem
           calc(var(--railx) + var(--railgap));
}
.dg-palco::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: var(--railx);
  width: 3px;
  border-radius: 2px;
  background: var(--rail);
}

/* O nó preso ao trilho: numerado nas perguntas, amarelo (nó-chave) no
   resultado, que é o marco que o visitante veio buscar. */
.dg-no {
  position: absolute;
  left: calc(-1 * var(--railgap));
  top: .15em;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--rail);
  color: var(--brand);
  font-family: var(--font-display);
  font-weight: var(--w-heading);
  font-size: .82rem;
}
.dg-no--chave { background: var(--accent); color: var(--viggo-navy); border-color: var(--accent); }

@media (max-width: 720px) {
  .dg-palco {
    --railx: 10px;
    --railgap: 24px;
    padding-right: 16px;
  }
  .dg-no { width: 24px; height: 24px; font-size: .68rem; border-width: 2px; }
  /* Em coluna estreita o título não pode competir com o trilho por largura. */
  .dg-pergunta__titulo { font-size: clamp(1.35rem, 6vw, 1.8rem); }
}

/* Barra de progresso: tráfego frio abandona quando não vê o fim. */
.dg-progresso {
  position: sticky;
  top: 0;
  height: 4px;
  background: var(--border);
  transform-origin: left;
  z-index: 10;
}
.dg-progresso__preenchimento {
  height: 100%;
  background: var(--progress);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.dg-pergunta, .dg-parcial, .dg-resultado, .dg-curto { position: relative; }

.dg-pergunta__titulo {
  font-family: var(--font-display);
  font-weight: var(--w-display);
  font-size: var(--t-section);
  line-height: 1.08;
  letter-spacing: -.015em;
  margin: 0 0 6px;
  max-width: var(--measure);
}
.dg-pergunta__ajuda {
  max-width: var(--measure);
  margin: 0 0 30px;
  font-size: var(--t-lead);
  color: var(--muted);
}

/* Uma pergunta por tela no celular, com alvos grandes. */
.dg-opcoes {
  display: grid;
  gap: .75rem;
}
.dg-opcao {
  min-height: 56px;
  padding: 1rem 1.25rem;
  text-align: left;
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.dg-opcao:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.dg-opcao:focus-visible { outline: 3px solid var(--interactive); outline-offset: 2px; }
/* O primeiro botão recebe foco por JS a cada pergunta (para leitor de tela).
   Sem isto o anel aparecia para quem usa mouse e lia como opção já escolhida. */
.dg-opcao:focus:not(:focus-visible) { outline: none; }
.dg-opcao:active { transform: scale(.99); }

/* Resultado parcial: a faixa aparece legítima, o número exato fica borrado. */
.dg-parcial__rotulo,
.dg-resultado__rotulo {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .8rem;
  color: var(--muted);
}
.dg-parcial__faixa,
.dg-resultado__numero {
  font-family: var(--font-display);
  font-weight: var(--w-display);
  letter-spacing: -.02em;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 1.05;
  margin-block: .25rem 1rem;
}
.dg-parcial__faixa span,
.dg-resultado__numero span {
  display: block;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}
.dg-borrado {
  filter: blur(8px);
  user-select: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
}

.dg-cadastro {
  display: grid;
  gap: .5rem;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.dg-cadastro input {
  min-height: 48px;
  padding: .75rem 1rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.dg-cadastro input:focus-visible { outline: 3px solid var(--interactive); outline-offset: 1px; }

/* Armadilha anti-robô: invisível e fora do foco do teclado. Mesmo padrão do
   formulário do guia. */
.dg-armadilha {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dg-botao {
  min-height: 56px;
  padding: 1rem 1.5rem;
  font: inherit;
  font-weight: 700;
  background: var(--btn-bg);
  color: var(--btn-ink);          /* navy sobre amarelo: 10.03:1 */
  border: 0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.dg-botao:hover { transform: translateY(-2px); filter: brightness(1.08); }
.dg-botao:active { transform: translateY(0); }
.dg-botao--fantasma {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--brand);
  box-shadow: none;
}
.dg-botao--fantasma:hover { background: var(--surface-alt); filter: none; }
.dg-botao:focus-visible { outline: 3px solid var(--interactive); outline-offset: 2px; }
.dg-microcopy { font-size: .85rem; color: var(--muted); text-align: center; }

.dg-tabela {
  width: 100%;
  border-collapse: collapse;
  margin-block: 1.5rem;
}
.dg-tabela td:last-child {
  font-family: var(--font-display);
  font-weight: var(--w-emphasis);
  font-variant-numeric: tabular-nums;
}
.dg-tabela th, .dg-tabela td {
  padding: .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.dg-linha--destaque { background: color-mix(in srgb, var(--viggo-yellow) 15%, transparent); font-weight: 700; }

/* O trilho carrega o resultado na página de impacto. */
.dg-trilho {
  list-style: none;
  padding: 0;
  margin-block: 1.5rem;
  border-left: 3px solid var(--rail);
}
.dg-marco {
  position: relative;
  padding: .75rem 0 .75rem 1.5rem;
  display: grid;
  gap: .1rem;
}
.dg-marco::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 1.1rem;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--rail);
}
.dg-marco--teste::before { background: var(--viggo-yellow); }
.dg-marco__ano {
  font-family: var(--font-display);
  font-weight: var(--w-display);
  font-size: 1.25rem;
}
.dg-marco__valor { font-family: var(--font-display); font-weight: var(--w-emphasis); font-variant-numeric: tabular-nums; }
.dg-marco__nota { font-size: .85rem; color: var(--muted); }

.dg-plano { margin-block: 2rem; }
.dg-plano ol { padding-left: 1.25rem; display: grid; gap: .5rem; }
.dg-acoes { display: grid; gap: .75rem; margin-block: 1.5rem; }
.dg-aviso { font-size: .85rem; color: var(--muted); }
.dg-cruzado { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }

@media (min-width: 640px) {
  .dg-acoes { grid-auto-flow: column; }
}

@media (prefers-reduced-motion: reduce) {
  .dg-progresso__preenchimento, .dg-opcao { transition: none; }
}

/* Mensagem de validação. Sem ela, um telefone curto fazia o botão não
   responder e o visitante abandonava sem saber por quê.
   Sem tarja nem borda lateral: o amarelo da marca é data-chave e ação, não
   erro. Aqui o peso do texto basta, e o campo inválido já se destaca sozinho. */
.dg-erro {
  margin: 0;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
}
.dg-cadastro input[aria-invalid="true"] { border-color: var(--text); border-width: 2px; }

/* O título da tela recebe foco a cada troca; o anel padrão do navegador
   aparecendo num heading confunde, e o foco aqui é programático. */
.dg-pergunta__titulo:focus-visible,
.dg-parcial h2:focus-visible,
.dg-resultado h2:focus-visible,
.dg-curto h2:focus-visible { outline: none; }

/* Com JS ativo o conteúdo começa em h2. Sem um h1, a navegação por cabeçalhos
   do leitor de tela fica sem âncora. Este título é lido, não visto. */
.dg-titulo-oculto {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Ressalva de contexto no resultado — não é erro de validação, por isso não
   herda .dg-erro. Recuo e cor secundária a separam do corpo sem virar tarja. */
.dg-ressalva {
  margin-block: 1rem;
  padding-left: 1rem;
  font-size: .9rem;
  color: var(--muted);
  border-left: 1px solid var(--border);
}

/* Promessa do cadastro: o visitante precisa saber o que ganha antes de dar o
   número. Fica acima do formulário, não como microcopy debaixo do botão. */
.dg-cadastro__promessa {
  margin: .5rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

/* ---- Gráfico da transição (barras por ano) ---- */
.dg-gtransicao { margin: 1.25rem 0; }
.dg-gtransicao svg { width: 100%; height: auto; display: block; }
.dg-gtransicao figcaption {
  margin-top: .4rem;
  font-size: .8rem;
  color: var(--muted);
}
.dg-barra { fill: var(--rail); opacity: .45; }
.dg-barra--hoje { opacity: .25; }
.dg-barra--sobe { fill: var(--viggo-yellow); opacity: 1; }
.dg-linha-hoje { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.dg-rotulo-hoje, .dg-eixo {
  fill: var(--muted);
  font-size: 9px;
  font-family: inherit;
}

/* ---- Gráfico dos regimes (barras horizontais) ---- */
.dg-gregimes { display: grid; gap: .6rem; margin: 1.25rem 0; }
/* Nome e valor na mesma linha, barra abaixo ocupando a largura toda: em
   coluna estreita o nome do regime e o valor ficavam longe um do outro. */
.dg-gbarra {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .6rem;
  margin-bottom: .55rem;
  font-size: .9rem;
}
/* Nome à esquerda e valor à direita na MESMA linha, barra abaixo dos dois.
   Com o valor solto embaixo, ele era lido como rótulo da barra seguinte. */
.dg-gbarra__nome { grid-column: 1; grid-row: 1; }
.dg-gbarra__valor {
  grid-column: 2; grid-row: 1;
  text-align: right;
  font-family: var(--font-display);
  font-weight: var(--w-emphasis);
  font-variant-numeric: tabular-nums;
}
.dg-gbarra__trilha { grid-row: 2; }
.dg-gbarra__nome { color: var(--muted); }
.dg-gbarra__trilha {
  grid-column: 1 / -1;
  height: 10px;
  background: color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 4px;
  overflow: hidden;
}
.dg-gbarra__preenche {
  display: block;
  height: 100%;
  background: var(--rail);
  opacity: .45;
  border-radius: 4px;
}
.dg-gbarra__valor { white-space: nowrap; }
.dg-gbarra--melhor .dg-gbarra__nome { color: var(--text); font-weight: 700; }
.dg-gbarra--melhor .dg-gbarra__preenche { background: var(--viggo-yellow); opacity: 1; }
.dg-gbarra--melhor .dg-gbarra__valor { font-weight: 700; }

/* Detalhe recolhível: o trilho ano a ano repete o gráfico, então fica
   disponível para quem quer conferir número por número, sem ocupar a tela. */
.dg-detalhe { margin-block: 1rem; }
.dg-detalhe summary {
  cursor: pointer;
  padding: .6rem 0;
  font-size: .9rem;
  color: var(--interactive);
}
.dg-detalhe summary:focus-visible { outline: 3px solid var(--interactive); outline-offset: 2px; }
.dg-eixo--marco { fill: var(--text); font-weight: 600; }

/* ---- Memória de cálculo ---- */
.dg-memoria {
  margin: 1.75rem 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.dg-memoria h3 { margin: 0 0 .75rem; font-size: 1.05rem; }
.dg-memoria__lista { margin: 0; display: grid; gap: .1rem; }
.dg-memoria__lista > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .45rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.dg-memoria__lista dt { color: var(--muted); font-size: .9rem; }
.dg-memoria__lista dd {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--w-emphasis);
  font-variant-numeric: tabular-nums;
}
.dg-memoria__credito dd { color: var(--muted); }
.dg-memoria__total {
  border-bottom: none !important;
  padding-top: .6rem !important;
  font-weight: 700;
}
.dg-memoria__total dt { color: var(--text) !important; font-weight: 700; }
.dg-memoria__nota {
  margin: .85rem 0 0;
  font-size: .85rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ---- Bloco secundário (o ângulo da outra página) ---- */
.dg-secundario {
  margin: 1.75rem 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.dg-secundario h3 { margin: 0 0 .5rem; font-size: 1.05rem; }
.dg-secundario p { margin: .5rem 0 0; font-size: .95rem; }

/* Ficha do documento: identifica cliente e data no papel. Na tela seria
   ruído — o visitante acabou de digitar o próprio nome. */
.dg-ficha { display: none; }

/* Em tela estreita os anos se tocariam numa linha só: os ímpares descem. */
.dg-eixo--alt { transform: translateY(9px); }

/* A segunda folha do PDF existe só no papel: na tela o visitante já tem tudo
   rolando, e repetir viraria página infinita. */
.dg-segunda-folha { display: none; }

/* Legenda sob a barra: diz o que aquele número significa para o cliente. */
.dg-gbarra__legenda {
  grid-column: 1 / -1;
  font-size: .8rem;
  color: var(--muted);
  margin-top: .1rem;
}

/* Decisão com prazo: é o alerta mais acionável da página para quem é do
   Simples, não uma nota de rodapé. Ganha peso de seção. */
.dg-prazo {
  margin-block: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.dg-prazo h3 { margin: 0 0 .6rem; font-size: 1.1rem; }
.dg-prazo p { margin: 0 0 .7rem; font-size: .95rem; }
.dg-prazo p:last-child { margin-bottom: 0; }
