/* ============================================================
   progress-bar.css — AAI Child Theme
   Multi-step form progress indicator
   Inherits design tokens from style.css (loads first)
   ============================================================ */


/* ── Wrapper ───────────────────────────────────────────────── */

.aai-progress {
  width: 100%;
  margin-bottom: clamp(2rem, 4vw, 3rem);
  /* Subtle card surround to frame the form top */
  background: var(--neutral-0);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 1.75rem) clamp(1.5rem, 4vw, 2.5rem);
  box-shadow: var(--shadow-card);
}

/* ── Track — the row that holds pills + connectors ─────────── */

.aai-progress__track {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

/* ── Connector line between pills ──────────────────────────── */

.aai-progress__connector {
  flex: 1;
  height: 2px;
  background: var(--neutral-200);
  border-radius: var(--radius-full);
  position: relative;
  overflow: hidden;
  min-width: 16px;
}

/* Animated fill — grows left-to-right when step is complete */
.aai-progress__connector::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--teal-500), var(--teal-400));
  border-radius: var(--radius-full);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.45s var(--ease-out);
}

.aai-progress__connector.is-complete::after {
  transform: scaleX(1);
}


/* ── Step pill ─────────────────────────────────────────────── */

.aai-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  position: relative;
  /* Pill width — enough for the badge + label on wider screens */
  min-width: 0;
}

/* The pill badge itself */
.aai-step__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--neutral-300);
  background: var(--neutral-0);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--neutral-400);
  white-space: nowrap;
  cursor: default;
  user-select: none;
  transition:
    background-color  0.3s var(--ease-out),
    border-color      0.3s var(--ease-out),
    color             0.3s var(--ease-out),
    box-shadow        0.3s var(--ease-out),
    transform         0.25s var(--ease-out);
  /* Entrance */
  will-change: transform;
}

/* Step number badge inside pill */
.aai-step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--neutral-400);
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  transition:
    background-color 0.3s,
    color 0.3s;
}

/* Step label text */
.aai-step__label {
  /* Shown inside the pill on wider screens, hidden on mobile */
}

/* ── STATE: active (current step) ──────────────────────────── */

.aai-step.is-active .aai-step__pill {
  background: var(--teal-500);
  border-color: var(--teal-500);
  color: var(--neutral-0);
  box-shadow:
    0 2px 8px rgba(52, 157, 140, 0.30),
    0 0 0 4px var(--teal-100);
  transform: translateY(-1px);
}

.aai-step.is-active .aai-step__num {
  background: rgba(255,255,255,0.25);
  color: var(--neutral-0);
}

/* Subtle pulse ring on the active pill */
@media (prefers-reduced-motion: no-preference) {
  .aai-step.is-active .aai-step__pill::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: var(--radius-full);
    border: 2px solid var(--teal-300);
    opacity: 0;
    animation: aai-pulse-ring 2.4s ease-out infinite;
  }

  @keyframes aai-pulse-ring {
    0%   { opacity: 0; transform: scale(0.92); }
    30%  { opacity: 0.6; }
    100% { opacity: 0; transform: scale(1.08); }
  }
}

/* ── STATE: complete (past step) ───────────────────────────── */

.aai-step.is-complete .aai-step__pill {
  background: var(--teal-50);
  border-color: var(--teal-300);
  color: var(--teal-700);
}

.aai-step.is-complete .aai-step__num {
  background: var(--teal-500);
  color: var(--neutral-0);
  /* Replace number with a checkmark via content trick */
  font-size: 0; /* hide the number */
  position: relative;
}

/* Checkmark drawn in pseudo-element */
.aai-step.is-complete .aai-step__num::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--neutral-0);
  border-bottom: 2px solid var(--neutral-0);
  border-radius: 1px;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* ── Caption row (below the track on wider screens) ────────── */

.aai-progress__captions {
  display: none; /* hidden on mobile — label is in the pill */
}

