/* ==========================================================================
   ALAVANCA — base.
   Reset moderno, tipografia, formulários nus, foco, movimento reduzido.
   Nada aqui conhece um componente. Camada 3 (ver assets/css/ORDEM.md).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--al-control-h) + var(--al-space-8));
  tab-size: 2;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--al-bg);
  color: var(--al-text);
  font-family: var(--al-font-sans);
  font-size: var(--al-text-base);
  line-height: var(--al-leading-normal);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, picture, svg, video, canvas { display: block; max-width: 100%; height: auto; }
img { background-color: var(--al-bg-sunken); }

svg { fill: none; stroke: currentColor; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; }

ul, ol, menu { margin: 0; padding: 0; }
li { list-style: none; }

figure, blockquote, dl, dd { margin: 0; }

table { border-collapse: collapse; border-spacing: 0; }

hr {
  height: 0;
  margin-block: var(--al-space-10);
  border: 0;
  border-top: 1px solid var(--al-border);
}

::selection { background: var(--al-brand-wash); color: var(--al-text); }

/* --------------------------------------------------------------------------
   2. Tipografia
   A serifa é o corpo do artigo e os títulos. A sans é a interface e o dado.
   Não há uma terceira decisão a tomar em cada componente.
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--al-font-serif);
  font-weight: var(--al-weight-semibold);
  line-height: var(--al-leading-tight);
  letter-spacing: var(--al-tracking-tight);
  text-wrap: balance;
  color: var(--al-text);
}

h1 { font-size: var(--al-text-4xl); }
h2 { font-size: var(--al-text-2xl); line-height: var(--al-leading-snug); }
h3 { font-size: var(--al-text-xl); line-height: var(--al-leading-snug); }
h4 { font-size: var(--al-text-lg); line-height: var(--al-leading-snug); }
h5, h6 {
  font-family: var(--al-font-sans);
  font-size: var(--al-text-2xs);
  font-weight: var(--al-weight-semibold);
  letter-spacing: var(--al-tracking-caps);
  text-transform: uppercase;
  color: var(--al-text-faint);
}

p { margin: 0; text-wrap: pretty; }

strong, b { font-weight: var(--al-weight-semibold); }
em, i { font-style: italic; }

small { font-size: var(--al-text-xs); }

code, kbd, samp, pre {
  font-family: var(--al-font-mono);
  font-size: 0.9375em;
  font-variant-ligatures: none;
}

code {
  padding: 0.1em 0.35em;
  background: var(--al-bg-sunken);
  border: 1px solid var(--al-border);
  border-radius: var(--al-radius-sm);
  /* Um identificador como `pme_prompt_resultado_esperado` não tem onde quebrar
     e, a 320 px, empurrava a página inteira para fora da tela. Código em linha
     quebra; o bloco de código é que rola, dentro do <pre>. */
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
pre code { padding: 0; background: none; border: 0; }

kbd {
  padding: 0.15em 0.4em;
  background: var(--al-bg-elev);
  border: 1px solid var(--al-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--al-radius-sm);
  font-size: var(--al-text-xs);
}

abbr[title] { text-decoration: underline dotted; cursor: help; }

mark {
  padding: 0.05em 0.2em;
  background: var(--al-data-wash);
  color: var(--al-on-data-wash);
  border-radius: var(--al-radius-sm);
}

blockquote {
  padding-left: var(--al-space-5);
  border-left: 2px solid var(--al-brand);
  font-family: var(--al-font-serif);
  font-size: var(--al-text-lg);
  line-height: var(--al-leading-relaxed);
  color: var(--al-text);
}

/* --------------------------------------------------------------------------
   3. Ligações
   -------------------------------------------------------------------------- */

