/* memoria — estilos da introdução, da aula e do laboratório (curso de AI Engineer). */

/* ---------- aula ---------- */
/* prefixo .mema- · demos de js/games/memoria/aula.js (os balões e o bloco "rodar no LLM" vêm de css/ai.css) */

/* canvases só de leitura: o dedo que começa neles ainda rola a página
   (duas classes: lesson.css carrega depois e põe touch-action: none em .ls-canvas) */
.ls-canvas.mema-canvas { touch-action: pan-y; }

.mema-ctrls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-width: 0; }
.mema-ctrls > div { min-width: 0; max-width: 100%; }
.mema-ctrls .ls-choices { min-width: 0; max-width: 100%; }
.mema-ctrls .seg { flex-wrap: wrap; max-width: 100%; }
.mema-scroll { max-width: 100%; overflow-x: auto; }

.mema-cap { margin: 0; font: 600 10px/1.4 var(--pixel-ui); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.mema-sub { margin: 6px 0 0; padding-top: 12px; border-top: 2px dashed var(--line); font: 600 10px/1.4 var(--pixel-ui); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.mema-q { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; padding: 10px 12px; border: 2px solid var(--line-2); border-left: 4px solid var(--info); background: var(--bg); font-size: 14.5px; line-height: 1.45; color: var(--text); }
.mema-q:empty { display: none; }

.mema-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.mema-legend span { display: inline-flex; align-items: center; gap: 6px; }
.mema-legend i { flex: none; display: inline-block; width: 14px; height: 8px; border: 1px solid #000; }
.mema-certo { font-weight: 600; color: var(--accent); }

.mema-verdict { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.mema-verdict:empty { display: none; }
.mema-verdict.good { color: var(--good); }
.mema-verdict.bad { color: var(--bad); }
.mema-verdict code, .mema-itens code, .mema-mem code, .mema-tab code, .mema-op { font: 400 11.5px/1.35 var(--mono); color: var(--accent); }

/* JSON e texto cru (pedido, resposta, contexto) */
.mema-json { margin: 0; padding: 10px 12px; max-height: 300px; overflow: auto; border: 2px solid var(--line-2); background: #0a0a0f; font: 400 12px/1.55 var(--mono); color: #d4d4d4; white-space: pre-wrap; overflow-wrap: anywhere; }
.mema-details { padding: 8px 10px; border: 2px dashed var(--line-2); background: var(--bg); }
.mema-details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.mema-details summary:hover { color: var(--text); }
.mema-details[open] summary { margin-bottom: 8px; }

/* conversa ao lado do bloco "rodar no LLM" */
.mema-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.mema-duo > section { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mema-duo .ai-chat { max-height: 420px; overflow: auto; padding-right: 4px; }
.mema-duo .ai-msg { max-width: 100%; font-size: 13px; }
@media (max-width: 760px) { .mema-duo { grid-template-columns: 1fr; } }

/* 1 · os cartões e os quatro tipos */
.mema-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 720px) { .mema-cards { grid-template-columns: 1fr; } }
.mema-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 12px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg); }
.mema-card.ok { border-left-color: var(--good); }
.mema-card.no { border-left-color: var(--bad); }
.mema-card-txt { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); }
.mema-tipos { display: flex; flex-wrap: wrap; gap: 6px; }
.mema-tipo { padding: 4px 9px; border: 2px solid var(--line-2); background: var(--surface); font: 500 12px/1.2 var(--pixel); color: var(--muted); white-space: nowrap; cursor: pointer; }
.mema-tipo:hover { border-color: var(--line-3); color: var(--text); }
.mema-tipo[aria-pressed='true'] { border-color: #000; background: var(--accent); color: var(--accent-ink); }
.mema-card.no .mema-tipo[aria-pressed='true'] { background: var(--bad); color: #000; }
.mema-tipo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mema-por { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.mema-por:empty { display: none; }
.mema-card.ok .mema-por { color: var(--good); }
.mema-card.no .mema-por { color: var(--bad); }

/* 2 e 5 · os itens aceitos e recusados */
.mema-itens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mema-itens li { display: grid; grid-template-columns: 16px minmax(0, max-content) minmax(0, 1fr); gap: 2px 10px; align-items: baseline; padding: 6px 10px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg); font-size: 13px; line-height: 1.45; color: var(--text); }
.mema-itens li > b { font: 600 12px/1 var(--mono); }
.mema-itens li > code { overflow-wrap: anywhere; }
.mema-itens li > span { min-width: 0; overflow-wrap: anywhere; }
.mema-itens li em { display: block; font-style: normal; font-size: 12px; color: var(--muted); }
.mema-itens li.ok { border-left-color: var(--good); }
.mema-itens li.ok > b { color: var(--good); }
.mema-itens li.no { border-left-color: var(--bad); color: var(--text-2); }
.mema-itens li.no > b, .mema-itens li.no em { color: var(--bad); }
.mema-itens li.warn { border-left-color: var(--warn); }
.mema-itens li.warn > b, .mema-itens li.warn em { color: var(--warn); }
@media (max-width: 520px) {
  .mema-itens li { grid-template-columns: 16px minmax(0, 1fr); }
  .mema-itens li > span { grid-column: 2; }
}
.mema-defeito { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mema-defeito:empty { display: none; }

/* 3 · o placar das três perguntas */
.mema-placar { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 620px) { .mema-placar { grid-template-columns: 1fr; } }
.mema-placar li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; padding: 6px 10px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg); font-size: 13px; line-height: 1.4; color: var(--text); }
.mema-placar li.cur { border-color: var(--line-3); }
.mema-placar li > b { font: 600 12px/1 var(--mono); }
.mema-placar li.ok { border-left-color: var(--good); }
.mema-placar li.ok > b { color: var(--good); }
.mema-placar li.no { border-left-color: var(--bad); }
.mema-placar li.no > b { color: var(--bad); }
.mema-placar em { flex-basis: 100%; font-style: normal; font: 400 11.5px/1.35 var(--mono); color: var(--muted); }

/* 4 · a linha do tempo e a tabela da memória */
.mema-linha { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mema-linha li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 6px 10px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg); color: var(--faint); }
.mema-linha li.feito { color: var(--text-2); border-left-color: var(--info); }
.mema-linha li.atual { color: var(--text); border-color: var(--line-3); border-left-color: var(--accent); box-shadow: 3px 3px 0 0 var(--accent-line); }
.mema-sem { flex: none; font-size: 11.5px; color: var(--muted); }
.mema-fala { font-size: 13.5px; line-height: 1.45; }
.mema-op { flex-basis: 100%; overflow-wrap: anywhere; }
.mema-tab { width: 100%; }
.mema-tab th, .mema-tab td { padding: 6px 10px; font-size: 12.5px; line-height: 1.35; }
.mema-tab .mema-td { text-align: left; color: var(--text-2); }
.mema-tab tr.contra td { background: var(--bad-soft); }
.mema-tab tr.contra td:first-child { box-shadow: inset 4px 0 0 0 var(--bad); }
@media (max-width: 520px) { .mema-tab th, .mema-tab td { padding: 5px 6px; font-size: 11.5px; } }

/* 5 · a memória da cliente e o teste do filtro */
.mema-mem { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mema-mem li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 6px 10px; border: 2px solid var(--line); border-left: 4px solid var(--info); background: var(--bg); font-size: 13px; line-height: 1.45; color: var(--text); }
.mema-mem li.vazia { border-left-color: var(--line-2); color: var(--muted); }
.mema-teste { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 2px dashed var(--line-2); background: var(--bg); }
.mema-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.mema-in input { flex: 1 1 220px; min-width: 0; height: 34px; padding: 0 10px; border: 2px solid var(--line-2); background: var(--bg-2); font: 400 13px/1 var(--mono); color: var(--text); }
.mema-in input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent-line); }

