/* =========================================================================
   The patient-facing questionnaire.

   Different job from the clinical interface: one column, large type, plenty
   of air, and nothing that looks like software. Most people fill this in on a
   phone, once, possibly nervous. It should feel like a letter, not a form.
   ========================================================================= */

:root {
  --bg:          #f7f6f3;
  --surface:     #ffffff;
  --surface-2:   #fbfaf8;
  --line:        #e4e1db;
  --line-strong: #cfcbc2;
  --ink:         #1c1f1e;
  --ink-2:       #4a504e;
  --ink-3:       #7b827f;
  --accent:      #0f766e;
  --accent-ink:  #ffffff;
  --accent-soft: #e3f2ef;
  --accent-line: #b7ddd6;
  --accent-deep: #0d3b36;
  --ok:      #15803d;  --ok-soft:     #e6f4ea;
  --warn:    #b45309;  --warn-soft:   #fdf1e0;
  --danger:  #b42318;  --danger-soft: #fdeceb;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 2px rgba(20,25,24,.05), 0 1px 3px rgba(20,25,24,.04);
  --shadow-2: 0 2px 4px rgba(20,25,24,.05), 0 8px 24px rgba(20,25,24,.07);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #121514;
    --surface:     #1a1e1d;
    --surface-2:   #1f2423;
    --line:        #2e3533;
    --line-strong: #414a47;
    --ink:         #eef1f0;
    --ink-2:       #b9c0bd;
    --ink-3:       #8a918e;
    --accent:      #4db6a5;
    --accent-ink:  #06231f;
    --accent-soft: #13312c;
    --accent-line: #1e4a43;
    --accent-deep: #8ed6c6;
    --ok: #4ade80;      --ok-soft: #14301f;
    --warn: #fbbf24;    --warn-soft: #33260c;
    --danger: #f87171;  --danger-soft: #3a1a19;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

#form-root { min-height: 100vh; }

.boot { display: grid; place-items: center; min-height: 70vh; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------- structure */

.shell { max-width: 720px; margin: 0 auto; padding: 0 20px 96px; }

.masthead {
  background: var(--accent-deep);
  color: #eef7f4;
  padding: 26px 0 30px;
  margin-bottom: 28px;
}
.masthead .shell { padding-bottom: 0; }
.masthead .clinic {
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  opacity: .75; margin: 0 0 8px;
}
.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 500;
  margin: 0;
  letter-spacing: -.01em;
}

/* The flag first, then the word. A patient who has opened a form written in
   a language they do not read should not have to read anything to get out of
   it — the tricolour or the blue-and-white is the instruction. */
.langbar { display: flex; gap: 7px; margin-top: 16px; flex-wrap: wrap; }
.langbar button {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); color: #eef7f4;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 5px 13px 5px 8px; font: inherit; font-size: 13px;
  cursor: pointer;
}
.langbar .flag {
  width: 21px; height: 14px; border-radius: 2px; flex: 0 0 auto; display: block;
  box-shadow: 0 0 0 1px rgba(255,255,255,.45);
}
.langbar button.on { background: #eef7f4; color: var(--accent-deep); border-color: #eef7f4; font-weight: 600; }
.langbar button.on .flag { box-shadow: 0 0 0 1px rgba(0,0,0,.2); }

.intro {
  font-size: 16.5px; color: var(--ink-2); margin: 0 0 28px;
  padding: 18px 20px; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
  white-space: pre-wrap;
}

/* --------------------------------------------------------------- section */

.section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  margin-bottom: 20px;
  overflow: hidden;
}
.section > h2 {
  font-family: var(--serif);
  font-size: 20px; font-weight: 500; margin: 0;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.section-body { padding: 20px 22px 24px; }

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

.f { margin-bottom: 22px; }
.f:last-child { margin-bottom: 0; }
.f > label.q {
  display: block; font-weight: 600; font-size: 15.5px;
  color: var(--ink); margin-bottom: 6px;
}
.f .req { color: var(--danger); margin-left: 3px; }
.f .help { font-size: 13.5px; color: var(--ink-3); margin: 0 0 9px; line-height: 1.5; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 520px) { .pair { grid-template-columns: 1fr; } }

input[type=text], input[type=email], input[type=tel], input[type=date],
input[type=number], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;                     /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.bad, textarea.bad, select.bad { border-color: var(--danger); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237b827f' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

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

.choices { display: flex; flex-direction: column; gap: 8px; }
.choices.inline { flex-direction: row; flex-wrap: wrap; }
.choice {
  display: flex; align-items: flex-start; gap: 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
  background: var(--surface);
  transition: border-color .12s, background .12s;
  font-size: 15.5px;
}
.choices.inline .choice { flex: 0 1 auto; padding: 10px 16px; }
.choice:hover { border-color: var(--accent-line); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 2px 0 0; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.choice span { flex: 1; }

.consent {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  margin-bottom: 12px; font-size: 15px; line-height: 1.5;
}
.consent.on { border-color: var(--accent-line); background: var(--accent-soft); }
.consent input { margin: 2px 0 0; accent-color: var(--accent); width: 19px; height: 19px; flex: none; }
/* Why it matters, under the sentence it qualifies. */
.consent-why { display: block; margin-top: 5px; font-size: 13.5px; line-height: 1.45; color: var(--ink-3); }

.note {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px;
  font-size: 14.5px; color: var(--ink-2); line-height: 1.6;
  margin-bottom: 20px; white-space: pre-wrap;
}

/* scale ------------------------------------------------------------------ */

.scale { display: flex; gap: 6px; flex-wrap: wrap; }
.scale button {
  flex: 1 0 40px; min-width: 40px; height: 46px;
  border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius); font: inherit; font-size: 15px; color: var(--ink-2);
  cursor: pointer;
}
.scale button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }

/* photos ----------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--line-strong); border-radius: var(--radius-lg);
  padding: 28px 20px; text-align: center; cursor: pointer;
  background: var(--surface-2); color: var(--ink-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone b { display: block; color: var(--ink); font-size: 15.5px; margin-bottom: 4px; }
.dropzone span { font-size: 13.5px; color: var(--ink-3); }

/* The three views a shape opinion needs, each its own slot with a figure
   showing how to stand. Done slots go green; the box under them is for
   anything extra. */
.views { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.view-slot { text-align: center; }
/* On a phone three portrait boxes stacked full-width would run to three
   screens; laid out as a checklist — picture on the left, what to do on
   the right — all three fit in one glance, which is the point of them. */
@media (max-width: 480px) {
  .views { grid-template-columns: 1fr; gap: 10px; }
  .view-slot {
    display: grid; grid-template-columns: 104px minmax(0, 1fr); grid-template-rows: auto auto;
    column-gap: 14px; align-content: center; align-items: center; text-align: left;
  }
  .view-slot .view-pic { grid-row: 1 / 3; }
  .view-slot b { margin-top: 0; align-self: end; }
  .view-slot span { align-self: start; }
}
.view-slot b { display: block; font-size: 14.5px; color: var(--ink); margin-top: 8px; }
.view-slot span { display: block; font-size: 12.5px; line-height: 1.4; color: var(--ink-3); margin-top: 2px; }
.view-pic {
  position: relative; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  border: 2px dashed var(--line-strong); background: var(--surface-2); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center;
}
.view-pic:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.view-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.view-slot.filled .view-pic { border: 2px solid var(--accent-line); }
.view-slot.filled b::after { content: ' ✓'; color: var(--accent); }
.view-figure svg { display: block; }
.dropzone.more { padding: 18px 16px; }
.dropzone.more b { font-size: 14px; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin-top: 14px; }
.thumb { position: relative; aspect-ratio: 3/4; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 5px; right: 5px; width: 26px; height: 26px;
  border-radius: 50%; border: none; background: rgba(20,25,24,.72); color: #fff;
  font-size: 15px; line-height: 1; cursor: pointer;
}
.thumb.busy::after {
  content: ''; position: absolute; inset: 0; background: rgba(255,255,255,.6);
}

/* Results, not photographs: a list of names with their sizes, because a PDF
   has no thumbnail and a blood report is read rather than looked at. */
.filelist { display: grid; gap: 8px; margin-top: 14px; }
.filerow {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); font-size: 14.5px;
}
.filerow .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .fsize { color: var(--ink-3); font-size: 13px; flex: none; }
.filerow button {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: none;
  background: var(--surface-3); color: var(--ink-2); font-size: 15px; line-height: 1; cursor: pointer;
}
.filerow button:hover { background: var(--danger-soft); color: var(--danger); }
.filerow.busy { opacity: .7; }
.filerow .spinner { flex: none; }

/* --------------------------------------------------------------- actions */

.actions { padding: 8px 0 4px; margin-top: 4px; }
.btn {
  width: 100%; font: inherit; font-size: 16px; font-weight: 600;
  padding: 15px 20px; border-radius: var(--radius);
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  cursor: pointer; box-shadow: var(--shadow-2);
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); box-shadow: none; font-weight: 500; }

