/* ============================================================
   simulate.css · Halcyon candidate-branch demo · the continuous test / eval
   preview. Page-specific layout + the evidence-readiness ring gauge on the
   shared Datum chassis. All color comes from the theme tokens, so light + dark
   + WCAG AA are inherited. Trust grammar (.km-*) lives in halcyon.css.

   Motion lives ENTIRELY inside @media (prefers-reduced-motion: no-preference).
   Under reduce, the gauge shows its final value with no sweep and every step
   rests in its final state. No horizontal overflow at 375 / 768 / 1280px.
   ============================================================ */

/* ---- department scope line ------------------------------------------- */
.sim-scope-line {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ---- two-column layout: controls + breakdown | outcome --------------- */
.sim-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}
.sim-left { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.sim-right { min-width: 0; }

.sim-section-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); }
.sim-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---- controls -------------------------------------------------------- */
.sim-controls {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.sim-control { display: flex; flex-direction: column; gap: 6px; }
.sim-control-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.sim-select {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
  box-sizing: border-box;
}
.sim-select:focus { outline: none; border-color: var(--border-accent); box-shadow: 0 0 0 2px var(--accent-pale); }

/* evidence-state segmented control */
.sim-segment {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 0;
}
.sim-seg-btn {
  appearance: none;
  flex: 1 1 0;
  min-width: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border: none;
  border-right: 1px solid var(--border);
  padding: 9px 8px;
  cursor: pointer;
}
.sim-seg-btn:last-child { border-right: none; }
.sim-seg-btn:hover { color: var(--text); }
.sim-seg-btn.is-active { color: var(--accent-deep); background: var(--accent-pale); }
.sim-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sim-run-btn {
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--accent);
  color: #0B0E13;
  border: 1px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.sim-run-btn:hover { background: var(--accent-deep); }
.sim-run-btn:disabled { opacity: 0.7; cursor: default; }
.sim-run-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sim-run-glyph { font-size: 12px; line-height: 1; }
.sim-controls-note { margin: 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }

/* ---- step breakdown -------------------------------------------------- */
.sim-breakdown {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.sim-legend { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

/* outcome-view toggle: all steps vs only the steps that need a look */
.sim-outcome-view {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}
.sim-view-btn {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border: none;
  border-right: 1px solid var(--border);
  padding: 7px 12px;
  cursor: pointer;
}
.sim-view-btn:last-child { border-right: none; }
.sim-view-btn:hover { color: var(--text); }
.sim-view-btn.is-active { color: var(--accent-deep); background: var(--accent-pale); }
.sim-view-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.sim-attention-clear {
  font-size: 12.5px;
  color: var(--accent-deep);
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px dashed var(--border-accent);
  border-radius: var(--radius-sm);
  background: var(--accent-pale);
}

.sim-steps { gap: 8px; }
.sim-steps .km-trace-step { align-items: center; }
.sim-step-outcome {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.sim-step-outcome.is-ok { color: var(--accent); background: var(--accent-pale); border-color: var(--border-accent); }
.sim-step-outcome.is-warning { color: var(--gold); background: var(--gold-soft); border-color: var(--gold); }
.sim-step-outcome.is-pending { color: var(--text-dim); }
.sim-step-outcome.is-error,
.sim-step-outcome.is-blocked { color: var(--danger); background: var(--warn-wash); border-color: var(--danger); }

/* a step that stopped the run (the blocked fail scenario) reads in danger */
.sim-steps .km-trace-step[data-outcome="blocked"],
.sim-steps .km-trace-step[data-outcome="error"] {
  border-color: var(--danger);
  background: var(--warn-wash);
}
.sim-steps .km-trace-step[data-outcome="blocked"] .km-trace-marker,
.sim-steps .km-trace-step[data-outcome="error"] .km-trace-marker {
  background: var(--danger);
  border-color: var(--danger);
  color: #0B0E13;
}

/* ---- the outcome result surface -------------------------------------- */
.sim-outcome {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  position: sticky;
  top: 16px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.sim-result { display: flex; flex-direction: column; gap: 16px; outline: none; }
/* the hidden attribute must win over display:flex on the result + empty regions */
.sim-result[hidden], .sim-outcome-empty[hidden] { display: none !important; }

/* verdict */
.sim-verdict { display: flex; flex-direction: column; gap: 8px; }
.sim-verdict-pill {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 14px;
}
.sim-verdict[data-verdict="pass"] .sim-verdict-pill { color: var(--accent); background: var(--accent-pale); border: 1px solid var(--border-accent); }
.sim-verdict[data-verdict="hold"] .sim-verdict-pill { color: var(--gold); background: var(--gold-soft); border: 1px solid var(--gold); }
.sim-verdict[data-verdict="blocked"] .sim-verdict-pill { color: var(--danger); background: var(--warn-wash); border: 1px solid var(--danger); }
.sim-verdict-line { margin: 0; font-size: 13.5px; color: var(--text); line-height: 1.55; }

/* the ring gauge */
.sim-gauge {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  min-width: 0;
}
.sim-gauge-svg { width: 96px; height: 96px; flex: none; }
.sim-gauge-track { stroke: var(--border); }
.sim-gauge-fill {
  stroke: var(--accent);
  stroke-dasharray: 314.16;        /* 2*pi*50, full ring; JS sets the offset */
  stroke-dashoffset: 314.16;       /* start empty, JS fills it */
}
.sim-gauge-fill[data-band="high"] { stroke: var(--accent); }
.sim-gauge-fill[data-band="mid"]  { stroke: var(--gold); }
.sim-gauge-fill[data-band="low"]  { stroke: var(--danger); }
.sim-gauge-num { fill: var(--text); font-size: 22px; font-weight: 700; font-family: var(--mono); }
.sim-gauge-cap { fill: var(--text-dim); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.sim-gauge-side { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.sim-gauge-side-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sim-gauge-side-copy { margin: 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }

/* open items */
.sim-open { display: flex; flex-direction: column; gap: 8px; }
.sim-open-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.sim-open-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.sim-open-list li { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.sim-open-list li.sim-open-clear { color: var(--accent-deep); list-style: none; margin-left: -18px; }

.sim-confidence-line {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
  padding: 10px 12px;
  border-left: 2px solid var(--border-accent);
  background: var(--accent-pale);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.sim-gate-row { align-self: flex-start; }

/* actions */
.sim-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sim-action-btn {
  appearance: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}
.sim-action-primary { background: var(--accent); color: #0B0E13; border: 1px solid var(--accent); }
.sim-action-primary:hover { background: var(--accent-deep); }
.sim-action-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.sim-action-ghost:hover { border-color: var(--border-accent); color: var(--accent-deep); }
.sim-action-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- footer ---------------------------------------------------------- */
.sim-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.sim-foot p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.55; max-width: 64ch; }
.packet-cta {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gold);
  text-decoration: none;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
}
.packet-cta:hover { box-shadow: var(--shadow-gold); }
.packet-cta:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- responsive ------------------------------------------------------ */
@media (max-width: 980px) {
  .sim-layout { grid-template-columns: minmax(0, 1fr); }
  .sim-outcome { position: static; }
}
@media (max-width: 560px) {
  .sim-gauge { flex-direction: column; align-items: flex-start; }
  .sim-actions { flex-direction: column; }
  .sim-action-btn { width: 100%; }
  /* narrow screens: let the step row wrap so the outcome chip drops below the
     text instead of pushing the row past the viewport (no horizontal overflow) */
  .sim-steps .km-trace-step { flex-wrap: wrap; align-items: flex-start; }
  .sim-step-outcome { margin-left: 32px; }
  .sim-outcome-view { width: 100%; }
  .sim-view-btn { flex: 1 1 0; }
}

/* ============================================================
   MOTION ON — the ONLY place animation turns on. Above is the static final
   state, so reduced-motion readers get a complete, still, readable surface.
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {
  .sim-gauge-fill { transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease; }
  .sim-run-btn, .sim-seg-btn, .sim-action-btn { transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease; }
  .sim-result { animation: sim-result-in 0.34s ease; }
  @keyframes sim-result-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  /* the running glyph spins while a run plays */
  .sim-run-btn:disabled .sim-run-glyph { animation: sim-run-spin 0.9s linear infinite; display: inline-block; }
  @keyframes sim-run-spin { to { transform: rotate(360deg); } }
}

@media (prefers-reduced-motion: reduce) {
  .sim-gauge-fill { transition: none !important; }
  .sim-result { animation: none !important; }
}
