/* ═══════════════════════════════════════════════════════════════════════════
   ZiulHub — Base
   Reset universal, elementos HTML base, :focus-visible global, skip-link.
   Depende de tokens.css (precisa carregar depois).
   ═══════════════════════════════════════════════════════════════════════════ */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-md);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background: var(--color-background);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

/* ── Tipografia de elementos HTML ──────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  line-height: var(--line-height-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }
h6 { font-size: var(--font-size-sm); }

p {
  line-height: var(--line-height-base);
}

small {
  font-size: var(--font-size-sm);
}

/* ── :focus-visible global (acessibilidade por teclado) ────────────────── */
*:focus {
  outline: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: inherit;
}

/* Inputs que já usam outline custom (datepickers, etc.) mantém border */

/* ── Skip link (primeiro tab pula para main) ───────────────────────────── */
.skip-link {
  position: fixed;
  top: calc(var(--space-2) * -1 - 50px);
  left: var(--space-4);
  background: var(--color-surface);
  color: var(--color-text-primary);
  padding: var(--space-3) var(--space-5);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  z-index: var(--z-tooltip);
  transition: top var(--motion-fast) var(--ease-standard);
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-3);
}

/* ── Utilitário: screen-reader only ────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Utilitário: valores tabulares (para alinhar números em tabelas) ──── */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* ── iOS-safe: evitar zoom de input em iPad com font-size < 16px ──────── */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: max(16px, var(--font-size-md));
  }
  /* Override interno: campos dentro de tabelas legais mantêm 13px
     porque são em contexto de preenchimento rápido e sem teclado frequente */
  .pd-input, .pi-input, .pi-textarea, .tl-input, .cit-input, .wf-input {
    font-size: var(--font-size-md);
  }
}
