/* ============================================================
   AXIOM · BASE — reset, tipografia, layout, acessibilidade
   ============================================================ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--altura-topo) + var(--e-4));
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  min-height: 100svh;
  background: var(--fundo);
  color: var(--tinta);
  font-family: var(--fonte-ui);
  font-size: var(--t-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-synthesis-weight: none;
}

img, svg, video, canvas { display: block; max-width: 100%; }

/* O atributo hidden precisa vencer qualquer display vindo de classe ou de
   elemento. Sem isto, .palco-tela[hidden] e video[hidden] continuam na tela:
   a regra do autor empata em especificidade com o [hidden] do navegador e o
   autor ganha. Isto vale para o app inteiro, nao so para a sala. */
[hidden] { display: none !important; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
ul, ol { list-style: none; padding: 0; }
a { color: inherit; text-decoration: none; }
:where(p, li) { text-wrap: pretty; }
:where(h1, h2, h3, h4) { text-wrap: balance; }

/* ---------- foco visível e consistente (WCAG 2.4.7) ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--sinal);
  outline-offset: 3px;
  border-radius: var(--raio-sm);
}
/* elementos que já têm superfície própria usam anel em vez de contorno */
.btn:focus-visible, .campo:focus-visible, .pill:focus-visible {
  outline: 2px solid var(--sinal);
  outline-offset: 2px;
}

/* ---------- pular para o conteúdo ---------- */
.pular {
  position: fixed; top: var(--e-2); left: var(--e-2);
  z-index: var(--z-toast);
  transform: translateY(-160%);
  background: var(--sinal); color: #fff;
  padding: var(--e-3) var(--e-5);
  border-radius: var(--raio-md);
  font-weight: 600; font-size: var(--t-sm);
  transition: transform var(--dur-media) var(--ease-saida);
}
.pular:focus-visible { transform: translateY(0); }

/* ---------- só para leitor de tela ---------- */
.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   TIPOGRAFIA
   ============================================================ */
.display {
  font-family: var(--fonte-display);
  font-weight: 500;
  font-variation-settings: 'SOFT' 0, 'WONK' 1, 'opsz' 40;
  letter-spacing: var(--track-tight);
  line-height: var(--leading-tight);
}
.display em { font-style: italic; font-variation-settings: 'SOFT' 8, 'WONK' 1; }

h1, h2, h3, h4 { font-weight: 650; line-height: var(--leading-snug); letter-spacing: -.01em; }
h1 { font-size: var(--t-3xl); }
h2 { font-size: var(--t-2xl); }
h3 { font-size: var(--t-xl); }
h4 { font-size: var(--t-lg); }

.eti {
  font-family: var(--fonte-mono);
  font-size: var(--t-3xs);
  letter-spacing: var(--track-eti);
  text-transform: uppercase;
  color: var(--tinta-3);
  font-weight: 500;
}
.mono { font-family: var(--fonte-mono); font-size: .92em; letter-spacing: var(--track-mono); }
.dim { color: var(--tinta-3); }
.dim-2 { color: var(--tinta-2); }

/* código inline */
:not(pre) > code {
  font-family: var(--fonte-mono);
  font-size: .875em;
  background: var(--superficie-2);
  border: 1px solid var(--linha-suave);
  border-radius: var(--raio-sm);
  padding: .12em .38em;
  color: var(--tinta);
  white-space: nowrap;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.env { width: min(var(--largura-max), 100% - 2 * var(--e-6)); margin-inline: auto; }
@media (max-width: 640px) { .env { width: calc(100% - 2 * var(--e-4)); } }

.pilha { display: flex; flex-direction: column; }
.linha { display: flex; align-items: center; }
.entre { justify-content: space-between; }
.g1 { gap: var(--e-1); } .g2 { gap: var(--e-2); } .g3 { gap: var(--e-3); }
.g4 { gap: var(--e-4); } .g6 { gap: var(--e-6); } .g8 { gap: var(--e-8); }
.envolve { flex-wrap: wrap; }
.cresce { flex: 1; min-width: 0; }

.secao { padding-block: var(--e-16); }
.secao-densa { padding-block: var(--e-10); }
@media (max-width: 780px) { .secao { padding-block: var(--e-12); } }

/* cabeçalho de seção reutilizável */
.sec-cab { display: flex; flex-direction: column; gap: var(--e-3); margin-bottom: var(--e-8); }
.sec-cab h2 { font-size: var(--t-3xl); }
.sec-cab p { color: var(--tinta-2); max-width: 56ch; font-size: var(--t-base); }

/* ============================================================
   ESTRUTURA DO APP
   ============================================================ */
#app { display: flex; flex-direction: column; min-height: 100svh; }
#rota { flex: 1; }

/* transição de rota (adaptado do #18 Page Transition) */
#rota.trocando { opacity: 0; transform: translateY(6px); }
#rota { opacity: 1; transform: none; transition: opacity 180ms var(--ease-padrao), transform 180ms var(--ease-padrao); }

/* fundo pontilhado de papel milimetrado — só em áreas de destaque */
.grade-fundo {
  background-image: radial-gradient(circle at 1px 1px, var(--grade-ponto) 1px, transparent 0);
  background-size: 22px 22px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- barra de rolagem discreta ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--linha-forte) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--linha-forte); border-radius: var(--raio-full); border: 3px solid var(--fundo); }
*::-webkit-scrollbar-thumb:hover { background: var(--tinta-4); }

/* ---------- seleção ---------- */
::selection { background: var(--sinal); color: #fff; }
