/* ==========================================================================
   BLUNANA · WEB DS — BASE
   Reset, tipografia, layout primitives, superfícies.
   Depende de: tokens.css
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-5));
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh-relaxed);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Rede de segurança: nenhuma sangria acidental gera scroll horizontal.
     clip (não hidden) não cria contexto de rolagem, então o header sticky
     continua funcionando. */
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

/* ---------- Foco visível — nunca remover ---------- */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
.surface-blue :focus-visible,
.surface-dark :focus-visible { outline-color: var(--yellow); }

::selection { background: var(--yellow); color: var(--ink); }

/* ---------- Tipografia ---------- */
h1, h2, h3, h4 {
  font-weight: var(--fw-bold);
  letter-spacing: var(--ls-tight);
  text-wrap: balance;
  color: var(--text);
}
h1 { font-size: var(--text-5xl); line-height: var(--lh-tight); }
h2 { font-size: var(--text-4xl); line-height: var(--lh-snug); }
h3 { font-size: var(--text-2xl); line-height: var(--lh-snug); font-weight: var(--fw-semibold); }
h4 { font-size: var(--text-xl);  line-height: var(--lh-snug); font-weight: var(--fw-semibold); letter-spacing: normal; }

p { text-wrap: pretty; }
p + p { margin-top: var(--space-4); }

/* Destaque de palavra-chave no título.
   Regra herdada do deck: amarelo sobre escuro, azul sobre claro — nunca
   amarelo sobre claro (contraste 1.4:1, ilegível). A troca é automática. */
.y { color: var(--accent); }
.surface-blue .y,
.surface-dark .y { color: var(--yellow); }
.surface-yellow .y { color: var(--blue); }

/* Lead — parágrafo de abertura sob o título */
.lead {
  font-size: var(--text-lg);
  line-height: var(--lh-relaxed);
  color: var(--text-secondary);
  max-width: 62ch;
}
.surface-blue .lead,
.surface-dark .lead { color: rgba(255, 255, 255, .78); }
.surface-yellow .lead { color: var(--ink-2); }

/* Números / dados sempre em mono, com tabular figures */
.mono, .num, time, kbd { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
.surface-blue a, .surface-dark a { color: var(--yellow); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container--wide   { max-width: var(--container-wide); }
.container--narrow { max-width: var(--container-narrow); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: calc(var(--section-y) * 0.6); }

.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Colunas de prosa (cards, listas) precisam de ~40ch para não virar sanfona.
   Colapsam cedo. Dados curtos (KPIs) aguentam duas colunas até bem estreito
   — daí a variante --dense. */
@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
.grid-2--dense { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 460px) { .grid-2--dense { grid-template-columns: 1fr; } }

.grid--center { margin-inline: auto; }

/* ---------- Superfícies
   Cor = ritmo narrativo, não decoração (deck system §10).
   azul ancora · escuro tensiona · off-white respira · amarelo é clímax (1x). */
.surface-light  { background: var(--off-white); color: var(--ink); }
.surface-white  { background: var(--white); color: var(--ink); }
.surface-blue   { background: var(--blue); color: var(--white); }
.surface-dark   { background: var(--dark); color: var(--white); }
.surface-yellow { background: var(--yellow); color: var(--ink); }

.surface-blue h1, .surface-blue h2, .surface-blue h3, .surface-blue h4,
.surface-dark h1, .surface-dark h2, .surface-dark h3, .surface-dark h4 { color: var(--white); }

.surface-blue, .surface-dark {
  --line: var(--line-on-dark);
  --line-strong: var(--line-on-dark-strong);
  --text-muted: rgba(255, 255, 255, .62);
}

/* Fundo amarelo SEM as regras de texto da surface-yellow. Para quando a seção
   é só um fundo e o conteúdo vive numa superfície aninhada (ex.: card azul) —
   evita que as regras de descendente da surface-yellow vazem para dentro do
   card e conflitem com a superfície interna. */
.bg-yellow { background: var(--yellow); color: var(--ink); }

/* Textura de onda — sutil, sobre azul/escuro.
   Usa `wave-stroke.png`: o traço "n" isolado da marca. Encaixa na horizontal
   (o traço sai da borda direita onde entra na esquerda) e empilha limpo na
   vertical (bordas topo/base transparentes), dando um pattern arejado.
   Só mexa em --wave-w: a altura é derivada para preservar a proporção. */
.texture {
  position: relative;
  isolation: isolate;
  --wave-w: 300px;
  --wave-opacity: .07;
  --wave-src: url('../assets/brand/wave-stroke.png');
}
.texture::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--wave-src);
  background-size: var(--wave-w) auto;   /* auto preserva a proporção do ladrilho */
  background-repeat: repeat;
  opacity: var(--wave-opacity);
  pointer-events: none;
}
.texture--tight {
  --wave-w: 210px;
  --wave-opacity: .09;
}

/* ---------- Utilitários ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.text-center { text-align: center; }
.text-center .lead { margin-inline: auto; }

/* Revelação na entrada — com stagger opcional via --reveal-delay (o JS define
   o delay em cada filho de um grupo). Só some se o JS estiver vivo (.js). */
.js [data-reveal],
.js .reveal-item {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.js [data-reveal].is-in,
.js .reveal-item.is-in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .js [data-reveal],
  .js .reveal-item { opacity: 1; transform: none; transition: none; }
}
