/* Keep the title and case aligned across all four tabs. */
#solution.outcomes-ready .outcome-panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

#solution.outcomes-ready .scenario-panel {
  display: grid;
  grid-area: 1 / 1 / span 2 / 2;
  grid-template-rows: subgrid;
  min-width: 0;
}
#solution.outcomes-ready .result-spread { grid-row: 2; }

/* Hidden cases still set the shared card size. */
#solution.outcomes-ready:has(input[value="leads"]:checked) .scenario-panel:not([data-outcome="leads"]),
#solution.outcomes-ready:has(input[value="control"]:checked) .scenario-panel:not([data-outcome="control"]),
#solution.outcomes-ready:has(input[value="routine"]:checked) .scenario-panel:not([data-outcome="routine"]),
#solution.outcomes-ready:has(input[value="errors"]:checked) .scenario-panel:not([data-outcome="errors"]) {
  visibility: hidden;
}

#solution .scenario-picker {
  margin-bottom: 16px;
}

#solution .case-title {
  max-width: 42ch;
  margin: 0 0 18px;
  font: 500 clamp(23px, 2.2vw, 34px)/1.14 var(--font-heading);
  text-wrap: balance;
}
.demo-symbols { position: absolute; pointer-events: none; }
.solution-demo {
  --node-size: 30px;
  --diagram-pad: clamp(16px, 2vw, 30px);
  position: relative;
  min-width: 0;
  padding: var(--diagram-pad);
  align-self: center;
}
.demo-path { margin: 0; padding: 0; list-style: none; }
.demo-path > li {
  position: relative;
  padding-inline-start: calc(var(--node-size) + clamp(10px, 1.1vw, 16px));
}
.demo-path > li + li { --transfer-delay: 2.3s; }
.demo-path > li:not(:last-child) { padding-bottom: clamp(14px, 1.2vw, 20px); }
.demo-path > li:not(:last-child)::before {
  content: "";
  position: absolute;
  top: calc(var(--node-size) / 2);
  left: calc(var(--node-size) / 2);
  height: 100%;
  border-left: 1px solid var(--color-line-strong);
}
.demo-node, .demo-replay svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.demo-node {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  width: var(--node-size);
  height: var(--node-size);
  padding: 5px;
  border: 1px solid var(--color-line-strong);
  border-radius: 50%;
  background: var(--color-paper);
}
.demo-path li:nth-child(2) > .demo-node {
  background: var(--color-ink);
  border-color: var(--color-ink);
  color: var(--color-paper);
}
.demo-path h4 {
  margin: 0 0 4px;
  padding-block: 6px 2px;
  font: 500 clamp(14px, 1.15vw, 17px)/1.24 var(--font-heading);
  font-size-adjust: none;
}
.solution-demo:has(.demo-replay:not([hidden])) li:first-child h4 { padding-inline-end: 94px; }
#solution .demo-path p, .demo-receipt, .demo-order {
  margin: 0;
  font-size: clamp(17px, 1.3vw, 20px);
  line-height: 1.25;
}
.demo-replay {
  position: absolute;
  z-index: 2;
  top: calc(var(--diagram-pad) - 3px);
  right: var(--diagram-pad);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-height: 36px;
  padding: 0 0 0 4px;
  border: 0;
  background: transparent;
  color: var(--color-ink);
  font: 500 13px/1 var(--font-heading);
  font-size-adjust: none;
  cursor: pointer;
}
.demo-replay[hidden] { display: none; }
.demo-replay svg { width: 15px; height: 15px; }
.demo-replay:hover { text-decoration: underline; text-underline-offset: 3px; }
.demo-receipt, .demo-order {
  border-block: 1px solid var(--color-line-strong);
  padding-block: 8px;
}
.demo-receipt strong { display: block; font-weight: 650; }
.demo-receipt span { display: block; margin-top: 3px; }
.demo-dialogue { display: grid; justify-items: start; gap: 5px; }
#solution .demo-dialogue p {
  max-width: 92%;
  padding: 5px 9px;
  border-radius: 7px 7px 7px 1px;
  background: #e7e7e2;
}
#solution .demo-dialogue p + p {
  justify-self: end;
  border-radius: 7px 7px 1px;
  background: #393936;
  color: var(--color-inverse-text);
}
.demo-evidence {
  background: linear-gradient(to top, #d6d6ce 45%, transparent 45%) left bottom / 100% 100% no-repeat;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  color: inherit;
}
.demo-order { font-variant-numeric: tabular-nums; }
.demo-order > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.demo-order > div + div { border-top: 1px solid var(--color-line); padding-top: 3px; margin-top: 3px; }
.demo-order dd { margin: 0; font-weight: 650; }
.demo-compare { display: flex; flex-wrap: wrap; }
.demo-compare > div { display: grid; padding: 0 16px 0 0; }
.demo-compare > div + div { border-left: 1px solid var(--color-line-strong); padding-left: 16px; }
.demo-compare small { font-size: 15px; line-height: 1.2; }
.demo-compare b { font: 500 clamp(20px, 1.8vw, 27px)/1.4 var(--font-heading); font-variant-numeric: tabular-nums; }
.demo-compare em { background: var(--color-ink); color: var(--color-paper); font-style: normal; }
.result-model {
  display: block;
  margin-top: 14px;
  color: #d7d7d0;
  font-size: 15px;
  line-height: 1.25;
}

.result-spread {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
  align-items: stretch;
  border: 1px solid var(--color-line-strong);
  background: var(--color-paper);
}

.result-chart {
  padding: clamp(22px, 2.8vw, 40px);
}

#solution .result-delta {
  display: flex;
  align-items: baseline;
  gap: .08em;
  margin: 0;
  color: inherit;
  font: 500 clamp(56px, 6vw, 86px)/.96 var(--font-heading);
  font-size-adjust: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.04em;
}

