/*
 * pages.css — páginas institucionais (Política de Privacidade, Termos de Uso) e 404.
 *
 * Folha autônoma: não depende de styles.css. Usa somente os tokens de tokens.css,
 * então o tema escuro funciona automaticamente (sistema ou html[data-theme]).
 * Visual v3: fonte do sistema, superfícies chapadas, fios finos no lugar de
 * cartões com sombra, uma cor de ação (amarelo com texto escuro).
 *
 * Sumário
 *   1. Base e utilitários
 *   2. Ícones e botões
 *   3. Barra do topo
 *   4. Abertura do documento
 *   5. Layout com índice
 *   6. Texto longo (prose) e componentes de conteúdo
 *   7. Rodapé
 *   8. Página 404
 *   9. Movimento reduzido e impressão
 */
@import "tokens.css";

/* ===================================================================== */
/* 1. Base e utilitários                                                  */
/* ===================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

main {
  flex: 1 0 auto;
}

main:focus {
  outline: none;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--text);
  text-wrap: balance;
}

p,
li,
dd {
  text-wrap: pretty;
}

a {
  color: var(--text);
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}

a:hover {
  color: var(--text);
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

::selection {
  background: var(--highlight);
  color: var(--on-highlight);
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: 100;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-full);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
  transform: none;
  color: var(--on-primary);
}

/* ===================================================================== */
/* 2. Ícones e botões                                                     */
/* ===================================================================== */

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 1rem;
  height: 1rem;
}

.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-4);
  border: 0;
  border-radius: var(--r-full);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: 600 var(--fs-sm) / 1.2 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.btn:hover {
  --btn-bg: var(--surface-3);
  color: var(--btn-fg);
}

.btn:active {
  transform: scale(.97);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn--primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--on-primary);
}

.btn--primary:hover {
  --btn-bg: var(--primary-hover);
}

