/* Workflow journey design system — primitives for AB4 multi-step flows.
   Designed to ride alongside ab4-system.css. No breadcrumb / nav.
   Frieze-quiet aesthetic: hairline rules, generous space, single accent.
   ~280 lines. */

/* ============== SHELL ==============
   Three shell patterns, all share the same base. */

.wf-shell {
  --wf-accent: var(--ab-orange);
  --wf-max: 640px;
  --wf-pad-block: clamp(24px, 4vw, 48px);
  background: var(--bg);
  color: var(--ink);
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  font-family: 'Oswald', 'Helvetica Neue', sans-serif;
  overflow: hidden;
}
.wf-body { overflow: auto; }

/* top bar — wordmark left, exit right, NO nav, NO breadcrumb */
.wf-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--line);
}
.wf-topbar__brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  line-height: 0;
}
.wf-topbar__mark {
  display: block;
  height: 32px;
  width: auto;
}
.wf-topbar__mark--dark { display: none; }
[data-theme="dark"] .wf-topbar__mark--light { display: none; }
[data-theme="dark"] .wf-topbar__mark--dark { display: block; }
.wf-topbar__exit {
  font-size: var(--text-small);
  color: var(--ink-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
}
.wf-topbar__exit:hover { color: var(--ink); }
.wf-topbar__journey {
  font-size: var(--text-micro);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 700;
}

/* progress — hairline bar (steps may branch, so just a fill ratio) */
.wf-progress {
  height: 2px;
  background: var(--line);
  position: relative;
}
.wf-progress__fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--wf-accent);
  transition: width var(--dur-normal) var(--ease-out);
}

/* page body — single column, generous breathing room */
.wf-body {
  padding: var(--wf-pad-block) clamp(16px, 4vw, 32px);
  display: flex;
  justify-content: center;
}
.wf-page {
  width: 100%;
  max-width: var(--wf-max);
  display: grid;
  gap: var(--space-6);
  align-content: start;
}

/* footer — sticky CTA bar, no styled chrome, just hairline rule */
.wf-footer {
  border-top: 1px solid var(--line);
  padding: 14px clamp(16px, 4vw, 32px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}
.wf-footer__back {
  font-size: var(--text-small);
  color: var(--ink-muted);
  background: transparent; border: 0; cursor: pointer;
  letter-spacing: 0.04em;
}
.wf-footer__back:hover { color: var(--ink); }
.wf-footer__counter {
  font-size: var(--text-micro);
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}

/* ============== STEP HEAD ==============
   Eyebrow + display + subtle helper. No "Step 3 of 7" — that's in the footer. */

.wf-eyebrow {
  font-size: var(--text-micro);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.wf-eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--wf-accent);
}
.wf-eyebrow--optional { color: var(--ink-faint); }
.wf-eyebrow--optional::before { background: var(--ink-muted); }
.wf-title {
  font-family: 'Bebas Neue', 'Oswald', sans-serif;
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 0.95;
  letter-spacing: 0.005em;
  margin: 0;
  max-width: 18ch;
}
.wf-helper {
  font-size: var(--text-body);
  color: var(--ink-muted);
  line-height: 1.5;
  max-width: 52ch;
  margin: 0;
}

/* ============== FIELD GROUPS ============== */

