/* =========================================================================
   BNCC API — design system compartilhado (FR-022).
   Build estático (sem CDN em runtime, research §1/§10). Estilo Minimalism/
   Swiss: tokens sóbrios, foco em legibilidade, performance e acessibilidade
   (SC-008). Uma única fonte de verdade de estilos para landing, portal,
   /guia e onboarding — sem estilos inline nos templates.
   ========================================================================= */

/* ------------------------------ Tokens ---------------------------------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --fg: #16181d;
  --fg-muted: #5b6270;
  --border: #e4e7ec;
  --brand: #1b4dff;
  --brand-strong: #1640d9;
  --brand-fg: #ffffff;
  --brand-soft: #eef2ff;
  --accent: #0d9488;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --code-bg: #0f172a;
  --code-fg: #e2e8f0;
  --code-key: #7dd3fc;
  --code-val: #86efac;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 8px 24px rgb(16 24 40 / 0.08);
  --radius: 10px;
  --maxw: 72rem;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14;
    --bg-soft: #151922;
    --fg: #e8eaed;
    --fg-muted: #9aa2b1;
    --border: #262b36;
    --brand: #5b7bff;
    --brand-strong: #7590ff;
    --brand-soft: #1a2036;
    --danger: #f97066;
    --danger-soft: #2a1715;
    --code-bg: #10141d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px rgb(0 0 0 / 0.45);
  }
}

/* ------------------------------ Base ------------------------------------ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.25rem); margin: 0 0 1rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 2.5rem 0 1rem; }
.muted { color: var(--fg-muted); }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 3rem 0; }
.section-narrow { max-width: 52rem; }
.lead { font-size: 1.25rem; color: var(--fg-muted); max-width: 42rem; }

/* Foco visível e movimento reduzido (a11y) */
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}
.btn, a, button { transition: opacity 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------------ Header ---------------------------------- */
.site-header { border-bottom: 1px solid var(--border); background: var(--bg); }
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 0; gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; width: 1.75rem; height: 1.75rem; flex: none; }
.brand-text { color: var(--fg); }
.nav-links { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.nav-links a { min-height: 44px; display: inline-flex; align-items: center; }
.nav-links a.is-active { color: var(--fg); font-weight: 600; }
.nav-github { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--fg); }
.nav-github:hover { color: var(--brand); text-decoration: none; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--brand);
  color: #fff; padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }
.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;
}

/* ------------------------------ Botões ----------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.7rem 1.2rem; border-radius: var(--radius); min-height: 44px;
  background: var(--brand); color: var(--brand-fg); font-weight: 600;
  font-size: 1rem; font-family: inherit; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer;
}
.btn:hover { text-decoration: none; background: var(--brand-strong); }
.btn-secondary { background: transparent; color: var(--brand); border-color: var(--border); }
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger); opacity: 0.88; }
.btn-lg { padding: 0.85rem 1.5rem; font-size: 1.05rem; }
.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.9rem; min-height: 36px; }
.btn-block { width: 100%; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

/* ------------------------------ Cards e grids ---------------------------- */
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; background: var(--bg-soft);
}

/* ------------------------------ Código e tabelas ------------------------- */
code, kbd, pre { font-family: var(--mono); }
pre {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; overflow-x: auto;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
th {
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--fg-muted);
}

/* ------------------------------ Formulários ------------------------------ */
form label { display: block; font-weight: 600; margin: 1rem 0 0.35rem; }
input, select, textarea {
  width: 100%; padding: 0.6rem 0.75rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--fg);
  font-size: 1rem; font-family: inherit; min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-help { color: var(--fg-muted); font-size: 0.85rem; margin: 0.35rem 0 0; }
.form-actions { margin-top: 1.5rem; }
.form-footer { color: var(--fg-muted); margin-top: 1rem; }

/* Página de autenticação (login/signup) */
.auth-wrap { max-width: 28rem; }
.auth-card { box-shadow: var(--shadow); background: var(--bg); padding: 1.5rem; }
/* Primeiro rótulo do formulário (quando não há OAuth acima) sem margem extra. */
.auth-form label:first-child { margin-top: 0; }

/* Login social (Google / GitHub) — prioridade, no topo do card */
.oauth-buttons { display: flex; flex-direction: column; gap: 0.6rem; }
.btn-oauth {
  background: var(--bg); color: var(--fg); border-color: var(--border); font-weight: 500;
}
.btn-oauth:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-oauth svg { flex: 0 0 auto; }
.oauth-divider {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--fg-muted); font-size: 0.85rem; margin: 1.25rem 0 0.5rem;
}
.oauth-divider::before, .oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* Campo com botão embutido (ex.: mostrar/ocultar senha) */
.input-affix { position: relative; }
.input-affix > input { padding-right: 3rem; }
.input-affix-btn {
  position: absolute; top: 0; right: 0; width: 2.75rem; height: 100%;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0; background: transparent; border: 0; color: var(--fg-muted); cursor: pointer;
}
.input-affix-btn:hover { color: var(--fg); }

