/* Expose complete title rows rather than a sliver of each previous sheet. */
#form.form-focus {
  --header-stack-base: 72px;
  --header-stack-step: 72px;
}
#form.form-focus > fieldset > legend {
  float: left;
  display: flex;
  width: 100%;
  font-size: 19px;
}
#form.form-focus > fieldset.is-past {
  margin-top: 0;
  top: calc(var(--header-stack-base) + var(--stack-step) * var(--header-stack-step));
  z-index: calc(20 - var(--stack-step));
  padding-top: 18px;
  padding-bottom: 20px;
  min-height: var(--header-stack-step);
}
#form.form-focus > fieldset.is-past > legend { margin-bottom: 0; }
#form.form-focus > fieldset.is-past .form-fold { height: 0; }
#form.form-focus > fieldset.is-active > legend {
  position: sticky;
  top: calc(var(--header-stack-base) + var(--stack-step) * var(--header-stack-step) + 18px);
  z-index: 2;
  background: #fff;
}
#form.form-focus > fieldset.is-active > legend::before {
  content: "";
  position: absolute;
  inset: -18px -22px -12px;
  z-index: -1;
  background: #fff;
  border-radius: 22px 22px 0 0;
}
#form.form-focus > fieldset.is-active {
  margin-top: -12px;
  padding-top: 28px;
  clip-path: inset(var(--stack-clip, 0px) 0 -100px);
}

@media (max-width: 760px) {
  #form.form-focus {
    --header-stack-base: calc(clamp(330px, 44svh, 420px) + 18px);
    --header-stack-step: 52px;
  }
  #form.form-focus > fieldset > legend { font-size: 18px; }
  #form.form-focus > fieldset.is-past { padding-top: 9px; padding-bottom: 9px; }
  #form.form-focus > fieldset.is-active > legend {
    top: calc(var(--header-stack-base) + var(--stack-step) * var(--header-stack-step) + 12px);
  }
  #form.form-focus > fieldset.is-active > legend::before { inset: -12px -18px -10px; border-radius: 19px 19px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  #form.form-focus > fieldset.is-past,
  #form.form-focus > fieldset.is-active > legend { position: relative; top: auto; }
}