.saved { text-align: center; font-size: 13px; color: var(--ink-3); margin-top: 12px; }

.err {
  background: var(--danger-soft); border: 1px solid var(--danger);
  color: var(--danger); border-radius: var(--radius);
  padding: 13px 16px; margin-bottom: 18px; font-size: 14.5px;
}

.preview-banner {
  background: var(--warn-soft); color: var(--warn);
  border: 1px dashed var(--warn); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 18px; font-size: 14px; text-align: center;
}

.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 24px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ----------------------------------------------------------------- final */

.done { text-align: center; padding: 60px 24px; }
.done .tick {
  width: 62px; height: 62px; margin: 0 auto 22px; border-radius: 50%;
  background: var(--ok-soft); color: var(--ok);
  display: grid; place-items: center;
}
.done .tick svg { width: 30px; height: 30px; }
.done h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0 0 12px; }
.done p { color: var(--ink-2); margin: 0 auto; max-width: 46ch; }

.message { max-width: 520px; margin: 90px auto; padding: 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.message h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 10px; }
.message p { color: var(--ink-2); margin: 0; }

.footnote { text-align: center; font-size: 12.5px; color: var(--ink-3); margin-top: 28px; }

/* The practice's logo above its name, when one has been set. */
.masthead-logo { display: block; height: auto; width: auto; max-height: 52px; max-width: 220px; margin: 0 0 10px; }
.footnote a, .help a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* A telephone box with its country in front (tel.js). */
.tel-field { display: flex; gap: 6px; align-items: stretch; min-width: 0; }
.tel-field .tel-cc { flex: 0 0 auto; width: auto; min-width: 0; padding-right: 26px; font-variant-numeric: tabular-nums; }
.tel-field .tel-nat { flex: 1 1 auto; min-width: 0; width: auto; }
