/*
 * Architect evidence visuals. Role tokens over Lectern's tokens
 * (desktop/src/styles/tokens.css, copied verbatim there from Lectern); this file
 * only names jobs and picks steps. Load after tokens.css, fonts.css and
 * motion.css (the working mark's keyframes).
 *
 * Steps were picked by measured contrast on --card (SPEC.md, "Colour"):
 * pine 700 is 12.7:1 on white but 1.3:1 on the dark card, so every pine role
 * steps up to 300 in dark.
 */

.viz {
  --viz-surface: var(--card);
  --viz-rule: var(--accent-700);        /* the bar, everywhere */
  --viz-mark: var(--accent-700);        /* exam rings, licensed fills, the practice score that sat the exam */
  --viz-unit: var(--accent-500);        /* exam units: one step lighter, so the rule reads through them */
  --viz-trail-old: var(--accent-300);   /* earlier practice measures */
  --viz-trail-new: var(--accent-500);   /* later practice measures */
  --viz-ref: var(--text-faint);         /* the best preset: grey tick, its link */
  --viz-context: var(--text-ghost);     /* points outside the claim */
  --viz-track: var(--divider);
  --viz-track-quiet: var(--hairline);
  --viz-frame: var(--divider);
  --viz-diagonal: var(--border);
  --viz-quad: var(--accent-100);        /* the caught quadrant, lit */
  --viz-on-mark: var(--on-accent);      /* the lock on a licensed ring */
  --viz-focus: var(--accent-500);
  margin: 0;
  color: hsl(var(--text));
  font-family: var(--font-sans);
}

html[data-theme="dark"] .viz {
  --viz-rule: var(--accent-300);
  --viz-mark: var(--accent-300);
  --viz-unit: var(--accent-400);
  --viz-trail-old: var(--accent-500);
  --viz-trail-new: var(--accent-400);
  --viz-quad: var(--accent-700);
  --viz-on-mark: var(--bg);
  --viz-focus: var(--accent-300);
}

.viz-svg { display: block; overflow: visible; max-width: 100%; height: auto; }
.viz .num, .viz-svg .viz-num, .viz-axis text { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-cap { font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; fill: hsl(var(--text-faint)); }

/* The bar: a pine rule, round-capped, the one line in every visual that is never grey. */
.viz-rule { stroke: hsl(var(--viz-rule)); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.viz-rule-label .viz-num { font-size: 12px; font-weight: 600; fill: hsl(var(--ink)); }
.viz-axis text { font-size: 11px; fill: hsl(var(--text-faint)); }
/* Axis titles are words: the caption face, never the numeral face their group defaults to. */
.viz-axis .viz-cap { font-family: var(--font-caption); font-variant-numeric: normal; }

/* ---- bar view ---------------------------------------------------------- */
.viz-track { stroke: hsl(var(--viz-track)); stroke-width: 1; }
.viz-row.is-pending .viz-track, .viz-row.is-skipped .viz-track { stroke: hsl(var(--viz-track-quiet)); }
.viz-name { font-family: var(--font-sans); font-size: 13px; font-weight: 500; fill: hsl(var(--text)); }
.viz-row.is-pending .viz-name, .viz-row.is-skipped .viz-name { fill: hsl(var(--text-faint)); }
.viz-row.is-ships .viz-name { fill: hsl(var(--ink)); font-weight: 600; }
.viz-working { color: hsl(var(--viz-mark)); }

.viz-tick { stroke: hsl(var(--viz-ref)); stroke-width: 2; stroke-linecap: round; }
.viz-link { stroke-width: 1.5; stroke-linecap: round; }
.viz-link.is-forge { stroke: hsl(var(--viz-mark)); }
.viz-link.is-preset { stroke: hsl(var(--viz-ref)); }
.viz-dot { stroke: hsl(var(--viz-surface)); stroke-width: 1.5; paint-order: stroke; }
.viz-dot.is-old { fill: hsl(var(--viz-trail-old)); }
.viz-dot.is-new { fill: hsl(var(--viz-trail-new)); }
.viz-dot.is-best { fill: hsl(var(--viz-mark)); stroke-width: 4; }

.viz-hit { fill: transparent; stroke: transparent; stroke-width: 2; }
.viz-halo { fill: hsl(var(--viz-surface)); }
.viz-ring-shape { fill: hsl(var(--viz-surface)); stroke: hsl(var(--viz-mark)); stroke-width: 1.5; }
.viz-ring.is-licensed .viz-ring-shape { fill: hsl(var(--viz-mark)); }
.viz-lock { stroke: hsl(var(--viz-mark)); }
.viz-ring.is-licensed .viz-lock { stroke: hsl(var(--viz-on-mark)); }
.viz-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; fill: hsl(var(--ink)); }
.viz-value.is-refused { font-weight: 500; fill: hsl(var(--text-mute)); }
.viz-value.is-unscored { font-family: var(--font-sans); font-size: 12px; font-weight: 500; fill: hsl(var(--text-faint)); }

.viz-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 6px;
  padding-left: var(--viz-legend-indent, 0px);
  font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: hsl(var(--text-faint));
}
.viz-legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.viz-legend svg { display: block; overflow: visible; }