@media (min-width: 600px) {
  .aai-progress__captions {
    display: flex;
    align-items: flex-start;
    margin-top: 0.6rem;
    /* Mirror the track layout */
    gap: 0;
  }

  .aai-progress__cap-spacer {
    flex: 1;
    min-width: 16px;
  }

  .aai-progress__cap {
    flex-shrink: 0;
    text-align: center;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--neutral-400);
    letter-spacing: 0.02em;
    transition: color 0.3s;
    /* Match pill width — set via JS after render */
  }

  .aai-step.is-active  ~ .aai-progress__captions .aai-progress__cap { color: var(--teal-600); }
  .aai-step.is-complete ~ .aai-progress__captions .aai-progress__cap { color: var(--teal-500); }
}


/* ── Mobile: collapse labels inside pills to numbers only ──── */

@media (max-width: 480px) {
  .aai-step__label {
    /* Hide text label, keep number badge */
    display: none;
  }

  .aai-step__pill {
    padding: 0.35rem 0.7rem;
  }

  /* Show a tiny caption below the pill on mobile */
  .aai-step::after {
    content: attr(data-label);
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--neutral-400);
    letter-spacing: 0.03em;
    margin-top: 0.2rem;
  }

  .aai-step.is-active::after  { color: var(--teal-600); }
  .aai-step.is-complete::after { color: var(--teal-500); }
}


/* ── Step panel sections (wraps form fields per step) ──────── */

.aai-form-step {
  display: none;
  opacity: 0;
  transform: translateX(16px);
  transition:
    opacity 0.35s var(--ease-out),
    transform 0.35s var(--ease-out);
}

.aai-form-step.is-active {
  display: block;
}

/* Two-frame trick: display:block on frame 1, then opacity on frame 2 */
.aai-form-step.is-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Slide-out direction for going backwards */
.aai-form-step.is-exiting-back {
  opacity: 0;
  transform: translateX(-16px);
  transition:
    opacity 0.22s var(--ease-in-out),
    transform 0.22s var(--ease-in-out);
}

/* ── Navigation buttons (Next / Back / Submit) ─────────────── */

.aai-form-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--neutral-100);
}

.aai-form-nav--end {
  justify-content: flex-end;
}

.aai-btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1.5px solid var(--neutral-300);
  color: var(--neutral-600);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s,
    background-color 0.15s;
}

.aai-btn-back:hover {
  border-color: var(--neutral-600);
  color: var(--neutral-800);
  background: var(--neutral-50);
}

.aai-btn-next {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--teal-500);
  border: none;
  color: var(--neutral-0);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(52, 157, 140, 0.28);
  transition:
    background-color 0.2s,
    transform 0.15s var(--ease-out),
    box-shadow 0.2s;
}

.aai-btn-next:hover {
  background-color: var(--teal-600);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(52, 157, 140, 0.36);
}

.aai-btn-next:active {
  transform: translateY(0);
}

/* Arrow nudge on hover */
.aai-btn-next__arrow,
.aai-btn-back__arrow {
  transition: transform 0.2s var(--ease-out);
  display: inline-block;
}

.aai-btn-next:hover .aai-btn-next__arrow  { transform: translateX( 3px); }
.aai-btn-back:hover .aai-btn-back__arrow  { transform: translateX(-3px); }

/* ── Validation: shake field on error ──────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .aai-field-error {
    animation: aai-shake 0.4s var(--ease-out);
  }

  @keyframes aai-shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX( 5px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX( 3px); }
  }
}

/* CF7 / WPForms field error highlight */
.aai-form-step .wpcf7-not-valid-tip,
.aai-form-step .wpforms-error {
  font-size: var(--text-xs);
  color: #c0392b;
  margin-top: 0.3rem;
}

.aai-form-step input.wpcf7-not-valid,
.aai-form-step select.wpcf7-not-valid,
.aai-form-step textarea.wpcf7-not-valid,
.aai-form-step input.wpforms-error,
.aai-form-step select.wpforms-error,
.aai-form-step textarea.wpforms-error {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.12);
}
