/* ==========================================================================================================
   labs.css — shared components of the multimodal laboratories (/lab/image, /lab/text, /lab/audio, /lab/tabular,
   /lab/compare). Loaded after site.css; uses its tokens only. Lab-specific rules live at the end, one section per
   lab (text, audio, tabular), so each lab has one owner.
   ========================================================================================================== */

/* the workbench takes the page's modality hue (site.css pins the FGSM hue on .workbench) */
[data-mod="text"] .workbench { --mod: var(--indigo); --mod-vivid: var(--indigo-vivid); --mod-ui: var(--indigo-ui); --mod-soft: var(--indigo-soft); }
[data-mod="audio"] .workbench { --mod: var(--teal); --mod-vivid: var(--teal-vivid); --mod-ui: var(--teal-ui); --mod-soft: var(--teal-soft); }
[data-mod="tabular"] .workbench { --mod: var(--orange); --mod-vivid: var(--orange-vivid); --mod-ui: var(--orange-ui); --mod-soft: var(--orange-soft); }

/* phones and tablets: controls above results (the FGSM ordering by CSS order is specific to that instrument) */
@media (max-width: 1023px) {
  .workbench.mm-bench { display: grid; gap: 0; padding: 0; }
  .workbench.mm-bench .wb-controls, .workbench.mm-bench .wb-results { display: grid; }
  .workbench.mm-bench .wb-controls { border-bottom: 1px solid var(--line); }
}
.mm-bench .wb-results { gap: 14px; }
/* result panels are never a silent blank: until the first result (data-phase on <main>, set by the lab through
   NIR_MM_UI.setPhase) an empty panel says what it is waiting for; the status line above carries the file progress */
main[data-phase="loading"] :is(.pred-card, #mm-checks, #pop-matrix):empty::before,
main[data-phase="error"] :is(.pred-card, #mm-checks, #pop-matrix):empty::before { display: block; padding: 10px 2px; color: var(--faint); font-size: 0.875rem; line-height: 1.45; }
main[data-phase="loading"] :is(.pred-card, #mm-checks, #pop-matrix):empty::before { content: "Модели и данные загружаются — результат появится здесь."; }
main[data-phase="error"] :is(.pred-card, #mm-checks, #pop-matrix):empty::before { content: "Результата нет: данные не загрузились. Причина — в строке состояния; страницу можно обновить."; }
.mm-bench .ctl select { min-height: 36px; font-size: 0.875rem; }
.mm-bench .ctl .btn.primary { width: 100%; }
.mm-run-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }

/* Uzbek glosses: visible only in UZ explanation mode (the existing .lang-uz mechanism, applied to labels) */
.uzg { display: none; }
:root[data-uz="on"] .uzg { display: inline; margin-left: 0.4em; font-size: 0.86em; font-weight: 500; color: var(--emerald); }
:root[data-uz="on"] .uzg.blk { display: block; margin-left: 0; margin-top: 2px; }
:root[data-uz="on"] .uzg::before { content: "· "; }
:root[data-uz="on"] .uzg.blk::before { content: "UZ · "; font-size: 0.85em; letter-spacing: 0.04em; }

/* evidence tags */
.tag.todo { color: var(--faint); border-style: dotted; }
.mm-prov { margin: 6px 0 0; font-size: var(--t-meta); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; max-width: 110ch; }
.mm-prov .tag { flex: 0 0 auto; }

/* predictions: class names are words, not digits */
.pred-value .digit.word { font-size: clamp(1.375rem, 1.15rem + 0.6vw, 1.875rem); letter-spacing: -0.015em; white-space: nowrap; }
.mm-bench .pred-value { min-width: 4.4rem; }

/* constraint checks */
.mm-checks-sum { margin: 0 0 8px; font-weight: 650; font-size: 0.9375rem; }
.mm-checks-sum.ok { color: var(--emerald); } .mm-checks-sum.bad { color: var(--coral); }
table.mm-checks td, table.mm-checks th { padding: 0.4rem 0.6rem; }
table.mm-checks tr.is-bad td { background: color-mix(in srgb, var(--coral-soft) 70%, transparent); }
table.mm-checks .why { display: block; font-size: var(--t-meta); color: var(--coral); margin-top: 2px; }

/* metric row and quad inside the lab */
.mm-metrics { margin-top: 4px; }
.stat-row.tight.c5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1099px) { .stat-row.tight.c5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stat-row.tight.c5 > .stat:nth-child(4) { padding-left: 0; border-left: 0; } }
@media (max-width: 759px) { .stat-row.tight.c5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat-row.tight.c5 > .stat:nth-child(4) { padding-left: 16px; border-left: 1px solid var(--line); } .stat-row.tight.c5 > .stat:nth-child(odd) { padding-left: 0; border-left: 0; } }
.mm-quad { max-width: 640px; }
.mm-quad .q b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

/* N×N matrices (3 models per new lab; the pilot's 4×4 rules stay in site.css) */
.heatmap.big.mm-matrix.n3 .hrow { grid-template-columns: 112px repeat(3, minmax(84px, 1fr)); }
.heatmap.big.mm-matrix.n2 .hrow { grid-template-columns: 112px repeat(2, minmax(96px, 1fr)); }
.heatmap.big.mm-matrix { max-width: 760px; }
.heatmap.big.mm-matrix button.cell { font: inherit; color: inherit; width: 100%; cursor: pointer; }
.heatmap.big.mm-matrix .cell.sel, .heatmap.big.mm-matrix .cell[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 1px; position: relative; z-index: 1; }
@media (max-width: 600px) { .heatmap.big.mm-matrix.n3 .hrow { grid-template-columns: 70px repeat(3, minmax(0, 1fr)); } }

/* traces and long tables */
.mm-trace { max-height: 340px; overflow: auto; }
.mm-trace table.data td, .mm-trace table.data th { white-space: nowrap; }
.mm-trace tr.accepted td { background: color-mix(in srgb, var(--emerald-soft) 75%, transparent); }
.mm-trace tr.rejected td { color: var(--muted); }

/* guided walkthrough */
.mm-guide { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--panel); display: grid; gap: 6px; max-width: 880px; }
.mm-guide-n { margin: 0; font-family: var(--font-mono); font-size: 0.75rem; color: var(--mod, var(--faint)); }
.mm-guide-t { margin: 0; font-size: 1.0625rem; }
.mm-guide-b { margin: 0; color: var(--ink-2); max-width: 80ch; }
.mm-spot { outline: 3px solid var(--mod-vivid, var(--azure-vivid)); outline-offset: 4px; border-radius: 10px; transition: outline-color 0.3s ease; }

/* modality index (overview, compare, image page) */
.mm-index { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); border-top: 1px solid var(--line); }
@media (min-width: 900px) { .mm-index { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mm-index > li:nth-child(2n) { border-left: 1px solid var(--line); padding-left: 24px; } .mm-index > li:nth-child(2n+1) { padding-right: 24px; } }
@media (min-width: 1400px) { .mm-index.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .mm-index.c4 > li { border-left: 1px solid var(--line); padding: 0 20px; } .mm-index.c4 > li:first-child { border-left: 0; padding-left: 0; } }
.mm-index > li { margin: 0; padding-top: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line); max-width: none; display: flex; flex-direction: column; gap: 6px; }
.mm-index .mod-h { margin: 0; display: flex; align-items: center; gap: 9px; font-size: 1.125rem; }
.mm-index .mod-h .ic { color: var(--mod); width: 20px; height: 20px; }
.mm-index p { margin: 0; color: var(--ink-2); font-size: 0.9375rem; }
.mm-index .meta { font-size: var(--t-meta); color: var(--muted); }
.mm-index .go { margin-top: auto; padding-top: 4px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--mod); text-decoration: none; }
.mm-index .go:hover { text-decoration: underline; }