.btn--lg {
  min-height: 52px;
  padding: 0 var(--sp-6);
  font-size: var(--fs-base);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.icon-btn .icon {
  width: 22px;
  height: 22px;
}

/* Botão de tema: mostra só o ícone do modo atual (data-mode vem do pages.js). */
.theme-toggle .icon {
  display: none;
}

.theme-toggle[data-mode="system"] .icon--system,
.theme-toggle[data-mode="light"] .icon--light,
.theme-toggle[data-mode="dark"] .icon--dark {
  display: block;
}

/* ===================================================================== */
/* 3. Barra do topo (mesma cara do app)                                   */
/* ===================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: var(--header-h);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  min-width: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  text-decoration: none;
  border-radius: var(--r-sm);
}

.brand:hover {
  color: var(--text);
}

.brand__mark {
  display: block;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
}

.brand__name {
  white-space: nowrap;
}

/* ===================================================================== */
/* 4. Abertura do documento                                               */
/* ===================================================================== */

.doc-hero {
  padding: clamp(1.75rem, 6vw, 3.5rem) 0 clamp(1.5rem, 4vw, 2.25rem);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 var(--sp-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.doc-hero h1 {
  max-width: 18ch;
  margin: 0 0 var(--sp-3);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}

.doc-hero .lead {
  max-width: 62ch;
  margin: 0 0 var(--sp-5);
  color: var(--text-muted);
  font-size: var(--fs-md);
  line-height: var(--lh-base);
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-meta li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.doc-meta .icon {
  width: 1rem;
  height: 1rem;
}

/* ===================================================================== */
/* 5. Layout com índice                                                   */
/* ===================================================================== */

.doc-layout {
  display: grid;
  gap: var(--sp-6);
  padding-block: var(--sp-6) var(--sp-16);
}

@media (min-width: 1080px) {
  .doc-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: var(--sp-16);
    padding-top: var(--sp-10);
  }
}

.toc {
  align-self: start;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.toc > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 52px;
  padding: 0 var(--sp-4);
  border-radius: inherit;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.toc > summary::-webkit-details-marker {
  display: none;
}

.toc > summary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.toc > summary .icon {
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease);
}

.toc[open] > summary .icon {
  transform: rotate(180deg);
}

.toc ol {
  margin: 0;
  padding: 0 var(--sp-2) var(--sp-2);
  list-style: none;
  counter-reset: toc;
}

.toc li {
  counter-increment: toc;
}

.toc a {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: .55rem var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.toc a::before {
  content: counter(toc) ".";
  min-width: 1.5em;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.toc a:hover {
  background: var(--surface-3);
  color: var(--text);
}

.toc a[aria-current] {
  color: var(--text);
  font-weight: 600;
}

.toc a[aria-current]::before {
  color: inherit;
}

@media (min-width: 1080px) {
  .toc {
    position: sticky;
    top: calc(var(--header-h) + var(--sp-6));
    max-height: calc(100vh - var(--header-h) - var(--sp-12));
    overflow-y: auto;
    background: transparent;
    scrollbar-width: thin;
  }

  .toc ol {
    padding: 0;
    border-left: 1px solid var(--border);
  }

  .toc a {
    margin-left: -1px;
    border-left: 2px solid transparent;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
  }

  .toc a:hover {
    background: var(--surface-2);
  }

  .toc a[aria-current] {
    border-left-color: var(--text);
  }

  /* Fixado pelo pages.js: no desktop o índice fica sempre aberto. */
  .toc.is-pinned > summary {
    min-height: 36px;
    padding: 0 var(--sp-3);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    cursor: default;
  }

  .toc.is-pinned > summary .icon {
    display: none;
  }
}

/* ===================================================================== */
/* 6. Texto longo e componentes de conteúdo                               */
/* ===================================================================== */

.prose {
  min-width: 0;
  max-width: 68ch;
  font-size: 1rem;
  line-height: 1.7;
}

.prose > section {
  scroll-margin-top: calc(var(--header-h) + var(--sp-4));
}

.prose > section + section {
  margin-top: var(--sp-10);
  padding-top: var(--sp-10);
  border-top: 1px solid var(--border);
}

.prose h2 {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
}

.h-num {
  flex: none;
  min-width: 1.5em;
  color: var(--text-subtle);
  font-family: var(--font-body);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.prose h3 {
  margin: var(--sp-6) 0 var(--sp-2);
  font-size: var(--fs-lg);
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: -.01em;
}

.prose p,
.prose ul,
.prose ol,
.prose dl {
  margin: 0 0 var(--sp-4);
}

.prose ul,
.prose ol {
  padding-left: 1.3em;
}

.prose li {
  margin-block: .4em;
  padding-left: .2em;
}

.prose li::marker {
  color: var(--text-subtle);
}

.prose ol > li::marker {
  font-weight: 600;
}

.prose a {
  overflow-wrap: anywhere;
}

.prose strong {
  font-weight: 650;
}

.prose code {
  padding: .1em .4em;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
  font-size: .85em;
  white-space: nowrap;
}

.prose abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: .2em;
  cursor: help;
}

/* Nome de botão/menu do site citado no texto. */
.ui {
  padding: .05em .45em;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .92em;
  font-weight: 600;
}

/* Resumo no topo: bloco chapado, sem moldura. */
.summary-card {
  margin: 0 0 var(--sp-10);
  padding: clamp(1.25rem, 4vw, 1.75rem);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

.summary-card h2 {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-lg);
}

.summary-card h2 .icon {
  align-self: center;
  color: var(--text);
}

.checklist {
  display: grid;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

.prose .checklist {
  margin: 0;
  padding: 0;
}

.checklist li {
  display: flex;
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
}

.checklist .icon {
  width: 1.375rem;
  height: 1.375rem;
  margin-top: .1em;
  padding: 4px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  stroke-width: 3;
}

/* Avisos em destaque. */
.callout {
  display: flex;
  gap: var(--sp-3);
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

.callout > .icon {
  margin-top: .15em;
  color: var(--text-muted);
}

.callout p {
  margin: 0;
}

.callout--warning {
  background: var(--warning-soft);
}

.callout--warning > .icon {
  color: var(--warning);
}

/* Lista de definições (dados, prazos, bases legais…) separada por fios. */
.data-list {
  display: grid;
  padding: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.data-list > div {
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-4) 0;
}

.data-list > div + div {
  border-top: 1px solid var(--border);
}

.data-list dt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 650;
  line-height: var(--lh-snug);
}

.data-list dd {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

@media (min-width: 640px) {
  .data-list > div {
    grid-template-columns: 12rem minmax(0, 1fr);
    gap: var(--sp-5);
  }

  .data-list dt {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--sp-1);
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 .55rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1;
}

.pill--required {
  background: var(--ink);
  color: var(--on-ink);
}

/* Passo a passo numerado. */
.prose .steps {
  display: grid;
  gap: 0;
  margin: 0 0 var(--sp-5);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.prose .steps > li {
  position: relative;
  margin: 0;
  padding: var(--sp-4) 0 var(--sp-4) 3.25rem;
  counter-increment: step;
}

.prose .steps > li + li {
  border-top: 1px solid var(--border);
}

.prose .steps > li::before {
  content: counter(step);
  position: absolute;
  top: var(--sp-4);
  left: 0;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.prose .steps h3 {
  margin: .2rem 0 var(--sp-1);
  font-size: var(--fs-md);
}

.prose .steps p {
  margin: 0;
  font-size: var(--fs-base);
  line-height: var(--lh-base);
}

.back-top {
  margin-top: var(--sp-10);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}

.back-top a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

.back-top a:hover {
  text-decoration: underline;
}

/* ===================================================================== */
/* 7. Rodapé                                                              */
/* ===================================================================== */

.site-footer {
  margin-top: auto;
  padding: var(--sp-8) 0 calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.site-footer__inner {
  display: grid;
  gap: var(--sp-5);
}

.site-footer .brand {
  font-size: var(--fs-md);
}

.site-footer .brand__mark {
  width: 28px;
  height: 28px;
}

.site-footer__tagline {
  max-width: 40ch;
  margin: var(--sp-1) 0 0;
}

.site-footer__nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--sp-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer__nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer__nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-footer__nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

.site-footer__legal {
  margin: 0;
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: var(--fs-xs);
}

@media (min-width: 760px) {
  .site-footer__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .site-footer__legal {
    grid-column: 1 / -1;
  }
}

/* ===================================================================== */
/* 8. Página 404                                                          */
/* ===================================================================== */

.notfound {
  display: grid;
  place-items: center;
  padding: clamp(2.5rem, 10vh, 6rem) 0;
  text-align: center;
}

.notfound__inner {
  display: grid;
  justify-items: center;
  width: min(100% - 2 * var(--gutter), 520px);
}

.notfound__dog {
  display: block;
  width: 112px;
  height: 112px;
  margin-bottom: var(--sp-5);
}

.notfound .eyebrow {
  margin-bottom: var(--sp-1);
}

.notfound h1 {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
}

.notfound .lead {
  max-width: 40ch;
  margin: 0 auto var(--sp-6);
  color: var(--text-muted);
  font-size: var(--fs-md);
}

.notfound__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--sp-2);
}

@media (max-width: 479px) {
  .notfound__actions {
    flex-direction: column;
    align-self: stretch;
  }
}

.notfound__suggest {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}

.notfound__suggest a {
  font-weight: 600;
}

.notfound__help {
  max-width: 44ch;
  margin: var(--sp-8) auto 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ===================================================================== */
/* 9. Movimento reduzido e impressão                                      */
/* ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .site-header,
  .site-footer,
  .toc,
  .skip-link,
  .back-top,
  .notfound__actions {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  .doc-hero {
    padding: 0 0 1rem;
    border: 0;
  }

  .doc-layout {
    display: block;
    padding: 0;
  }

  .prose {
    max-width: none;
    font-size: 11pt;
  }

  .prose a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: .85em;
  }

  .summary-card,
  .data-list,
  .prose .steps > li,
  .callout {
    break-inside: avoid;
  }
}
