/*
 * flow-story.css - product-flow scroll story and "what you get" grid
 * (templates/marketing/flow/_story.html, _bento.html) on the home page and
 * the staff prototype (/design/flow/). Loaded non-blocking (media="print"
 * swap + <noscript>), after flow.css, which defines --tone-c and .flow-tag.
 * Tokens only.
 *   1 story       .flow-story*, .flow-chapter*, .flow-rail*, .flow-panel*, .flow-visual
 *   2 story cards .flow-card-ui*, .flow-srcs, .flow-json*, .flow-check*, .flow-size*, .flow-outcome*, .flow-journal
 *   3 bento       .flow-bento, .flow-tile*, .flow-art-*, .flow-chip
 *   4 motion      only under prefers-reduced-motion: no-preference
 */
@layer page {

/* ---------- 1. scroll story ---------- */
.flow-story {
  padding-block: var(--section-y);
  scroll-margin-top: var(--header-h);
}
.flow-story-body { position: relative; }
.flow-chapters {
  display: grid;
  gap: var(--space-14);
  margin: 0;
  padding: 0;
  list-style: none;
}
.flow-chapter {
  display: grid;
  gap: var(--space-6);
  scroll-margin-top: calc(var(--header-h) + var(--space-8));
}
@media (min-width: 901px) {
  .flow-chapter {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: center;
    gap: var(--space-12);
  }
}
.flow-chapter-num {
  margin: 0 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: .08em;
  color: var(--action-ink);
}
.flow-chapter-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}
.flow-chapter-lead {
  max-width: 46ch;
  margin: 0;
  font-size: var(--text-lead);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.flow-visual { min-width: 0; }
.flow-fine {
  max-width: 70ch;
  margin: var(--space-10) auto 0;
  text-align: center;
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--ink-3);
}

/* enhanced (flow-story.js on a wide, fine-pointer screen with motion allowed) */
.flow-story.is-enhanced .flow-story-body {
  display: grid;
  grid-template-columns: auto minmax(0, 5fr) minmax(0, 7fr);
  gap: var(--space-10);
  align-items: start;
}
.flow-story.is-enhanced .flow-chapters { gap: 0; }
.flow-story.is-enhanced .flow-chapter {
  display: flex;
  align-items: center;
  min-height: 70vh;
}
.flow-story.is-enhanced .flow-chapter:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: var(--space-2);
  border-radius: var(--radius-lg);
}
.flow-story.is-enhanced .flow-chapter-text { opacity: .3; }
.flow-story.is-enhanced .flow-chapter.is-active .flow-chapter-text { opacity: 1; }
.flow-rail {
  position: sticky;
  top: calc(50vh - var(--space-16));
  align-self: start;
  padding-top: var(--space-8);
}
.flow-rail ol {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.flow-rail ol::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--border-strong);
}
.flow-rail-dot {
  position: relative;
  display: block;
  width: 10px;
  height: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.flow-rail-dot::after {
  content: "";
  position: absolute;
  inset: -7px;
}
.flow-rail-dot[aria-current="step"] {
  height: 28px;
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.flow-rail-dot:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
.flow-panel {
  position: sticky;
  top: calc(var(--header-h) + var(--space-8));
  display: flex;
  align-items: center;
  min-height: calc(100vh - var(--header-h) - var(--space-16));
}
.flow-panel-stage {
  position: relative;
  display: grid;
  width: 100%;
}
.flow-panel-stage > .flow-visual {
  grid-area: 1 / 1;
  align-self: center;
  visibility: hidden;
  opacity: 0;
  transform: translateY(var(--space-4)) scale(.98);
}
.flow-panel-stage > .flow-visual.is-active {
  visibility: visible;
  opacity: 1;
  transform: none;
}

/* ---------- 2. story cards ---------- */
.flow-card-ui {
  position: relative;
  overflow: hidden;
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2), var(--shadow-inset);
}
.flow-card-ui::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 50%;
  pointer-events: none;
  background: radial-gradient(60% 100% at 30% 0%, var(--brand-soft), transparent 70%);
}
.flow-card-ui > * { position: relative; }
.flow-card-ui-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.flow-card-ui-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--ink);
}
.flow-card-ui-sub {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-3);
}
.flow-card-ui-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  font-size: var(--text-sm);
  color: var(--ink-2);
}
.flow-srcs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
}
.flow-srcs .flow-chip.is-active {
  color: var(--action-ink);
  background: var(--action-soft);
  border-color: var(--border-brand);
}
.flow-req-from { color: var(--ink-2); }
.flow-req {
  margin: 0 0 var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.flow-req-method {
  font-weight: var(--weight-semi);
  color: var(--ok);
}
.flow-json {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--code-ink);
  background: var(--code-bg);
  border-radius: var(--radius-lg);
}
.flow-json-line {
  display: block;
  white-space: pre;
}
.flow-json-k { color: color-mix(in srgb, var(--brand) 45%, var(--code-ink)); }
.flow-json-s { color: color-mix(in srgb, var(--ok) 60%, var(--code-ink)); }
.flow-json-n { color: color-mix(in srgb, var(--warn) 60%, var(--code-ink)); }

