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

/* ---------- aula ---------- */
/* prefixo .rrka- · demos de js/games/rerank/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.rrka-canvas { touch-action: pan-y; }

/* a pergunta em destaque */
.rrka-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); }
.rrka-q > span:last-child { min-width: 0; overflow-wrap: anywhere; }

/* legendas dos gráficos: as mesmas cores do canvas (PAL de pixel.js) */
.rrka-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.rrka-legend span { display: inline-flex; align-items: center; gap: 5px; }
.rrka-legend i { flex: none; display: inline-block; width: 14px; height: 6px; border-radius: 3px; }
.rrka-legend .k-rr { background: #c8f53c; }
.rrka-legend .k-bi { height: 0; border-radius: 0; border-top: 2px dashed #7ad7ff; }
.rrka-legend .k-over { height: 10px; border-radius: 0; border: 1px dashed #ff6159; background: rgba(255, 97, 89, 0.14); }
.rrka-legend .k-alvo { background: #64d98b; }
.rrka-legend .k-up { background: #7ad7ff; }
.rrka-legend .k-down { background: #5b5675; }
.rrka-legend .k-dot { width: 8px; height: 8px; border-radius: 50%; background: #5b9bff; }
.rrka-legend .k-diag { height: 0; border-radius: 0; border-top: 2px dashed #8b84a3; }

/* o pedido que vai para a API */
.rrka-det { padding: 8px 10px; border: 2px dashed var(--line-2); background: var(--bg); }
.rrka-det summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.rrka-det summary:hover { color: var(--text); }
.rrka-det[open] summary { margin-bottom: 8px; }
.rrka-req { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.rrka-req .ai-msg { max-width: 100%; font-size: 12.5px; }

/* 2 · as notas do reranker, na nova ordem */
.rrka-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rrka-list li { display: grid; grid-template-columns: 20px minmax(0, 150px) 64px minmax(0, 1fr); gap: 4px 10px; align-items: baseline; padding: 7px 10px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg); }
.rrka-list li.alvo { border-color: var(--good); background: var(--good-soft); box-shadow: 2px 2px 0 0 rgba(0, 0, 0, 0.45); }
.rrka-pos { font-size: 12px; color: var(--accent); }
.rrka-id { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text); }
.rrka-nota { font-size: 11.5px; color: var(--muted); }
.rrka-nota b { font-weight: 600; color: var(--text); }
.rrka-list li.alvo .rrka-nota b { color: var(--good); }
.rrka-raw { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0; border: 0; background: none; font: 400 11.5px/1.4 var(--mono); color: var(--muted); }
.rrka-txt { grid-column: 2 / -1; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
@media (max-width: 560px) {
  .rrka-list li { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .rrka-raw { grid-column: 2 / -1; }
}

/* 3 · a conversa, a reescrita e as duas buscas lado a lado */
.rrka-conv .ai-msg { font-size: 13px; }
.rrka-rew { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0; padding: 10px 12px; border: 2px solid var(--accent-line); border-left: 4px solid var(--accent); background: var(--accent-soft); font-size: 14px; line-height: 1.45; }
.rrka-rew b { min-width: 0; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.rrka-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 720px) { .rrka-duo { grid-template-columns: 1fr; } }
.rrka-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 10px; border: 2px dashed var(--line-2); background: var(--bg); }
.rrka-col .sg-label { margin: 0; }
.rrka-cq { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; }
.rrka-rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: rrka; }
.rrka-rank li { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 2px 8px; padding: 6px 8px; border: 2px solid var(--line); border-left-width: 4px; background: var(--bg-2); counter-increment: rrka; }
.rrka-rank li::before { content: counter(rrka); grid-row: span 2; font: 400 12px/1.5 var(--mono); color: var(--faint); }
.rrka-rank li.alvo { border-color: var(--good); background: var(--good-soft); }
.rrka-rank li .mono { font-size: 11.5px; color: var(--text); }
.rrka-rank li span:last-child { font-size: 12px; line-height: 1.4; color: var(--muted); }
.rrka-verdict { margin: 0; font: 500 12.5px/1.45 var(--mono); color: var(--muted); }
.rrka-verdict.good { color: var(--good); }
.rrka-verdict.bad { color: var(--bad); }

/* 4 · as variações (botões que ligam e desligam) */
.rrka-vars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 640px) { .rrka-vars { grid-template-columns: 1fr; } }
.rrka-var { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: baseline; width: 100%; padding: 8px 10px; border: 2px solid var(--line-2); background: var(--surface); font-size: 13.5px; line-height: 1.4; text-align: left; color: var(--muted); }
.rrka-var:hover { border-color: var(--accent-line); color: var(--text); }
.rrka-var:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rrka-var:active { transform: translate(2px, 2px); }
.rrka-var[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: 2px 2px 0 0 rgba(0, 0, 0, 0.45); }
.rrka-tag { display: inline-grid; place-items: center; height: 20px; border: 1px solid #000; background: var(--bg); font-size: 11.5px; font-weight: 600; }
.rrka-msg { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.rrka-msg:empty { display: none; }
.rrka-msg.good { color: var(--good); }
.rrka-msg.bad { color: var(--bad); }

/* 5 · o trecho hipotético */
.rrka-cap { margin: 0; }

/* ---------- jogo ---------- */
/* raiz do jogo: .rrkg · prefixo .rrk- · "A Peneira" (js/games/rerank/game.js); a base vem de .sg-* (css/games.css) */

.rrkg { --rrk-hard: 3px 3px 0 0 rgba(0, 0, 0, 0.5); }

/* campo (a cena do balcão em pixel art, o resto em gráfico limpo): só toques, nada se arrasta, então o dedo ainda rola a página */
.rrkg .sg-canvas {
  border-radius: 0;
  background: #141320;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: var(--rrk-hard);
  touch-action: manipulation;
}
/* nas fases de dados o mesmo canvas vira gráfico limpo (chart.js, em resolução de tela): sem pixelated */
.rrkg .sg-canvas.chart-canvas { image-rendering: auto; }
.rrkg .sg-canvas.rrk-short { height: 240px; }
@media (max-width: 640px) { .rrkg .sg-canvas.rrk-short { height: 200px; } }

/* leitura sob o campo: chips de HUD */
.rrkg .sg-caption { justify-content: flex-start; gap: 6px; font: 400 11px/1.3 var(--pixel-ui); color: var(--muted); }
.rrkg .sg-caption:empty { display: none; }
.rrkg .sg-caption span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; padding: 4px 8px; border: 2px solid var(--line-2); background: var(--bg-2); overflow-wrap: anywhere; }
.rrkg .sg-caption b { font-weight: 400; color: var(--accent); }
/* as mesmas cores do canvas (PAL de pixel.js) */
.rrk-dot { flex: none; display: inline-block; width: 9px; height: 9px; border: 1px solid #000; }
.rrk-dot.pool { background: #434b30; border-color: #7aa418; }
.rrk-dot.ok { background: #64d98b; }
.rrk-dot.lido { background: #ff8c2e; }
.rrk-dot.no { background: #a14242; }
.rrk-dot.alvo { background: transparent; border: 2px solid #ffd23f; }

/* painel de controles */
.rrk-controls { display: flex; flex-direction: column; gap: 12px; }
.rrk-msg:empty { display: none; }
.rrk-msg .mono { font-size: 0.95em; }
.rrk-more { color: var(--muted); }
.rrk-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(--rrk-hard); }
.rrk-ask b { color: var(--text); font-weight: 500; }
.rrkg .sg-formula { border-radius: 0; border-color: var(--line-2); background: var(--bg); box-shadow: var(--rrk-hard); }
.rrkg .sg-formula .muted { font-size: 11.5px; }
.rrkg .sg-slider > .mono { font-family: var(--pixel); font-size: 16px; color: var(--accent); }
.rrkg .sg-slider output { font-family: var(--pixel-ui); font-size: 11px; }
.rrkg .sg-stats div { border-radius: 0; border-width: 2px; border-color: var(--line-2); background: var(--bg-2); box-shadow: var(--rrk-hard); }
.rrkg .sg-stats dd small { display: block; margin-top: 4px; font: 400 10.5px/1.2 var(--mono); letter-spacing: 0; color: var(--muted); }
.rrkg .sg-stats.rrk-stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rrkg .sg-goal, .rrkg .sg-msg { border-radius: 0; }
.rrk-mini { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.rrkg .btn kbd { margin-left: 6px; }
.rrk-keys { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }

/* abaixo do campo */
.rrk-board { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.rrk-board[hidden] { display: none; }
.rrk-board .sg-label { line-height: 1.4; }
.rrk-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); box-shadow: var(--rrk-hard); }
.rrk-q > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.rrk-note { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.rrk-key { flex: none; display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 4px; border: 2px solid var(--line-2); background: var(--bg); font-size: 11px; color: var(--muted); }

/* fase 2: os candidatos (o trecho, ou a resposta crua do LLM) */
.rrk-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; }
.rrk-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 8px;
  width: 100%; height: 100%; padding: 8px 10px; border: 2px solid var(--line-2); background: var(--surface);
  text-align: left; color: var(--text-2); box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.rrk-card:hover:not(:disabled) { border-color: var(--line-3); color: var(--text); }
.rrk-card:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.rrk-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rrk-card:disabled { cursor: default; }
.rrk-card.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.rrk-card.no { border-color: var(--bad); background: var(--bad-soft); }
.rrk-cid { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text); }
.rrk-cid small { margin-left: 8px; font-size: 11px; color: var(--muted); }
.rrk-pos { justify-self: end; min-width: 22px; font-size: 12px; text-align: right; color: var(--accent); }
.rrk-txt { grid-column: 1 / -1; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.rrk-bruta { grid-column: 1 / -1; justify-self: start; max-width: 100%; padding: 4px 8px; border: 1px solid var(--line-2); background: var(--bg); font: 400 12.5px/1.45 var(--mono); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.rrk-why { grid-column: 1 / -1; font-size: 12px; line-height: 1.45; color: var(--muted); }
.rrk-why b { font-weight: 500; color: var(--text); }
.rrk-grau { display: inline-block; margin-right: 6px; padding: 1px 6px; border: 1px solid #000; font: 400 10px/1.5 var(--pixel-ui); letter-spacing: 0.03em; text-transform: uppercase; color: #0c0b10 !important; }
.rrk-grau.g0 { background: #8b84a3; }
.rrk-grau.g1 { background: #7ad7ff; }
.rrk-grau.g2 { background: #c8f53c; }
.rrk-grau.g3 { background: #64d98b; }

/* fase 3: a conversa e as opções */
.rrk-chat .ai-msg { font-size: 13px; }
.rrk-opts, .rrk-vars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rrk-opt, .rrk-var {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 10px;
  width: 100%; padding: 9px 10px; border: 2px solid var(--line-2); background: var(--surface);
  text-align: left; color: var(--text-2); box-shadow: 2px 2px 0 0 #000; cursor: pointer;
}
.rrk-otxt { font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.rrk-opt small, .rrk-var small { grid-column: 2; font-size: 12px; line-height: 1.4; color: var(--muted); }
.rrk-opt:hover:not(:disabled), .rrk-var:hover:not(:disabled) { border-color: var(--line-3); color: var(--text); }
.rrk-opt:active:not(:disabled), .rrk-var:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.rrk-opt:focus-visible, .rrk-var:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.rrk-opt:disabled, .rrk-var:disabled { cursor: default; }
.rrk-opt.no { border-color: var(--bad); background: var(--bad-soft); opacity: 0.85; }
.rrk-opt.no small { color: var(--bad); }
.rrk-opt.ok { border-color: var(--good); background: var(--good-soft); color: var(--text); }
.rrk-opt.ok small { color: var(--good); }

/* fase 4: as variações (ligam e desligam) */
.rrk-var[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.rrk-var.no { border-color: var(--bad); background: var(--bad-soft); }
.rrk-var.no small { color: var(--bad); }
.rrk-var.miss { border-style: dashed; border-color: var(--warn); }
.rrk-var.ok small { color: var(--good); }
.rrk-tag { display: inline-grid; place-items: center; min-width: 28px; height: 20px; border: 1px solid #000; background: var(--bg); font-size: 11.5px; font-weight: 600; color: var(--c, var(--text)); }

/* celular e tablet: objetivo primeiro, depois o campo, os candidatos e os controles */
@media (max-width: 920px) {
  .rrkg .sg-body { display: flex; flex-direction: column; gap: 12px; }
  .rrkg .sg-main, .rrkg .sg-ctrl { display: contents; }
  .rrkg .sg-head { order: 1; }
  .rrkg .sg-goal { order: 2; }
  .rrkg .sg-canvas { order: 3; }
  .rrkg .sg-caption { order: 4; }
  .rrkg .rrk-board { order: 5; }
  .rrkg .rrk-controls { order: 6; }
  .rrkg .rrk-msg { order: 7; }
  .rrkg .sg-actions { order: 8; }
}
@media (max-width: 520px) {
  .rrk-cards { grid-template-columns: minmax(0, 1fr); }
  .rrkg .sg-stats { gap: 6px; }
  .rrkg .sg-stats div { padding: 8px; }
  .rrkg .sg-stats dd { font-size: 15px; }
  .rrk-cid small { display: block; margin: 2px 0 0; }
}
/* no celular não há teclado: some a linha de atalhos, as teclas dos botões e os números das opções */
@media (hover: none) and (pointer: coarse) {
  .rrk-keys, .rrkg kbd, .rrkg .rrk-key { display: none; }
  .rrk-card { grid-template-columns: minmax(0, 1fr) auto; }
  .rrk-opt { grid-template-columns: minmax(0, 1fr); }
  .rrk-opt small { grid-column: 1; }
}
