/* ============================================================
   TRACE A DECISION — the evidence-to-decision spine
   ------------------------------------------------------------
   This is the one public surface that shows the platform's actual
   differentiator: a recommendation in a VoiceInsights publication can be walked
   BACKWARDS to the words a person said.

   Every edge drawn here is a field that exists in the public API response —
   recommendation.evidence_used, evidence.survey_question,
   evidence.respondent_group, evidence.quote, evidence.verification_status. No
   relationship is inferred and none is decorative.

   Colour, type and spacing come from the design authority. This file introduces
   no palette of its own.
   ============================================================ */

.vitrace { display: grid; gap: var(--space-5, 1.5rem); }
.vitrace * { min-width: 0; }

/* ---- the honesty strip ---- */
.vitrace-provenance {
  display: flex; flex-wrap: wrap; gap: .45rem .9rem; align-items: center;
  padding: .6rem .85rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px); background: var(--surface-2);
  font-size: .74rem; line-height: 1.5; color: var(--text-muted);
}
.vitrace-provenance b { color: var(--text); font-weight: 650; }
.vitrace-tag {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .5rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; font-weight: 700;
  color: var(--text-muted);
}
.vitrace-tag[data-tone="verified"] { color: var(--success); border-color: var(--success); }
.vitrace-tag[data-tone="brand"] { color: var(--accent-text); border-color: var(--accent-text); }

/* ---- decision picker ---- */
.vitrace-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.vitrace-picker button {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .8rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); font: inherit; font-size: .8rem; font-weight: 600;
  transition: background var(--motion-base, .18s ease), color var(--motion-base, .18s ease), border-color var(--motion-base, .18s ease);
}
.vitrace-picker button:hover { border-color: var(--accent-text); color: var(--accent-text); }
.vitrace-picker button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.vitrace-picker button:focus-visible { outline: var(--focus-ring, 2px solid var(--accent)); outline-offset: 2px; }

/* ---- the spine ---- */
.vitrace-spine { position: relative; display: grid; gap: 0; }
.vitrace-step { position: relative; padding: 0 0 var(--space-5, 1.5rem) 2.4rem; }
.vitrace-step:last-child { padding-bottom: 0; }
/* the connecting line, drawn once per step so it never outruns the content */
.vitrace-step::before {
  content: ""; position: absolute; left: .72rem; top: 1.55rem; bottom: -.2rem;
  width: 2px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 22%, transparent));
}
.vitrace-step:last-child::before { display: none; }
.vitrace-step > .vitrace-node {
  position: absolute; left: 0; top: .55rem;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--accent); color: var(--accent-text);
}
.vitrace-step > .vitrace-node svg { width: 13px; height: 13px; }

.vitrace-kicker {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700; color: var(--accent-text); margin: 0 0 .3rem;
}
.vitrace-step h3 { margin: 0 0 .4rem; font-size: 1.02rem; line-height: 1.35; color: var(--text); }
.vitrace-step p { margin: 0 0 .5rem; font-size: .88rem; line-height: 1.6; color: var(--text-muted); }

/* ---- fact rows ---- */
.vitrace-facts { display: grid; gap: .4rem; margin: .55rem 0 0; padding: 0; list-style: none; }
.vitrace-facts > li { display: grid; grid-template-columns: minmax(7.5rem, 9.5rem) 1fr; gap: .3rem .9rem; font-size: .82rem; line-height: 1.55; }
.vitrace-facts dt, .vitrace-facts .k { color: var(--text-dim); font-weight: 600; }
.vitrace-facts .v { color: var(--text); }

/* ---- the verbatim, which is the point of the whole section ---- */
.vitrace-quote {
  margin: .6rem 0 0; padding: .7rem .9rem;
  border-left: 3px solid var(--accent);
  background: var(--surface-champagne-soft, var(--surface-2));
  border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
  font-size: .9rem; line-height: 1.62; color: var(--text);
}
html[data-theme="dark"] .vitrace-quote { background: var(--surface-2); }
.vitrace-quote cite { display: block; margin-top: .45rem; font-style: normal; font-size: .75rem; color: var(--text-dim); }

/* ---- expandable evidence ---- */
.vitrace-ev { border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); background: var(--surface); margin-top: .55rem; }
.vitrace-ev + .vitrace-ev { margin-top: .5rem; }
.vitrace-ev > button {
  width: 100%; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .6rem .75rem; background: none; border: 0; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600; color: var(--text); text-align: left;
}
.vitrace-ev > button:focus-visible { outline: var(--focus-ring, 2px solid var(--accent)); outline-offset: -2px; }
.vitrace-ev > button .vitrace-chev { margin-left: auto; color: var(--text-dim); display: inline-flex; transition: transform var(--motion-base, .18s ease); }
.vitrace-ev > button[aria-expanded="true"] .vitrace-chev { transform: rotate(180deg); }
.vitrace-ev-body { padding: 0 .75rem .75rem; border-top: 1px solid var(--border); }
.vitrace-ev-body[hidden] { display: none; }

/* ---- states ---- */
.vitrace-state {
  padding: 1.6rem 1rem; text-align: center; border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm, 6px); color: var(--text-muted); font-size: .88rem;
}
.vitrace-state[data-tone="error"] { border-style: solid; border-color: var(--danger); color: var(--danger); }
.vitrace-skeleton { display: grid; gap: .5rem; }
.vitrace-skeleton i {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: vitrace-shimmer 1.4s ease infinite;
}
.vitrace-skeleton i:nth-child(2) { width: 86%; }
.vitrace-skeleton i:nth-child(3) { width: 68%; }
@keyframes vitrace-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (prefers-reduced-motion: reduce) {
  .vitrace-skeleton i { animation: none; }
  .vitrace-ev > button .vitrace-chev { transition: none; }
}

@media (max-width: 640px) {
  .vitrace-step { padding-left: 2rem; }
  .vitrace-facts > li { grid-template-columns: 1fr; gap: .1rem; }
  .vitrace-facts dt, .vitrace-facts .k { font-size: .74rem; }
}