a {
  color: var(--al-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 0.18em;
  transition: color var(--al-dur-1) var(--al-ease),
              text-decoration-color var(--al-dur-1) var(--al-ease);
}
a:hover { color: var(--al-link-hover); text-decoration-color: currentColor; }
a:active { color: var(--al-link-hover); }

/* --------------------------------------------------------------------------
   4. Foco
   Um único desenho de foco em todo o produto: anel de 2px na marca, com
   afastamento. Nunca removido — quando o contorno não serve (elemento com
   fundo próprio), é substituído por sombra equivalente, nunca por nada.
   -------------------------------------------------------------------------- */

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--al-brand);
  outline-offset: 2px;
  border-radius: var(--al-radius-sm);
}

/* Elemento que já tem fundo escuro: o anel usa a sombra composta do token. */
.al-btn:focus-visible,
.al-botao:focus-visible,
.al-card__link:focus-visible {
  outline: 2px solid var(--al-brand);
  outline-offset: 3px;
}

/* Só rato: sem anel, mas o estado activo continua a existir. */
:focus:not(:focus-visible) { outline: none; }

/* --------------------------------------------------------------------------
   5. Formulários nus (o vestido está em componentes.css)
   -------------------------------------------------------------------------- */

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }

label { display: inline-block; }

::placeholder { color: var(--al-text-faint); opacity: 1; }

textarea { resize: vertical; min-height: 6rem; }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right var(--al-space-4) center, calc(100% - var(--al-space-4) + 5px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--al-space-10);
}

input[type="checkbox"], input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--al-brand);
  cursor: pointer;
}

/* Alvo de toque.
   Esta regra dá só o comportamento de ponteiro. A área de 44 px vem de outro
   sítio em cada caso: do `padding` dos botões, do `min-height` dos campos, do
   `::after` esticado dos cartões, e — na caixa de consentimento — do `<label>`
   associado, que mede 144 px de altura e é onde o dedo acerta.
   O comentário anterior dizia "qualquer controlo interactivo tem 44px de área",
   e não era esta regra que o entregava. Um comentário que promete mais do que a
   regra cumpre é o mesmo defeito das tabelas: a etiqueta a afirmar o que o
   conteúdo não sustenta. A verificação real está em `bin/verificar-a11y.php`,
   que mede no navegador e isenta ligação em linha, como a WCAG 2.5.8 manda. */
button, [role="button"], input[type="submit"], summary {
  cursor: pointer;
  touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   6. Tabelas nuas
   -------------------------------------------------------------------------- */

th { text-align: left; font-weight: var(--al-weight-semibold); }
caption { text-align: left; }

/* --------------------------------------------------------------------------
   7. Utilitários de acessibilidade
   -------------------------------------------------------------------------- */

.al-oculto-visual {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.al-oculto-visual:focus-visible {
  position: static !important;
  width: auto; height: auto;
  margin: 0; overflow: visible;
  clip-path: none; white-space: normal;
}

[hidden] { display: none !important; }

.al-sem-js .js-somente-com-js { display: none !important; }
.al-com-js .js-somente-sem-js { display: none !important; }

/* --------------------------------------------------------------------------
   8. Movimento
   `prefers-reduced-motion` já zera as durações em tokens.css. Aqui desligam-se
   as animações que não dependem de duração — paralaxe, rolagem suave e
   qualquer coisa que se mova sozinha.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .al-estado__pulso,
  .al-esqueleto { animation: none !important; }
  .al-esqueleto { opacity: 0.5; }
}

/* --------------------------------------------------------------------------
   9. Números
   Dado é sempre tabular. Uma coluna de números que dança é uma coluna que
   ninguém lê.
   -------------------------------------------------------------------------- */

.al-num,
.al-tabela--dados td,
.al-metrica-card__valor,
.al-calculadora__saida-valor {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* --------------------------------------------------------------------------
   10. Sobrelinha — o elemento gráfico de identidade
   -------------------------------------------------------------------------- */

.al-sobrelinha {
  margin: 0;
  font-family: var(--al-font-sans);
  font-size: var(--al-text-2xs);
  font-weight: var(--al-weight-semibold);
  letter-spacing: var(--al-tracking-caps);
  text-transform: uppercase;
  color: var(--al-text-faint);
}
