/* ══════════════════════════════════════════════════════════════════════
   docs-demo.css — prévia animada do Easy AI Docs (chat · LaTeX · PDF).
   Componente só de CSS, usado em easy-ai-docs.html (visitante) e na
   homepage (trilha 01 · Para você). Depende só dos tokens do styles.css
   (--text, --muted, --line, --line-soft, --surface).

   · Tudo em `em`: o tamanho do desenho segue o font-size do .docs-demo.
   · Animação em ciclo (--dd-cycle): o pedido entra no chat, a IA "digita"
     e responde, o LaTeX é escrito linha a linha, o PDF compila e a seção
     nova aparece com a equação destacada; depois recomeça.
   · Os estilos-base são o ESTADO FINAL do ciclo: com movimento reduzido
     (ou sem suporte a animação), a prévia aparece completa e parada.
   ══════════════════════════════════════════════════════════════════════ */

.docs-demo {
  --dd-accent-dark: #3730a3;
  --dd-accent-tint: #eef2ff;
  --dd-code-bg: #1e1e1e;
  --dd-cycle: 12s;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.1em;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(17, 34, 38, 0.12);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.4;
  text-align: left;
}

.docs-demo-bar {
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.65em 0.9em;
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.82em;
  font-weight: 600;
}

.docs-demo-bar i {
  flex: none;
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  background: #dfe3de;
}

.docs-demo-bar span {
  min-width: 0;
  margin-left: 0.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-demo-bar em {
  flex: none;
  margin-left: auto;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background: var(--dd-accent-tint);
  color: var(--dd-accent-dark);
  font-size: 0.88em;
  font-style: normal;
  font-weight: 700;
}

.docs-demo-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas: "chat code pdf";
  min-height: 17em;
}

.docs-demo-body > div {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  min-width: 0;
  padding: 0.8em;
}

