/* Developed by Jady Pamella | jadypamella.com */
/* Questionnaire pages. Builds on /styles.css (theme variables, shared header and footer). */

/* Keeps a focused field clear of the sticky header and the progress bar under it. */
html { scroll-padding-top: 8rem; }

.survey-page { padding: 2rem 0 4rem; }
.survey-page h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); }

.back { font-size: 1rem; margin-bottom: 1.5rem; }
.survey-facts {
  list-style: none;
  margin: 1.5rem 0 0;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.5rem;
  border-radius: var(--radius-lg);
  background: var(--green-light);
  font-size: 1rem;
}
.survey-facts li { display: flex; align-items: flex-start; gap: 0.6rem; }
.survey-facts .icon { color: var(--green); margin-top: 0.15rem; }

.survey-start { margin-top: 1.75rem; }
.survey-start .button { min-height: 3.25rem; }
.survey-start .hint { margin-top: 0.6rem; }

/* Answer progress: a slim bar under the sticky header while the form is on screen.
   survey.js sets --answered (0 to 1) through the CSSOM. */
.answer-progress {
  position: sticky;
  top: 4.25rem;
  z-index: 10;
  padding: 0.5rem 0 0.4rem;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.answer-progress + #questions > .question:first-child { border-top: 0; }
.answer-progress-track {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--green-light);
  overflow: hidden;
}
.answer-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transform: scaleX(var(--answered, 0));
  transform-origin: left center;
  transition: transform 0.4s ease;
}
.answer-progress-text {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.notice {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border-left: 4px solid var(--orange);
  background: var(--green-light);
  color: var(--ink);
  font-weight: 600;
}

#survey-form { margin-top: 2.5rem; }

.question {
  margin-bottom: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.question > label,
.question > legend {
  display: flex;
  gap: 0.5rem;
  font-size: 1.1rem;
  line-height: 1.45;
  margin-bottom: 0.75rem;
}
/* A legend sits on the fieldset border by default: float it so the border stays above it. */
.question > legend {
  float: left;
  width: 100%;
  padding: 0;
}
.question > legend + * { clear: both; }
.q-num {
  flex-shrink: 0;
  min-width: 1.6rem;
  color: var(--green);
}
.input-short { max-width: 12rem; }

/* Choices: the whole row is the tap target, at least 44 px high. */
.question .choice {
  align-items: center;
  min-height: 2.75rem;
  margin-bottom: 0.25rem;
  padding: 0 0.6rem;
  border-radius: var(--radius);
}
.question .choice input { margin: 0; width: 1.35rem; height: 1.35rem; }
.question .choice label { flex: 1; padding: 0.55rem 0; cursor: pointer; }
.question .choice:hover { background: var(--green-light); }

.follow-up {
  margin: 0.75rem 0 0 1.85rem;
  padding-left: 1rem;
  border-left: 3px solid var(--line);
}
.follow-up[hidden] { display: none; }
.follow-up .field { margin-bottom: 0.9rem; }
.follow-up .hint { margin-top: 0; }

/* Out of sight for people, still in the DOM for bots that fill every field. */
.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.privacy {
  margin: 2.5rem 0 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  background: var(--green-light);
}
.privacy h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.privacy p { margin: 0; font-size: 1rem; }

.consent { margin-bottom: 1.5rem; }
.consent input[aria-invalid="true"] { outline: 2px solid var(--error); outline-offset: 2px; }
input[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }

.button:disabled {
  opacity: 0.7;
  cursor: progress;
}

#survey-thanks h2 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.thanks-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.thanks-lead { margin: 0; font-weight: 600; }

/* Thank-you sprout: the disc settles, then the ground, stem and leaves draw themselves once. */
.thanks-sprout { flex-shrink: 0; overflow: visible; }
.sprout-disc { fill: var(--green); animation: sprout-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; transform-box: fill-box; transform-origin: center; }
.sprout-lines { stroke: var(--white); }
.sprout-lines path { stroke-dasharray: 1; }
.sprout-leaf { fill: var(--white); }
.sprout-ground { animation: sprout-draw 0.5s ease-out 0.35s both; }
.sprout-stem { animation: sprout-draw 0.5s ease-out 0.6s both; }
.sprout-leaf-left { animation: sprout-draw 0.5s ease-out 0.85s both, sprout-fill 0.4s ease 1.25s both; }
.sprout-leaf-right { animation: sprout-draw 0.5s ease-out 1s both, sprout-fill 0.4s ease 1.4s both; }
@keyframes sprout-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes sprout-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes sprout-fill {
  from { fill-opacity: 0; }
}
#survey-thanks p + p { margin-top: 1rem; }

/* Voice answers */
.recorder { margin-top: 0.75rem; }
.rec-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.rec-controls .button { min-height: 2.75rem; padding: 0.5rem 1rem; font-size: 1rem; }
.rec-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}
.rec-timer::before {
  content: "";
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--error);
  animation: rec-pulse 1.6s ease-out infinite;
}
.rec-timer[hidden] { display: none; }
@keyframes rec-pulse {
  from { box-shadow: 0 0 0 0 var(--error); }
  70%, to { box-shadow: 0 0 0 0.45rem transparent; }
}
/* Live level meter (recorder.js draws it in the text colour): its own row under the buttons. */
.rec-meter {
  display: block;
  flex: 0 0 100%;
  max-width: 20rem;
  height: 2rem;
  color: var(--green);
}
.rec-meter[hidden] { display: none; }
.rec-hint { margin: 0.4rem 0 0; font-size: 0.88rem; }
.rec-result { margin-top: 0.75rem; }
.rec-result[hidden] { display: none; }
.rec-result audio { width: 100%; max-width: 26rem; display: block; }
.rec-result-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.rec-status { margin: 0.5rem 0 0; font-size: 0.95rem; color: var(--ink); }
.rec-status:empty { display: none; }
.link-button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button[hidden] { display: none; }

/* Banner photo under the questionnaire title. */
.survey-banner { display: block; width: 100%; height: auto; aspect-ratio: 12 / 5; object-fit: cover; border-radius: 1rem; margin: 0.5rem 0 1.25rem; }

/* Character count under open answers; turns orange near the limit. */
.char-count { margin: 0.3rem 0 0; max-width: none; width: 100%; text-align: right; font-size: 0.85rem; }
.char-count.near-limit { color: #9A4A14; font-weight: 600; }