/* ---- exam chart -------------------------------------------------------- */
.viz-exam { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px 36px; }
.viz-unit.is-correct { fill: hsl(var(--viz-unit)); }
.viz-unit.is-missed { fill: none; stroke: hsl(var(--viz-unit)); stroke-width: 1.5; }
.viz-unit.is-invalid, .viz-unit.is-over { fill: none; stroke: hsl(var(--viz-unit)); stroke-width: 1.9; stroke-linecap: round; }
.viz-unit.is-unscored { fill: none; stroke: hsl(var(--viz-track)); stroke-width: 1.5; }

.viz-exam-side { display: flex; flex-direction: column; gap: 14px; min-width: 150px; }
.viz-exam-score { margin: 0; display: flex; align-items: center; gap: 9px; }
.viz-score { font-family: var(--font-mono); font-size: 24px; font-weight: 500; line-height: 1; letter-spacing: -0.01em; color: hsl(var(--ink)); }
.viz-score.is-unscored { font-family: var(--font-sans); font-size: 14px; color: hsl(var(--text-mute)); }
.viz-of { font-size: 0.62em; color: hsl(var(--text-faint)); letter-spacing: 0; }
.viz-verdict { display: inline-flex; color: hsl(var(--viz-mark)); }
.viz-verdict.is-refused { color: hsl(var(--text-mute)); }
.viz-exam-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.viz-exam-key li { display: grid; grid-template-columns: 12px 30px auto; align-items: center; column-gap: 8px; font-size: 12.5px; color: hsl(var(--text-mute)); }
.viz-exam-key li .num { text-align: right; font-size: 12.5px; font-weight: 500; color: hsl(var(--ink)); }
.viz-exam-key li.is-zero, .viz-exam-key li.is-zero .num { color: hsl(var(--text-faint)); }
.viz-exam-key svg { display: block; overflow: visible; }

/* ---- gate scatter ------------------------------------------------------ */
.viz-frame { fill: none; stroke: hsl(var(--viz-frame)); stroke-width: 1; }
.viz-diagonal { stroke: hsl(var(--viz-diagonal)); stroke-width: 1; }
.viz-quad { fill: hsl(var(--viz-quad)); opacity: 0; transition: opacity 240ms cubic-bezier(0.4, 0, 0.2, 1); }
.viz-scatter.is-lit .viz-quad { opacity: 1; }
.viz-pt-shape { transition: fill 240ms cubic-bezier(0.4, 0, 0.2, 1), stroke 240ms cubic-bezier(0.4, 0, 0.2, 1); }
.viz-pt.is-solid .viz-pt-shape { fill: hsl(var(--viz-mark)); }
.viz-pt.is-hollow .viz-pt-shape { fill: none; stroke: hsl(var(--viz-mark)); stroke-width: 1.5; }
.viz-scatter.is-lit .viz-pt.is-context.is-solid .viz-pt-shape { fill: hsl(var(--viz-context)); }
.viz-scatter.is-lit .viz-pt.is-context.is-hollow .viz-pt-shape { stroke: hsl(var(--viz-context)); }
.viz-note { opacity: 0; transition: opacity 240ms cubic-bezier(0.4, 0, 0.2, 1) 120ms; }
.viz-scatter.is-lit .viz-note { opacity: 1; }
.viz-note-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-num-strong { font-size: 17px; font-weight: 600; fill: hsl(var(--ink)); }
.viz-num-soft { font-size: 13px; font-weight: 500; fill: hsl(var(--text-mute)); }
.viz-note-text { font-family: var(--font-sans); font-size: 12.5px; font-weight: 500; fill: hsl(var(--text)); }
.viz-scatter-note { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; margin: 10px 0 0; font-size: 12.5px; font-weight: 500; color: hsl(var(--text)); }
.viz-scatter-note .num { font-family: var(--font-mono); color: hsl(var(--text-mute)); }
.viz-scatter-note .viz-strong { font-size: 15px; font-weight: 600; color: hsl(var(--ink)); }
.viz-swatch { width: 12px; height: 12px; border-radius: 3px; background: hsl(var(--viz-quad)); box-shadow: inset 0 0 0 1px hsl(var(--viz-mark) / 0.25); }

