/* style.css, deliberately plain. Change the colors at the top and the whole
 * study restyles. Nothing here affects your data. */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8eaed;
  --subtle: #9aa3af;
  --accent: #4f8cff;
  --good: #4ade80;
  --bad: #f87171;
  --radius: 12px;
  --maxw: 720px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 20px 80px;
}

h1 { font-size: 1.9rem; margin: 0 0 4px; }
h2 { font-size: 1.35rem; margin: 28px 0 12px; }
code { background: #000; padding: 2px 6px; border-radius: 4px; font-size: .9em; }
.subtle { color: var(--subtle); font-size: .92rem; }
.good { color: var(--good); }
.bad  { color: var(--bad); }

/* ---- screens: exactly one is visible at a time ------------------------- */
.screen { display: none; }
.screen.visible { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.prose { background: var(--panel); padding: 16px 20px; border-radius: var(--radius); }
.prose p:first-child { margin-top: 0; }
.prose p:last-child  { margin-bottom: 0; }

/* ---- controls ---------------------------------------------------------- */
button.primary {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 15px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}
button.primary:hover:not(:disabled) { filter: brightness(1.12); }
button.primary:disabled { background: #333a47; color: #777f8c; cursor: not-allowed; }

.field { margin-top: 20px; }
.field label { display: block; font-size: .9rem; color: var(--subtle); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  background: var(--panel); color: var(--text);
  border: 1px solid #2a2f3a; border-radius: var(--radius);
}

/* ---- the camera view --------------------------------------------------- */
#stage {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  aspect-ratio: 4 / 3;
  margin: 16px 0;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}

/* Flipped so the participant sees a mirror image, which is what people
   expect from a webcam. Text is kept outside this element on purpose. */
#stage .mirror { position: absolute; inset: 0; transform: scaleX(-1); }
#stage video, #stage canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

.readout {
  position: absolute; top: 14px; left: 18px;
  display: flex; align-items: baseline; gap: 8px;
  text-shadow: 0 2px 10px rgba(0,0,0,.85);
  pointer-events: none;
}
.readout .big  { font-size: 3.4rem; font-weight: 700; line-height: 1; }
.readout .unit { font-size: 1rem; color: var(--subtle); }

.timer {
  position: absolute; top: 14px; right: 18px;
  font-size: 1.4rem; font-weight: 600;
  text-shadow: 0 2px 10px rgba(0,0,0,.85);
  pointer-events: none;
}

.countdown {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  font-size: 7rem; font-weight: 800;
  background: rgba(0,0,0,.45);
  pointer-events: none;
}
.countdown.visible { display: flex; }
.countdown.pulse { animation: pop .5s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: .2; } to { transform: scale(1); opacity: 1; } }

/* ---- progress ---------------------------------------------------------- */
.progress { font-size: .9rem; color: var(--subtle); }
.progress-bar { height: 6px; background: var(--panel); border-radius: 3px; margin-top: 6px; overflow: hidden; }
#progress-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.prompt { font-size: 1.15rem; margin: 14px 0 0; }

/* ---- status lines ------------------------------------------------------ */
.status { font-weight: 600; }
.status.good { color: var(--good); }
.status.bad  { color: var(--bad); }

.help { margin-top: 20px; color: var(--subtle); }
.help summary { cursor: pointer; }

/* ---- spinner ----------------------------------------------------------- */
.spinner {
  width: 34px; height: 34px; margin: 40px auto 20px;
  border: 3px solid #2a2f3a; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- check.html -------------------------------------------------------- */
.check {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--panel); padding: 14px 16px;
  border-radius: var(--radius); margin-bottom: 10px;
  border-left: 4px solid #2a2f3a;
}
.check.pass { border-left-color: var(--good); }
.check.fail { border-left-color: var(--bad); }
.check.busy { border-left-color: var(--accent); }
.check .icon { font-size: 1.2rem; line-height: 1.5; width: 1.4em; flex: none; }
.check .body { flex: 1; min-width: 0; }
.check .name { font-weight: 600; }
.check .detail { color: var(--subtle); font-size: .9rem; margin-top: 4px; white-space: pre-wrap; }
.check .detail a { color: var(--accent); }

/* ---- demo-mode banner -------------------------------------------------- */
.banner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 18px;
  background: #3a2f12;
  border-bottom: 2px solid #f0ad4e;
  color: #ffe9c2;
  font-size: .92rem;
  line-height: 1.5;
}
.banner a { color: #ffd08a; }
.banner code { background: rgba(0,0,0,.4); }

/* ---- results table on the final screen --------------------------------- */
table.results {
  width: 100%;
  margin: 18px 0 8px;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}
table.results th, table.results td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #232833;
}
table.results tr:first-child th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--subtle);
  font-weight: 600;
}
table.results tr:last-child th, table.results tr:last-child td { border-bottom: 0; }
table.results td { font-variant-numeric: tabular-nums; }

.banner.subtle-banner {
  background: #1b2230;
  border-bottom-color: #4f8cff;
  color: #c8d4e8;
}

/* ---- consent form ------------------------------------------------------ */
#consent-doc-wrap {
  margin: 18px 0 8px;
  border: 1px solid #2a2f3a;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
#consent-doc {
  display: block;
  width: 100%;
  height: 62vh;
  min-height: 380px;
  border: 0;
}

.q-choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  cursor: pointer;
  line-height: 1.5;
}
.q-choice input { margin-top: .35em; flex: none; width: 17px; height: 17px; accent-color: var(--accent); }

.affirm {
  padding: 12px 14px;
  margin-top: 8px;
  background: var(--panel);
  border-radius: var(--radius);
}

/* ---- generated questions ----------------------------------------------- */
.q { margin-top: 22px; }
.q > label { display: block; font-weight: 600; margin-bottom: 6px; }
.q .req { color: var(--bad); }
.q-help { margin: 0 0 8px; color: var(--subtle); font-size: .88rem; }

.q input[type="text"],
.q input[type="number"],
.q select,
.q textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid #2a2f3a;
  border-radius: var(--radius);
}
.q select { appearance: none; cursor: pointer; }
.q textarea { resize: vertical; }
.q input:focus, .q select:focus, .q textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.q-group { background: var(--panel); border-radius: var(--radius); padding: 6px 14px; }

.q-error { margin: 6px 0 0; color: var(--bad); font-size: .88rem; }
.bad-field input, .bad-field select, .bad-field textarea, .bad-field .q-group {
  border-color: var(--bad);
}

/* ---- preview.html ------------------------------------------------------ */
pre.prose { white-space: pre-wrap; word-break: break-word; font-size: .88rem; margin: 12px 0; }
.banner ul { margin: 8px 0 0; padding-left: 20px; }
