/* Hallmark · genre: editorial with the v5 night · macrostructure: Workbench (the questions beside the document) · design-system: design.md · designed-as-app
 * Hallmark · pre-emit critique: P5 H5 E5 S5 R5 V4 · contrast: pass (40-41) · tokens: pass (48) · mobile: pass (34, 49, 50-57)
 * "Pergunte a um documento seu": only this page's workspace. The page, the upload card, the progress, the examples and
 * the service band are in /site/capi/paginas/demos.css. Every text that comes from a document, a question or the model
 * is written by the script as text. The workspace follows the homepage's conversation window: the document in a calm
 * panel like the "Ficha do projeto", the question field with its pill inside, the visitor's question as an ink bubble,
 * the answer as plain text with its numbered sources, the words cited marked on crema-3 with the accent under them. */

/* ---------- The document and the questions: side by side from 901 px (where the script stops folding the document) ---------- */
.trabalho-grade { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-xl); align-items: start; }
.trabalho-grade > .qa { order: -1; min-width: 0; }
@media (min-width: 56.3125rem) {
  .trabalho-grade { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--space-xl) clamp(var(--space-lg), 4vw, var(--space-3xl)); }
  .trabalho-grade > .qa { order: 0; }
  .doc-painel { position: sticky; top: calc(var(--header-h) + var(--space-md)); }
}

/* The document: an open column under an ink rule (its name, the notes), then the one box: the picture, or the
   fictional document's own text on crema-2 */
.doc-painel { min-width: 0; }
.doc-cabeca { padding-block: var(--space-md) var(--space-sm); border-top: 2px solid var(--color-ink); border-bottom: 1px solid var(--color-rule); }
.doc-cabeca strong { display: block; font-size: 1.125rem; font-weight: var(--wght-ui); line-height: 1.3; }
.doc-cabeca span { display: block; margin-top: var(--space-3xs); color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-small); line-height: 1.4; }
.doc-selo { margin-top: var(--space-sm); color: var(--color-ink-2); font-size: var(--text-sm); font-weight: var(--wght-ui); line-height: 1.45; }
.doc-notas { display: grid; gap: var(--space-2xs); margin: var(--space-sm) 0 0; padding: 0; list-style: none; color: var(--color-ink-2); font-size: 0.9375rem; line-height: 1.5; }
.doc-notas li { padding-top: var(--space-2xs); border-top: 1px solid var(--color-rule); }
.doc-notas li:first-child { padding-top: 0; border-top: 0; }
.doc-notas li[data-tipo="aviso"] { color: var(--color-ink); font-weight: var(--wght-ui); }
p.doc-notas { display: block; }
.doc-previa { margin-top: var(--space-md); overflow: hidden; border: 1px solid var(--color-rule); border-radius: var(--radius-media); background: var(--color-paper-2); }
.doc-previa img { width: 100%; height: auto; max-height: 42vh; object-fit: contain; }
.doc-ligacao {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: var(--space-xs);
  font-weight: var(--wght-ui);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.3em;
  transition: text-decoration-color var(--dur-color) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .doc-ligacao:hover { text-decoration-color: var(--color-accent); } }
/* The fictional document's own text, page by page, in a box that scrolls on its own */
.doc-leitor {
  max-height: min(62vh, 640px);
  margin-top: var(--space-md);
  padding: var(--space-2xs) var(--space-md) var(--space-md);
  overflow: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-media);
  background: var(--color-paper-2);
  color: var(--color-ink-2);
  font-size: 0.9375rem;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule-strong) transparent;
}
.doc-pagina { padding-top: var(--space-sm); }
.doc-pagina + .doc-pagina { margin-top: var(--space-sm); border-top: 1px solid var(--color-rule); }
.doc-pagina h3 { margin-bottom: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-ui); line-height: 1.4; }
.doc-pagina p { white-space: pre-line; overflow-wrap: anywhere; }
.doc-recolher { display: none; }
@media (max-width: 56.25rem) {
  .doc-painel[data-recolhido] .doc-leitor { max-height: 180px; overflow: hidden; }
  .doc-painel[data-recolhido] .doc-previa img { max-height: 200px; object-fit: cover; object-position: top; }
  .doc-recolher {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-top: var(--space-2xs);
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-ink);
    font: inherit;
    font-weight: var(--wght-ui);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 0.3em;
    cursor: pointer;
  }
}
.doc-acoes { margin-top: var(--space-md); }