.result-delta span {
  font-size: .39em;
  letter-spacing: -.025em;
}

#solution .result-headline {
  margin: 8px 0 clamp(20px, 2.4vw, 34px);
  max-width: 26ch;
  font-size: clamp(22px, 2.25vw, 32px);
  line-height: 1.1;
}

.result-chart {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--color-inverse-text);
  background: var(--color-inverse);
}

.result-chart h4 {
  margin: 0 0 12px;
  font: 500 clamp(15px, 1.2vw, 18px)/1.25 var(--font-heading);
  font-size-adjust: none;
}

.result-chart dl { margin: 0; }
.result-chart dl > div { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 5px 12px; }
.result-chart dl > div + div { margin-top: 17px; }
.result-chart dt { font-size: 17px; }
.result-chart dd { margin: 0; font-size: 22px; font-weight: 600; }

.result-chart dl > div::after {
  content: "";
  grid-column: 1 / -1;
  height: 6px;
  background: linear-gradient(to right, var(--result-fill, #aaa9a3) 0 var(--result-share), #494944 var(--result-share) 100%);
  transform-origin: left;
}

.result-chart dl > div:last-child { --result-fill: #f6f6f2; }

@media (max-width: 500px) {
  .solution-demo { --node-size: 26px; }
  .solution-demo:has(.demo-replay:not([hidden])) li:first-child h4 { padding-inline-end: 44px; }
  .demo-replay { width: 44px; height: 44px; top: calc(var(--diagram-pad) - 8px); right: calc(var(--diagram-pad) - 8px); justify-content: center; gap: 0; padding: 0; font-size: 0; }
  .demo-replay svg { width: 18px; height: 18px; }
}

@media (min-width: 900px) and (pointer: fine) {
  main > #solution.scenarios-section {
    align-items: flex-start;
    padding-block: clamp(32px, calc((100svh - 660px) / 2), 14svh);
  }
}

@media (max-width: 767px) {
  .result-spread { grid-template-columns: 1fr; }
  #solution.outcomes-ready .scenario-panel { grid-row: 1 / span 3; }
  #solution.outcomes-ready .result-spread { grid-row: 2 / span 2; grid-template-rows: subgrid; }
  .result-chart { padding: 20px; }
  .result-chart h4 { margin-bottom: 14px; }
  .result-chart dl > div + div { margin-top: 11px; }
}

@media (prefers-reduced-motion: no-preference) {
  .solution-demo.is-playing .demo-path > li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: calc(var(--node-size) / 2 - 5px);
    top: calc(var(--node-size) / 2);
    width: 11px;
    height: 100%;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 9'%3E%3Crect x='.5' y='.5' width='11' height='8' rx='1' fill='%23393936'/%3E%3Cpath d='m1 1 5 4 5-4' fill='none' stroke='%23f8f8f6'/%3E%3C/svg%3E") top center / 11px 9px no-repeat;
    animation: demo-send 650ms cubic-bezier(.45,0,.25,1) var(--transfer-delay, 450ms) both;
  }
  .solution-demo.is-playing .demo-path li:nth-child(2) .demo-node {
    animation: demo-read 520ms var(--ease-out) 1s backwards;
  }
  .solution-demo.is-playing .demo-dialogue p {
    animation: demo-reply 450ms var(--ease-out) 1.13s backwards;
  }
  .solution-demo.is-playing .demo-dialogue p + p { --reply-offset: 14px; animation-delay: 1.86s; }
  .solution-demo.is-playing .demo-evidence {
    animation: demo-highlight 650ms ease-out 1.2s backwards;
  }
  .solution-demo.is-playing .demo-evidence + .demo-evidence { animation-delay: 1.65s; }
  .solution-demo.is-playing .demo-compare em {
    animation: demo-difference 460ms ease 1.4s backwards;
  }
  .solution-demo.is-playing .demo-path li:last-child .demo-receipt {
    animation: demo-file-result 600ms var(--ease-out) 2.95s backwards;
  }
  .solution-demo.is-playing .demo-order dd {
    animation: demo-enter-field 450ms var(--ease-out) 2.95s backwards;
  }
  .solution-demo.is-playing .demo-order > div:nth-child(2) dd { animation-delay: 3.2s; }
  .solution-demo.is-playing .demo-order > div:nth-child(3) dd { animation-delay: 3.45s; }
  @keyframes demo-send {
    0% { transform: translateY(0); opacity: 0; }
    12%, 82% { opacity: 1; }
    100% { transform: translateY(100%); opacity: 0; }
  }
  @keyframes demo-read { from { transform: scale(.8); } }
  @keyframes demo-reply { from { opacity: 0; transform: translateX(var(--reply-offset, -14px)); } }
  @keyframes demo-highlight { from { background-size: 0% 100%; } }
  @keyframes demo-difference { from { background: transparent; color: inherit; } }
  @keyframes demo-file-result { from { opacity: .15; transform: translateY(-8px); } }
  @keyframes demo-enter-field { from { opacity: 0; transform: translateX(-20px); } }
  .outcomes-ready .result-chart dl > div::after {
    animation: result-bar-enter 340ms cubic-bezier(.16, 1, .3, 1);
  }
  @keyframes result-bar-enter {
    from { transform: scaleX(.35); }
    to { transform: scaleX(1); }
  }
}
