/* Questions and their controls. State is carried by words and aria-invalid, never by colour alone. */

/* ---------- progress ---------- */

.progress {
  display: grid;
  gap: var(--sp-2);
}

.progress__label {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-200);
  font-weight: 600;
}

.progress__org {
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

.progress__track {
  height: 0.5rem;
  background: var(--ui-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--brand-navy);
  border-radius: 999px;
  transition: width 300ms ease;
}

.steps-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: space-between;
  align-items: center;
}

/* ---------- a question ---------- */

.question {
  display: grid;
  gap: var(--sp-3);
}

.question + .question {
  padding-top: var(--sp-5);
  border-top: 1px solid var(--ui-surface-2);
}

.question--sub + .question,
.question + .question--sub {
  border-top: 0;
  padding-top: 0;
}

.question__label {
  font-weight: 700;
  font-size: var(--fs-400);
  line-height: 1.35;
  text-wrap: pretty;
}

.question--sub .question__label {
  font-size: var(--fs-300);
}

.question__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 1.75rem;
  margin-right: var(--sp-2);
  padding: 0 var(--sp-2);
  border-radius: 999px;
  background: var(--brand-navy);
  color: var(--brand-white);
  font-size: var(--fs-100);
  font-weight: 700;
  vertical-align: 0.1em;
}

.question__hint {
  font-size: var(--fs-200);
  color: var(--ui-text-secondary);
}

.question__message {
  font-size: var(--fs-200);
  font-weight: 700;
  color: var(--sem-error);
}

.question__message:empty {
  display: none;
}

.question__counter {
  font-size: var(--fs-100);
  color: var(--ui-text-secondary);
  justify-self: end;
}

/* ---------- text controls ---------- */

.input {
  width: 100%;
  min-height: 3rem;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--ui-edge);
  border-radius: var(--ui-radius-small);
  background: var(--brand-white);
}

textarea.input {
  min-height: 6rem;
  resize: vertical;
}

.input--short {
  max-width: 11rem;
}

.input--medium {
  max-width: 22rem;
}

.input[aria-invalid='true'],
fieldset[aria-invalid='true'] > .option-group > .option,
.row[data-invalid='true'] {
  border-color: var(--sem-error);
}

/* A legend is not laid out by the fieldset's grid, so it carries its own gap. */
legend.question__label {
  margin-bottom: var(--sp-3);
}

.input[aria-invalid='true'] {
  border-width: 2px;
}

/* ---------- options (radio and checkbox as large targets) ---------- */

.option-group {
  display: grid;
  gap: var(--sp-2);
}

.option-group--inline {
  display: flex;
  flex-wrap: wrap;
}

.option {
  display: grid;
  border: 1px solid var(--ui-edge);
  border-radius: var(--ui-radius-small);
  background: var(--brand-white);
  line-height: 1.35;
  transition: background-color var(--ui-motion), border-color var(--ui-motion);
}

.option:hover {
  background: var(--ui-surface-1);
}

.option__main {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  min-height: 3rem;
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
}

.option__box {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.1rem 0 0;
  accent-color: var(--brand-navy);
}

.option:has(.option__box:checked) {
  border-color: var(--brand-navy);
  box-shadow: inset 0 0 0 1px var(--brand-navy);
  background: var(--ui-surface-1);
}

.option:has(.option__box:checked) .option__main {
  font-weight: 600;
}

.option:has(.option__box:focus-visible) {
  outline: 3px solid var(--brand-navy);
  outline-offset: 2px;
}

.option:has(.option__box:disabled) {
  opacity: 0.55;
}

.option:has(.option__box:disabled) .option__main {
  cursor: not-allowed;
}

.option[data-invalid='true'] {
  border: 2px solid var(--sem-error);
}

/* The field that opens under a ticked option, aligned with the option's text. */
.option__extra {
  display: grid;
  gap: var(--sp-1);
  padding: 0 var(--sp-4) var(--sp-4) calc(var(--sp-4) + 1.25rem + var(--sp-3));
}

.option__extra-label {
  font-size: var(--fs-200);
}

/* ---------- rows with a small set of answers (practices, matrix, scales) ---------- */

.dimension {
  display: grid;
  gap: var(--sp-3);
}

.dimension + .dimension {
  margin-top: var(--sp-4);
}

.dimension__title {
  font-family: var(--ui-font-heading);
  font-weight: 600;
  font-size: var(--fs-500);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.15;
}

.row {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius-small);
  background: var(--brand-white);
}

.row[data-invalid='true'] {
  border-width: 2px;
}

.row__label {
  font-weight: 600;
  line-height: 1.35;
}

.segments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
}

.segments--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segments--five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: var(--sp-2);
  border: 1px solid var(--ui-edge);
  border-radius: var(--ui-radius-small);
  background: var(--brand-white);
  font-size: var(--fs-200);
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.segment__box {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.segment:has(.segment__box:checked) {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: var(--brand-white);
  font-weight: 700;
}

.segment:has(.segment__box:focus-visible) {
  outline: 3px solid var(--brand-navy);
  outline-offset: 2px;
}

@media (min-width: 44rem) {
  .segments--practice {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .row--wide {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    align-items: center;
  }
}

.scale-ends {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-100);
  color: var(--ui-text-secondary);
}

/* ---------- goals ---------- */

.goal-owner {
  display: grid;
  gap: var(--sp-3);
}

.goal-owner__fields {
  display: grid;
  gap: var(--sp-3);
}

.field-label {
  display: grid;
  gap: var(--sp-1);
  font-size: var(--fs-200);
  font-weight: 600;
}

/* Off-screen instead of display:none: some robots skip fields that are plainly hidden. */
.form__trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- guidance: why a block or a goal matters. A speech bubble beside the content, in the
   light surface of the Interface Guides; the orange rule is decoration, never the only edge. ---------- */

.guidance {
  position: relative;
  display: grid;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  background: var(--ui-surface-1);
  font-size: var(--fs-200);
}

.guidance::before {
  content: '';
  position: absolute;
  top: -0.45rem;
  left: 1.5rem;
  width: 0.8rem;
  height: 0.8rem;
  border-top: 1px solid var(--ui-border);
  border-left: 1px solid var(--ui-border);
  background: var(--ui-surface-1);
  transform: rotate(45deg);
}

.guidance__title {
  font-weight: 700;
}

.guidance__link {
  font-weight: 700;
}

.guidance--goal {
  padding: var(--sp-3);
  border-radius: var(--ui-radius-small);
  background: var(--brand-white);
}

.guidance--goal::before {
  display: none;
}

/* ---------- review ---------- */

.summary {
  display: grid;
  gap: var(--sp-3);
}

.summary__item {
  display: grid;
  gap: var(--sp-1);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--ui-surface-2);
}

.summary__term {
  font-size: var(--fs-100);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-text-secondary);
}

.summary__value ul {
  padding-left: 1.2rem;
}
