/* ── Tyre Vision QC ─────────────────────────────────────────────
   Layers on top of style.css; reuses its .card / .grid / .hero
   primitives and brand.css tokens. Only the vision-specific
   pieces live here. */

/* ── Demo switch ── */
.demo-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 26px 0 4px;
}

.demo-tab {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.demo-tab:hover { border-color: var(--primary); }
.demo-tab.is-active {
  border-color: var(--primary);
  background: var(--accent-soft);
}

.demo-tab .tab-idx {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
  padding-top: 2px;
}
.demo-tab.is-active .tab-idx { color: var(--primary); }

.demo-tab .tab-body { display: flex; flex-direction: column; gap: 3px; }
.demo-tab .tab-body b { font-size: 14px; font-weight: 600; letter-spacing: -0.03em; }
.demo-tab .tab-body em {
  font-style: normal;
  font-size: 12.5px;
  color: var(--muted-foreground);
}

/* ── Pane visibility ── */
.demo-pane { display: none; }
.demo-pane.is-active { display: block; }

/* ── Image stage ── */
.img-stage {
  position: relative;
  width: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.img-stage canvas {
  max-width: 100%;
  max-height: 420px;
  display: block;
}
.img-stage canvas:not([data-loaded]) { display: none; }

.stage-empty {
  position: absolute;
  font-size: 13px;
  color: var(--ink-faint);
  pointer-events: none;
}
.img-stage.is-loaded .stage-empty { display: none; }

.img-stage.is-busy::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--primary-rgb), 0.14),
    transparent
  );
  animation: sweep 1.1s var(--ease) infinite;
}
@keyframes sweep {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}

/* ── TIN display ── */
.tin-wrap { display: flex; flex-direction: column; gap: 12px; }

.tin-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 62px;
  padding: 14px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.tin-placeholder { font-size: 13px; color: var(--ink-faint); font-family: inherit; }

/* One glyph of the TIN, tinted by per-character confidence. */
.tin-char {
  position: relative;
  min-width: 26px;
  padding: 8px 4px;
  text-align: center;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 3px;
  border-bottom: 2px solid var(--conf, var(--green));
  background: var(--panel);
}
.tin-char[data-low="1"] { background: rgba(180, 83, 9, 0.1); }
.tin-char[data-low="2"] { background: rgba(221, 37, 37, 0.12); }

/* Field-group separators inside the TIN. */
.tin-gap { width: 10px; }
.tin-group-label {
  width: 100%;
  font-family: var(--font-ui, inherit);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ── Reconciliation ── */
.reconcile-empty {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.reconcile-list { list-style: none; padding: 0; margin: 0; }
.reconcile-list li {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.reconcile-list li:last-child { border-bottom: none; }
.reconcile-list .rc-name { color: var(--muted-foreground); }
.reconcile-list .rc-val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}
.reconcile-list .rc-arrow { color: var(--ink-faint); }
.reconcile-list .rc-flag { font-weight: 600; font-size: 12px; }
.rc-flag.ok { color: var(--green); }
.rc-flag.bad { color: var(--red); }

.verdict {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid transparent;
}
.verdict.pass {
  background: var(--green-soft);
  border-color: rgba(var(--primary-rgb), 0.3);
  color: var(--accent-bg-foreground);
}
.verdict.fail {
  background: rgba(221, 37, 37, 0.09);
  border-color: rgba(221, 37, 37, 0.3);
  color: var(--red);
}
.verdict b { display: block; margin-bottom: 4px; font-size: 14px; }

/* ── Assessment ── */
.det-wrap { display: flex; flex-direction: column; gap: 16px; }

.assess-placeholder { font-size: 13px; color: var(--ink-faint); }

.assess-verdict {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.assess-verdict.ok {
  background: var(--green-soft);
  border-color: rgba(var(--primary-rgb), 0.3);
}
.assess-verdict.bad {
  background: rgba(221, 37, 37, 0.09);
  border-color: rgba(221, 37, 37, 0.3);
}

.assess-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-foreground);
}
.assess-verdict.ok .assess-icon { background: var(--green); }
.assess-verdict.bad .assess-icon { background: var(--red); }

.assess-verdict b {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.assess-verdict.ok b { color: var(--accent-bg-foreground); }
.assess-verdict.bad b { color: var(--red); }
.assess-verdict em {
  font-style: normal;
  font-size: 12.5px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: var(--muted-foreground);
}

.assess-note {
  margin: 12px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted-foreground);
}

/* ── Probability bars ── */
.prob-bars { display: flex; flex-direction: column; gap: 9px; }
.prob-row {
  display: grid;
  grid-template-columns: 76px 1fr 48px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.prob-name { color: var(--muted-foreground); }
.prob-track {
  height: 7px;
  border-radius: 4px;
  background: var(--field);
  overflow: hidden;
}
.prob-fill { display: block; height: 100%; border-radius: 4px; }
.prob-fill.ok { background: var(--green); }
.prob-fill.bad { background: var(--red); }
.prob-pct {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12.5px;
  text-align: right;
}

/* ── Sample picker ── */
.sample-picker { display: flex; flex-direction: column; gap: 9px; width: 100%; }

.sample-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.sample-tile {
  position: relative;
  display: block;
  padding: 0;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}
.sample-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.sample-tile.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
}

.sample-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Caption sits over the image so the tiles stay square and dense. */
.sample-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 6px 5px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82) 55%);
}
.sample-tag.bad { color: #ff9b9b; }
.sample-tag.ok { color: #9bf0ae; }

@media (max-width: 900px) {
  .sample-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── Confidence slider ── */
.conf-slider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.conf-slider label { color: var(--muted-foreground); white-space: nowrap; }
.conf-slider input[type="range"] { accent-color: var(--primary); width: 130px; }
.conf-slider output {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  min-width: 34px;
}

/* ── Provenance note ── */
.provenance {
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted-foreground);
  margin: 0;
}
.provenance b { color: var(--foreground); font-weight: 600; }

/* ── Raw response blocks ── */
#traceRaw, #defectRaw {
  max-height: 260px;
  overflow: auto;
}

/* ── Narrow screens ── */
@media (max-width: 720px) {
  .demo-tabs { grid-template-columns: 1fr; }
  .reconcile-list li { grid-template-columns: 1fr auto; row-gap: 4px; }
  .conf-slider { width: 100%; }
}
