/* ==========================================================================
   UIForge step form engine: styles
   Works with assets/js/form-engine.js. Uses tokens from tokens.css.
   ========================================================================== */

.sf {
  display: grid;
  gap: var(--s-5);
  padding: var(--s-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-panel);
}

.sf-head { display: grid; gap: var(--s-3); }
.sf-title { font-size: var(--fs-lg); font-weight: 650; }

/* Progress: the bar shows more temper colors as it fills */
.sf-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.sf-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--temper);
  background-size: 300% 100%;
  border-radius: 3px;
  transition: width 0.45s cubic-bezier(.2, .7, .2, 1);
}

.sf-steps {
  display: flex;
  gap: var(--s-4);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.sf-steps li { display: inline-flex; align-items: center; gap: 6px; }
.sf-steps li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
}
.sf-steps li[data-state="done"]::before { background: var(--accent); border-color: var(--accent); }
.sf-steps li[aria-current="step"] { color: var(--ink); font-weight: 600; }
.sf-steps li[aria-current="step"]::before { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.sf-step { display: grid; gap: var(--s-4); }
.sf-step[hidden] { display: none; }
.sf-step h3 { font-size: var(--fs-lg); }
.sf-step > p { color: var(--muted); font-size: var(--fs-sm); margin-top: calc(var(--s-3) * -1); }

/* Fields */
.sf-field { display: grid; gap: 6px; }
.sf-field label, .sf-legend { font-weight: 600; font-size: var(--fs-sm); color: var(--ink); }
.sf-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 520px) { .sf-row { grid-template-columns: 1fr; } }

.sf input:not([type="radio"]):not([type="checkbox"]):not([type="range"]),
.sf select,
.sf textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-md);
}
.sf textarea { min-height: 96px; resize: vertical; }
.sf input:focus, .sf select:focus, .sf textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: transparent;
}
.sf [aria-invalid="true"] { border-color: var(--err) !important; }

.sf-error {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--err);
  font-weight: 500;
}
.sf-error[hidden] { display: none; }

.sf-hint { font-size: var(--fs-xs); color: var(--muted); }

/* Choice cards (radio / checkbox) */
.sf-choices { border: 0; margin: 0; padding: 0; display: grid; gap: var(--s-2); min-width: 0; }
.sf-choices legend { padding: 0; margin-bottom: var(--s-2); }
.sf-choice-grid { display: grid; gap: var(--s-2); }
.sf-choice-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sf-choice-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 520px) {
  .sf-choice-grid.cols-3 { grid-template-columns: 1fr; }
  .sf-choice-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.sf-choice { position: relative; display: block; cursor: pointer; }
.sf-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sf-choice > span {
  display: grid;
  gap: 2px;
  height: 100%;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.15s, background-color 0.15s;
}
.sf-choice strong { font-size: var(--fs-sm); font-weight: 600; }
.sf-choice small { font-size: var(--fs-xs); color: var(--muted); line-height: 1.4; }
.sf-choice:hover > span { border-color: var(--muted); }
.sf-choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.sf-choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.sf-choice.compact > span { text-align: center; padding: var(--s-2); }
.sf-choices[aria-invalid="true"] .sf-choice > span { border-color: var(--err); }

.sf-check { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--fs-sm); color: var(--muted); }
.sf-check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }

/* Range */
.sf-range { display: grid; gap: var(--s-2); }
.sf-range-top { display: flex; justify-content: space-between; align-items: baseline; }
.sf-range output { font-size: var(--fs-xl); font-weight: 700; font-stretch: var(--wide); font-variant-numeric: tabular-nums; }
.sf input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.sf-range-scale { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }

/* Password strength */
.sf-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sf-meter i { height: 4px; border-radius: 2px; background: var(--line); transition: background-color 0.2s; }
.sf-meter[data-score="1"] i:nth-child(-n+1) { background: var(--err); }
.sf-meter[data-score="2"] i:nth-child(-n+2) { background: #C98A2E; }
.sf-meter[data-score="3"] i:nth-child(-n+3) { background: var(--accent); }
.sf-meter[data-score="4"] i { background: var(--ok); }

/* Review summary */
.sf-summary { display: grid; gap: 0; margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.sf-summary div { display: grid; grid-template-columns: minmax(110px, 0.8fr) 1.2fr; gap: var(--s-3); padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); }
.sf-summary div + div { border-top: 1px solid var(--line); }
.sf-summary dt { color: var(--muted); }
.sf-summary dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

/* Navigation */
.sf-nav { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding-top: var(--s-2); }
.sf-nav .btn[data-prev][hidden] { display: inline-flex; visibility: hidden; }
.sf-count { font-size: var(--fs-xs); color: var(--muted); }

/* Done */
.sf-done { display: grid; gap: var(--s-3); justify-items: start; padding-block: var(--s-4); }
.sf-done[hidden] { display: none; }
.sf-done-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.sf-done-icon svg { width: 22px; height: 22px; }
.sf-done h3 { font-size: var(--fs-xl); outline: none; }
.sf-done p { color: var(--muted); }

.sf.is-done .sf-nav, .sf.is-done .sf-steps { display: none; }

@media (max-width: 520px) {
  .sf { padding: var(--s-5); }
  .sf-steps { flex-wrap: wrap; gap: var(--s-2) var(--s-3); }
}