/* ------------------------------ Badges e avisos -------------------------- */
.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.5rem;
  border-radius: 999px; background: var(--accent); color: #fff; vertical-align: middle;
}
.badge-muted { background: var(--border); color: var(--fg-muted); }
.notice {
  border-left: 3px solid var(--accent); background: var(--bg-soft);
  padding: 0.75rem 1rem; border-radius: 6px; margin: 1rem 0;
}
.notice-danger { border-left-color: var(--danger); background: var(--danger-soft); }

/* =========================================================================
   Landing comercial (v2)
   ========================================================================= */
.eyebrow {
  display: inline-block; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--brand); background: var(--brand-soft); border: 1px solid var(--border);
  padding: 0.25rem 0.75rem; border-radius: 999px; margin: 0 0 1rem;
}
.hero { padding: 4rem 0 3rem; }
.hero-grid {
  display: grid; gap: 2.5rem; align-items: center;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
@media (max-width: 820px) { .hero-grid { grid-template-columns: 1fr; } }
.hero-note { font-size: 0.9rem; margin-top: 0.5rem; }

/* Janela de código */
.code-window {
  background: var(--code-bg); color: var(--code-fg); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden;
  font-size: 0.88rem;
}
.code-window pre { background: transparent; border: 0; margin: 0; padding: 1.1rem 1.25rem; }
.code-window code { color: var(--code-fg); }
.code-window-bar {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.65rem 1rem; border-bottom: 1px solid rgb(255 255 255 / 0.08);
}
.code-window-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: rgb(255 255 255 / 0.22); }
.code-window-title { margin-left: 0.5rem; font-family: var(--mono); font-size: 0.8rem; color: rgb(255 255 255 / 0.65); }
.tk { color: var(--code-key); }
.tv { color: var(--code-val); }

/* Faixa de números */
.stat-strip { background: var(--bg-soft); border-block: 1px solid var(--border); }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem; padding: 1.75rem 1.25rem; text-align: center;
}
.stat strong { display: block; font-size: 1.9rem; letter-spacing: -0.02em; color: var(--fg); }
.stat span { color: var(--fg-muted); font-size: 0.95rem; }

/* Casos de uso */
.uc-grid { grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); margin-top: 1.5rem; }
.uc-card { display: flex; flex-direction: column; gap: 0.35rem; box-shadow: none; }
.uc-card h3 { margin: 0.25rem 0 0; font-size: 1.12rem; }
.uc-card p:last-child { margin-top: auto; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.uc-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.6rem; height: 2.6rem; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand);
}
.uc-icon svg { width: 1.4rem; height: 1.4rem; }
.endpoint {
  display: inline-block; font-size: 0.78rem; padding: 0.2rem 0.55rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--fg-muted); white-space: nowrap; max-width: 100%; overflow: hidden;
  text-overflow: ellipsis;
}
.uc-card-cta { border-style: dashed; align-items: flex-start; justify-content: center; }

/* Passos */
.steps-grid { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 1.5rem 0; }
.step { position: relative; padding-top: 1.5rem; }
.step-num {
  position: absolute; top: -1.1rem; left: 1.1rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  background: var(--brand); color: var(--brand-fg); font-weight: 700;
}
.curl-block { font-size: 0.88rem; }

/* FAQ */
.faq-list { max-width: 52rem; display: grid; gap: 0.75rem; margin-top: 1.5rem; }
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft);
}
.faq-item summary {
  cursor: pointer; font-weight: 600; padding: 1rem 1.25rem;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: ""; flex: none; width: 0.6rem; height: 0.6rem;
  border-right: 2px solid var(--fg-muted); border-bottom: 2px solid var(--fg-muted);
  transform: rotate(45deg); transition: transform 0.18s ease;
}
.faq-item[open] summary::after { transform: rotate(-135deg); }
.faq-item p { margin: 0; padding: 0 1.25rem 1rem; color: var(--fg-muted); }

/* Apoie o projeto */
.sponsor-section { background: var(--bg-soft); border-block: 1px solid var(--border); }
.sponsor-grid { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); margin-top: 1.5rem; }
.sponsor-card { background: var(--bg); display: flex; flex-direction: column; gap: 0.5rem; }
.sponsor-card h3 { margin: 0.25rem 0 0; }
.sponsor-card .btn { align-self: flex-start; }
.pix-qr {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  padding: 6px; image-rendering: pixelated;
}
.pix-copy { display: flex; flex-direction: column; gap: 0.5rem; }
.pix-copy code {
  font-size: 0.72rem; word-break: break-all; color: var(--fg-muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.5rem 0.6rem; display: block;
}
.pix-copy .btn { align-self: flex-start; }

/* CTA final */
.cta-final { text-align: center; }
.cta-final .lead { margin-inline: auto; }
.cta-final .cta-row { justify-content: center; }

/* ------------------------------ Rodapé ----------------------------------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg); color: var(--fg-muted); }
.footer-grid {
  display: grid; gap: 2rem;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
}
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-title { font-weight: 700; color: var(--fg); margin: 0 0 0.5rem; }
.footer-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.footer-links a { color: var(--fg-muted); }
.footer-links a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--border); padding: 1rem 1.25rem; font-size: 0.9rem; }

/* =========================================================================
   Painel do portal
   ========================================================================= */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.page-header h1 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); }
