/**
 * base.css — Reset + grid de layout responsivo (LJSSoftware)
 *
 * Fonte: .md/TASK.md T1.3 + .md/UX-SPEC.md Seção 6 (Comportamento
 * Responsivo). Breakpoints (mobile-first, min-width):
 *   - Mobile (base):  360px – 767px  -> 1 coluna
 *   - Tablet:         768px – 1023px -> 2 colunas
 *   - Desktop:        >= 1024px      -> 3 colunas
 *
 * Reutiliza `--color-bg` já declarado em `tokens.css` (T1.1) — nenhum token
 * de cor é redefinido aqui. `tokens.css` deve ser carregado antes deste
 * arquivo em qualquer página consumidora.
 *
 * RF-06/RNF (UX-SPEC.md Seção 6): mínimo 360px, sem rolagem horizontal, sem
 * sobreposição de elementos, em qualquer largura entre os breakpoints.
 */

/* -------------------------------------------------------------------- */
/* Reset básico                                                          */
/* -------------------------------------------------------------------- */

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

* {
  margin: 0;
  padding: 0;
}

html {
  /* Evita rolagem horizontal por overflow acidental de qualquer elemento
     filho (ex.: forma decorativa mal posicionada) */
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@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;
    scroll-behavior: auto !important;
  }
}

body {
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
  background: var(--color-bg);
  font-family: var(--font-body, system-ui, sans-serif);
  line-height: 1.5;
  text-rendering: optimizeSpeed;
}

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

ul,
ol {
  list-style: none;
}

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

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

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

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: inherit;
  line-height: 1.2;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* Acessibilidade: skip link e classe utilitária "somente leitor de tela"
   (usadas em T2.1, disponíveis desde já como base) */
.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;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 1000;
  padding: 0.75em 1em;
  background: var(--color-accent, #7FE3D2);
  color: var(--color-bg, #0B2545);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* Foco de teclado sempre visível — nunca `outline: none` sem substituto
   (TASK.md Seção 1.2 / UX-SPEC.md Seção 5). Componentes sobre o header
   branco sobrescrevem a cor de foco com contraste equivalente (ver T4.2). */
:focus-visible {
  outline: 2px solid var(--color-accent, #7FE3D2);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------- */
/* Container                                                             */
/* -------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 768px) {
  .container {
    padding-inline: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-inline: 2rem;
  }
}

/* -------------------------------------------------------------------- */
/* Grid responsivo                                                       */
/* -------------------------------------------------------------------- */

/**
 * Grid genérico mobile-first. Uso:
 *   <div class="grid grid--3col">...</div>
 *
 * Modificadores de coluna alvo em desktop (>=1024px):
 *   .grid--2col -> 1 / 2 / 2 colunas (mobile / tablet / desktop)
 *   .grid--3col -> 1 / 2 / 3 colunas (mobile / tablet / desktop) — grid de
 *                  apps (UX-SPEC.md Seção 6)
 *
 * Em todos os casos, base mobile é 1 coluna (UX-SPEC.md: "grid de apps em 1
 * coluna" no breakpoint mobile).
 */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
}

@media (min-width: 768px) {
  .grid--2col,
  .grid--3col {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .grid--3col {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Empilhamento vertical explícito (ex.: rodapé em mobile, UX-SPEC.md Seção
   6: "rodapé empilhado verticalmente") — reaproveita o mesmo grid de 1
   coluna da base, com espaçamento menor. */
.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

@media (min-width: 768px) {
  .stack--row-tablet-up {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