/* ---- motion: a value arrives once, at its value, and settles ----------- */
.viz-enter { animation: viz-in 180ms cubic-bezier(0.16, 1, 0.3, 1) both; transform-box: fill-box; transform-origin: center; }
line.viz-enter, text.viz-enter { animation-name: viz-fade; animation-duration: 220ms; }
@keyframes viz-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes viz-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .viz-enter, line.viz-enter, text.viz-enter { animation: viz-fade 120ms linear both; }
  .viz-quad, .viz-pt-shape, .viz-note { transition-duration: 0ms; transition-delay: 0ms; }
}

/* ---- focus and hover readouts ----------------------------------------- */
.viz [tabindex]:focus { outline: none; }
.viz [tabindex]:focus-visible .viz-hit { stroke: hsl(var(--viz-focus) / 0.6); }
.viz [data-tip] { cursor: default; }
.viz-tip {
  position: absolute; left: 0; top: 0; z-index: 70; pointer-events: none; max-width: 280px;
  padding: 5px 8px; border-radius: 6px; font: 500 11.5px/1.3 var(--font-sans); white-space: normal;
  color: hsl(var(--bg)); background: hsl(var(--ink)); opacity: 0; transition: opacity 120ms ease;
}
.viz-tip.is-on { opacity: 1; transition-delay: 120ms; }

/* ---- hash line --------------------------------------------------------- */
/* Label, value, state, action. The value column is exactly four groups wide, so the
   two lines of a hash read as a block and the marks beside it line up down a card. */
.hashlines { container-type: inline-size; display: flex; flex-direction: column; gap: 2px; }
.hashline {
  display: grid; grid-template-columns: 34px minmax(0, calc(32ch + 1.8em)) 24px 24px; justify-content: start; align-items: start; column-gap: 10px;
  font-family: var(--font-mono); font-size: 12px;
}
.hashline-label { font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; line-height: 22px; color: hsl(var(--text-faint)); }
.hashline-value { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; }
.hashline-hash {
  display: flex; flex-wrap: wrap; column-gap: 0.6em; min-width: 0;
  font-family: var(--font-mono); font-size: 12px; font-weight: 500; line-height: 22px; color: hsl(var(--text));
  font-variant-numeric: tabular-nums;
}
/* Four groups of eight to a line; on a very narrow column, two. Never one orphaned group. */
.hashline-half, .hashline-quarter { display: inline-flex; flex-wrap: wrap; column-gap: 0.6em; }
.hashline-quarter { flex-wrap: nowrap; white-space: nowrap; }
.hashline.is-key .hashline-half, .hashline.is-key .hashline-quarter { column-gap: 0.45em; }
.hashline.is-key .hashline-hash { color: hsl(var(--text-mute)); }
.hashline-alg { font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; line-height: 22px; color: hsl(var(--text-faint)); }
/* Before the container query below, so a narrow container can move the note under the label. */
.hashline-note { grid-column: 2 / -1; font-family: var(--font-sans); font-size: 12px; line-height: 1.4; color: hsl(var(--text-faint)); overflow-wrap: anywhere; }
@container (max-width: 380px) {
  .hashline { grid-template-columns: minmax(0, calc(32ch + 1.8em)) 24px 24px; }
  .hashline-label { grid-column: 1 / -1; line-height: 18px; }
  .hashline-note { grid-column: 1 / -1; }
}
.hashline-state-cell, .hashline-action { display: flex; align-items: center; justify-content: center; height: 22px; }
.hashline-state { display: inline-flex; }
.hashline-state.is-match { color: hsl(var(--viz-mark, var(--accent-700))); }
.hashline-state.is-mismatch { color: hsl(var(--warn)); }
html[data-theme="dark"] .hashline-state.is-match { color: hsl(var(--accent-300)); }

