/* Decision layer: the answer sentence, the Robust / Sensitive / Fragile chip,
   "what would change the answer" and the compact what-if table. Shared by
   every tool page; link it after the tool's own styles.css:
     <link rel="stylesheet" href="/assets/decision.css">
   Uses the tool tokens (--surface-raised, --text-*, --good*, --warning*,
   --critical, --series-*), so light and dark mode follow the tool. Every
   class is dc- prefixed so it can't collide with a tool's own styles. */

/* --- The answer ---------------------------------------------------------- */
.dc-sentence {
  font-size: 1.02rem;
  line-height: 1.45;
  color: var(--text-primary);
  margin: 0;
}
.dc-sentence strong { font-weight: 700; }

.dc-solid {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.dc-solid a { color: var(--text-muted); white-space: nowrap; }

/* --- Robustness chip ------------------------------------------------------
   Three levels only. Colour is a hint; the word carries the meaning. */
.dc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid transparent;
}
.dc-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.dc-chip.robust {
  background: color-mix(in srgb, var(--good) 15%, transparent);
  border-color: color-mix(in srgb, var(--good) 35%, transparent);
  color: var(--good-text);
}
.dc-chip.sensitive {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
  color: var(--warning-text);
}
.dc-chip.fragile {
  background: color-mix(in srgb, var(--critical) 13%, transparent);
  border-color: color-mix(in srgb, var(--critical) 35%, transparent);
  color: var(--critical);
}

/* --- What would change the answer ---------------------------------------- */
/* h2 and .card h2 forms outrank tools' own .card h2 rules */
.dc-drivers-head,
h2.dc-drivers-head,
.card h2.dc-drivers-head {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  margin: 16px 0 6px;
}
.dc-drivers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.dc-drivers li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  align-items: baseline;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  font-size: 0.84rem;
  color: var(--text-secondary);
}
.dc-drivers .dc-what { color: var(--text-primary); font-weight: 600; }
.dc-drivers .dc-flip { grid-column: 1 / -1; }
.dc-drivers .dc-move {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.dc-none { font-size: 0.84rem; color: var(--text-secondary); margin: 0; }

/* --- Compact what-if table ------------------------------------------------ */
.dc-whatif {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.dc-whatif th,
.dc-whatif td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--gridline, var(--border));
  text-align: right;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}
.dc-whatif th:first-child,
.dc-whatif td:first-child { text-align: left; padding-left: 0; }
.dc-whatif th:last-child,
.dc-whatif td:last-child { padding-right: 0; }
.dc-whatif thead th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dc-whatif .dc-note {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 400;
}
.dc-whatif td.dc-verdict { font-weight: 600; white-space: nowrap; }
.dc-whatif tr.dc-mine td { font-weight: 600; }
.dc-whatif tr.dc-mine td:first-child { color: var(--text-primary); }
.dc-whatif td.dc-flipped { color: var(--critical); }
.dc-whatif td.dc-flipped::after {
  content: "flips";
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--critical) 13%, transparent);
}
@media (max-width: 640px) {
  .dc-whatif td.dc-flipped::after { display: table; margin: 2px 0 0 auto; }
}

/* --- Where the result comes from: stacked bars ---------------------------- */
.dc-split { display: grid; gap: 10px; }
.dc-split-row { display: grid; gap: 4px; }
.dc-split-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.dc-split-top strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.dc-bar {
  display: flex;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--gridline, var(--border));
}
.dc-seg { height: 100%; min-width: 0; }
.dc-seg + .dc-seg { border-left: 2px solid var(--surface); }
.dc-seg.s1 { background: var(--series-1); }
.dc-seg.s2 { background: color-mix(in srgb, var(--series-1) 45%, var(--surface)); }
.dc-seg.s3 { background: var(--series-2); }
.dc-seg.s4 { background: color-mix(in srgb, var(--series-2) 45%, var(--surface)); }
/* In dark mode a mix toward the dark surface sits too close to the bar's
   empty track (--gridline), so the lighter segments mix toward white instead. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .dc-seg.s2 { background: color-mix(in srgb, var(--series-1) 55%, #ffffff); }
  :root:where(:not([data-theme="light"])) .dc-seg.s4 { background: color-mix(in srgb, var(--series-2) 55%, #ffffff); }
}
:root[data-theme="dark"] .dc-seg.s2 { background: color-mix(in srgb, var(--series-1) 55%, #ffffff); }
:root[data-theme="dark"] .dc-seg.s4 { background: color-mix(in srgb, var(--series-2) 55%, #ffffff); }
.dc-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin: 0;
  padding: 0;
  list-style: none;
}
.dc-keys li { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.dc-keys .dc-key { width: 10px; height: 10px; border-radius: 2px; flex: none; }

@media print {
  .dc-chip, .dc-seg, .dc-key { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
