/* A focused response space, using FieldNotes' existing type and palette. */
/* Scrolling something into view (focus, errors, notes) stops above the sticky
   footer, which is about 84px tall with its build label. */
html {
  scroll-padding-bottom: 96px;
}
.questionnaire-page {
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.q-header {
  padding: 25px 40px;
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 30px;
}
.q-header .brand {
  font-size: 20px;
}
.q-form-name {
  color: var(--muted);
  font-size: 14px;
  padding-left: 28px;
  border-left: 1px solid var(--line);
  max-width: 600px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.q-preview {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 12px;
  border-radius: 5px;
  padding: 7px 10px;
  background: var(--lilac);
}
.questionnaire {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 52px 40px 72px;
}
.questionnaire > .loading {
  margin: auto;
}
.q-stage {
  width: min(100%, 760px);
  margin: auto;
  overflow-wrap: anywhere;
  animation: q-arrive 180ms ease-out both;
}
.q-stage h1 {
  font-size: clamp(30px, 3.1vw, 44px);
  line-height: 1.18;
  letter-spacing: -0.035em;
  font-weight: 550;
  margin: 0 0 20px;
  max-width: 22ch;
}
.q-stage h1:focus {
  outline: none;
}
.q-stage.q-still {
  animation: none;
}
.q-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--forest);
  margin-bottom: 21px;
}
.q-requirement {
  color: var(--muted);
  font-size: 12px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}
.q-section-name {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.q-section-intro {
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 60ch;
  margin: -12px 0 18px;
}
.q-intro {
  width: min(100%, 1080px);
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  align-items: center;
  gap: 75px;
}
.q-intro h1 {
  font-size: clamp(38px, 4.4vw, 60px);
  line-height: 1.08;
}
.q-description {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
  max-width: 54ch;
  white-space: pre-line;
  margin: 0 0 28px;
}
.q-art {
  width: 100%;
  height: auto;
  border-radius: 24px;
}
.q-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 30px;
}
.q-primary {
  color: var(--q-button-text);
  min-height: 50px;
  font-size: 16px;
  padding: 13px 23px;
  border-radius: 8px;
}
.q-key-hint {
  font-size: 13px;
  color: var(--muted);
}
.button.q-secondary {
  min-height: 50px;
  font-size: 16px;
  padding: 13px 23px;
  border-radius: 8px;
  border-color: var(--forest);
  color: var(--forest);
}
.q-help {
  color: var(--muted);
  font-size: 15px;
  margin: -6px 0 24px;
}
.q-help:empty {
  display: none;
}
.q-answer {
  margin-top: 30px;
}
.questionnaire input.q-text-input,
.questionnaire textarea.q-text-input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--q-border);
  border-radius: 0;
  background: transparent;
  padding: 10px 0 15px;
  font-size: clamp(22px, 2.5vw, 30px);
  line-height: 1.5;
  color: var(--forest);
  box-shadow: none;
  min-height: 0;
}
.questionnaire .q-text-input::placeholder {
  color: var(--q-placeholder);
  opacity: 1;
}
.questionnaire .q-text-input:focus {
  border-color: var(--forest);
}
.questionnaire .q-text-input:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 7px;
}
.questionnaire textarea.q-text-input {
  resize: vertical;
  min-height: 130px;
  max-height: 55vh;
}
.q-answer-choice,
.q-answer-multi {
  display: grid;
  gap: 9px;
  max-width: 610px;
}
.q-option {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  min-height: 58px;
  padding: 12px 16px;
  background: var(--q-surface);
  border: 1px solid var(--q-border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 19px;
  line-height: 1.4;
}
.q-option:hover {
  background: var(--q-hover);
  border-color: var(--q-key-border);
}
/* Selected and focus states work without :has() (Chrome 105): form.js sets
   is-checked, and the key and check mark follow the input. Keep any :has()
   rule separate: a browser without :has() drops every rule that uses it. */
.q-option.is-checked {
  border-color: var(--forest);
  background: var(--q-selected);
  box-shadow: inset 0 0 0 1px var(--forest);
}
/* Enhancement: covers a state the class ever misses. */
.q-option:has(input:checked) {
  border-color: var(--forest);
  background: var(--q-selected);
  box-shadow: inset 0 0 0 1px var(--forest);
}
.q-option:focus-within {
  outline: 3px solid var(--q-focus);
  outline-offset: 3px;
}
/* Enhancement: where :has() works, a click shows no ring; the keyboard still
   does. */
.q-option:has(input:focus:not(:focus-visible)) {
  outline: none;
}
/* Keep the native inputs focusable and announced, while the whole label is a
   target. The margin brings the whole card into view when the input is focused. */
.q-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  scroll-margin: 36px 0;
}
.q-choice-key {
  display: grid;
  place-items: center;
  border: 1px solid var(--q-key-border);
  background: var(--paper);
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}
.q-answer-multi .q-choice-key {
  border-radius: 2px;
}
.q-option input:checked ~ .q-choice-key {
  background: var(--forest);
  color: var(--q-button-text);
  border-color: var(--forest);
}
.q-option-text {
  flex: 1;
  min-width: 0;
}
.q-choice-check {
  opacity: 0;
  flex-shrink: 0;
}
.q-option input:checked ~ .q-choice-check {
  opacity: 1;
}
.q-answer[aria-invalid="true"] .q-option {
  border-color: var(--error);
}
/* A limited choose-several question counts picks, and says why one more
   didn't tick. */
