/* =============================================================================
   NAVEC LABS — BASE
   Reset enxuto, elementos, layout de seção e utilitários mínimos.
   Depende de tokens.css. Nenhum valor bruto aqui.
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Âncora não some atrás do cabeçalho fixo */
  scroll-padding-top: calc(var(--header-h) + var(--space-s));
  -moz-tab-size: 2;
  tab-size: 2;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  min-height: 100svh;
  font-family: var(--font-text);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: var(--leading-normal);
  color: var(--text);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;

  /* clip, não hidden: barra a rolagem horizontal sem criar contexto de
     rolagem, o que quebraria position:sticky nos filhos. */
  overflow-x: clip;
}

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

img, video {
  height: auto;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: 0; }

textarea { resize: vertical; }

ul[class], ol[class] { list-style: none; padding: 0; }

/* ==========================================================================
   Tipografia dos elementos
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--text-strong);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  font-variation-settings: 'wdth' var(--wdth-normal);
}

/* Escala única de títulos. Se você está pensando em sobrescrever font-size de
   h1 ou h2 numa página, não: o check-chrome.py acusa. */
h1 { font-size: var(--step-h1); font-weight: 900; line-height: var(--leading-display); }
h2 { font-size: var(--step-h2); font-weight: 900; line-height: var(--leading-title); }
h3 { font-size: var(--step-2); font-weight: 800; }
h4 { font-size: var(--step-1); font-weight: 800; }
h5, h6 { font-size: var(--step-0); font-weight: 700; }

p { text-wrap: pretty; }

strong, b { font-weight: 700; color: var(--text-strong); }

a {
  color: var(--accent);
  text-decoration-thickness: max(1px, 0.06em);
  text-underline-offset: 0.18em;
  transition: color var(--dur-fast) var(--ease);
}

a:hover { color: var(--text-strong); }

::selection {
  background-color: var(--navec-pink);
  color: var(--neutral-0);
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

hr {
  border: 0;
  border-top: var(--hairline) solid var(--border);
  margin-block: var(--space-l);
}

/* ==========================================================================
   Foco — desenhado, nunca o outline apagado do navegador
   ========================================================================== */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-xs);
  box-shadow: 0 0 0 6px var(--focus-ring-halo);
}

/* ==========================================================================
   Pular para o conteúdo
   ========================================================================== */
.skip-link {
  position: absolute;
  top: var(--space-2xs);
  left: var(--space-2xs);
  z-index: var(--z-skip);
  padding: var(--space-2xs) var(--space-s);
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  background: var(--navec-void);
  color: var(--neutral-0);
  font-weight: 700;
  border-radius: var(--radius-s);
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--dur-fast) var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
  color: var(--neutral-0);
}

/* ==========================================================================
   Barra de rolagem
   ========================================================================== */
@supports (scrollbar-color: auto) {
  html { scrollbar-color: var(--navec-purple) var(--navec-dark); }
}

@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--navec-dark); }
  ::-webkit-scrollbar-thumb {
    background: var(--navec-purple);
    border-radius: var(--radius-pill);
    border: 2px solid var(--navec-dark);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--navec-nebula); }
}

/* ==========================================================================
   Layout — seção e container
   ========================================================================== */
.section {
  position: relative;
  padding-block: var(--section-y);
  background-color: var(--surface);
  color: var(--text);
  isolation: isolate;
}

/* Quem redefine os tokens também PINTA.
   Sem isto, um elemento com .section--dark mas sem .section trocava as
   variáveis e continuava com fundo claro — texto branco sobre branco.
   Foi o que aconteceu com a hero e com a faixa do marquee. */
.section--dark,
.section--light,
.section--deep {
  background-color: var(--surface);
  color: var(--text);
}

.section--tight { padding-block: var(--section-y-tight); }
.section--flush-top { padding-block-start: 0; }
.section--flush-bottom { padding-block-end: 0; }

.container {
  position: relative;
  width: min(100% - (var(--gutter) * 2), var(--container));
  margin-inline: auto;
}

/* O conteúdo sobe acima dos ornamentos de fundo (que ficam em z-index 0).
   Ver "CONTRATO DOS ORNAMENTOS" em components.css. */
.section > .container,
.section > .container--wide,
.section > .container--prose { z-index: 1; }

.container--wide { width: min(100% - (var(--gutter) * 2), var(--container-wide)); }
.container--prose { width: min(100% - (var(--gutter) * 2), var(--container-prose)); }

/* Pilha vertical com ritmo consistente */
.stack > * + * { margin-block-start: var(--flow, var(--space-s)); }
.stack--s  { --flow: var(--space-2xs); }
.stack--m  { --flow: var(--space-m); }
.stack--l  { --flow: var(--space-l); }

/* Grade que se adapta sozinha, sem breakpoint */
.grid-auto {
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--col-min, 17rem)), 1fr));
}

/* Blocos largos rolam dentro de si, nunca empurram a página */
.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Corpo de artigo — medida confortável
   ========================================================================== */
.prose {
  max-width: var(--measure);
  font-size: var(--step-0);
  line-height: var(--leading-relaxed);
  color: var(--text);
}

.prose > * + * { margin-block-start: var(--space-s); }
.prose h2 { font-size: var(--step-3); margin-block-start: var(--space-xl); }
.prose h3 { font-size: var(--step-1); margin-block-start: var(--space-l); }
.prose ul, .prose ol { padding-inline-start: var(--space-m); }
.prose li + li { margin-block-start: var(--space-2xs); }
.prose a { font-weight: 600; }

/* ==========================================================================
   Utilitários
   ========================================================================== */
.visually-hidden:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.text-center { text-align: center; }
.measure { max-width: var(--measure); }
.measure-narrow { max-width: var(--measure-narrow); }

/* Gradiente assinatura atravessando o texto */
.text-gradient {
  background-image: var(--grad-signature);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Fallback: se background-clip:text não pintar, o texto não some */
  -webkit-text-fill-color: transparent;
}

@supports not ((-webkit-background-clip: text) or (background-clip: text)) {
  .text-gradient {
    background-image: none;
    color: var(--accent);
    -webkit-text-fill-color: currentColor;
  }
}

/* Sublinhado grosso marcando a palavra-chave, como nos posts */
.text-marked {
  background-image: var(--grad-signature);
  background-repeat: no-repeat;
  background-position: 0 88%;
  background-size: 100% 0.22em;
  padding-inline: 0.06em;
}

.italic-display {
  font-style: italic;
  font-variation-settings: 'wdth' var(--wdth-condensed);
}

/* ==========================================================================
   Imagens — CLS zero
   ========================================================================== */
.media {
  display: block;
  width: 100%;
  aspect-ratio: var(--ratio, 16 / 9);
  object-fit: cover;
  background-color: var(--surface-sunken);
  border-radius: var(--radius-m);
}

.ratio-square { --ratio: 1; }
.ratio-portrait { --ratio: 4 / 5; }
.ratio-wide { --ratio: 21 / 9; }

/* ==========================================================================
   Impressão
   ========================================================================== */
@media print {
  .site-header, .site-footer, .float-cta, .read-progress, .noise, canvas { display: none !important; }
  .section { padding-block: 1rem; }
  body { color: #000; background: #fff; }
}
