/* Documentação pública (docs.finstat.com.br). CSS puro, sem Tailwind: páginas estáticas geradas
   por scripts/build-docs.ts. Paleta e fonte de docs/identidade-visual.md; terracota só no
   símbolo, vermelho só em erro. Tema segue prefers-color-scheme; data-theme vem do docs.js. */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("pjs-var.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #faf9f8;
  --work: #eceae7;
  --surface: #ffffff;
  --text: #201e1d;
  --muted: #625b55;
  --line: #ded7cf;
  --line-strong: #aba198;
  --hover: #e9e5df;
  --logo: #b8442a;
  --focus: #625b55;
  --ok-text: #2b6b45;
  --ok-bg: #e3f1e8;
  --error-text: #a3261b;
  --error-bg: #fbe9e7;
  --code-bg: #24201d;
  --code-head: #2f2a26;
  --code-text: #eee6e0;
  --code-muted: #b1aaa4;
  --inline-code: #f1eeea;
  --code-border: transparent;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --topbar: 3.5rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18120e;
    --work: #0d0905;
    --surface: #211a15;
    --text: #eee6e0;
    --muted: #b1aaa4;
    --line: #3a312a;
    --line-strong: #5a5048;
    --hover: #342e28;
    --logo: #e08a68;
    --focus: #b1aaa4;
    --ok-text: #8fcfa5;
    --ok-bg: #1f3326;
    --error-text: #f2a39a;
    --error-bg: #3a1d19;
    --code-bg: #16100c;
    --code-head: #211a15;
    --code-border: #3a312a;
    --inline-code: #2a221c;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #18120e;
  --work: #0d0905;
  --surface: #211a15;
  --text: #eee6e0;
  --muted: #b1aaa4;
  --line: #3a312a;
  --line-strong: #5a5048;
  --hover: #342e28;
  --logo: #e08a68;
  --focus: #b1aaa4;
  --ok-text: #8fcfa5;
  --ok-bg: #1f3326;
  --error-text: #f2a39a;
  --error-bg: #3a1d19;
  --code-bg: #16100c;
  --code-head: #211a15;
  --code-border: #3a312a;
  --inline-code: #2a221c;
  color-scheme: dark;
}

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

html {
  scroll-padding-top: calc(var(--topbar) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-color: currentColor;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 20;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
}
.skip:focus {
  left: 0.5rem;
}

/* Barra superior */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar);
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.05em;
  text-decoration: none;
}
.brand svg {
  color: var(--logo);
}
.brand-docs {
  color: var(--muted);
  font-weight: 500;
  letter-spacing: -0.02em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}
.topbar-link {
  color: var(--muted);
  text-decoration: none;
}
.topbar-link:hover {
  color: var(--text);
}
.icon-button {
  min-height: 2rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.icon-button:hover {
  background: var(--hover);
}

/* Estrutura */
.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 1.5rem 1rem 3rem 1.25rem;
  border-right: 1px solid var(--line);
  font-size: 0.9rem;
}
.nav-title {
  margin: 1.25rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.nav-title:first-child {
  margin-top: 0;
}
.sidebar ul,
.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
}
.sidebar a:hover {
  background: var(--hover);
  color: var(--text);
}
.sidebar a[aria-current="page"] {
  background: var(--hover);
  color: var(--text);
  font-weight: 600;
}
.nav-method {
  min-width: 2.6rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 46rem) 13rem;
  gap: 3rem;
  padding: 2.5rem 2.5rem 5rem;
}
.main-wide {
  display: block;
  padding: 0;
}

/* Texto dos guias */
.prose h1 {
  margin: 0 0 1rem;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.prose h2,
.op-doc h2 {
  margin: 2.5rem 0 0.75rem;
  font-size: 1.4rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.prose h3,
.op-doc h3 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.05rem;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1rem;
}
.prose ul:not(.terms),
.prose ol {
  display: grid;
  gap: 0.3rem;
}
.prose > p:first-of-type {
  color: var(--muted);
  font-size: 1.1rem;
}
code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--inline-code);
  font-family: var(--mono);
  font-size: 0.86em;
}
.note {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
.note p {
  margin: 0;
}
.table {
  margin: 0 0 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th,
td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--surface);
  font-weight: 600;
}
tr:last-child td {
  border-bottom: 0;
}
td code {
  white-space: nowrap;
}

