/* PUZL setup components (P05): strip, Home next-step bar, setup step bar,
 * step rail, Home step list, copy prompt box, toast. Markup comes from
 * api/templates/_shared/puzl_setup.html; behaviour from puzl-setup.js.
 *
 * Values are copied from Joe's mockup (intake/TOKENS.md, intake/COMPONENTS.md);
 * the mockup line each rule comes from is on the rule. Colours go through the
 * tokens in tokens-portal.css. Class names carry a ps- prefix because the
 * portal already owns .pill, .toast, .prompt and .row.
 *
 * Three mockup values are deliberately not copied:
 *   - white on --success (the Copied button, the done step number): painted
 *     with --on-success, which P03 sets to reach 4.5:1 in light and dark.
 *   - the cobalt fill of the strip and bar: --cobalt-fill, which stays dark
 *     enough under white text in dark mode (--cobalt goes light there).
 *   - the segment "off" colour: --seg-off, for the same reason.
 */

/* Buttons the mockup has and the portal does not (mockup line 106-118). The
 * portal's .btn, .btn-ghost and .btn-sm already exist in portal-chrome.css;
 * these three load after it and win by order. */
.btn-gold { background: var(--marigold); color: #14213a; }
.btn-gold:hover { background: #ffd36b; color: #14213a; }
.btn-onblue { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.btn-onblue:hover { background: rgba(255,255,255,.12); color: #fff; }
.btn-text {
  background: none; border: 0; color: var(--link); font: inherit; font-weight: 700;
  cursor: pointer; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px;
}
.btn-text.onblue { color: #fff; }

/* Segments (mockup 127-129). */
.ps-segs { display: flex; gap: 4px; }
.ps-segs i { flex: 1; height: 8px; border-radius: 4px; background: var(--seg-off); }
.ps-segs i.on { background: var(--marigold); }

/* Setup strip (mockup 84-88). */
.ps-strip { background: var(--cobalt-fill); color: #fff; }
.ps-strip-in {
  max-width: 1240px; margin: 0 auto; padding: 10px 24px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.ps-strip p { margin: 0; font-weight: 600; font-size: 15.5px; flex: 1; }
.ps-strip .ps-segs { width: 140px; }

/* Home next-step bar (mockup 155-157). It sits on the Home setup block, which
 * paints the cobalt; the bar has no fill of its own. */
.ps-nextbar { display: flex; align-items: center; gap: 14px; padding: 22px 32px 26px; flex-wrap: wrap; }
.ps-nextbar .ps-note { flex: 1; color: var(--cobalt-100); font-size: 15px; margin: 0; }
.ps-nextbar form { margin: 0; }

/* Setup shell bar (mockup 212-215), fixed to the bottom. */
.ps-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--cobalt-fill); color: #fff;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ps-bar-in {
  max-width: 1240px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.ps-bar .ps-note { flex: 1; color: var(--cobalt-100); font-size: 15px; margin: 0; }
.ps-bar form { margin: 0; }
body:has(.ps-bar) { padding-bottom: 84px; }

/* Step rail (mockup 185-191). */
.ps-rail { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 30px; list-style: none; padding: 0; }
.ps-rail li {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 8px;
  border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-size: 14.5px; color: var(--ink-soft);
}
.ps-rail .ps-n {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12.5px; box-shadow: inset 0 0 0 2px var(--line);
}
.ps-rail li.done .ps-n { background: var(--success); color: var(--on-success); box-shadow: none; }
.ps-rail li.cur { background: var(--cobalt-fill); color: #fff; border-color: var(--cobalt-fill); }
.ps-rail li.cur .ps-n { background: var(--marigold); color: #14213a; box-shadow: none; }

/* Home step list (mockup 144-153). */
.ps-steps {
  list-style: none; margin: 22px 32px 0; padding: 0; background: var(--surface); color: var(--ink);
  border-radius: var(--r-md); overflow: hidden;
}
.ps-steps li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 16px; align-items: center;
  padding: 16px 20px; border-top: 1px solid var(--line);
}
.ps-steps li:first-child { border-top: 0; }
.ps-steps .ps-ic {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 14px; box-shadow: inset 0 0 0 2px var(--line); color: var(--ink-soft);
}
.ps-steps li.done .ps-ic { background: var(--success); box-shadow: none; color: var(--on-success); }
.ps-steps li.next { background: var(--marigold-tint); }
.ps-steps li.next .ps-ic { background: var(--marigold); box-shadow: none; color: #14213a; }
.ps-steps h3 { font-size: 17px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.ps-steps p { margin: 2px 0 0; font-size: 15px; color: var(--ink-soft); }
.ps-steps select {
  font: inherit; font-size: 15px; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
}
.ps-steps form { margin: 0; }

/* Pills (mockup 120-126). */
.ps-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700;
  border-radius: var(--r-pill); padding: 4px 11px; white-space: nowrap;
}
.ps-pill--sage { background: var(--sage); color: var(--sage-ink); }
.ps-pill--gold { background: var(--marigold-tint); color: var(--ink); box-shadow: inset 0 0 0 1px var(--marigold); }
.ps-pill--line { background: transparent; color: var(--ink-soft); box-shadow: inset 0 0 0 1.5px var(--line); }

/* The Live dot inside the pill (mockup 74-75). */
.ps-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex: none; }
.ps-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--success); opacity: 0; animation: ping var(--dur-ping) ease-out infinite;
}

/* Copy prompt box (mockup 251-258). */
.ps-prompt {
  background: var(--inset); border: 1.5px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; margin-top: 10px; color: var(--ink);
}
.ps-prompt-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ps-prompt-h b { font-size: 14.5px; }
.ps-prompt-t { margin: 10px 0 8px; font-size: 16px; line-height: 1.5; color: var(--ink); }
.ps-prompt-f { font-size: 14px; color: var(--ink-soft); }
.ps-prompt--big { padding: 22px; background: var(--surface); }
.ps-prompt--big .ps-prompt-t { font-size: 19px; font-weight: 600; }
.ps-prompt .ps-notice {
  margin: 0 0 12px; background: var(--marigold-tint); border-radius: var(--r-md);
  padding: 14px 16px; font-size: 15.5px;
}
.ps-prompt .ps-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
/* Copied: the mockup paints white on --success (2.16:1 in dark). --on-success
 * is the pair P03 measured at 4.5:1 or more in light, toggle dark and device dark. */
.ps-copybtn.ps-ok, .ps-copybtn.ps-ok:hover { background: var(--success); color: var(--on-success); box-shadow: none; border-color: var(--success); }

/* Toast (mockup 294-296). One at a time. */
.ps-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: var(--r-pill);
  font-weight: 700; z-index: 80; opacity: 0; transition: opacity var(--dur-fade); pointer-events: none;
}
.ps-toast.show { opacity: 1; }
body:has(.ps-bar) .ps-toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 560px) {
  /* Stack: the button, then the note, then Hide, each on its own row (mockup
   * home_390). Side by side, the note is squeezed into a narrow column. */
  .ps-nextbar { padding-left: 20px; padding-right: 20px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .ps-nextbar .ps-note { flex: none; }
  .ps-steps { margin: 18px 12px 0; }
  .ps-steps li { grid-template-columns: 30px 1fr; padding: 14px; }
  .ps-steps li > .ps-act { grid-column: 2; }
}

/* Reduced motion: the Live dot ring and the toast fade stop (the fill of a
 * segment never animated in the mockup; nothing else here moves). */
@media (prefers-reduced-motion: reduce) {
  .ps-dot::after { animation: none; }
  .ps-toast { transition: none; }
}