.account-line { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }
.metric { display: grid; gap: 0.15rem; }
.metric-label { color: var(--fg-muted); font-size: 0.9rem; margin: 0; }
.metric-value {
  font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; margin: 0;
  font-variant-numeric: tabular-nums;
}
.key-reveal { margin: 0.5rem 0; }
.key-reveal pre { margin: 0; }
.empty-state {
  border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 2rem 1.5rem; text-align: center; color: var(--fg-muted);
}
.inline-form { margin: 0; }
.key-form { margin-bottom: 1.5rem; }
.key-form label { margin-top: 0; }

/* =========================================================================
   Onboarding do portal — wizard de uma pergunta por vez.
   ========================================================================= */
.onb-wrap { max-width: 34rem; }
.onb-progress { margin: 0.25rem 0 1.25rem; }
.onb-progress-label {
  margin: 0 0 0.4rem; font-size: 0.85rem; font-weight: 600;
  color: var(--fg-muted); letter-spacing: 0.02em;
}
.onb-bar {
  height: 0.4rem; border-radius: 999px; background: var(--border); overflow: hidden;
}
.onb-bar-fill {
  display: block; height: 100%; border-radius: inherit; background: var(--brand);
  transition: width 0.25s ease-out;
}
.onb-card {
  padding: 1.75rem 1.5rem; box-shadow: var(--shadow);
  animation: onb-in 0.22s ease-out;
}
@keyframes onb-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.onb-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.onb-title {
  padding: 0; font-size: 1.45rem; font-weight: 700;
  line-height: 1.25; letter-spacing: -0.02em;
}
.onb-subtitle { margin: 0.5rem 0 1.25rem; }
.onb-error { margin: 0 0 1rem; }
.onb-options { display: grid; gap: 0.65rem; }
.onb-option {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.85rem 1rem; min-height: 44px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; font-weight: 400; margin: 0;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.onb-option:hover { border-color: var(--brand); }
.onb-option:has(input:checked) {
  border-color: var(--brand); background: var(--brand-soft);
}
.onb-option:has(input:focus-visible) {
  outline: 3px solid var(--brand); outline-offset: 2px;
}
.onb-option input {
  width: 1.15rem; height: 1.15rem; flex: none; margin: 0.2rem 0 0;
  min-height: 0;
  accent-color: var(--brand); cursor: pointer;
}
.onb-option-body { display: grid; gap: 0.1rem; }
.onb-option-body .muted { font-size: 0.9rem; line-height: 1.45; }
.onb-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-top: 1.5rem;
}
.onb-note { font-size: 0.9rem; margin-top: 1.25rem; }

/* =========================================================================
   Hub de documentação (/guia) — layout de duas colunas com sumário fixo.
   ========================================================================= */
.docs-layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.5rem;
  padding-top: 2.5rem;
  padding-bottom: 3.5rem;
  align-items: start;
}
.docs-sidebar {
  position: sticky;
  top: 1.5rem;
  align-self: start;
}
.docs-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.docs-nav-title {
  margin: 1.25rem 0 0.4rem; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted);
}
.docs-nav-title:first-child { margin-top: 0; }
.docs-nav a {
  display: block; padding: 0.4rem 0.7rem; border-radius: 8px;
  color: var(--fg-muted); font-size: 0.95rem; border-left: 2px solid transparent;
}
.docs-nav a:hover { color: var(--brand); background: var(--bg-soft); text-decoration: none; }
.docs-nav a:target,
.docs-nav a.is-active {
  color: var(--brand); background: var(--brand-soft); border-left-color: var(--brand);
}
.docs-nav-ext { color: var(--brand) !important; font-weight: 500; }

.docs-content { min-width: 0; max-width: 48rem; }
.docs-content h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0.5rem 0 1rem; }
.docs-content .eyebrow { margin-bottom: 0.75rem; }
.docs-section { scroll-margin-top: 1.5rem; }
.docs-section + .docs-section { margin-top: 3rem; padding-top: 2.5rem; border-top: 1px solid var(--border); }
.docs-content h2 { margin-top: 0; }
.docs-content h3 { font-size: 1.1rem; margin: 1.75rem 0 0.5rem; }
.docs-content pre { font-size: 0.9rem; }
.docs-content table { margin: 1.25rem 0; font-size: 0.95rem; }

@media (max-width: 860px) {
  .docs-layout { grid-template-columns: 1fr; gap: 1rem; }
  .docs-sidebar {
    position: static; border-bottom: 1px solid var(--border);
    padding-bottom: 1rem; margin-bottom: 1rem;
  }
  .docs-nav { flex-flow: row wrap; gap: 0.35rem; }
  .docs-nav-title { width: 100%; margin: 0.5rem 0 0.1rem; }
  .docs-nav a { border-left: 0; padding: 0.35rem 0.6rem; border: 1px solid var(--border); }
  .docs-nav a:target, .docs-nav a.is-active { border-color: var(--brand); }
}
