/* ============================================================
   Manual FAPEX 2026 — Sistema de design
   Editorial institucional · sério, calmo, legível
   ============================================================ */

/* Fallback com métricas ajustadas para a serif display — reduz a CLS na troca de
   fonte (rewrap do título grande). Valores estimados; confirmar no navegador. */
@font-face {
  font-family: "Newsreader-fallback";
  src: local("Georgia"), local("Times New Roman"), local("Times");
  size-adjust: 94%;
  ascent-override: 95%;
  descent-override: 25%;
  line-gap-override: 0%;
}

:root {
  /* Cor — papel/tinta */
  --paper: #f6f3ec;          /* off-white quente */
  --paper-2: #efeae0;        /* recuo */
  --paper-3: #e6dfd2;        /* divisórias suaves */
  --ink: #1a1f24;            /* tinta principal */
  --ink-2: #3a4148;          /* tinta secundária */
  --ink-3: #5b6270;          /* meta — escurecido p/ contraste WCAG AA (>=4.5:1 sobre o papel) */
  --rule: #d8d0c0;           /* régua */

  /* Cor — institucional */
  --petrol: #0f3a4a;         /* azul-petróleo, autoridade */
  --petrol-2: #1a5468;
  --petrol-ink: #062430;
  --amber: #b4651e;          /* alerta / atenção */
  --amber-2: #d68843;
  --moss: #4a6741;           /* verificado / OK */
  --moss-2: #6b8c5e;
  --rose: #9b3a3a;           /* vedação / negativo */

  /* Camadas tipográficas */
  --serif: "Newsreader", "Newsreader-fallback", "Source Serif Pro", Georgia, serif;
  --sans: "Public Sans", "Söhne", "Helvetica Neue", Helvetica, sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;

  /* Escala (1.250 — major third, calma) */
  --t-xs: 11px;
  --t-sm: 13px;
  --t-base: 15px;
  --t-md: 17px;
  --t-lg: 21px;
  --t-xl: 27px;
  --t-2xl: 34px;
  --t-3xl: 44px;
  --t-4xl: 60px;
  --t-5xl: 84px;

  /* Métricas */
  --measure: 68ch;
  --gutter: 28px;
  --radius: 4px;
  --radius-lg: 10px;

  /* Largura útil */
  --shell: 1280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* Sem barra horizontal fantasma + scrollbar fina e na paleta */
html { overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 8px; border: 2px solid var(--paper); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

body {
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "ss01", "cv11", "cv05";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--petrol); text-decoration: none; }
a:hover { color: var(--petrol-2); text-decoration: underline; text-underline-offset: 3px; }
/* Links em corpo de texto: sublinhado por padrão (WCAG 1.4.1 — não distinguir só pela cor) */
main p a, .footer a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

::selection { background: var(--petrol); color: var(--paper); }

/* ---------- Tipografia ---------- */
.serif { font-family: var(--serif); font-weight: 420; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}
.lede {
  font-family: var(--serif);
  font-size: var(--t-xl);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink-2);
  font-weight: 380;
  max-width: var(--measure);
  text-wrap: pretty;
}

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 480; letter-spacing: -0.02em; color: var(--ink); margin: 0; text-wrap: balance; }
h1 { font-size: var(--t-4xl); line-height: 1.02; letter-spacing: -0.035em; font-weight: 420; }
h2 { font-size: var(--t-2xl); line-height: 1.15; }
h3 { font-size: var(--t-lg); line-height: 1.25; }

/* ---------- Layout shell ---------- */
.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- Top bar institucional ---------- */
.topstrip {
  background: var(--petrol-ink);
  color: #c8d4d9;
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  padding: 8px 0;
}
.topstrip .shell { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.topstrip a { color: #c8d4d9; }
.topstrip .pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #2a4a55; padding: 2px 8px; border-radius: 99px;
  color: #98c3d0;
}
.topstrip .pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--moss-2); box-shadow: 0 0 0 3px rgba(107,140,94,0.18);
}

/* ---------- Header / nav principal ---------- */
.header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(246,243,236,0.92);
}
.header .shell { display: flex; align-items: center; gap: 32px; padding-top: 18px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 14px; flex-shrink: 0; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .sigil {
  width: 36px; height: 36px;
  background: var(--petrol);
  color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.04em;
  border-radius: 3px;
  position: relative;
}
.brand .sigil::after {
  content: ""; position: absolute; inset: 3px; border: 1px solid rgba(246,243,236,0.3); border-radius: 1px;
}
.brand .lockup { line-height: 1.1; }
.brand .lockup .top { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--ink-3); text-transform: uppercase; }
.brand .lockup .bot { font-family: var(--serif); font-size: 18px; color: var(--ink); letter-spacing: -0.02em; }

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  font-size: var(--t-sm);
  color: var(--ink-2);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 500;
}
.nav a:hover { background: var(--paper-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--petrol); color: var(--paper); }