.viz-icon { display: block; flex: none; }
.viz-icon-button {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: hsl(var(--text-faint)); cursor: pointer;
  transition: background 120ms, color 120ms;
}
.viz-icon-button:hover { background: hsl(var(--bg-muted)); color: hsl(var(--text)); }
.viz-icon-button:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--bg)), 0 0 0 4px hsl(var(--accent-500) / 0.55); }

/* ---- receipt card ------------------------------------------------------ */
.receipt {
  --viz-mark: var(--accent-700);
  container-type: inline-size;
  box-sizing: border-box; width: 100%; max-width: 480px; padding: 18px 20px 14px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--card-line)); border-radius: 12px; color: hsl(var(--text));
}
html[data-theme="dark"] .receipt { --viz-mark: var(--accent-300); }
.receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid hsl(var(--hairline)); }
.receipt-id { min-width: 0; }
.receipt-name { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: hsl(var(--ink)); }
.receipt-date { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; color: hsl(var(--text-faint)); }
.receipt-result { text-align: right; flex: none; }
.receipt-score { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 22px; font-weight: 500; line-height: 1; color: hsl(var(--ink)); }
.receipt-score .viz-verdict { color: hsl(var(--viz-mark)); }
.receipt-score .viz-verdict.is-refused { color: hsl(var(--text-mute)); }
.receipt-meta { margin: 6px 0 0; font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: hsl(var(--text-faint)); }
.receipt-meta .num { font-family: var(--font-mono); font-size: 11.5px; color: hsl(var(--text-mute)); }
.receipt .sep { margin: 0 0.5em; }

.receipt-table { width: 100%; border-collapse: collapse; margin: 4px 0 2px; }
.receipt-table thead th { padding: 10px 0 4px 12px; text-align: right; font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: hsl(var(--text-faint)); }
.receipt-table tbody th { padding: 8px 0; text-align: left; font-weight: 400; vertical-align: baseline; }
/* Role and model share a line; the model wraps inside its own column on a narrow card. */
.receipt-who { display: flex; align-items: baseline; gap: 8px; }
.receipt-role { flex: none; width: 58px; font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: hsl(var(--text-faint)); }
.receipt-model { min-width: 0; font-size: 13px; font-weight: 500; line-height: 1.35; color: hsl(var(--text)); }
.receipt-table td { padding: 8px 0 8px 12px; text-align: right; vertical-align: baseline; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; line-height: 1.35; font-variant-numeric: tabular-nums; color: hsl(var(--text)); }
.receipt-table tbody tr + tr > * { border-top: 1px solid hsl(var(--hairline)); }
.receipt-table tfoot > tr > * { padding-top: 8px; padding-bottom: 12px; border-top: 1px solid hsl(var(--divider)); vertical-align: baseline; }
.receipt-table tfoot th { text-align: left; font-family: var(--font-caption); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; color: hsl(var(--text-faint)); }
.receipt-table tfoot td { color: hsl(var(--ink)); font-weight: 600; }

.receipt-proof { padding-top: 12px; border-top: 1px solid hsl(var(--hairline)); }

@media (max-width: 420px) {
  .receipt { padding: 16px 14px 12px; }
}
@container (max-width: 400px) {
  .receipt-table td { padding-left: 8px; font-size: 12px; }
  .receipt-table thead th { padding-left: 8px; }
  .receipt-role { width: 52px; }
  .receipt-model { font-size: 12.5px; }
  .receipt-family { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
