/**
 * Multi-Step Form Styles
 *
 * Step visibility, Previous/Next navigation and the progress indicator
 * (numbered steps, percentage bar, checkmarks). Everything is scoped to
 * the multi-step classes, so single-page forms are unaffected.
 *
 * Progressive enhancement: until the multistep script adds the
 * `afb-multistep-ready` class (or when JavaScript is unavailable) all
 * steps stay visible, the navigation and progress bar stay hidden, and
 * the form works as a normal single-page form.
 *
 * @package Auto_Form_Builder
 * @since 1.3
 */

/* =========================================================
   Steps
   ========================================================= */

.afb-multistep.afb-multistep-ready .afb-step {
  display: none;
}

.afb-multistep.afb-multistep-ready .afb-step.is-active {
  display: block;
}

/* Focus is moved to the step container on step change; the container
   itself does not need a visible ring (the first field inside shows
   focus as usual when tabbing). */
.afb-multistep .afb-step:focus {
  outline: none;
}

.afb-multistep .afb-step-title {
  margin: 0 0 16px;
}

/* Submit button only appears on the last step. */
.afb-multistep.afb-multistep-ready:not(.afb-on-last-step) .submit-wrapper {
  display: none;
}

/* =========================================================
   Previous / Next navigation
   ========================================================= */

.afb-multistep .afb-step-nav {
  display: none;
}

.afb-multistep.afb-multistep-ready .afb-step-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

/* Keep the hidden attribute authoritative over the flex display above. */
.afb-multistep .afb-step-nav button[hidden] {
  display: none;
}

.afb-multistep .afb-step-nav .afb-step-prev,
.afb-multistep .afb-step-nav .afb-step-next {
  padding: 10px 22px;
  border-radius: 4px;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.afb-multistep .afb-step-nav .afb-step-next {
  margin-left: auto;
  background: var(--afb-primary, #2271b1);
  border: 1px solid var(--afb-primary, #2271b1);
  color: #fff;
}

.afb-multistep .afb-step-nav .afb-step-next:hover {
  filter: brightness(0.92);
}

.afb-multistep .afb-step-nav .afb-step-prev {
  background: transparent;
  border: 1px solid #c8cbd0;
  color: #344054;
}

.afb-multistep .afb-step-nav .afb-step-prev:hover {
  border-color: var(--afb-primary, #2271b1);
  color: var(--afb-primary, #2271b1);
}

.afb-multistep .afb-step-nav .afb-step-prev:focus-visible,
.afb-multistep .afb-step-nav .afb-step-next:focus-visible {
  outline: 2px solid var(--afb-primary, #2271b1);
  outline-offset: 2px;
}

/* =========================================================
   Progress indicator (shared)
   ========================================================= */

.afb-progress {
  display: none;
  margin: 0 0 24px;
}

.auto-form-builder-wrapper.afb-multistep-ready .afb-progress {
  display: block;
}

/* Accessibility-only live region. Defined here because embed pages and
   many themes never ship a .screen-reader-text rule. */
.afb-progress .screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* =========================================================
   Progress: numbered steps / checkmarks
   ========================================================= */

.afb-progress .afb-progress-list {
  display: flex;
  align-items: flex-start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.afb-progress .afb-progress-item {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  text-align: center;
}

/* Connector line between markers. */
.afb-progress .afb-progress-item + .afb-progress-item::before {
  content: "";
  position: absolute;
  top: 16px;
  right: calc(50% + 20px);
  left: calc(-50% + 20px);
  height: 2px;
  background: #d5d8dc;
}

.afb-progress .afb-progress-item.is-complete + .afb-progress-item::before {
  background: var(--afb-primary, #2271b1);
}

.afb-progress .afb-progress-marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid #d5d8dc;
  border-radius: 50%;
  background: #fff;
  color: #667085;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.afb-progress .afb-progress-item.is-current .afb-progress-marker {
  border-color: var(--afb-primary, #2271b1);
  color: var(--afb-primary, #2271b1);
}

.afb-progress .afb-progress-item.is-complete .afb-progress-marker {
  border-color: var(--afb-primary, #2271b1);
  background: var(--afb-primary, #2271b1);
  color: #fff;
  cursor: pointer;
}

.afb-progress .afb-progress-marker:disabled {
  cursor: default;
}

.afb-progress .afb-progress-marker:focus-visible {
  outline: 2px solid var(--afb-primary, #2271b1);
  outline-offset: 2px;
}

.afb-progress .afb-progress-label {
  max-width: 120px;
  color: #667085;
  font-size: 12px;
  line-height: 1.3;
}

.afb-progress .afb-progress-item.is-current .afb-progress-label {
  color: var(--afb-primary, #2271b1);
  font-weight: 600;
}

/* Step branching: markers for steps off the active path are removed from
   the flow entirely; the remaining markers are renumbered by the step
   engine, so the bar always shows the visitor's real route. */
.afb-progress .afb-progress-item--skipped {
  display: none;
}

/* Checkmarks mode: completed markers show a check instead of a number. */
.afb-progress--checkmarks .afb-progress-item.is-complete .afb-progress-marker-number {
  display: none;
}

.afb-progress--checkmarks .afb-progress-item.is-complete .afb-progress-marker::after {
  content: "\2713";
}

/* =========================================================
   Progress: percentage bar
   ========================================================= */

.afb-progress--percentage {
  display: none;
  align-items: center;
  gap: 12px;
}

.auto-form-builder-wrapper.afb-multistep-ready .afb-progress--percentage {
  display: flex;
}

.afb-progress--percentage .afb-progress-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e4e7ec;
}

.afb-progress--percentage .afb-progress-fill {
  width: 0;
  height: 100%;
  border-radius: 4px;
  background: var(--afb-primary, #2271b1);
  transition: width 0.3s ease;
}

.afb-progress--percentage .afb-progress-text {
  min-width: 40px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* =========================================================
   Mobile
   ========================================================= */

@media (width <= 480px) {
  .afb-progress .afb-progress-label {
    display: none;
  }

  .afb-progress .afb-progress-marker {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .afb-progress .afb-progress-item + .afb-progress-item::before {
    top: 14px;
    right: calc(50% + 18px);
    left: calc(-50% + 18px);
  }
}