/* ---------- jogo ---------- */
/* raiz .memg · prefixo .mem- · "O Caderno do Atendente" (js/games/memoria/game.js); a base vem de .sg-* (css/games.css) */

.memg { --mem-hard: 3px 3px 0 0 rgba(0, 0, 0, 0.5); --mem-sky: #7ad7ff; }

/* a cena (pixel art) e o gráfico (chart.js): só toques, então o dedo ainda rola a página por cima deles */
.memg .sg-canvas { border-radius: 0; background: #141320; box-shadow: var(--mem-hard); touch-action: manipulation; }
.memg .mem-scene { height: 250px; image-rendering: pixelated; image-rendering: crisp-edges; }
.memg .mem-chart { height: 270px; background: #0c0b10; image-rendering: auto; }
.memg .sg-canvas[hidden] { display: none; }
@media (max-width: 640px) {
  .memg .mem-scene { height: 240px; }
  .memg .mem-chart { height: 250px; }
  .memg .mem-chart.mem-duplo { height: 380px; }
}

/* leitura sob os canvases: chips de HUD */
.memg .sg-caption { justify-content: flex-start; gap: 6px; font: 400 11px/1.3 var(--pixel-ui); color: var(--muted); }
.memg .sg-caption:empty { display: none; }
.memg .sg-caption span { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 4px 8px; border: 2px solid var(--line-2); background: var(--bg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memg .sg-caption b { font-weight: 400; color: var(--accent); }

/* painel de controles */
.mem-controls { display: flex; flex-direction: column; gap: 12px; }
.mem-msg:empty { display: none; }
.mem-ask { margin: 0; padding: 10px 12px; border: 2px solid var(--line-2); border-left: 4px solid var(--accent); background: var(--bg); font-size: 14px; line-height: 1.5; color: var(--text-2); box-shadow: var(--mem-hard); overflow-wrap: anywhere; }
.mem-ask b { color: var(--text); font-weight: 500; }
.memg .sg-formula { border-radius: 0; border-color: var(--line-2); background: var(--bg); box-shadow: var(--mem-hard); white-space: normal; overflow-wrap: anywhere; }
.memg .sg-formula .muted { font-size: 11.5px; }
.memg .sg-stats div { border-radius: 0; border-width: 2px; border-color: var(--line-2); background: var(--bg-2); box-shadow: var(--mem-hard); min-width: 0; }
.memg .sg-stats dd small { display: block; margin-top: 4px; font: 400 10.5px/1.2 var(--mono); color: var(--muted); }
.memg .sg-slider { grid-template-columns: 30px minmax(0, 1fr) 96px; }
.memg .sg-goal, .memg .sg-msg { border-radius: 0; }
.memg .sg-msg span { min-width: 0; overflow-wrap: anywhere; }
.memg .btn kbd { margin-left: 6px; }
.mem-keys { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
/* no celular não há teclado: some a linha de atalhos e as teclas dos botões */
@media (hover: none) and (pointer: coarse) {
  .mem-keys, .memg kbd { display: none; }
}

/* botões segmentados: o k, a ferramenta, barra/passa */
.mem-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.mem-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 40px; min-height: 38px; padding: 6px 10px;
  border: 2px solid var(--line-2); background: var(--surface-2); font: 500 13px/1.2 var(--mono); color: var(--text-2);
  box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.mem-seg button .icon { width: 13px; height: 13px; }
.mem-seg button:hover:not(:disabled) { border-color: var(--line-3); color: var(--text); }
.mem-seg button[aria-pressed='true'] { border-color: #000; background: var(--accent); color: var(--accent-ink); }
.mem-seg button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mem-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mem-seg button:disabled { cursor: default; opacity: 0.6; }
.mem-seg button[aria-pressed='true']:disabled { opacity: 1; }
.mem-tools button { flex: 1 1 150px; }
.mem-mini { flex: none; gap: 4px; }
.mem-mini button { min-width: 0; min-height: 32px; padding: 4px 9px; font-size: 12px; }

/* abaixo dos canvases */
.mem-board { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mem-board:empty { display: none; }
.mem-board .sg-label { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.mem-pre { margin: 0; padding: 8px 10px; border: 2px solid var(--line-2); background: #0a0a0f; font: 400 12px/1.5 var(--mono); color: #d4d4d4; white-space: pre-wrap; overflow-wrap: anywhere; }
.mem-pre.small { font-size: 11.5px; color: var(--muted); }
.mem-details { padding: 8px 10px; border: 2px dashed var(--line-2); background: var(--bg); }
.mem-details summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.mem-details summary:hover { color: var(--text); }
.mem-details[open] summary { margin-bottom: 8px; }
.mem-key { flex: none; display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border: 2px solid var(--line-2); background: var(--bg); font: 400 11px/1 var(--mono); color: var(--muted); }

/* a conversa (fase 1) */
.mem-conv { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mem-conv li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; font-size: 13px; line-height: 1.45; color: var(--text-2); }
.mem-conv li b { font: 400 10px/1.9 var(--pixel-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.mem-conv li.user b { color: var(--info); }
.mem-conv li.user span { color: var(--text); }

/* listas de itens tocáveis (candidatos, itens do extrator, fatos, linhas do caderno, textos de teste) */
.mem-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mem-lista > li { display: flex; flex-direction: column; gap: 4px; padding: 2px; border: 2px solid transparent; }
.mem-lista > li.cur { border-color: var(--line-3); }
.mem-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 10px;
  border: 2px solid var(--line-2); background: var(--surface); text-align: left; color: var(--text);
  box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.mem-item:hover:not(:disabled) { border-color: var(--line-3); }
.mem-item:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mem-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mem-item:disabled { cursor: default; }
.mem-item[aria-pressed='true'] { border-color: var(--accent-line); background: var(--accent-soft); }
.mem-txt { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
code.mem-txt { font: 400 12.5px/1.45 var(--mono); color: var(--text); }
.mem-txt small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.mem-txt small code { font: 400 11.5px/1.3 var(--mono); color: var(--accent); }
.mem-txt.riscado { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--bad); }
.mem-tag { flex: none; display: inline-flex; align-items: center; gap: 4px; font: 400 10px/1.4 var(--pixel-ui); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.mem-tag .icon { width: 12px; height: 12px; }
.mem-item[aria-pressed='true'] .mem-tag { color: var(--accent); }
.mem-por { margin: 0 4px 2px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.mem-lista > li.ok .mem-item, .mem-lista > li.novo .mem-item { border-color: var(--good); }
.mem-lista > li.ok .mem-por, .mem-lista > li.ok .mem-tag { color: var(--good); }
.mem-lista > li.fora .mem-item { border-color: var(--line-2); opacity: 0.75; }
.mem-lista > li.no .mem-item, .mem-lista > li.errado .mem-item { border-color: var(--bad); background: var(--bad-soft); }
.mem-lista > li.no .mem-por, .mem-lista > li.no .mem-tag { color: #ffb3ad; }
.mem-nova .mem-txt { color: var(--muted); font: 400 13px/1.4 var(--mono); }
.mem-nova { border-style: dashed; background: transparent; }
.mem-teste-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 8px 10px; border: 2px solid var(--line-2); background: var(--surface); }
.mem-lista > li.ok .mem-teste-row { border-color: var(--good); }
.mem-lista > li.no .mem-teste-row { border-color: var(--bad); background: var(--bad-soft); }

/* fase 2 · as três perguntas */
.mem-qs { display: flex; flex-direction: column; gap: 6px; }
.mem-q {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
  border: 2px solid var(--line-2); border-left-width: 4px; background: var(--surface); text-align: left; color: var(--text);
  box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.mem-q span { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13.5px; line-height: 1.4; }
.mem-q b { font-weight: 500; }
.mem-q small { font: 400 11.5px/1.35 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.mem-q.ok { border-left-color: var(--good); }
.mem-q.ok small { color: var(--good); }
.mem-q.no { border-left-color: var(--bad); }
.mem-q.no small { color: #ffb3ad; }
.mem-q[aria-pressed='true'] { border-color: var(--line-3); background: var(--surface-2); }
.mem-q[aria-pressed='true'].ok { border-left-color: var(--good); }
.mem-q[aria-pressed='true'].no { border-left-color: var(--bad); }
.mem-q:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* fase 3 · as semanas e a fala da vez */
.mem-linha { display: flex; flex-wrap: wrap; gap: 4px; }
.mem-chip { padding: 2px 6px; border: 2px solid var(--line-2); background: var(--bg); font: 400 11px/1.3 var(--mono); color: var(--faint); }
.mem-chip.ok { border-color: var(--good); color: var(--good); }
.mem-chip.cur { border-color: var(--coin); color: var(--text); }
.mem-evento { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 2px solid var(--line-2); border-left: 4px solid var(--coin); background: var(--surface); box-shadow: var(--mem-hard); min-width: 0; }
.mem-evento header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.mem-evento header b { font-weight: 500; color: var(--text); }
.mem-tag2 { padding: 2px 6px; border: 1px solid #000; background: var(--coin); font: 400 10px/1.4 var(--pixel-ui); letter-spacing: 0.04em; text-transform: uppercase; color: #0c0b10; }
.mem-fala { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; }
.mem-extraido { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.mem-extraido code { font: 400 12px/1.45 var(--mono); color: var(--accent); overflow-wrap: anywhere; }

/* fase 4 · os quatro códigos do "apaguem tudo" */
.mem-ops { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mem-ops > li { display: flex; flex-direction: column; gap: 6px; }
.mem-op {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 10px 12px;
  border: 2px solid var(--line-2); background: var(--surface); text-align: left; color: var(--text);
  box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.mem-op span { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mem-op b { font-weight: 500; font-size: 14px; }
.mem-op code { font: 400 12px/1.45 var(--mono); color: var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; }
.mem-op:hover:not(:disabled) { border-color: var(--line-3); }
.mem-op:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mem-op:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mem-op:disabled { cursor: default; }
.mem-ops > li.ok .mem-op { border-color: var(--good); background: var(--good-soft); }
.mem-ops > li.no .mem-op { border-color: var(--bad); background: var(--bad-soft); }

/* celular e tablet: objetivo primeiro, depois a cena, o gráfico, a lista, o retorno (junto do botão) e os controles */
@media (max-width: 920px) {
  .memg .sg-body { display: flex; flex-direction: column; gap: 12px; }
  .memg .sg-main, .memg .sg-ctrl { display: contents; }
  .memg .sg-head { order: 1; }
  .memg .sg-goal { order: 2; }
  .memg .sg-canvas { order: 3; }
  .memg .sg-caption { order: 4; }
  .memg .mem-board { order: 5; }
  .memg .mem-msg { order: 6; }
  .memg .mem-controls { order: 7; }
  .memg .sg-actions { order: 8; }
}
@media (max-width: 520px) {
  .mem-item { gap: 8px; padding: 7px 8px; }
  .mem-txt { font-size: 13.5px; }
  .mem-conv li { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .mem-fala { font-size: 14px; }
  .mem-tag { font-size: 9px; }
  .memg .sg-stats { gap: 6px; }
  .memg .sg-stats div { padding: 8px; }
  .memg .sg-stats dd { font-size: 15px; }
  .memg .sg-slider { grid-template-columns: 26px minmax(0, 1fr) 88px; }
}