.toc {
  position: sticky;
  top: calc(var(--topbar) + 2.5rem);
  align-self: start;
  font-size: 0.85rem;
}
.toc a {
  display: block;
  padding: 0.2rem 0;
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover {
  color: var(--text);
}

/* Código */
/* Realce de sintaxe (classes do highlight.js geradas no build). O fundo do código é escuro nos
   dois temas; cores mornas e neutras da identidade: sem terracota (só o símbolo) e sem vermelho
   (só erros). Contraste >= 4.5:1 sobre --code-bg nos dois temas. */
.hljs-comment,
.hljs-quote {
  color: #9a918a;
  font-style: italic;
}
.hljs-keyword,
.hljs-built_in,
.hljs-selector-tag,
.hljs-meta .hljs-keyword {
  color: #d9b98c;
}
.hljs-string,
.hljs-template-string,
.hljs-regexp,
.hljs-addition {
  color: #b8cb9c;
}
.hljs-number,
.hljs-literal,
.hljs-symbol {
  color: #92c1cf;
}
.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-variable,
.hljs-params {
  color: #e5d4bb;
}
.hljs-title,
.hljs-title.function_,
.hljs-title.class_,
.hljs-section {
  color: #f1e6d6;
  font-weight: 600;
}
.hljs-meta,
.hljs-punctuation,
.hljs-operator {
  color: var(--code-muted);
}
.hljs-subst {
  color: var(--code-text);
}

.code {
  margin: 0 0 1.25rem;
  overflow: hidden;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: var(--code-head);
  color: var(--code-muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.copy {
  padding: 0.15rem 0.5rem;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 5px;
  background: transparent;
  color: var(--code-muted);
  font: inherit;
  cursor: pointer;
}
.copy:hover {
  color: var(--code-text);
  border-color: rgb(255 255 255 / 0.4);
}
.code pre {
  margin: 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.6;
}
.code code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}
.tabs {
  margin: 0 0 1.25rem;
}
.tabs .code {
  margin: 0;
}
/* Sem JS: painéis empilhados, cada um com o rótulo no cabeçalho. */
.tabs .tab-panel + .tab-panel {
  margin-top: 0.75rem;
}
.js .tabs {
  overflow: hidden;
  border: 1px solid var(--code-border);
  border-radius: 8px;
  background: var(--code-bg);
}
.js .tabs .tab-panel + .tab-panel {
  margin-top: 0;
}
.js .tabs .code {
  border: 0;
  border-radius: 0;
}
.tab-list {
  display: flex;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem 0;
  background: var(--code-head);
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}
.tab-list[hidden] {
  display: none;
}
.tab-list button {
  padding: 0.35rem 0.7rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--code-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-list button[aria-selected="true"] {
  color: var(--code-text);
  border-bottom-color: var(--code-text);
}
.js .tabs {
  position: relative;
}
/* Com abas, o rótulo já está na aba; o cabeçalho vira só o botão de copiar, sobre a barra. */
.js .tabs .code-head {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  padding: 0;
  background: none;
}
.js .tabs .code-head span {
  display: none;
}

/* Referência: três colunas (navegação, texto, código) */
.op {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}
.op-doc {
  padding: 2.5rem 2.5rem 3rem;
  max-width: 44rem;
}
.op-doc h2:first-child {
  margin-top: 0;
}
.op-code {
  padding: 2.5rem 2rem 3rem;
  background: var(--work);
}
/* Respostas longas (histórico) rolam dentro do bloco para o código acompanhar o texto. */
.op-code pre {
  max-height: 28rem;
}
.sticky {
  position: sticky;
  top: calc(var(--topbar) + 1.5rem);
}
.ref-group {
  margin: 0;
  padding: 2.5rem 2.5rem 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}
.endpoint code {
  font-size: 0.9rem;
}
.method {
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
}
.scope {
  color: var(--muted);
  font-size: 0.9rem;
}
.fields {
  margin: 0;
  border-top: 1px solid var(--line);
}
.field {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.field dt {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.field dt code {
  padding: 0;
  background: none;
  font-weight: 600;
}
.field dd {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.field dd p {
  margin: 0.25rem 0 0;
}
.type {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}
.req {
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.notes {
  font-size: 0.85rem;
}
.responses {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.responses li {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.status {
  align-self: start;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}
.status-error {
  background: var(--error-bg);
  color: var(--error-text);
}

/* Termos */
.terms {
  columns: 2;
  column-gap: 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}
.terms li {
  break-inside: avoid;
  margin: 0 0 0.3rem;
}
.count {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* Telas médias: referência empilha código abaixo do texto */
@media (max-width: 75rem) {
  .main {
    grid-template-columns: minmax(0, 46rem);
  }
  .toc {
    display: none;
  }
  .op {
    grid-template-columns: minmax(0, 1fr);
  }
  .op-doc {
    max-width: none;
    padding-bottom: 1.5rem;
  }
  .op-code {
    padding-top: 1.5rem;
  }
  .op-code:empty {
    display: none;
  }
}

/* Celular: menu recolhido (com JS) ou lista no topo (sem JS) */
@media (max-width: 56rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .js .sidebar {
    display: none;
  }
  .js .nav-open .sidebar {
    display: block;
  }
  .main {
    padding: 1.75rem 1rem 4rem;
  }
  .op-doc,
  .op-code {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .ref-group {
    padding: 2rem 1rem 0;
  }
  .prose h1 {
    font-size: 1.7rem;
  }
  .terms {
    columns: 1;
  }
  .topbar {
    padding: 0 1rem;
  }
  .topbar-link {
    display: none;
  }
}

@media (min-width: 56.01rem) {
  .nav-toggle {
    display: none;
  }
}
