/* Questionnaire: multi-step form, progress indicator and form controls.
   Builds on the design tokens in styles.css (:root). */

/* --- Progress ------------------------------------------------------------ */
.form-progress {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: 0 0 22px;
  padding: 14px 18px 12px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.form-progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 700;
}

.form-progress-meta span:last-child {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.form-progress-bar {
  height: 8px;
  margin: 10px 0 12px;
  background: #e6f2f8;
  border-radius: 999px;
  overflow: hidden;
}

.form-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--green));
  border-radius: inherit;
  transition: width .35s ease;
}

.form-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.form-stepper button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}

.form-stepper button:hover:not(:disabled) { background: #f0f7fb; color: var(--text); }
.form-stepper button:disabled { cursor: not-allowed; opacity: .55; }
.form-stepper button:focus-visible { outline: 3px solid rgba(66, 153, 210, .45); outline-offset: 1px; }

.form-stepper-number {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: white;
  font-size: 13px;
}

.form-stepper-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-stepper .is-current button { color: var(--text); }
.form-stepper .is-current .form-stepper-number { border-color: var(--primary); background: var(--primary); color: white; }
.form-stepper .is-complete .form-stepper-number { border-color: var(--green); background: var(--green); color: white; font-size: 0; }
.form-stepper .is-complete .form-stepper-number::after { content: "✓"; font-size: 14px; }

/* --- Questions and choices ----------------------------------------------- */
.questionnaire .question {
  scroll-margin-top: 150px;
}

.questionnaire-section { scroll-margin-top: 140px; }
.questionnaire-section-title:focus { outline: none; }

.questionnaire .choice {
  margin: 8px 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  line-height: 1.45;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}

.questionnaire .choice:hover { border-color: #b7d6ea; background: #f8fcfe; }

.questionnaire .choice input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  cursor: pointer;
}

.questionnaire .choice:has(input:checked) {
  border-color: var(--primary);
  background: #eef7fd;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.questionnaire .choice:has(input:focus-visible) {
  outline: 3px solid rgba(66, 153, 210, .35);
  outline-offset: 1px;
}

.questionnaire .choice:has(input:disabled:not(:checked)) {
  cursor: not-allowed;
  opacity: .55;
}

.questionnaire-readonly .choice { cursor: default; }
.questionnaire-readonly .choice:hover { border-color: var(--border); background: white; }

.question h3 {
  margin: 18px 0 4px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.question input[name$="Other"] { margin-top: 4px; }

/* Process questions: one card per HR process */
.questionnaire .process-question {
  margin: 0 0 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfe;
}

.questionnaire .process-question > label:first-child {
  font-size: 18px;
  margin-bottom: 12px;
}

.questionnaire .process-question > label:not(:first-child),
.questionnaire .process-question-prompt {
  margin-top: 20px;
}

/* Explanation of the scales (part 3) */
.scale-guide {
  margin: 0 0 22px;
  padding: 4px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7fbfd;
}

.scale-guide summary {
  padding: 10px 0;
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
}

.scale-guide[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* --- Errors ---------------------------------------------------------------- */
.questionnaire .choice.is-invalid { border-color: var(--red); background: #fdf6f7; }
.questionnaire input.is-invalid,
.questionnaire textarea.is-invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(207, 93, 100, .12); }

.field-error {
  margin: 6px 0 0;
  color: #a64049;
  font-size: 14px;
  font-weight: 650;
}

.field-error::before { content: "! "; }

/* --- Step navigation ------------------------------------------------------- */
.form-nav {
  align-items: center;
  flex-wrap: wrap;
}

.form-nav [data-form-nav="prev"] { margin-right: auto; }

.form-draft-status {
  color: var(--muted);
  font-size: 13px;
}

.btn-link {
  padding: 8px 6px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
}

.btn-link:hover { color: var(--text); }

.btn:focus-visible { outline: 3px solid rgba(66, 153, 210, .45); outline-offset: 2px; }

[hidden] { display: none !important; }

@media (max-width: 800px) {
  .form-stepper-name { display: none; }
  .form-stepper .is-current .form-stepper-name { display: inline; }
  .form-stepper { grid-template-columns: repeat(5, auto); justify-content: space-between; }
  .questionnaire .process-question { padding: 16px; }
}

@media (max-width: 600px) {
  .form-progress { padding: 12px; border-radius: 0; margin-left: -12px; margin-right: -12px; }
  .form-progress-meta { flex-direction: column; gap: 2px; }
  .form-nav { justify-content: stretch; }
  .form-nav .btn-primary, .form-nav .btn-secondary { flex: 1 1 40%; }
  .form-draft-status { order: 10; width: 100%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .form-progress-bar span, .questionnaire .choice { transition: none; }
}