.q-count {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.q-count-note {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 600;
}
.q-count-note:empty {
  display: none;
}
.q-answer-rating {
  display: flex;
  gap: 12px;
}
.q-answer-rating .q-option {
  justify-content: center;
  padding: 0;
  width: 78px;
  min-height: 78px;
  font-size: 27px;
}
.q-answer-rating .q-choice-key,
.q-answer-rating .q-choice-check {
  display: none;
}
.q-answer-rating .q-option-text {
  flex: 0;
}
.q-skip {
  border: none;
  background: none;
  color: var(--muted);
  padding: 12px;
  font-size: 14px;
  margin-left: auto;
}
.q-skip:hover {
  color: var(--forest);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.q-error {
  margin: 20px 0 0;
  color: var(--error);
  font-size: 15px;
}
.q-error:empty {
  display: none;
}
.q-review .q-error {
  margin: 0 0 18px;
}
/* On a question the error sits right under the title, above the answers. */
.q-error.q-error-question {
  margin: -6px 0 18px;
}
.q-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  padding: 18px 40px max(18px, env(safe-area-inset-bottom));
  min-height: 80px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.q-footer-meta {
  display: grid;
  gap: 6px;
}
.q-legal {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
}
.q-legal a {
  text-decoration: none;
}
.q-legal a:hover {
  text-decoration: underline;
}
.q-dock {
  display: flex;
  align-items: center;
  gap: 30px;
}
.q-progress {
  width: 155px;
  font-size: 12px;
  color: var(--muted);
  display: grid;
  gap: 7px;
}
.q-progress progress {
  appearance: none;
  border: 0;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
  height: 5px;
  background: var(--line);
  color: var(--forest);
}
.q-progress progress::-webkit-progress-bar {
  background: var(--line);
}
.q-progress progress::-webkit-progress-value {
  background: var(--forest);
  transition: width 180ms ease-out;
}
.q-progress progress::-moz-progress-bar {
  background: var(--forest);
}
.q-navigation {
  display: flex;
  gap: 6px;
}
.q-nav-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 42px;
  background: var(--forest);
  color: var(--q-button-text);
  border: 1px solid var(--forest);
  border-radius: 6px;
}
.q-back {
  background: var(--paper);
  color: var(--forest);
  border-color: var(--q-border);
}
.q-nav-button:hover:not(:disabled) {
  filter: brightness(0.94);
}
.q-review h1 {
  margin-bottom: 12px;
}
/* Section headings share the list, so answers are numbered with a counter. */
.q-review-list {
  list-style: none;
  padding: 0 0 0 22px;
  margin: 25px 0 30px;
  counter-reset: answer;
}
.q-review-list li {
  position: relative;
  padding: 20px 84px 20px 9px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  counter-increment: answer;
}
.q-review-list li::before {
  content: counter(answer) ".";
  position: absolute;
  left: -22px;
  top: 20px;
  color: var(--muted);
}
.q-review-list li.q-review-section {
  counter-increment: none;
  border-bottom: 0;
  padding: 26px 0 4px;
}
.q-review-list li.q-review-section::before {
  content: none;
}
.q-review-list li.q-review-section:first-child {
  padding-top: 0;
}
.q-review-list li.q-review-section h2 {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--forest);
  margin: 0;
}
.q-review-answer h2 {
  font-size: 15px;
  letter-spacing: 0;
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--muted);
}
.q-review-answer p {
  font-size: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0;
}
.q-edit {
  position: absolute;
  top: 14px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--forest);
  font-size: 13px;
  padding: 8px;
}
.q-edit:hover:not(:disabled) {
  background: var(--mint);
  border-radius: 5px;
}
.q-consent {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  max-width: 520px;
  font-size: 15px;
  line-height: 1.5;
}
.q-consent input {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  margin: 2px 0 0;
  accent-color: var(--forest);
}
.q-save-note {
  font-size: 12px;
  color: var(--muted);
  margin: 9px 0 25px 31px;
}
.q-intro .q-save-note {
  margin: 4px 0 22px;
  max-width: 48ch;
}
/* Resume screen: plain words about whose answers these might be. */
.q-resume {
  max-width: 48ch;
}
.q-resume p {
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 8px;
}
.q-success-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--forest);
  margin-bottom: 26px;
}
.q-receipt {
  color: var(--muted);
  font-size: 13px;
}
.q-receipt summary {
  cursor: pointer;
  padding: 5px 0;
}
.q-receipt p {
  margin: 10px 0 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.q-message {
  padding-block: 50px;
}
@keyframes q-arrive {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 850px) {
  .q-header {
    padding: 22px 26px;
    gap: 20px;
  }
  .q-form-name {
    padding-left: 20px;
  }
  .questionnaire {
    padding: 40px 32px 56px;
  }
  .q-intro {
    gap: 35px;
  }
  .q-intro h1 {
    font-size: 40px;
  }
  .q-footer {
    padding-inline: 26px;
  }
}
@media (max-width: 600px) {
  .q-header {
    padding: 20px 22px;
    min-height: 72px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .q-header .brand {
    font-size: 18px;
  }
  .q-header .brand img {
    width: 22px;
    height: 26px;
  }
  .q-form-name {
    display: none;
  }
  .q-preview {
    font-size: 10px;
  }
  .questionnaire {
    padding: 34px 24px 50px;
  }
  .q-stage h1 {
    font-size: 30px;
  }
  .q-intro {
    display: flex;
    flex-direction: column-reverse;
    gap: 28px;
    align-items: stretch;
  }
  .q-intro h1 {
    font-size: 38px;
  }
  .q-intro .q-art {
    align-self: flex-start;
    width: 150px;
    height: 100px;
    border-radius: 10px;
  }
  .q-intro .q-meta {
    margin-bottom: 14px;
  }
  .q-description {
    font-size: 16px;
    margin-bottom: 24px;
  }
  .q-meta {
    font-size: 13px;
    margin-bottom: 18px;
  }
  .q-answer {
    margin-top: 24px;
  }
  .q-option {
    font-size: 17px;
    min-height: 56px;
    padding: 11px 12px;
    gap: 11px;
  }
  .q-answer-rating {
    gap: 8px;
  }
  .q-answer-rating .q-option {
    flex: 1;
    min-width: 0;
    width: auto;
    min-height: 60px;
    font-size: 23px;
  }
  .q-actions {
    gap: 12px;
    margin-top: 26px;
  }
  .q-key-hint {
    display: none;
  }
  .q-help {
    font-size: 14px;
  }
  .q-skip {
    margin-left: 0;
  }
  .q-footer {
    padding: 14px 22px max(14px, env(safe-area-inset-bottom));
    gap: 17px;
    flex-wrap: wrap;
  }
  .q-dock {
    order: -1;
    justify-content: space-between;
    width: 100%;
    gap: 20px;
  }
  .q-progress {
    width: min(55%, 220px);
  }
  .q-legal {
    gap: 18px;
    font-size: 11px;
  }
  .q-review-list li {
    padding-right: 65px;
  }
  .q-review-answer p {
    font-size: 16px;
  }
  .q-edit {
    gap: 4px;
    padding-inline: 4px;
  }
  .q-complete .q-art {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .q-stage {
    animation: none;
  }
  .q-progress progress::-webkit-progress-value {
    transition: none;
  }
}

.questionnaire .q-primary:hover {
  background: var(--forest);
  filter: brightness(0.94);
}
.q-file-picker {
  border: 1px dashed var(--q-border, var(--line));
  border-radius: 12px;
  padding: 28px;
  background: var(--q-surface, var(--paper));
  max-width: 650px;
}
.q-file-picker input {
  display: block;
  width: 100%;
  margin: 16px 0;
  font: inherit;
  color: var(--ink);
}
.q-file-picker input::file-selector-button {
  border: 1px solid var(--q-border, var(--line));
  background: var(--paper);
  color: var(--ink);
  border-radius: 7px;
  padding: 10px 16px;
  font: inherit;
  margin-right: 12px;
  cursor: pointer;
}
/* Chrome 88 only knows the older name. Kept apart: in one list, the name a
   browser doesn't know would drop both. */
.q-file-picker input::-webkit-file-upload-button {
  border: 1px solid var(--q-border, var(--line));
  background: var(--paper);
  color: var(--ink);
  border-radius: 7px;
  padding: 10px 16px;
  font: inherit;
  margin-right: 12px;
  cursor: pointer;
}
/* Autosave: a plain-spoken note on the welcome screen, with its opt-out. */
.q-autosave {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 4px 18px;
  align-items: center;
  max-width: 520px;
  margin: 4px 0 26px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper, #fff);
}
.q-autosave-art {
  width: 88px;
  height: 88px;
  object-fit: contain;
}
.q-autosave h2 {
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
  font-weight: 600;
  margin: 0 0 5px;
}
.q-autosave p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}
.q-autosave a {
  color: var(--forest);
  text-underline-offset: 3px;
}
.q-autosave-choice {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.45;
  cursor: pointer;
}
.q-autosave-choice input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 1px 0 0;
  accent-color: var(--forest);
}
.q-save-state {
  min-height: 1em;
  font-size: 11px;
  color: var(--muted);
}
@media (max-width: 560px) {
  .q-autosave {
    grid-template-columns: 56px 1fr;
    padding: 14px;
  }
  .q-autosave-art {
    width: 56px;
    height: 56px;
  }
}
/* Welcome: long titles and descriptions shouldn't push the start button off
   a phone screen. */
.q-intro h1.q-title-long {
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.12;
}
.q-description.is-clamped {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}
.q-read-more {
  border: 0;
  background: none;
  padding: 0;
  margin: -6px 0 22px;
  font: inherit;
  font-size: 14px;
  color: var(--forest);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
@media (max-width: 850px) {
  /* The side artwork is decoration; on narrower screens the words win. */
  .q-intro:not(.q-complete) {
    grid-template-columns: 1fr;
  }
  .q-intro:not(.q-complete) .q-art {
    display: none;
  }
  .q-intro h1.q-title-long {
    font-size: 34px;
  }
}
@media (max-width: 600px) {
  .q-intro h1.q-title-long {
    font-size: 29px;
  }
  .q-intro .q-description {
    font-size: 16px;
  }
}
/* On short or narrow screens a sticky footer would cover too much of the
   question, so it stays at the end of the page. */
@media (max-width: 600px), (max-height: 500px) {
  html {
    scroll-padding-bottom: 0;
  }
  .q-footer {
    position: static;
  }
}