.docs-demo-chat { grid-area: chat; }
.docs-demo-code { grid-area: code; background: var(--dd-code-bg); }
.docs-demo-pdf { grid-area: pdf; background: #eef0ec; }

.docs-demo-h {
  color: var(--muted);
  font-size: 0.66em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Chat ── */
.docs-demo-chat p {
  margin: 0;
  padding: 0.45em 0.6em;
  border-radius: 0.65em;
  font-size: 0.78em;
  line-height: 1.35;
}

.docs-demo-chat .u {
  align-self: flex-end;
  max-width: 92%;
  border-bottom-right-radius: 0.2em;
  background: var(--dd-accent-tint);
  color: var(--dd-accent-dark);
}

/* "digitando…" e a resposta ocupam o mesmo lugar */
.docs-demo-reply {
  display: grid;
}

.docs-demo-reply > p {
  grid-area: 1 / 1;
  justify-self: start;
  align-self: start;
  max-width: 92%;
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 0.2em;
  background: #fff;
}

.docs-demo-chat .t {
  display: inline-flex;
  gap: 0.25em;
  padding: 0.65em 0.7em;
  opacity: 0;
}

.docs-demo-chat .t i {
  width: 0.38em;
  height: 0.38em;
  border-radius: 50%;
  background: #9aa3a0;
}

/* ── LaTeX ── */
.docs-demo-code .docs-demo-h { color: #9aa0a6; }

.docs-demo-code code {
  display: block;
  overflow: hidden;
  color: #d4d4d4;
  font: 500 0.72em/1.6 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  text-overflow: ellipsis;
  white-space: pre;
}

.docs-demo-code .c1 { color: #c586c0; }

.docs-demo-caret {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 2px;
  background: #d4d4d4;
  vertical-align: -0.2em;
}

/* ── PDF ── */
.docs-demo-pdf-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4em;
}

.docs-demo-sts {
  display: grid;
}

.docs-demo-st {
  grid-area: 1 / 1;
  justify-self: end;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  font-size: 0.62em;
  font-weight: 700;
  white-space: nowrap;
}

.docs-demo-st.st-run { background: #fff4e0; color: #8a5a00; opacity: 0; }
.docs-demo-st.st-ok { background: #e6f7ef; color: #0f6b43; }

.docs-demo-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.4em;
  padding: 0.8em;
  border-radius: 0.25em;
  background: #fff;
  box-shadow: 0 0.25em 0.9em rgba(0, 0, 0, 0.08);
  font-family: Georgia, "Times New Roman", serif;
}

.docs-demo-page b {
  font-size: 0.8em;
  font-weight: 700;
}

.docs-demo-page .l {
  display: block;
  height: 0.32em;
  border-radius: 0.2em;
  background: #e4e7e3;
}

.docs-demo-page .l.s { width: 70%; }
.docs-demo-page .l.m { width: 86%; }

.docs-demo-new {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  margin-top: 0.35em;
}

.docs-demo-page .eq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.15em 0.3em;
  padding: 0.25em 0.3em;
  border-radius: 0.3em;
  font-size: 0.72em;
  font-style: italic;
  white-space: nowrap;
}

/* sem espaço, o "(1)" desce de linha em vez de sobrepor a fração */
.docs-demo-page .eq > span {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.3em;
}

.docs-demo-page .eq > small {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
}

.docs-demo-page .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
}

.docs-demo-page .frac > span:first-child {
  align-self: stretch;
  border-bottom: 1px solid currentColor;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════
   Animação (ciclo de 12s). Linha do tempo, em % do ciclo:
     3–7  pedido entra · 10–21 digitando · 21–25 resposta
     27–49 LaTeX linha a linha · 50–63 compilando · 64–69 seção nova no PDF
     67–86 destaque da equação · 91–97 tudo sai e o ciclo recomeça
   ══════════════════════════════════════════════════════════════════════ */
.docs-demo .docs-demo-chat .u { animation: ddUser var(--dd-cycle) ease infinite; }
.docs-demo .docs-demo-chat .t { animation: ddTyping var(--dd-cycle) linear infinite; }
.docs-demo .docs-demo-chat .t i { animation: ddDot 1s ease-in-out infinite; }
.docs-demo .docs-demo-chat .t i:nth-child(2) { animation-delay: 0.15s; }
.docs-demo .docs-demo-chat .t i:nth-child(3) { animation-delay: 0.3s; }
.docs-demo .docs-demo-chat .b { animation: ddBot var(--dd-cycle) ease infinite; }
.docs-demo .docs-demo-code .c1 { animation: ddC1 var(--dd-cycle) steps(14, end) infinite; }
.docs-demo .docs-demo-code .c2 { animation: ddC2 var(--dd-cycle) steps(12, end) infinite; }
.docs-demo .docs-demo-code .c3 { animation: ddC3 var(--dd-cycle) steps(8, end) infinite; }
.docs-demo .docs-demo-code .c4 { animation: ddC4 var(--dd-cycle) steps(14, end) infinite; }
.docs-demo .docs-demo-code .c5 { animation: ddC5 var(--dd-cycle) steps(10, end) infinite; }
.docs-demo .docs-demo-caret { animation: ddBlink 1s steps(1, end) infinite; }
.docs-demo .st-run { animation: ddRun var(--dd-cycle) linear infinite; }
.docs-demo .st-ok { animation: ddOk var(--dd-cycle) linear infinite; }
.docs-demo .docs-demo-new { animation: ddNew var(--dd-cycle) ease infinite; }
.docs-demo .docs-demo-new .eq { animation: ddFlash var(--dd-cycle) ease infinite; }

@keyframes ddUser {
  0%, 3% { opacity: 0; transform: translateY(0.4em); }
  7%, 91% { opacity: 1; transform: none; }
  96%, 100% { opacity: 0; transform: none; }
}

@keyframes ddTyping {
  0%, 10% { opacity: 0; }
  12%, 20% { opacity: 1; }
  22%, 100% { opacity: 0; }
}

@keyframes ddDot {
  0%, 60%, 100% { opacity: 0.4; transform: none; }
  30% { opacity: 1; transform: translateY(-0.25em); }
}

@keyframes ddBot {
  0%, 21% { opacity: 0; transform: translateY(0.4em); }
  25%, 91% { opacity: 1; transform: none; }
  96%, 100% { opacity: 0; transform: none; }
}

/* "digitação": a linha é revelada da esquerda para a direita */
@keyframes ddC1 {
  0%, 27% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
  32%, 92% { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
  97%, 100% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
}

@keyframes ddC2 {
  0%, 32% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
  36%, 92% { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
  97%, 100% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
}

@keyframes ddC3 {
  0%, 36% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
  39%, 92% { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
  97%, 100% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
}

@keyframes ddC4 {
  0%, 39% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
  45%, 92% { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
  97%, 100% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
}

@keyframes ddC5 {
  0%, 45% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
  49%, 92% { -webkit-clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0); }
  97%, 100% { -webkit-clip-path: inset(0 100% 0 0); clip-path: inset(0 100% 0 0); }
}

@keyframes ddBlink {
  50% { opacity: 0; }
}

@keyframes ddRun {
  0%, 50% { opacity: 0; }
  52%, 62% { opacity: 1; }
  64%, 100% { opacity: 0; }
}

@keyframes ddOk {
  0%, 63% { opacity: 0; }
  66%, 92% { opacity: 1; }
  97%, 100% { opacity: 0; }
}

@keyframes ddNew {
  0%, 64% { opacity: 0; transform: translateY(0.3em); }
  69%, 92% { opacity: 1; transform: none; }
  97%, 100% { opacity: 0; transform: none; }
}

@keyframes ddFlash {
  0%, 67% { background-color: transparent; }
  72% { background-color: rgba(79, 70, 229, 0.16); }
  86%, 100% { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .docs-demo *,
  .docs-demo *::before,
  .docs-demo *::after {
    animation: none !important;
  }
}

/* Celular: chat e PDF lado a lado, LaTeX embaixo */
@media (max-width: 600px) {
  .docs-demo-body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "chat pdf" "code code";
    min-height: 0;
  }
}
