/* The four-step workflow as a scroll story. Without JS (and on narrow screens):
   four stacked panels, each with its scene above its caption. With JS on wide
   screens (.is-story, workflow.js): captions scroll down the left while one
   sticky stage on the right swaps to the scene of the caption in the middle
   of the viewport. Nothing to click. */

.workflow {
  min-width: 0;
}

.workflow-step {
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-kicker {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.workflow-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.workflow-panel {
  display: grid;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--r-sm);
  background: var(--surface);
}

.workflow-scene {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 40px 24px;
}

.workflow-scene > div {
  width: min(380px, 100%);
  padding: 20px;
  border-radius: var(--r-sm);
  background: var(--paper);
  box-shadow: var(--shadow-frag);
  color: var(--ink);
  font-size: var(--fs-frag);
  letter-spacing: -0.02em;
}

.workflow-caption {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 0 32px 32px;
}

.workflow-caption > p {
  max-width: 360px;
  font-size: var(--fs-sm);
  line-height: 1.43;
  color: var(--text);
}

.workflow-ui-label {
  margin-bottom: 16px;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-chat {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.workflow-chat .workflow-ui-label {
  margin-bottom: 4px;
}

.workflow-bubble {
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 12px 12px 12px 3px;
  background: var(--surface);
  color: var(--ink);
}

.workflow-bubble.workflow-agent {
  justify-self: end;
  border-radius: 12px 12px 3px 12px;
  background: var(--ink);
  color: var(--bg);
}

.workflow-source {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-source svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.workflow-document {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 16px 14px;
  border-radius: var(--r-sm);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.workflow-document svg {
  width: 28px;
  height: 28px;
  flex: none;
}

.workflow-document b,
.workflow-slot b,
.workflow-task b {
  display: block;
  font-weight: 500;
}

.workflow-document small,
.workflow-slot small,
.workflow-task small {
  display: block;
  margin-top: 3px;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-delivered {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
  margin-top: 12px;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-delivered svg {
  width: 20px;
  height: 12px;
}

.workflow-week {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin-bottom: 14px;
  font-size: var(--fs-micro);
  text-align: center;
  color: var(--muted);
}

.workflow-week > * {
  padding: 7px 0;
  font-weight: 400;
}

.workflow-week b {
  border-radius: var(--r-btn);
  background: var(--ink);
  color: var(--bg);
}

.workflow-slot {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 36px;
  border-top: 1px solid var(--line);
}

.workflow-slot > span {
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-slot > div {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
}

.workflow-record h4 {
  margin: 0 0 10px;
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: -0.03em;
}

.workflow-record > p:not(.workflow-ui-label) {
  line-height: 1.55;
  color: var(--text);
}

.workflow-record-links {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  padding: 14px 0;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.workflow-task svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.workflow-note {
  margin-top: 16px;
  font-size: var(--fs-micro);
  color: var(--muted);
}

.workflow-note a {
  color: var(--ink);
  text-underline-offset: 3px;
}

/* ---------- story: sticky stage beside scrolling captions ---------- */

.workflow.is-story {
  --stage-h: clamp(420px, 36vw, 520px);
  --step-h: clamp(300px, 40vh, 380px);
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(32px, 5vw, 88px);
  align-items: start;
}

/* pad the ends so the first and last captions line up with the stage centre */
.workflow.is-story .workflow-panels {
  display: block;
  grid-column: 1;
  grid-row: 1;
  padding-block: calc((var(--stage-h) - var(--step-h)) / 2);
}

.workflow.is-story .workflow-panel {
  display: flex;
  align-items: center;
  min-height: var(--step-h);
  overflow: visible;
  border-radius: 0;
  background: none;
}

.workflow.is-story .workflow-caption {
  gap: 12px;
  padding: 0;
  opacity: 0.3;
  transition: opacity 450ms var(--ease);
}

/* step titles sit between the section h2 (30 to 37.5) and card h3 (18 to 19.5) */
.workflow.is-story .workflow-caption h3 {
  font-size: clamp(1.5rem, 1rem + 1.1vw, 1.875rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.workflow.is-story .workflow-caption > p:not(.workflow-kicker) {
  max-width: 400px;
  font-size: var(--fs-body);
  line-height: 1.5;
}

.workflow.is-story .workflow-panel.is-active .workflow-caption {
  opacity: 1;
}

.workflow-stage {
  position: sticky;
  top: calc(50vh - var(--stage-h) / 2);
  grid-column: 2;
  grid-row: 1;
  height: var(--stage-h);
  overflow: hidden;
  border-radius: var(--r-sm);
  background-color: var(--surface);
}

.workflow-stage-frame {
  position: absolute;
  inset: 0 0 36px;
}

.workflow-stage .workflow-scene {
  position: absolute;
  inset: 0;
  min-height: 0;
  opacity: 0;
  transform: translateY(18px) scale(0.98);
  transition:
    opacity 450ms var(--ease),
    transform 650ms var(--ease-out);
}

.workflow-stage .workflow-scene.is-active {
  opacity: 1;
  transform: none;
}

.workflow-progress {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.workflow-progress span {
  height: 2px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background-color 450ms var(--ease);
}

.workflow-progress span.is-done {
  background: var(--ink);
}

@media (max-width: 760px) {
  .workflow-panels {
    grid-template-columns: minmax(0, 1fr);
  }

  .workflow-caption {
    padding: 0 24px 24px;
  }
}

@media (max-width: 560px) {
  .workflow-scene {
    padding: 24px 4px;
  }

  .workflow-scene > div {
    padding: 16px;
  }

  .workflow-slot {
    grid-template-columns: 56px 1fr;
    gap: 6px;
  }

  .workflow-record-links {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workflow.is-story .workflow-caption,
  .workflow-stage .workflow-scene,
  .workflow-progress span {
    transition: none;
  }

  .workflow-stage .workflow-scene {
    transform: none;
  }
}

@media print {
  .workflow.is-story {
    display: block;
  }

  .workflow.is-story .workflow-caption {
    opacity: 1;
  }

  .workflow-stage {
    position: static;
    height: auto;
  }

  .workflow-stage-frame,
  .workflow-stage .workflow-scene {
    position: static;
    opacity: 1;
    transform: none;
  }

  .workflow-progress {
    display: none;
  }

  .workflow-panel {
    break-inside: avoid;
    margin-bottom: 24px;
  }
}
