/* RECAS-0809 study form — "clinical document" design
   Warm paper ground, deep slate-teal ink, serif headings, ruled sections. */

:root {
  --paper: #faf7f2;
  --paper-raised: #ffffff;
  --ink: #1f3134;
  --ink-soft: #47605f;
  --ink-faint: #7d928f;
  --rule: #d8d2c6;
  --accent: #0e6f6a;
  --accent-deep: #0a4f4b;
  --accent-wash: #e7f1ef;
  --error: #a4381f;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(31,49,52,0.04) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.sheet {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

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

.masthead { margin-bottom: 2.5rem; }
.masthead-rule {
  height: 6px;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent) 55%, transparent);
  margin-bottom: 1.5rem;
}
.masthead-kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 0.6rem;
}
.masthead-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.25;
  margin: 0;
  text-wrap: balance;
}
.masthead-sub {
  font-family: var(--serif);
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
}

/* ---------- sections ---------- */

.section { margin: 2.25rem 0; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.5rem;
  margin-bottom: 1.25rem;
}
.section-num {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  white-space: nowrap;
}
.section-head h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0;
}
.section-note { color: var(--ink-soft); font-size: 0.92rem; margin: -0.75rem 0 1.25rem; }

.prose { color: var(--ink-soft); }

/* ---------- callout (PIS) ---------- */

.callout {
  background: var(--accent-wash);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  margin: 1.5rem 0;
}
.callout a { color: var(--accent-deep); font-weight: 600; }

/* ---------- form controls ---------- */

.field { margin: 1.4rem 0; }
.field > label, .field > .q {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.hint { font-weight: 400; color: var(--ink-faint); font-size: 0.9rem; display: block; }
.req { color: var(--error); }
.opt-tag {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0.05rem 0.4rem;
  vertical-align: 0.15em; margin-left: 0.35rem;
}

input[type="text"], input[type="email"], input[type="tel"], input[type="date"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}
textarea { min-height: 6.5rem; resize: vertical; }
input:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.choices { display: flex; flex-direction: column; gap: 0.15rem; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 400;
}
.choice:hover { background: rgba(14, 111, 106, 0.06); }
.choice input {
  margin-top: 0.3rem;
  width: 1.05rem; height: 1.05rem;
  accent-color: var(--accent);
  flex: none;
}
/* "Other — please specify": a full-width block under the option, greyed out
   until that option is ticked. */
.other-block {
  margin: 0.25rem 0 0.5rem 2.3rem;
  border-radius: 8px;
  transition: opacity 120ms ease;
}
.other-block .other-input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
}
.other-block .other-input::placeholder { color: var(--ink-faint); }
.other-block.is-locked { cursor: pointer; }
.other-block.is-locked .other-input {
  background: rgba(31, 49, 52, 0.04);
  border-style: dashed;
  color: var(--ink-faint);
  pointer-events: none;
}
.other-block.is-locked:hover .other-input { border-color: var(--ink-faint); }
@media (max-width: 34rem) { .other-block { margin-left: 0; } }

/* ---------- consent declarations ---------- */

.decl {
  display: flex;
  gap: 0.85rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  margin: 0.75rem 0;
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.decl:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.decl input {
  width: 1.2rem; height: 1.2rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex: none;
}
.decl p { margin: 0; font-size: 0.95rem; }

/* ---------- signature ---------- */

.sig-wrap {
  background: var(--paper-raised);
  border: 1px dashed var(--ink-faint);
  border-radius: 8px;
  position: relative;
  touch-action: none;
}
.sig-wrap canvas { display: block; width: 100%; height: 180px; border-radius: 8px; cursor: crosshair; }
.sig-baseline {
  position: absolute;
  left: 1.5rem; right: 1.5rem; bottom: 2.4rem;
  border-bottom: 1px solid var(--rule);
  pointer-events: none;
}
.sig-x {
  position: absolute;
  left: 1.5rem; bottom: 2.55rem;
  font-family: var(--serif);
  color: var(--ink-faint);
  pointer-events: none;
}
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; }
.sig-hint { color: var(--ink-faint); font-size: 0.85rem; }
.btn-ghost {
  font: inherit; font-size: 0.85rem;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink-soft);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink-soft); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 34rem) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- submit ---------- */