.header .tools { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* Botão de busca tipo cmdk */
.searchbtn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: var(--t-sm);
  color: var(--ink-3);
  cursor: pointer;
  min-width: 240px;
  transition: border-color 120ms;
}
.searchbtn:hover { border-color: var(--ink-3); }
.searchbtn kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--ink-3);
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: 0.005em;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 80ms ease, background 120ms;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--petrol); color: var(--paper); }
.btn-primary:hover { background: var(--petrol-2); color: var(--paper); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn-amber { background: var(--amber); color: var(--paper); }
.btn-amber:hover { background: var(--amber-2); color: var(--paper); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  border: 1px solid;
  white-space: nowrap;
}
.badge.verified { color: var(--moss); border-color: var(--moss); background: rgba(74,103,65,0.06); }
.badge.pending { color: var(--amber); border-color: var(--amber); background: rgba(180,101,30,0.06); }
.badge.reg { color: var(--petrol); border-color: var(--petrol); background: rgba(15,58,74,0.06); }
.badge.muted { color: var(--ink-3); border-color: var(--rule); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Régua tipográfica ---------- */
.rule {
  height: 1px;
  background: var(--rule);
  border: 0;
  margin: 48px 0;
}
.rule-dotted {
  height: 1px;
  background-image: linear-gradient(to right, var(--rule) 50%, transparent 0%);
  background-size: 6px 1px;
  background-repeat: repeat-x;
  border: 0;
}

/* ---------- Cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color 140ms, transform 140ms;
}
.card:hover { border-color: var(--ink-2); }

.linkcard {
  display: flex; flex-direction: column; gap: 10px;
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.linkcard:hover { text-decoration: none; }
.linkcard .arrow {
  margin-top: auto;
  font-family: var(--mono);
  font-size: var(--t-sm);
  color: var(--petrol);
  display: inline-flex; align-items: center; gap: 6px;
}
.linkcard:hover .arrow span:last-child { transform: translateX(3px); }
.linkcard .arrow span:last-child { transition: transform 160ms; display: inline-block; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 96px;
  padding: 48px 0 64px;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font-size: var(--t-sm);
  color: var(--ink-2);
}
.footer .shell { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.footer h4 { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; margin-bottom: 14px; }
.footer ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.footer a { color: var(--ink-2); }
.footer a:hover { color: var(--ink); }
.footer .colophon { font-family: var(--serif); font-size: var(--t-md); color: var(--ink); line-height: 1.4; max-width: 36ch; }

/* ---------- Utility ---------- */
.cluster { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap, 12px); }
.grid { display: grid; gap: var(--gap, 20px); }
.muted { color: var(--ink-3); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Search modal (estilo cmdk) ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,31,36,0.55);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(640px, 92vw);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.4);
  overflow: hidden;
}
.modal input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 18px 22px;
  font-family: var(--sans);
  font-size: var(--t-md);
  background: transparent;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.modal input::placeholder { color: var(--ink-3); }
.modal-results { max-height: 50vh; overflow-y: auto; padding: 8px; }
.modal-results .row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none; color: inherit;
}
.modal-results .row:hover, .modal-results .row.active { background: var(--paper-2); text-decoration: none; }
.modal-results .row .kind { font-family: var(--mono); font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; min-width: 80px; }
.modal-results .row .ttl { flex: 1; font-size: var(--t-sm); }
.modal-results .row .meta { font-family: var(--mono); font-size: 10px; color: var(--ink-3); }
.modal .foot {
  display: flex; gap: 14px; padding: 10px 18px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 10px; color: var(--ink-3);
  letter-spacing: 0.06em;
}
.modal .foot kbd {
  font-family: var(--mono); font-size: 9px;
  background: var(--paper-2); border: 1px solid var(--rule);
  padding: 1px 5px; border-radius: 3px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 920px) {
  h1 { font-size: var(--t-3xl); }
  .header .shell { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .searchbtn { min-width: 0; }
  .footer .shell { grid-template-columns: 1fr 1fr; }
}

/* ---------- Impressão / PDF (capa e utilitários; capítulos herdam do styles-v2) ---------- */
@media print {
  html { overflow: visible; }
  body { background: #fff; color: #000; }
  .topstrip, .header, .footer, .searchbtn, .modal-backdrop, .cta-row, .calc-mini, .calc-result { display: none !important; }
  main.shell, .shell { max-width: 100%; padding: 0; }
  a { color: #000; }
  .part, .persona, .tool, .institutional, .changelog .row, section { break-inside: avoid; }
}
