/* Wayfinder — trail-map palette. Deliberately light-only: this runs on
   shared clinic tablets where a device-level dark mode would render a
   form about a child's behaviour in a way nobody designed or checked. */

:root {
  color-scheme: light;

  --paper: #fcfdff;
  --wash: #e8f2f8;
  --wash-deep: #d7e8f2;
  --ink: #17394b;
  --ink-soft: #4a6b7c;
  --pine: #26685a;
  --pine-deep: #1d5145;
  --trail: #e8834a;
  --trail-ink: #a8501f;
  --edge: #6e97ac;
  --alert: #a3271f;

  --radius: 20px;
  --radius-sm: 14px;
  --tap: 3.5rem;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --shadow: 0 1px 2px rgba(23, 57, 75, 0.05), 0 12px 28px -18px rgba(23, 57, 75, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  /* Two very soft washes suggest sky above and ground below without
     resorting to a literal illustration. */
  background:
    radial-gradient(120% 60% at 50% 0%, var(--wash) 0%, transparent 70%),
    radial-gradient(90% 50% at 50% 100%, #eef7f3 0%, transparent 70%),
    var(--paper);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 4vw, 2rem);
  gap: clamp(1rem, 3vw, 2rem);
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.wordmark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--pine);
}

/* The expansion earns its place once — it tells a parent what they have
   been handed — then gets out of the way at every other size. */
.wordmark-full {
  margin: 0.25rem 0 0;
  max-width: 30rem;
  text-align: center;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  color: var(--ink-soft);
}

.test-banner {
  margin: 0;
  max-width: 44rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--trail-ink);
  border-radius: var(--radius-sm);
  background: #fdf1e7;
  color: var(--trail-ink);
  font-weight: 700;
  font-size: 0.9375rem;
  text-align: center;
}

/* ---------- stage ---------- */

.stage {
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  outline: none;
}

.step {
  background: var(--paper);
  border: 1px solid var(--wash-deep);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 5vw, 3rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.display {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  outline: none;
}

.display--question {
  font-size: clamp(1.5rem, 4.2vw, 2.125rem);
  margin-bottom: 1.75rem;
}

.lede {
  margin: 0 0 2rem;
  color: var(--ink-soft);
  max-width: 34rem;
}

.note {
  margin: 1.5rem 0 0;
  padding: 1rem 1.25rem;
  background: var(--wash);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.9375rem;
}

.hint {
  margin: 0.5rem 0 0;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.hint--center {
  text-align: center;
  margin-top: 1.25rem;
}

.alert {
  margin: 1.25rem 0 0;
  padding: 0.875rem 1.125rem;
  border-left: 4px solid var(--alert);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: #fdf0ef;
  color: var(--alert);
  font-weight: 600;
}

/* ---------- fields ---------- */

.field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

#code-input {
  width: 100%;
  min-height: var(--tap);
  padding: 0.75rem 1rem;
  border: 2px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#code-input::placeholder {
  color: var(--ink-soft);
}

/* ---------- choices ---------- */

.choice-group {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  gap: 0.875rem;
}

.choice-group--scale > div {
  display: grid;
  gap: 0.875rem;
}

.choice {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--tap);
  padding: 1rem 1.25rem;
  border: 2px solid var(--edge);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  font-size: 1.125rem;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.choice:hover {
  background: var(--wash);
}

.choice:active {
  transform: scale(0.995);
}

/* The radio stays in the accessibility tree and keeps native keyboard
   behaviour; only its default rendering is replaced. */
.choice input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  flex: 0 0 auto;
  width: 1.625rem;
  height: 1.625rem;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--paper);
}

.choice input[type="radio"]:checked {
  border-color: var(--pine);
  border-width: 0.5rem;
}

.choice:has(input:checked) {
  border-color: var(--pine);
  background: #eef6f3;
}

.choice:has(input:focus-visible) {
  outline: 3px solid var(--trail-ink);
  outline-offset: 3px;
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
}

.actions--split {
  justify-content: space-between;
}

.button {
  min-height: var(--tap);
  padding: 0.875rem 1.75rem;
  border: 2px solid var(--pine);
  border-radius: 999px;
  background: var(--pine);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.button:hover:not(:disabled) {
  background: var(--pine-deep);
  border-color: var(--pine-deep);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button--quiet {
  background: transparent;
  color: var(--pine);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.button--quiet:hover:not(:disabled) {
  background: var(--wash);
  border-color: transparent;
  color: var(--pine-deep);
}

/* ---------- the trail (signature) ---------- */

.trail {
  margin-bottom: 1.75rem;
}

.trail-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

#trail-path,
#trail-path-done {
  stroke: var(--wash-deep);
  stroke-width: 3;
  stroke-linecap: round;
}

.trail-walked {
  stroke: var(--trail);
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
  transition: stroke-dashoffset 320ms ease;
}

.trail-dot {
  fill: var(--wash-deep);
}

.trail-dot.is-done {
  fill: var(--trail);
}

.trail-marker {
  fill: var(--trail);
  stroke: var(--trail-ink);
  stroke-width: 2;
  transition: transform 320ms ease;
}

.progress-text {
  margin: 0.5rem 0 0;
  text-align: center;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------- result ---------- */

/* ---------- footer, utilities ---------- */

.footer {
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.footer p {
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 10;
  padding: 0.75rem 1.25rem;
  background: var(--pine);
  color: #ffffff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transition: top 120ms ease;
}

.skip-link:focus {
  top: 0.5rem;
}

:focus-visible {
  outline: 3px solid var(--trail-ink);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (max-width: 30rem) {
  .actions {
    flex-direction: column-reverse;
  }

  .actions--split {
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