.submit-row { margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.btn-primary {
  font: inherit;
  font-weight: 600;
  font-size: 1.05rem;
  background: var(--accent-deep);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.85rem 2.25rem;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.btn-primary:hover { background: var(--accent); transform: translateY(-1px); }
.form-error {
  display: none;
  color: var(--error);
  font-weight: 600;
  margin-top: 0.75rem;
}
.form-error.show { display: block; }

/* ---------- thanks ---------- */

.thanks-mark {
  font-family: var(--serif);
  font-size: 3rem;
  color: var(--accent);
  margin: 0;
}

/* ---------- colophon ---------- */

.colophon {
  margin-top: 4rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.colophon a { color: var(--accent-deep); }
.colophon-fine { color: var(--ink-faint); font-size: 0.8rem; }

/* ---------- admin ---------- */

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--paper-raised); }
.admin-table th, .admin-table td { border: 1px solid var(--rule); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.admin-table th { font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.admin-scroll { overflow-x: auto; }
.admin-sig { height: 42px; background: #fff; border: 1px solid var(--rule); }
details.answers summary { cursor: pointer; color: var(--accent-deep); }
details.answers pre { white-space: pre-wrap; font-size: 0.78rem; margin: 0.4rem 0 0; }

/* ---------- feature-feedback form (/features) ---------- */

/* shared card look for both pool and top-5 rows */
.rank-item {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--paper-raised); user-select: none;
}
.rank-label { flex: 1; }
.rank-label .hint { margin-top: 0.1rem; }
.rank-arrows { display: flex; flex-direction: column; gap: 0.15rem; }
.rank-arrows button {
  font-size: 0.7rem; line-height: 1; padding: 0.25rem 0.5rem;
  color: var(--ink-soft); background: var(--paper-raised);
  border: 1px solid var(--rule); border-radius: 5px; cursor: pointer;
}
.rank-arrows button:hover { border-color: var(--accent); color: var(--accent-deep); }

/* --- wide sheet + narrow inner wrappers (features page only) --- */
.sheet-wide { max-width: 64rem; }
.sheet-wide > .masthead, .sheet-wide > .colophon {
  max-width: 46rem; margin-left: auto; margin-right: auto;
}
.narrow { max-width: 46rem; margin-left: auto; margin-right: auto; }

/* live counter line */
.top5-counter {
  font-family: var(--mono); font-size: 0.85rem; color: var(--ink-soft);
  margin: 0 0 0.75rem;
}
.top5-counter.is-done { color: var(--accent-deep); font-weight: 600; }
.top5-counter.is-warn { color: var(--error); font-weight: 600; }

/* --- side-by-side layout (top 5 | pool) --- */
.top5-columns {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem;
  align-items: start; margin-top: 0.5rem;
}
@media (max-width: 52rem) { .top5-columns { grid-template-columns: 1fr; } }
.col-title { font-weight: 600; margin: 0 0 0.6rem; }
.col-title .hint { display: inline; font-weight: 400; }

/* --- top 5 (5 fixed ordered slots) --- */
.top5-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.top5-slot {
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 3.6rem; padding: 0.55rem 0.7rem;
  border: 1px dashed var(--rule); border-radius: 10px; background: transparent;
}
.top5-slot.filled {
  border-style: solid; background: var(--paper-raised);
  touch-action: none; cursor: grab;
}
.top5-slot.filled.drag-source { opacity: 0.35; }
.top5-slot.drop-target { border-color: var(--accent); background: var(--accent-wash); }
.top5-empty-hint { color: var(--ink-faint); font-size: 0.85rem; font-style: italic; }
.top5-slot .rank-label { flex: 1; }
.top5-pos {
  flex: 0 0 1.9rem; height: 1.9rem; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 600; font-size: 0.9rem;
  background: rgba(14, 111, 106, 0.08); color: var(--accent-deep);
  border-radius: 50%;
}
.top5-slot:not(.filled) .top5-pos {
  background: transparent; color: var(--ink-faint); border: 1px dashed var(--rule);
}
.top5-handle {
  flex: 0 0 auto; cursor: grab;
  color: var(--ink-faint); font-size: 1.05rem; letter-spacing: -0.15em;
  padding: 0.3rem 0.45rem 0.3rem 0.25rem;
}
.top5-slot.filled.drag-source .top5-handle { cursor: grabbing; }
.top5-remove {
  flex: 0 0 auto; font-size: 1.1rem; line-height: 1; padding: 0.2rem 0.5rem;
  color: var(--ink-soft); background: var(--paper-raised);
  border: 1px solid var(--rule); border-radius: 5px; cursor: pointer;
}
.top5-remove:hover { border-color: var(--error); color: var(--error); }

/* --- pool (all capabilities to pick from) --- */
.pool-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.pool-item {
  cursor: pointer; touch-action: none;
  transition: border-color 120ms ease, background 120ms ease;
}
.pool-item:hover { border-color: var(--accent); background: rgba(14, 111, 106, 0.05); }
.pool-item.drag-source { opacity: 0.35; }
.pool-add-wrap { flex: 0 0 auto; }
.pool-add {
  font-size: 1.05rem; line-height: 1; padding: 0.25rem 0.55rem;
  color: var(--accent-deep); background: var(--paper-raised);
  border: 1px solid var(--rule); border-radius: 5px; cursor: pointer;
}
.pool-item:hover .pool-add { border-color: var(--accent); }

/* --- floating drag ghost --- */
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 1000;
  margin: 0; list-style: none; pointer-events: none;
  border: 1px solid var(--accent); border-radius: 10px;
  background: var(--paper-raised);
  box-shadow: 0 10px 26px rgba(31, 49, 52, 0.28);
  transform: scale(1.02); opacity: 0.96;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.7rem;
}

/* --- likert (per-capability rating) --- */
.likert-field { margin: 1.4rem 0; }
.likert { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.likert .lk {
  flex: 1; min-width: 2.4rem; display: flex; flex-direction: column;
  align-items: center; gap: 0.25rem; padding: 0.45rem 0.3rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--paper-raised); cursor: pointer; text-align: center;
}
.likert .lk:hover { border-color: var(--accent); }
.likert .lk:has(input:checked) {
  border-color: var(--accent); background: rgba(14, 111, 106, 0.08);
}
.likert .lk span { font-size: 0.85rem; color: var(--ink-soft); }
.likert .lk input { accent-color: var(--accent); }
.likert .lk-na { border-style: dashed; }

/* fully-labelled 7-point scale: number on top, anchor text under it */
.likert-labeled { gap: 0.25rem; }
.likert-labeled .lk { min-width: 4.2rem; padding: 0.4rem 0.2rem; }
.likert-labeled .lk-num {
  font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--ink-soft);
}
.likert-labeled .lk-lab {
  font-size: 0.72rem; line-height: 1.15; color: var(--ink-faint);
}