.flow-checks,
.flow-sizes,
.flow-outcomes {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.flow-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.flow-check[data-state="flag"] { border-color: color-mix(in srgb, var(--neutral) 45%, transparent); }
.flow-check-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: var(--radius-pill);
}
.flow-check[data-state="flag"] .flow-check-icon {
  color: var(--ink-2);
  background: var(--neutral-soft);
}
.flow-check-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.flow-check-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--ink);
}
.flow-check-note,
.flow-check-state {
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.flow-check-state {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--ok);
}
.flow-check[data-state="flag"] .flow-check-state { color: var(--ink-2); }

.flow-sizes { gap: var(--space-4); }
.flow-size {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-3);
  align-items: center;
}
.flow-size-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--ink);
}
.flow-size-qty {
  grid-row: 1;
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.flow-size-method {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.flow-size-track {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  background: var(--sunken);
  border-radius: var(--radius-pill);
}
.flow-size-bar,
.flow-art-bar {
  display: block;
  width: var(--w);
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--action-ink));
  border-radius: inherit;
  transform-origin: left center;
}

.flow-outcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3);
  background: var(--sunken);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tone-c);
  border-radius: var(--radius-lg);
}
.flow-outcome-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--ink);
}
.flow-outcome-why {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  color: var(--ink-3);
}
.flow-journal { font-size: var(--text-xs); }

/* ---------- 3. what you get ---------- */
.flow-get { padding-block: 0 var(--section-y); }
.flow-bento {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 641px) {
  .flow-bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-tile--wide { grid-column: span 2; }
}
@media (min-width: 901px) {
  .flow-bento { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .flow-tile--wide:last-child { grid-column: 1 / -1; }
}
.flow-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow: hidden;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.flow-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(70% 60% at 50% 0%, var(--brand-soft), transparent 70%);
  opacity: 0;
}
.flow-tile > * { position: relative; }
.flow-tile:hover { border-color: var(--border-brand); }
.flow-tile:hover::before { opacity: 1; }
.flow-tile-art {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 92px;
  margin-bottom: var(--space-3);
}
.flow-tile-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: var(--weight-semi);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
}
.flow-tile-text {
  max-width: 52ch;
  margin: 0;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--ink-2);
}
.flow-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--ink-2);
  background: var(--sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.flow-chip--soft {
  color: var(--action-ink);
  background: var(--action-soft);
  border-color: transparent;
}
.flow-art-approve,
.flow-art-bars,
.flow-art-reasons,
.flow-art-journal { flex-direction: column; flex-wrap: nowrap; }
.flow-art-bars { justify-content: center; gap: var(--space-3); }
.flow-art-bar { height: 10px; border-radius: var(--radius-pill); }
.flow-art-row,
.flow-art-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.flow-art-row {
  padding: var(--space-2) var(--space-3);
  background: var(--sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.flow-art-actions {
  display: flex;
  gap: var(--space-2);
}
.flow-art-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--ink-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
}
.flow-art-btn--go {
  color: var(--on-action);
  background: var(--action);
  border-color: transparent;
}
.flow-art-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

/* ---------- 4. motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .flow-story.is-enhanced .flow-chapter-text { transition: opacity var(--dur-panel) var(--ease-out); }
  .flow-rail-dot { transition: height var(--dur-panel) var(--ease-out), background-color var(--dur-panel) var(--ease-out), box-shadow var(--dur-panel) var(--ease-out); }
  .flow-panel-stage > .flow-visual {
    transition: opacity var(--dur-reveal) var(--ease-out), transform var(--dur-reveal) var(--ease-out), visibility 0s linear var(--dur-reveal);
  }
  .flow-panel-stage > .flow-visual.is-active {
    transition: opacity var(--dur-reveal) var(--ease-out), transform var(--dur-reveal) var(--ease-out), visibility 0s;
  }

  .flow-tile { transition: border-color var(--dur-quick) var(--ease-out), transform var(--dur-panel) var(--ease-out), box-shadow var(--dur-panel) var(--ease-out); }
  .flow-tile::before { transition: opacity var(--dur-panel) var(--ease-out); }
  .flow-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-2);
  }
  .flow-chip,
  .flow-art-btn { transition: transform var(--dur-quick) var(--ease-out), border-color var(--dur-quick) var(--ease-out); }
  .flow-tile:hover .flow-chip:nth-child(odd) { transform: translateY(-2px); }
  .flow-tile:hover .flow-art-btn--go { box-shadow: 0 0 0 4px var(--action-soft); }

  /* in view (flow-story.js sets data-inview, then .is-inview per tile) */
  .flow-bento[data-inview] .flow-tile:not(.is-inview) .flow-tile-art > * { opacity: 0; }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-tile-art > * {
    animation: flow-rise var(--dur-reveal) var(--ease-out) both;
  }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-tile-art > :nth-child(2) { animation-delay: var(--stagger); }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-tile-art > :nth-child(3) { animation-delay: calc(var(--stagger) * 2); }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-tile-art > :nth-child(4) { animation-delay: calc(var(--stagger) * 3); }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-tile-art > :nth-child(n+5) { animation-delay: calc(var(--stagger) * 4); }
  .flow-bento[data-inview] .flow-tile.is-inview .flow-art-bar { animation-name: flow-grow; }
}
@keyframes flow-rise {
  from { opacity: 0; transform: translateY(6px); }
}
@keyframes flow-grow {
  from { transform: scaleX(0); }
}

@media (forced-colors: active) {
  .flow-rail-dot[aria-current="step"] { background: Highlight; }
}

} /* @layer page */