/* ---------- The questions ---------- */
.qa-cabeca h2 {
  max-width: 22ch;
  font-size: clamp(1.75rem, 1.15rem + 1.6vw, 3rem);
  font-weight: var(--wght-display);
  font-stretch: var(--wdth-display);
  letter-spacing: -0.025em;
  line-height: 1.02;
  text-wrap: balance;
}
.qa-cabeca p { max-width: 45ch; margin-top: var(--space-sm); color: var(--color-ink-2); }

/* The question field: the homepage's compose field, the pill inside it */
.pergunta-form { margin-top: var(--space-lg); }
.pergunta-form label { display: block; margin-bottom: var(--space-2xs); font-weight: var(--wght-ui); line-height: 1.35; }
.pergunta-linha {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2xs);
  padding: var(--space-3xs);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-media);
  background: var(--color-paper);
  transition: border-color var(--dur-color) var(--ease-out);
}
.pergunta-linha:has(textarea:focus-visible) { border-color: var(--color-ink-2); outline: 2px solid var(--color-focus); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { .pergunta-linha:hover:not(:has(textarea:focus-visible)):not(:has(textarea:disabled)) { border-color: var(--color-ink-2); } }
.pergunta-linha textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  max-height: 180px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-input);
  background: transparent;
  color: var(--color-ink);
  font-size: 1.0625rem;
  line-height: 1.45;
  resize: none;
  outline: none;
}
.pergunta-linha textarea::placeholder { color: var(--color-muted); opacity: 1; }
.pergunta-linha textarea:disabled { color: var(--color-muted); cursor: not-allowed; }
.pergunta-linha .btn { flex: none; min-height: 48px; }
.pergunta-ajuda { margin-top: var(--space-2xs); color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-small); line-height: 1.45; }
.pergunta-ajuda[data-tipo="erro"] { color: var(--color-accent); font-weight: var(--wght-ui); }

/* Suggested questions: ruled rows, each a whole-width button with a small drawn arrow */
.sugestoes { margin-top: var(--space-lg); }
.sugestoes > p { color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-ui); line-height: 1.4; }
.sugestoes-lista { margin-top: var(--space-2xs); border-top: 1px solid var(--color-rule); }
.sugestao {
  position: relative;
  display: block;
  width: 100%;
  min-height: 52px;
  padding: var(--space-xs) var(--space-xl) var(--space-xs) 0;
  border: 0;
  border-bottom: 1px solid var(--color-rule);
  background: none;
  color: var(--color-ink);
  font: inherit;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur-color) var(--ease-out);
}
.sugestao::after {
  content: "";
  position: absolute;
  top: 50%;
  right: var(--space-xs);
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform var(--dur-short) var(--ease-out);
}
.sugestao:active:not(:disabled) { transform: translateY(1px); }
.sugestao:disabled { color: var(--color-muted); cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .sugestao:hover:not(:disabled) { text-decoration: underline; text-decoration-color: var(--color-accent); text-decoration-thickness: 1.5px; text-underline-offset: 0.22em; }
  .sugestao:hover:not(:disabled)::after { transform: translateX(3px) rotate(45deg); }
}

