/* ============================================================================
   AFRITRONIC — BASE V4
   ----------------------------------------------------------------------------
   A camada que TODAS as páginas herdam: reset, tipografia, foco, movimento.

   Não pinta nada de nenhuma página em concreto. Se uma regra aqui precisasse
   de saber «estou no /estoque/?», estaria no sítio errado.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--af-font);
  font-size: var(--af-body);
  line-height: 1.6;
  color: var(--af-text);
  background-color: var(--af-night);
  background-image: var(--af-page);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- 1. Mídia: nunca transborda, e respeita a proporção ----
   `max-width:100%` sozinho deixa as imagens altas a esticar o layout; o
   `height:auto` é o que falta na maioria dos sites. */
img, svg, video, canvas, picture {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ---- 2. Tipografia ----
   As medidas vêm dos tokens (medidas na home). O `text-wrap: balance` nos
   títulos evita a linha órfã nos telemóveis pequenos — é grátis onde é
   suportado e ignorado no resto. */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: var(--af-h2-weight);
  letter-spacing: var(--af-h2-track);
  line-height: 1.15;
  color: var(--af-ink);
  text-wrap: balance;
}
h1 {
  font-size: var(--af-h1);
  font-weight: var(--af-h1-weight);
  letter-spacing: var(--af-h1-track);
  line-height: 1.02;
}
h2 { font-size: var(--af-h2); }
h3 { font-size: 15px; letter-spacing: -0.02em; }
p  { margin: 0 0 var(--af-3); }

a {
  color: var(--af-cyan);
  text-decoration: none;
}
a:hover { text-decoration: underline; text-underline-offset: 3px; }

small, .af-small { font-size: var(--af-small); color: var(--af-muted); }

/* Números que não dançam: preços e quantidades alinham à direita do ecrã. */
.af-num { font-variant-numeric: tabular-nums; }

/* ---- 3. Foco ----
   `:focus-visible` e não `:focus`: um rato não precisa de um anel amarelo,
   um teclado precisa e não o pode perder. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--af-focus);
  outline-offset: 3px;
  border-radius: var(--af-2);
}

/* ---- 4. Formulários ----
   `font: inherit` é o que impede o iOS de fazer zoom ao focar um campo. */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button { cursor: pointer; background: none; border: 0; }

/* ---- 5. Utilitários mínimos ----
   Cinco, não cinquenta. Cada classe utilitária a mais é uma decisão de design
   tomada no HTML em vez de aqui. */
.af-shell {
  width: min(100% - 32px, var(--af-shell));
  margin-inline: auto;
}
.af-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.af-stack > * + * { margin-top: var(--af-4); }
.af-cluster { display: flex; flex-wrap: wrap; gap: var(--af-3); align-items: center; }
.af-skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--af-ocean); color: #fff;
  padding: var(--af-3) var(--af-4); border-radius: 0 0 var(--af-2) 0;
}
.af-skip:focus { left: 0; }

/* ---- 6. Movimento ----
   Quem pediu menos movimento não recebe transições NEM o deslocamento do
   hover. Desligar só a `transition` deixa o salto instantâneo, que é pior. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- 7. Impressão ----
   Há um botão «Catálogo em PDF» na loja. Em papel, fundo escuro é tinta a
   mais e texto claro é ilegível: inverte-se e tiram-se as sombras. */
@media print {
  body { background: #fff !important; color: #000; }
  h1, h2, h3, h4 { color: #000; }
  a { color: #000; text-decoration: underline; }
  .af-no-print { display: none !important; }
}
