/* ==========================================================================
   Platform page · 4 — Shape the workflow to fit your institution
   The wireframe's demo, finished like a product screen:
     settings (switches + segmented choices)  │  the live loan workflow
   - a setting turned on adds its step in teal (the switch is teal too, so
     cause and effect share a colour); turning it off folds the step away
   - dashed steps behave differently with your settings; their label swaps
   - the step count reports each change with a brief +1 / −1
   - hovering a setting marks the step(s) it touches
   - until the first change, the first switch carries a soft pulse
   States (js/platform/workflow.js): .wf-step.is-new / .is-out / .is-linked,
   .wf-sim.is-fresh. Prefixed .wf- and scoped to .wf.
   ========================================================================== */

.wf {
  --wf-frame: #FFFFFF;
  --wf-teal:      var(--good);
  --wf-teal-soft: var(--good-soft);
  --wf-teal-text: #0B6B58;

  position: relative;
  padding: clamp(72px, 9vw, 120px) var(--page-px);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
:root[data-theme="dark"] .wf { --wf-frame: #0B1F42; --wf-teal-text: var(--good); }

.wf-inner { max-width: var(--container); margin: 0 auto; }
.wf-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: clamp(36px, 4.5vw, 56px); }
.wf-title { max-width: 760px; font-size: var(--fs-section-title); font-weight: 600; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }
.wf-title em { font-style: normal; color: var(--accent); }
.wf-sub { max-width: 720px; font-size: var(--fs-section-sub); line-height: 1.6; color: var(--text-secondary); }

/* ─── The demo frame ──────────────────────────────────────────────────── */
.wf-sim {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  background: var(--wf-frame);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(10,47,107,0.04), 0 24px 48px -36px rgba(10,47,107,0.35);
}
.wf-panel { padding: clamp(22px, 3vw, 36px); min-width: 0; }
.wf-panel--flow { border-left: 1px solid var(--border); }
.wf-h3 { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
.wf-muted { margin-top: 6px; font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); }
.wf-hint { display: none; }

/* ─── Settings ────────────────────────────────────────────────────────── */
.wf-cfg { margin-top: 22px; border-top: 1px solid var(--border); }
.wf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.wf-row--seg { flex-direction: column; align-items: stretch; gap: 10px; }
.wf-label { font-size: 14.5px; font-weight: 500; color: var(--text-primary); }

/* switch: teal when on, matching the teal step it adds */
.wf-switch {
  position: relative;
  flex: none;
  width: 40px; height: 22px;
  padding: 0;
  background: var(--border-strong);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.18s ease;
}
.wf-switch[aria-checked="true"] { background: var(--wf-teal); }
.wf-knob {
  position: absolute;
  left: 2px; top: 2px;
  width: 18px; height: 18px;
  background: #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(10,30,60,0.25);
  transition: transform 0.18s var(--ease-out);
}
.wf-switch[aria-checked="true"] .wf-knob { transform: translateX(18px); }
.wf-switch:active .wf-knob { width: 21px; }
.wf-switch[aria-checked="true"]:active .wf-knob { transform: translateX(15px); }
.wf-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* segmented choice: a sliding face marks the selected option */
.wf-seg {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 3px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.wf-seg-ind {
  position: absolute;
  left: 3px; top: 3px; bottom: 3px;
  width: calc((100% - 6px) / var(--n, 2));
  background: var(--wf-frame);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(10,30,60,0.10), 0 0 0 1px var(--border);
  transform: translateX(calc(var(--k, 0) * 100%));
  transition: transform 0.25s var(--ease-out);
}
.wf-seg button {
  position: relative;
  z-index: 1;
  padding: 8px 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.wf-seg button:hover { color: var(--text-primary); }
.wf-seg button[aria-checked="true"] { color: var(--text-primary); font-weight: 600; }
.wf-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
html:not(.has-js) .wf-seg button[aria-checked="true"] { background: var(--wf-frame); }

/* first-visit nudge: a soft ring on the first switch until anything changes */
.wf-sim.is-fresh .wf-row:first-child .wf-switch::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 1.5px solid var(--wf-teal);
  animation: wf-nudge 1.8s ease-out infinite;
  pointer-events: none;
}
@keyframes wf-nudge {
  0%   { opacity: 0.7; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35, 1.6); }
}

/* ─── The live workflow ───────────────────────────────────────────────── */
.wf-flow-head { display: flex; align-items: center; gap: 10px; }
.wf-flow-head .wf-h3 { flex: 1; }
.wf-count {
  order: 2;
  display: inline-flex;
  gap: 4px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.wf-count-n { display: inline-block; }
.wf-count-n.is-roll { animation: wf-roll 0.35s var(--ease-out); }
@keyframes wf-roll { from { transform: translateY(70%); opacity: 0; } }
.wf-delta {
  order: 1;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s var(--ease-out);
}
.wf-delta.is-on) { margin-left: 0; }
.wf-delta.is-on { opacity: 1; transform: none; }
.wf-delta.is-up   { color: var(--wf-teal); }
.wf-delta.is-down { color: var(--text-muted); }

.wf-flow { position: relative; margin-top: 20px; }
/* the rail through the nodes */
.wf-flow::before {
  content: '';
  position: absolute;
  left: 17px; top: 22px; bottom: 22px;
  border-left: 1px solid var(--border-strong);
}

/* each step folds open / shut via a 0fr ↔ 1fr row */
.wf-step {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.32s var(--ease-out), opacity 0.25s ease;
}
.wf-step.is-out,
.wf-step.is-pre { grid-template-rows: 0fr; opacity: 0; }
.wf-step-in {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0 12px;
}
/* the step's face, inset so neighbouring steps keep a hairline of air */
.wf-step-in::after {
  content: '';
  position: absolute;
  inset: 2px 0;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: background-color 0.4s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.wf-step-in::before { content: ''; display: block; height: 44px; width: 0; flex: none; margin-right: -14px; }
.wf-node {
  position: relative;
  z-index: 1;
  flex: none;
  width: 10px; height: 10px;
  background: var(--wf-frame);
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
}
.wf-step-name {
  position: relative;
  z-index: 1;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-primary);
  transition: opacity 0.15s ease;
}

/* teal: on only when you turn it on */
.wf-step--opt .wf-step-in::after { background: var(--wf-teal-soft); }
.wf-step--opt .wf-node { background: var(--wf-teal); border-color: var(--wf-teal); }
.wf-step--opt .wf-step-name { color: var(--wf-teal); font-weight: 600; }
.wf-step--opt .wf-step-name { color: var(--wf-teal-text); }
/* dashed: behaves differently with your settings */
.wf-step--var .wf-step-in::after { border: 1px dashed var(--border-strong); }
.wf-step--var .wf-node { border-style: dashed; }
.wf-step-name.is-swap { opacity: 0; }

/* just added: a brief glow that settles; the node pops */
.wf-step.is-new .wf-step-in::after { animation: wf-flash 1.4s ease-out; }
.wf-step.is-new .wf-node { animation: wf-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s backwards; }
@keyframes wf-flash { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--wf-teal) 35%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes wf-pop { from { transform: scale(0); } }

/* linked: the steps a hovered setting touches */
.wf-step.is-linked .wf-step-in::after { border-color: var(--accent); }

/* ─── Footnote + CTA ──────────────────────────────────────────────────── */
.wf-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  flex-wrap: wrap;
  margin-top: 20px;
}
.wf-note { max-width: 620px; font-size: 13.5px; line-height: 1.55; color: var(--text-muted); }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .wf-sim { grid-template-columns: minmax(0, 1fr); }
  .wf-panel--flow { border-left: 0; border-top: 1px solid var(--border); }
  .wf-hint { display: block; margin-top: 16px; }
}
@media (max-width: 420px) {
  .wf-seg { grid-auto-flow: row; grid-auto-rows: auto; }
  .wf-seg-ind { display: none; }
  .wf-seg button[aria-checked="true"] { background: var(--wf-frame); box-shadow: 0 0 0 1px var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  .wf-step, .wf-step-in::after, .wf-knob, .wf-seg-ind, .wf-delta, .wf-step-name { transition: none; }
  .wf-step.is-new .wf-step-in::after, .wf-step.is-new .wf-node, .wf-count-n.is-roll { animation: none; }
  .wf-sim.is-fresh .wf-row:first-child .wf-switch::after { animation: none; opacity: 0; }
}

/* dark: the selected face needs its own tone, the frame colour vanishes here */
:root[data-theme="dark"] .wf-seg { background: rgba(4, 14, 34, 0.55); }
:root[data-theme="dark"] .wf-seg-ind,
:root[data-theme="dark"] .wf-seg button[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent) 24%, var(--wf-frame));
  box-shadow: 0 0 0 1px var(--accent-line);
}
:root[data-theme="dark"] .wf-seg button[aria-checked="true"] { color: #FFFFFF; }
@media (min-width: 421px) {
  :root[data-theme="dark"] .wf-seg button[aria-checked="true"] { background: none; box-shadow: none; }
}