/* ---------- The answers, newest first ---------- */
.respostas { margin-top: var(--space-xl); border-top: 2px solid var(--color-ink); }
.respostas-vazio { padding-block: var(--space-md); color: var(--color-muted); }
.resposta { display: grid; gap: var(--space-sm); padding-block: var(--space-lg); border-bottom: 1px solid var(--color-rule); scroll-margin-top: calc(var(--header-h) + var(--space-md)); }
@media (prefers-reduced-motion: no-preference) { .resposta[data-novo] { animation: demo-chega 420ms var(--ease-out) both; } }
@keyframes demo-chega { from { opacity: 0; transform: translateY(10px); } }
/* The visitor's question: an ink bubble, as in the homepage's conversation */
.resposta-pergunta {
  justify-self: end;
  max-width: min(36rem, 88%);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-media);
  background: var(--color-ink);
  color: var(--color-paper);
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.resposta[data-resultado="resumo"] .resposta-pergunta { justify-self: start; padding: 0; border-radius: 0; background: none; color: var(--color-ink); font-size: var(--text-title); font-weight: var(--wght-ui); letter-spacing: var(--track-title); line-height: 1.2; }
.resposta-estado { justify-self: start; }
.resposta-partes { display: grid; gap: var(--space-xs); }
.resposta-partes p { max-width: 48ch; font-size: 1.0625rem; line-height: 1.6; overflow-wrap: anywhere; }
.resposta-nao { max-width: 48ch; line-height: 1.6; }
.resposta-procurado, .resposta-nota { max-width: 50ch; color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-small); line-height: 1.5; }
.resposta-alerta { padding-top: var(--space-sm); border-top: 1px solid var(--color-rule); color: var(--color-ink-2); font-size: 0.9375rem; line-height: 1.5; }
.resposta-alerta strong { display: block; color: var(--color-ink); font-weight: var(--wght-ui); }
.resposta-alerta ul { margin: var(--space-3xs) 0 0; padding-left: 1.15em; }
.resposta-alerta li { overflow-wrap: anywhere; }
/* Waiting for an answer: a small turning ring and the question being looked for */
.resposta-carregando { display: flex; align-items: center; gap: var(--space-xs); padding-block: var(--space-md); border-bottom: 1px solid var(--color-rule); color: var(--color-ink-2); font-size: 0.9375rem; line-height: 1.5; overflow-wrap: anywhere; }
.resposta-carregando::before { content: ""; flex: none; width: 16px; height: 16px; border: 2px solid var(--color-rule); border-top-color: var(--color-ink); border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) { .resposta-carregando::before { animation: demo-gira 800ms linear infinite; } }

/* Where each part came from: the number, the page and a way to see it, the words with the cited part marked */
.fontes { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--color-rule); }
.fonte { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr); gap: var(--space-2xs); align-items: baseline; padding-block: var(--space-sm); border-bottom: 1px solid var(--color-rule); scroll-margin-top: calc(var(--header-h) + var(--space-md)); }
.fonte:last-child { border-bottom: 0; }
.fonte:target { background: var(--color-paper-2); }
.fonte-onde { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-sm); color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-ui); line-height: 1.4; }
.fonte-onde button, .fonte-onde a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-ink);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.25em;
  cursor: pointer;
  transition: text-decoration-color var(--dur-color) var(--ease-out);
}
@media (pointer: coarse) { .fonte-onde button, .fonte-onde a { min-height: 44px; } }
@media (hover: hover) and (pointer: fine) { .fonte-onde button:hover, .fonte-onde a:hover { text-decoration-color: var(--color-accent); } }
.fonte blockquote { margin-top: var(--space-3xs); color: var(--color-ink-2); font-size: 0.9375rem; line-height: 1.6; overflow-wrap: anywhere; }
.fonte-aviso { margin-top: var(--space-2xs); color: var(--color-accent); font-size: var(--text-sm); font-weight: var(--wght-ui); line-height: 1.45; }

/* The contract summary: ruled rows like the "Ficha do projeto", each value with its quote */
.resumo-campos { margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--color-ink); }
.resumo-campo { padding-block: var(--space-sm); border-bottom: 1px solid var(--color-rule); }
.resumo-nome { display: block; color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--wght-small); line-height: 1.4; }
.resumo-valor { margin-top: var(--space-3xs); font-weight: var(--wght-ui); line-height: 1.45; overflow-wrap: anywhere; }
.resumo-valor[data-vazio] { color: var(--color-muted); font-weight: var(--wght-small); }
.resumo-campo .fontes { margin-top: var(--space-2xs); }

@media (max-width: 39.99rem) {
  .resposta-pergunta { max-width: 92%; }
  .dados .btn, .doc-acoes .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .sugestao, .sugestao::after, .pergunta-linha, .doc-ligacao { transition: none; }
}
