/* ==========================================================================
   EvoluAI — ML Basics · mlb-04 Treino e Teste (prefixo mts-) · tema pixel
   Os canvases são gráficos limpos em alta resolução (epoch/js/chart.js), com o
   Louro, o robô e os clientes em pixel art por cima. Aqui só o acabamento:
   cantos retos, bordas de 2px, sombras duras.
   ========================================================================== */

.mts {
  --mts-hard: 3px 3px 0 0 rgba(0, 0, 0, 0.5);
  --mts-n: #7ad7ff; /* normal (PAL.sky) */
  --mts-s: #ff7ab6; /* spam (PAL.pink) */
}

/* ---------- canvas e mini-gráfico ---------- */

.mts .sg-canvas,
.mts-mini {
  border-radius: 0;
  background: #0c0b10;
  box-shadow: var(--mts-hard);
  /* toque rápido nos envelopes e quadrantes, sem zoom de toque duplo; a página ainda rola */
  touch-action: manipulation;
}
.mts .sg-canvas { cursor: pointer; }
.mts .sg-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mts-mini { display: block; width: 100%; height: 150px; border: 1px solid var(--line); }
.mts-mini[hidden] { display: none; }

/* ---------- legenda sob o gráfico ---------- */

.mts .sg-caption { justify-content: flex-start; gap: 6px; font: 400 11px/1.3 var(--pixel-ui); color: var(--muted); }
.mts .sg-caption span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 2px solid var(--line-2);
  background: var(--bg-2);
}
/* as mesmas formas do mapa: normal = círculo azul, spam = losango rosa */
.mts-key { display: inline-block; width: 8px; height: 8px; }
.mts-key.n { background: var(--mts-n); border-radius: 50%; }
.mts-key.s { width: 7px; height: 7px; margin: 0 1px; background: var(--mts-s); transform: rotate(45deg); }

/* ---------- controles ---------- */

.mts-controls { display: flex; flex-direction: column; gap: 14px; }
.mts-msg:empty { display: none; }
.mts .sg-formula { border-color: var(--line-2); background: var(--bg); box-shadow: var(--mts-hard); }
.mts .sg-slider > .mono { font-family: var(--pixel); font-size: 15px; color: var(--accent); }
.mts .sg-slider output { font-family: var(--pixel-ui); font-size: 11px; }
.mts .sg-stats div { border-width: 2px; border-color: var(--line-2); background: var(--bg-2); box-shadow: var(--mts-hard); }
.mts .sg-stats dd { overflow-wrap: anywhere; }
.mts .sg-chip-toggle { background: var(--surface-2); box-shadow: 2px 2px 0 0 #000; min-height: 40px; }
.mts .sg-chip-toggle[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); border-color: #000; }
.mts .sg-chip-toggle:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mts .sg-chip-toggle:disabled { opacity: 0.45; cursor: not-allowed; }

/* fase 01: anterior · abrir · próximo */
.mts-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; }
.mts-nav .btn { min-height: 44px; border-radius: 0; }
.mts-tip { margin: -6px 0 0; font: 400 11px/1.4 var(--pixel-ui); color: var(--muted); }

/* fase 02: embaralhar e semente */
.mts-split { gap: 10px; }
.mts-seed { display: inline-flex; align-items: center; gap: 6px; }
.mts-seed button {
  width: 40px; height: 40px;
  border: 2px solid var(--line-2); border-radius: 0;
  background: var(--surface-2); color: var(--text);
  font: 400 18px/1 var(--pixel);
  box-shadow: 2px 2px 0 0 #000;
  cursor: pointer;
}
.mts-seed button:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mts-seed button:disabled { opacity: 0.45; cursor: not-allowed; }
.mts-seed button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mts-seed output { min-width: 2ch; text-align: center; font: 400 18px/1 var(--pixel); color: var(--accent); }

/* fase 03: rótulo do k (overfitting × underfitting) */
.mts-tag { padding: 8px 10px; border: 2px dashed var(--line-2); background: var(--bg-2); font: 400 11px/1.45 var(--pixel-ui); color: var(--text-2); }
.mts-tag.warn { border-color: var(--warn); color: var(--warn); }

/* fase 04: os quatro quadrantes como botões grandes */
.mts-cells { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: center; }
.mts-cells > .sg-label { text-align: center; line-height: 1.3; }
.mts-cells > .sg-label:nth-child(3n + 1) { text-align: right; max-width: 64px; }
.mts-cell {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 64px; padding: 8px 10px;
  border: 2px solid var(--line-2); border-radius: 0;
  background: var(--surface-2); color: var(--text);
  box-shadow: 2px 2px 0 0 #000;
  text-align: left; cursor: pointer;
  position: relative;
}
.mts-cell b { font: 400 18px/1 var(--pixel); }
.mts-cell.diag { border-color: color-mix(in srgb, var(--good) 55%, var(--line-2)); }
.mts-cell.diag b { color: var(--good); }
.mts-cell.off { border-color: color-mix(in srgb, var(--bad) 55%, var(--line-2)); }
.mts-cell.off b { color: var(--bad); }
.mts-cell small { font: 400 10.5px/1.3 var(--pixel-ui); color: var(--muted); }
.mts-cell kbd { position: absolute; top: 6px; right: 6px; }
.mts-cell:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: none; }
.mts-cell:disabled { opacity: 0.45; cursor: not-allowed; }
.mts-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* fase 05: a matriz do limiar em quatro chips */
.mts-quad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.mts-quad span {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px;
  border: 2px solid var(--line-2); background: var(--bg-2);
  font: 400 15px/1 var(--pixel); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.mts-quad b { font: 400 10.5px/1 var(--pixel-ui); }
.mts-quad .vn b, .mts-quad .vp b { color: var(--good); }
.mts-quad .fp b, .mts-quad .fn b { color: var(--bad); }

/* no toque, os atalhos de teclado só ocupam espaço */
@media (hover: none) {
  .mts kbd { display: none; }
}

/* ---------- celular: o que se mexe fica logo abaixo do gráfico ---------- */

@media (max-width: 920px) {
  .mts .sg-body { display: flex; flex-direction: column; gap: 12px; }
  .mts .sg-main, .mts .sg-ctrl { display: contents; }
  .mts .sg-head { order: 0; }
  .mts .sg-goal { order: 1; }
  .mts .sg-canvas { order: 2; }
  .mts .sg-caption { order: 3; }
  .mts-controls { order: 4; }
  .mts-mini { order: 5; }
  .mts-msg { order: 6; }
  .mts .sg-actions { order: 7; }
}

@media (max-width: 640px) {
  .mts .sg-canvas { height: 300px; }
  .mts-mini { height: 124px; }
  .mts .sg-caption { font-size: 10px; gap: 4px; }
  .mts .sg-caption span { padding: 3px 6px; }
  .mts .sg-stats { gap: 6px; }
  .mts .sg-stats div { padding: 8px; }
  .mts .sg-stats dd { font-size: 15px; }
  .mts-cell { min-height: 58px; padding: 6px 8px; }
}
