/* =====================================================================
   BASE — usada pelo site E pelo painel
   ---------------------------------------------------------------------
   Organizado em "camadas" (@layer): regras de uma camada posterior
   sempre vencem as anteriores, sem brigas de especificidade.
     tokens  -> cores, fontes, espaçamentos (mude a identidade aqui)
     reset   -> zera diferenças entre navegadores
     base    -> tipografia e elementos HTML
     ui      -> componentes reutilizáveis (botões, campos, selos...)
   ===================================================================== */
@layer tokens, reset, base, ui, layout, pages;

@layer tokens {
  :root {
    /* Cores — inspiradas na marca (azul) e no ipê-amarelo da região */
    --ink: #0d2440;          /* azul-noite: títulos, rodapé, fundos escuros */
    --blue: #0b5fa5;         /* azul Dimensão: links e botões principais */
    --blue-dark: #084a82;
    --sky: #e9f1f8;          /* azul bem claro: fundos de destaque */
    --ipe: #f4b41a;          /* ipê-amarelo: chamada para ação em fundo escuro */
    --ipe-dark: #d99c05;
    --paper: #fafbfc;        /* fundo das páginas */
    --white: #fff;
    --text: #1c2733;
    --muted: #5d6b7b;
    --line: #dce3ea;
    --success: #1d7a46;
    --danger: #b42318;
    --whatsapp: #1fa855;

    /* Tipografia — uma família (Archivo) em duas larguras */
    --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --wide: 112;             /* largura "expandida" para títulos */
    --step--1: 0.8125rem;    /* 13px */
    --step-0: 1rem;          /* 16px texto */
    --step-1: 1.25rem;       /* 20px */
    --step-2: 1.5625rem;     /* 25px */
    --step-3: 1.9375rem;     /* 31px */
    --step-4: 2.4375rem;     /* 39px */
    --step-5: clamp(2.25rem, 1.6rem + 2.8vw, 3.8rem); /* título principal */

    /* Espaços (múltiplos de 4px) */
    --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem;
    --s-5: 1.5rem; --s-6: 2rem; --s-7: 3rem; --s-8: 4.5rem; --s-9: 7rem;

    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 14px;
    --container: 1200px;
    --header-h: 72px;
    --focus: 0 0 0 3px rgba(11, 95, 165, 0.35);
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; }
  img, svg, video { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; }
  table { border-collapse: collapse; }
  [hidden] { display: none !important; }
}

@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
  body {
    font-family: var(--font);
    font-size: var(--step-0);
    line-height: 1.6;
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3, h4 {
    font-variation-settings: 'wdth' var(--wide);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.015em;
    color: var(--ink);
    text-wrap: balance;
  }
  h1 { font-size: var(--step-4); }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-1); }
  p { text-wrap: pretty; }
  a { color: var(--blue); text-underline-offset: 0.18em; }
  a:hover { color: var(--blue-dark); }
  :focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }
  ::selection { background: var(--ipe); color: var(--ink); }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }
}

@layer ui {
  .icon {
    width: 1.25em; height: 1.25em; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .container { width: min(100% - 2.5rem, var(--container)); margin-inline: auto; }

  /* ---------- Botões ---------- */
  .btn {
    --btn-bg: var(--white); --btn-fg: var(--ink); --btn-border: var(--line);
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-height: 44px; padding: 0 var(--s-5);
    border: 1px solid var(--btn-border); border-radius: var(--radius);
    background: var(--btn-bg); color: var(--btn-fg);
    font-weight: 600; font-size: 0.9375rem; text-decoration: none; white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  }
  .btn:hover { --btn-border: #b9c6d3; color: var(--btn-fg); }
  .btn:disabled, .btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; }
  .btn--primary { --btn-bg: var(--blue); --btn-fg: var(--white); --btn-border: var(--blue); }
  .btn--primary:hover { --btn-bg: var(--blue-dark); --btn-border: var(--blue-dark); }
  .btn--ipe { --btn-bg: var(--ipe); --btn-fg: var(--ink); --btn-border: var(--ipe); }
  .btn--ipe:hover { --btn-bg: var(--ipe-dark); --btn-border: var(--ipe-dark); }
  .btn--whatsapp { --btn-bg: var(--whatsapp); --btn-fg: var(--white); --btn-border: var(--whatsapp); }
  .btn--whatsapp:hover { --btn-bg: #178a45; --btn-border: #178a45; }
  .btn--danger { --btn-fg: var(--danger); }
  .btn--danger:hover { --btn-bg: #fdf0ef; --btn-border: var(--danger); }
  .btn--ghost { --btn-bg: transparent; --btn-border: transparent; }
  .btn--ghost:hover { --btn-bg: var(--sky); --btn-border: transparent; }
  .btn--small { min-height: 36px; padding: 0 var(--s-3); font-size: var(--step--1); }
  .btn--block { width: 100%; }
  .btn--icon { padding: 0; width: 44px; }
  .btn--icon.btn--small { width: 36px; }

  /* ---------- Campos de formulário ---------- */
  .field { display: grid; gap: var(--s-1); align-content: start; }
  .field > span, .field-label { font-size: var(--step--1); font-weight: 600; color: var(--ink); }
  .field small { color: var(--muted); font-size: var(--step--1); }
  .input {
    width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3);
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--white); color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .input:hover { border-color: #b9c6d3; }
  .input:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
  .input:user-invalid { border-color: var(--danger); }
  textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
  select.input {
    appearance: none; padding-right: 2.25rem;
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6b7b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.75rem center / 1rem;
  }
  .check { display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; }
  .check input { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }
  .honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

  /* ---------- Selos ---------- */
  .tag {
    display: inline-flex; align-items: center; gap: var(--s-1);
    padding: 0.15rem 0.55rem; border-radius: 999px;
    background: var(--sky); color: var(--ink); font-size: var(--step--1); font-weight: 600; line-height: 1.5;
  }
  .tag--ipe { background: var(--ipe); }
  .tag--success { background: #e3f4ea; color: var(--success); }
  .tag--muted { background: #eef1f4; color: var(--muted); }
  .tag--danger { background: #fdecea; color: var(--danger); }

  /* ---------- Avisos de formulário ---------- */
  .notice { padding: var(--s-3) var(--s-4); border-radius: var(--radius); font-size: 0.9375rem; }
  .notice--success { background: #e3f4ea; color: var(--success); }
  .notice--error { background: #fdecea; color: var(--danger); }
  .notice--info { background: var(--sky); color: var(--ink); }

  /* ---------- Janela (dialog nativo do HTML) ---------- */
  dialog { border: 0; padding: 0; color: var(--text); background: var(--white); border-radius: var(--radius-lg); max-width: min(100% - 2rem, 640px); max-height: calc(100dvh - 2rem); }
  dialog::backdrop { background: rgba(13, 36, 64, 0.6); }
  dialog[open] { animation: dialog-in 0.2s var(--ease); }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(8px); } }

  /* ---------- Carregando e vazio ---------- */
  .loading { display: grid; place-items: center; gap: var(--s-3); padding: var(--s-8) var(--s-4); color: var(--muted); grid-column: 1 / -1; }
  .loading::before {
    content: ''; width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--blue); animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .empty { padding: var(--s-7) var(--s-4); text-align: center; color: var(--muted); grid-column: 1 / -1; }
  .empty strong { display: block; color: var(--ink); font-size: var(--step-1); margin-bottom: var(--s-2); }
}