.wf-fieldset {
  display: grid;
  gap: var(--space-6);
  border: 0; padding: 0; margin: 0;
}
.wf-field { display: grid; gap: 6px; }
.wf-field__label {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.wf-field__hint {
  font-size: var(--text-micro);
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.wf-field__error {
  font-size: var(--text-small);
  color: var(--ab-red);
  display: flex; align-items: center; gap: 6px;
}
.wf-field__error::before { content: "!"; font-weight: 700; }

/* editorial input — hairline underline, transparent */
.wf-input {
  font: inherit;
  font-size: 1rem;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.wf-input:hover { border-bottom-color: var(--line-strong); }
.wf-input:focus { border-bottom-color: var(--ink); border-bottom-width: 2px; padding-bottom: 7px; }
.wf-input::placeholder { color: var(--ink-faint); }
.wf-input--error { border-bottom-color: var(--ab-red); }

/* boxed input — for textareas and uploads */
.wf-textarea {
  font: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 12px 14px;
  color: var(--ink);
  min-height: 88px;
  resize: vertical;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
  width: 100%;
  box-sizing: border-box;
}
.wf-textarea:hover { border-color: var(--line-strong); }
.wf-textarea:focus { border-color: var(--ink); }

/* radio / pick group — quiet, no fills */
.wf-pick { display: grid; gap: 8px; }
.wf-pick__option {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
  min-width: 0;
  /* Reset native <button> UA styling so a button option renders identically to an
     anchor option (otherwise the button gets a white bg + centered text, which reads
     as "picked" and makes the muted sub-text unreadable). */
  width: 100%;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  appearance: none;
  -webkit-appearance: none;
}
.wf-pick__option:hover { border-color: var(--line-strong); }
.wf-pick__option--active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.wf-pick__option--disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.wf-pick__option--disabled .wf-pick__dot { background: repeating-linear-gradient(45deg, var(--line) 0 3px, transparent 3px 6px); border-color: var(--line); }
.wf-pick__row { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.wf-pick__price { font-family: 'Bebas Neue','Oswald',sans-serif; font-size: 1.4rem; letter-spacing: 0.02em; color: var(--ink); white-space: nowrap; }
.wf-pick__option--disabled .wf-pick__price { color: var(--ink-faint); text-decoration: line-through; }
/* "Coming soon" tag for greyed-out join branches (replaces the arrow). */
.wf-pick__soon {
  font-family: 'Oswald', sans-serif; font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  color: var(--ink-faint); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px;
}
.wf-pick__lock {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-micro); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ab-red); font-weight: 700; margin-top: 6px;
}
.wf-pick__lock::before { content: "⌧"; font-size: 0.9rem; }
.wf-pick__dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  margin-top: 3px; flex-shrink: 0;
}
.wf-pick__option--active .wf-pick__dot { border-color: var(--ink); border-width: 4px; }
.wf-pick__text { display: grid; gap: 2px; min-width: 0; flex: 1 1 auto; }
.wf-pick__label { font-weight: 600; font-size: var(--text-body); }
.wf-pick__sub { font-size: var(--text-small); color: var(--ink-muted); line-height: 1.4; text-wrap: pretty; }

/* segmented row — for short enums like host_kind */
.wf-segments { display: flex; gap: 0; }
.wf-segment {
  flex: 1; padding: 12px 14px;
  font-size: var(--text-small); font-weight: 600;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.04em;
}
.wf-segment + .wf-segment { border-left: 0; }
.wf-segment--active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ============== FREQUENCY SLIDER ==============
   A continuum slider for low-cardinality enums where the values progress
   along a single axis (one_time → weekly_or_more). Each step is a real
   button (≥44px tap target) + a visual "track" with a snapping thumb.
   Custom props drive thumb position so the markup stays free of inline
   percentage math. */
.wf-slider {
  --wf-slider-count: 1;
  --wf-slider-active: -1;
  display: grid;
  gap: 8px;
  position: relative;
  padding: 6px 0 4px;
}
.wf-slider__track {
  position: relative;
  height: 2px;
  background: var(--line);
  margin: 18px 12px 12px;
}
.wf-slider__thumb {
  position: absolute;
  top: 50%;
  /* (active / (count - 1)) * 100% — clamped to [0,100]. */
  left: calc(var(--wf-slider-active) / max(calc(var(--wf-slider-count) - 1), 1) * 100%);
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--wf-accent);
  transform: translate(-50%, -50%);
  transition: left var(--dur-normal) var(--ease-out);
  box-shadow: 0 0 0 3px var(--bg);
}
.wf-slider__steps {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
}
.wf-slider__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 44px;
  padding: 6px 4px 4px;
  font: inherit;
  font-size: var(--text-micro);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.wf-slider__step:hover { color: var(--ink); }
.wf-slider__tick {
  width: 1px; height: 8px;
  background: var(--line-strong);
  display: block;
}
.wf-slider__step--active { color: var(--ink); font-weight: 700; }
.wf-slider__step--active .wf-slider__tick { background: var(--wf-accent); width: 2px; height: 12px; }
.wf-slider__label { line-height: 1.1; text-align: center; }

/* ============== REVIEW (grouped sections) ==============
   The review step uses the same wf-receipt primitive but layered into named
   sections, each with a subdued "Edit" link that POSTs _journey_goto. */
