/* Flow pieces for multi-step forms (register, reset, change password, GM sign-in).
   Promoted from D6. JS helpers: js/lib/forms.js.
   .pw-wrap + .pw-toggle (+ .pw-meter, .pw-verdict)   password with Show/Hide and a strength meter
   .form-field.code-field input.code-input             the six-slot one-time code (one real input)
   ol.flow-steps > li[data-step] > .flow-gem            the steps strip; setSteps(list, name)
   .flow-done > .seal                                   the done seal (one authored moment)
   .flow-done-body                                      the seal beside the words, inside a form window */

/* Password with Show/Hide inside the field. The button is 44px tall inside the 48px input. */
.pw-wrap { position: relative; }
.form-field .pw-wrap input { padding-right: 5.25rem; }
.pw-toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  min-width: 4.5rem;
  padding: 0 var(--s-3);
  font-family: var(--font-control);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent-hi);
  background: transparent;
  border: 0;
  border-radius: calc(var(--r-2) - 2px);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.pw-toggle:hover { background: var(--tint); }
.pw-toggle[aria-pressed="true"] { background: var(--tint-strong); }
.pw-toggle:focus-visible { outline-offset: -3px; }

/* Strength: four bars that fill from the left; the word in the hint says the same. */
.pw-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-1);
  margin-top: var(--s-2);
}
.pw-meter i {
  display: block;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line-soft);
  transition: background-color var(--dur-2) var(--ease-out);
}
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: var(--warn); }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: var(--accent); }
.pw-meter[data-score="4"] i { background: var(--ok); }
.pw-verdict { font-weight: 600; color: var(--text); }
.pw-verdict[data-score="1"] { color: var(--danger); }
.pw-verdict[data-score="2"] { color: var(--warn); }
.pw-verdict[data-score="4"] { color: var(--ok); }

/* One-time code: one real field drawn as six slots. Every digit sits centred over its slot:
   a slot is 1.9ch (1ch digit + 0.9ch letter-spacing), the field starts with half the spacing. */
.form-field.code-field input.code-input {
  --cell: 1.9ch;
  width: calc(6 * var(--cell) + 0.45ch + 0.3ch + 2px);
  max-width: 100%;
  min-height: 64px;
  padding: 0 0 0 0.45ch;
  font-family: var(--font-mono);
  font-size: clamp(1.625rem, 1.45rem + 0.8vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.9ch;
  font-variant-numeric: tabular-nums lining-nums;
  color: var(--text);
  text-align: left;
  background-color: var(--ink-1);
  background-image: repeating-linear-gradient(90deg, var(--line-strong) 0 1.5ch, transparent 1.5ch var(--cell));
  background-repeat: no-repeat;
  background-size: calc(6 * var(--cell)) 2px;
  background-position: 0.2ch calc(100% - 12px);
}
.form-field.code-field input.code-input:focus-visible {
  background-image: repeating-linear-gradient(90deg, var(--accent) 0 1.5ch, transparent 1.5ch var(--cell));
}

/* The steps strip: three gems on a dashed road. Current = crimson gem, done = gold, to come = outline. */
.flow-steps {
  display: grid;
  grid-template-columns: repeat(var(--steps, 3), minmax(0, 1fr));
  margin: 0 0 var(--s-6);
  max-width: 34rem;
}
.flow-steps li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  text-align: center;
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.3;
  color: var(--text-2);
}
.flow-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 8px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line-strong) 0 5px, transparent 5px 10px);
}
.flow-steps li.is-done:not(:last-child)::after { background: var(--accent); }
.flow-gem {
  width: 13px;
  height: 13px;
  margin: 2px;
  border: 1px solid var(--line-strong);
  background: var(--ink-0);
  transform: rotate(45deg);
  transition: background-color var(--dur-3) var(--ease-out), border-color var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}
.flow-steps li[aria-current="step"] { color: var(--text); }
.flow-steps li[aria-current="step"] .flow-gem {
  background: var(--action);
  border-color: var(--accent-hi);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--action) 28%, transparent), 0 2px 8px rgb(var(--shadow-rgb) / 0.6);
}
.flow-steps li.is-done { color: var(--accent-hi); }
.flow-steps li.is-done .flow-gem { background: var(--accent); border-color: var(--accent-hi); }

/* Done: the seal. The one authored moment of these pages: the gem presses in like wax and a gold
   ring spreads once. With reduced motion it simply is there. */
/* Children stretch (a title bar inside spans the window); only the seal keeps to the start. Inside a window
   (<section class="flow-done"><div class="window-head">..</div><div class="window-body flow-done-body">..</div>)
   the title bar meets the body with no gap, and .flow-done-body sets the seal beside the words. */
.flow-done { display: grid; gap: var(--s-3); }
.flow-done > .seal { justify-self: start; }
.flow-done:has(> .window-head) { gap: 0; }
.flow-done-body { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: var(--s-3) var(--s-5); align-items: center; }
.flow-done-body .seal { margin: var(--s-2); justify-self: center; }
.flow-done .flow-done-body > .card-text { margin-bottom: 0; } /* outranks the views' card-text spacing */
.flow-done-body .actions { grid-column: 1 / -1; margin-top: var(--s-3); }
@container view (max-width: 419px) {
  .flow-done-body { grid-template-columns: minmax(0, 1fr); }
  .flow-done-body .seal { justify-self: start; margin: var(--s-3) var(--s-3) var(--s-2); }
}
.seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: var(--s-2) 0 var(--s-3) var(--s-2);
  color: var(--text);
  background: linear-gradient(160deg, var(--action-hi), var(--action) 55%, var(--action-lo));
  border: 2px solid var(--accent-hi);
  border-radius: 6px;
  transform: rotate(45deg);
  box-shadow: var(--edge), 0 10px 24px -8px rgb(var(--shadow-rgb) / 0.9);
}
.seal .icon { width: 26px; height: 26px; stroke-width: 2.2; transform: rotate(-45deg); }
.seal::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 1px solid var(--accent-hi);
  border-radius: 6px;
  opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .flow-done:not([hidden]) .seal { animation: seal-press var(--dur-4) var(--ease-out) both; }
  .flow-done:not([hidden]) .seal::after { animation: seal-ring 1100ms var(--ease-out) 260ms both; }
}
@keyframes seal-press {
  from { transform: rotate(45deg) scale(1.35); filter: blur(6px); opacity: 0; }
  to { transform: rotate(45deg) scale(1); filter: blur(0); opacity: 1; }
}
@keyframes seal-ring {
  from { opacity: 0.9; transform: scale(1); }
  to { opacity: 0; transform: scale(1.9); }
}