/* comparison tables */
table.mm-compare { min-width: 860px; }
table.mm-compare th[scope="row"] { color: var(--muted); font-weight: 600; width: 12rem; }
table.mm-compare td.mod-cell { font-weight: 650; }
.mm-warn-list li { margin-bottom: 6px; }

/* lab-specific styles live in mm-text.css, mm-audio.css and mm-tabular.css (one owner per file) */

/* home: the modality strip under the live instrument, kept compact */
.mm-home .mm-index > li { padding-top: 12px; padding-bottom: 12px; gap: 4px; }
.mm-home .mm-index .mod-h { font-size: 1rem; }
.mm-home .mm-index p { font-size: 0.875rem; color: var(--muted); }

/* phones/tablets: site.css orders FGSM instrument blocks with CSS `order` (.verdict, .pred-grid, .drawer, .lang-uz,
   .ctl-pair …); the modality benches keep their own source order instead */
@media (max-width: 1023px) {
  .workbench.mm-bench .wb-controls > *, .workbench.mm-bench .wb-results > * { order: 0; }
}
/* figures on modality pages never let a wide table or chart widen the page */
.mm-page .fig { grid-template-columns: minmax(0, 1fr); }

/* literature: strands of the multimodal references */
.bib-entry[data-strand="taxonomy"] { --mod: var(--ink); --mod-vivid: var(--ink-2); }
.bib-entry[data-strand="text"] { --mod: var(--indigo); --mod-vivid: var(--indigo-vivid); }
.bib-entry[data-strand="audio"] { --mod: var(--teal); --mod-vivid: var(--teal-vivid); }
.bib-entry[data-strand="tabular"] { --mod: var(--orange); --mod-vivid: var(--orange-vivid); }
.bib-links a + a { margin-left: 0; }