.wf-review { display: grid; gap: var(--space-6); }
.wf-review__section { gap: 0; }
.wf-review__section + .wf-review__section { margin-top: 0; }
.wf-review__header {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px;
  padding: 4px 0 10px;
  border-bottom: 0;
}
.wf-receipt__group-title {
  font-family: 'Bebas Neue', 'Oswald', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--ink);
  text-transform: uppercase;
}
.wf-review__edit {
  font: inherit;
  font-size: var(--text-micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 2px 0;
  cursor: pointer;
}
.wf-review__edit:hover { color: var(--ink); border-bottom-color: var(--ink); }
.wf-receipt__empty { color: var(--ink-faint); font-style: italic; font-size: var(--text-small); }

/* Subdued derived/optional hint variants — used by the city → timezone hint
   and the progressive-feature reveal. */
.wf-field__hint--derived { color: var(--ink-muted); }
.wf-field__hint--muted { color: var(--ink-faint); font-style: italic; }

/* T4 will style .journey-wf__feedback--pending if it needs a distinct tone. */

/* ============== MOBILE 390px POLISH ==============
   Tightens spacing and shrinks labels at narrow widths so feature triplets
   (label/description) don't overlap input zones. */
@media (max-width: 540px) {
  .wf-field { gap: 4px; }
  .wf-field__label { font-size: calc(var(--text-small) * 0.92); }
  .wf-segments:has(> .wf-segment:nth-child(3)) { flex-direction: column; }
  .wf-segments:has(> .wf-segment:nth-child(3)) .wf-segment + .wf-segment { border-left: 1px solid var(--line); border-top: 0; }
  .wf-pick__option { padding: 12px 14px; }
  .wf-slider__step { font-size: calc(var(--text-micro) * 0.92); }
}

/* receipt — typeset confirmation list */
.wf-receipt { display: grid; gap: 0; border-top: 2px solid var(--line-strong); }
.wf-receipt__row {
  display: grid; grid-template-columns: 160px 1fr; gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.wf-receipt__key {
  font-size: var(--text-micro); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-muted); font-weight: 700;
}
.wf-receipt__val { font-size: var(--text-body); color: var(--ink); }
@media (max-width: 540px) {
  .wf-receipt__row { grid-template-columns: 1fr; gap: 4px; padding: 10px 0; }
}

/* ============== SIGN-IN PRIMITIVES ============== */

.wf-check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--text-small); color: var(--ink-muted);
}
.wf-check input { accent-color: var(--ink); }

/* ============== FEATURE CHECKS ============== */

.wf-check2 {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.wf-check2:hover { border-color: var(--line-strong); }
.wf-check2 input { grid-row: span 2; margin: 2px 0 0; accent-color: var(--ink); width: 16px; height: 16px; }
.wf-check2:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.wf-check2__label { font-weight: 600; font-size: var(--text-body); }
.wf-check2__sub { grid-column: 2; font-size: var(--text-micro); letter-spacing: 0.04em; color: var(--ink-faint); }

/* ============== LOADING ============== */

.wf-loading {
  display: inline-block; width: 14px; height: 14px;
  border: 1.5px solid var(--line); border-top-color: var(--ink);
  border-radius: 50%; animation: wf-spin 0.8s linear infinite;
}
@keyframes wf-spin { to { transform: rotate(360deg); } }

/* ============== SHELL VARIANTS ============== */
/* B — modal/sheet variant */
.wf-shell--sheet {
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -32px rgba(0,0,0,0.25);
  max-width: 720px; margin: 32px auto; min-height: auto;
}
/* C — side-rail dots */
.wf-shell--rail .wf-body {
  padding-left: 80px;
  position: relative;
}
.wf-rail {
  position: absolute; left: 24px; top: var(--wf-pad-block);
  display: grid; gap: 14px;
}
.wf-rail__dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
}
.wf-rail__dot--done { background: var(--ink); border-color: var(--ink); }
.wf-rail__dot--active { background: var(--wf-accent); border-color: var(--wf-accent); transform: scale(1.4); }
@media (max-width: 540px) {
  .wf-shell--rail .wf-body { padding-left: clamp(16px, 4vw, 32px); }
  .wf-rail { display: none; }
}

/* Post-submit success screen. Replaces the form chrome (rail, fields, footer
   stepper) when $shell.Submitted is true. Generous spacing, single accent
   button, small receipt block; no progress visuals. */
.wf-page--done {
  padding: 32px 0;
}
.wf-success {
  display: grid;
  gap: 28px;
  max-width: 640px;
}
.wf-success .wf-receipt {
  border-top: 2px solid var(--line-strong);
  padding-top: 0;
}
.wf-success__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}
.wf-footer--done {
  justify-content: flex-end;
}
.journey-wf--done .wf-body {
  padding-left: clamp(24px, 4vw, 48px);
}
