/* LCF · camada editorial de acessibilidade e leitura · 2026-10-30.
   Carregada APÓS os estilos específicos dos dossiês pelo site.js. */
:root {
  --surface: #ffffff;
  --surface-text: #18283b;
  --surface-muted: #526275;
  --lcf-reader-scale: 1;
}
:root[data-theme="dark"] {
  --surface: #1a283a;
  --surface-text: #ecf2f9;
  --surface-muted: #b5c2d2;
}
html, body { max-width: 100%; }
main, main article, main section, main aside, main .container { min-width: 0; }
main :is(p, h1, h2, h3, h4, h5, h6, li, td, th, a) { overflow-wrap: break-word; }
main :is(.table-wrap,.ledger-table-wrap,.intelligence-table-wrap,.matrix-wrap,.table-scroll) {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
main img, main video, main canvas, main svg { max-width: 100%; height: auto; }
main :is(input,select,textarea,button) { max-width: 100%; }
main :is(.article-body,.prose) { line-height: 1.8; }

/* Superfícies claras mantidas por estilos próprios não podem herdar texto branco
   apenas porque o navegador/sistema está no tema escuro. */
:root[data-theme="dark"] :is(
  .quiz-shell, .urn-tool-section, .insight-band, .router-section,
  .planner-section, .sixlab, .flight-section:nth-of-type(even),
  .evidence-section, .mapa-page
) { color: #192b40; }
:root[data-theme="dark"] :is(
  .claim-card, .quiz-shell .result-card, .urn-fields, .urn-result,
  .flight-panel, .flight-result, .flight-card, .flight-timeline > div,
  .sixlab-form, .sixlab-output, .planner-form,
  .irpf-stats article, .irpf-route > span, .irpf-insights article,
  .insight-band .insight-grid article, .share-panel,
  .deadline-card
) { color: #192b40; }
:root[data-theme="dark"] :is(.metric-card,.module-row,.check-card,.router-form,.router-section .result-card,.summary-grid > div) {
  color: var(--surface-text);
}
:root[data-theme="dark"] .router-section :is(.router-form,.result-card) :is(input,select,textarea) {
  color: var(--surface-text);
}
/* As caixas que usam --ink como fundo devem continuar escuras no modo noturno. */
:root[data-theme="dark"] :is(.aside-note,.finding-callout,.causal-chain span) {
  background: #0b1728;
  color: #f3f6fb;
}
:root[data-theme="dark"] .finding-callout h2 { color: #ffffff; }
:root[data-theme="dark"] .finding-callout p { color: #cbd5e5; }
:root[data-theme="dark"] .article-body .fact-box { background: #0b1728; color: #f3f6fb; }
:root[data-theme="dark"] .article-body .fact-box :is(h2,h3,p,li,strong) { color: #f3f6fb; }

/* Reparação pontual: a checagem WCAG no site.js só marca texto cujo contraste
   computado está abaixo do mínimo. Não redesenha cores legíveis nem gráficos. */
.lcf-contrast-ink { color: #14263a !important; }
.lcf-contrast-light { color: #f8fbff !important; }


/* Linguagem visual editorial coerente, sem alterar a hierarquia semântica. */
main :is(.dossier-card,.path-card,.platform-card,.solution-card,.radar-card,
  .editorial-grid article,.explore-grid a,.check-grid article,.metric-card,.data-chart) {
  border-radius: 12px;
  box-shadow: 0 3px 18px rgba(19,39,59,.035);
}
main :is(.dossier-card,.path-card,.platform-card,.solution-card,.radar-card) :is(h2,h3) {
  line-height: 1.19;
  letter-spacing: -.022em;
  text-wrap: pretty;
}
main :is(.article-body,.prose,.section) :is(p,li) { text-wrap: pretty; }
main :is(.article-body,.prose) a { text-underline-offset: .16em; }
main :is(.article-body,.prose) :is(h2,h3,h4) { scroll-margin-top: 96px; }
main :is(.button,.card-arrow,a,button,input,select,textarea):focus-visible {
  outline: 3px solid #2b71c8;
  outline-offset: 3px;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  main :is(.dossier-card,.path-card,.platform-card,.solution-card,.radar-card):hover {
    box-shadow: 0 14px 34px rgba(19,39,59,.09);
  }
}

/* Controles discretos e acessíveis de leitura, apenas nos dossiês. */
.lcf-reading-toolbar {
  position: fixed;
  inset: auto max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) auto;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  max-width: calc(100vw - 28px);
  background: #ffffff;
  color: #1b2b40;
  border: 1px solid #c8d2dd;
  border-radius: 999px;
  box-shadow: 0 9px 28px rgba(12,31,50,.16);
  font: 700 .84rem/1.3 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}
.lcf-reading-toolbar button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  padding: 9px 14px;
  color: #19354c;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.lcf-reading-toolbar button:hover { background: #edf3f8; }
.lcf-reading-toolbar button:focus-visible { outline: 3px solid #1b67bd; outline-offset: 1px; }
.lcf-reading-toolbar [data-reader-toggle] { background: #133d5c; color: #ffffff; }
.lcf-reading-toolbar [data-reader-toggle]:hover { background: #225b81; }
.lcf-reading-toolbar [data-reader-size] { display: none; min-width: 42px; padding-inline: 8px; }
:root[data-lcf-reading="on"] .lcf-reading-toolbar [data-reader-size] { display: inline-flex; }
:root[data-lcf-reading="on"] .lcf-reading-toolbar [data-reader-toggle] { background: #efe8d8; color: #24354b; }
:root[data-lcf-reading="on"] {
  --paper: #f8f6f0;
  --paper-soft: #ffffff;
  --ink: #1b2939;
  --muted: #4d5c6d;
  --line: #d9d6cf;
  --surface: #ffffff;
  --surface-text: #1b2939;
  --surface-muted: #4d5c6d;
  color-scheme: light;
}
:root[data-lcf-reading="on"] body,
:root[data-lcf-reading="on"] main {
  background: #f8f6f0;
  color: #1b2939;
}
:root[data-lcf-reading="on"] main .container { max-width: min(880px, calc(100% - 32px)); }
:root[data-lcf-reading="on"] .article-layout {
  grid-template-columns: minmax(0,1fr);
  max-width: 900px;
  margin-inline: auto;
  gap: 0;
}
:root[data-lcf-reading="on"] .article-aside { display: none; }
:root[data-lcf-reading="on"] main :is(.article-body,.prose) {
  font-size: calc(1.05rem * var(--lcf-reader-scale));
  line-height: 1.9;
}
:root[data-lcf-reading="on"] main :is(.article-body,.prose) :is(p,li,dd,blockquote),
:root[data-lcf-reading="on"] main article .section p {
  font-size: calc(1.075rem * var(--lcf-reader-scale));
  line-height: 1.9;
}
:root[data-lcf-reading="on"] .article-body :is(p,li) { color: #293747; }
:root[data-lcf-reading="on"] .article-deck { color: #425162; }
:root[data-lcf-reading="on"] main :is(.article-body,.prose) a {
  text-decoration-thickness: 1px;
  text-underline-offset: .17em;
}
@media (max-width: 780px) {
  main :is(.nfse-hero-grid,.router-grid,.cbs-hero-grid,.urn-hero-grid,.urn-tool,
  .lab-grid,.equation-grid,.answer-grid,.insight-grid,.related-grid,
  .flight-grid,.planner-grid,.sixlab-grid,.document-note) {
    grid-template-columns: minmax(0,1fr);
  }
  main :is(.table-wrap,.ledger-table-wrap,.matrix-wrap) { width: 100%; }
  main :is(.article-body,.prose) { line-height: 1.75; }
}
@media (max-width: 600px) {
  main :is(.article-hero,.page-hero,.intelligence-hero) h1 {
    font-size: clamp(2rem, 8.7vw, 3.05rem);
    line-height: 1.12;
    letter-spacing: -.035em;
  }
  main :is(.article-body,.prose) :is(p,li) { font-size: 1rem; }
  main .container { width: min(calc(100% - 30px), var(--max, 1200px)); }
}
@media (max-width: 480px) {
  main :is(.section,.page-hero,.article-hero) { padding-block: clamp(30px, 8vw, 58px); }
  main :is(.claim-card,.result-card,.flight-panel,.flight-result,.router-form,.urn-fields,.urn-result) {
    padding: clamp(16px, 4vw, 24px);
  }
  .lcf-reading-toolbar { left: 12px; right: 12px; bottom: max(12px,env(safe-area-inset-bottom)); justify-content: center; }
  .lcf-reading-toolbar button { padding-inline: 12px; }
}
@media print {
  .lcf-reading-toolbar { display: none !important; }
  main :is(.article-body,.prose) { font-size: 11pt; line-height: 1.5; }
}
