/* SafeBARS Mirror Study 1 — questionnaire page
   Clean, official-form aesthetic: section bars, numbered questions,
   7-column Likert grids, Yes/No, ruled open-answer boxes.
   Reuses the companion-site palette tokens. */

:root {
  --navy: #050a4b;
  --navy-2: #111c63;
  --navy-3: #1b2a86;
  --hero-blue: #0b73f6;
  --hero-blue-dark: #075dd9;
  --hero-blue-soft: #e8f1ff;
  --yellow: #ffdc00;
  --ink: #111c48;
  --muted: #53617c;
  --mist: #f4f7fc;
  --mist-2: #eef3fb;
  --line: #d8e1ef;
  --line-strong: #b8c9de;
  --white: #ffffff;
  --danger: #a84d2c;
  --danger-soft: #fff0ed;
  --green: #1f9d6b;
  --green-soft: #e7f6ee;
  --shadow-soft: 0 1px 2px rgba(5, 10, 75, 0.04), 0 10px 30px rgba(5, 10, 75, 0.08);
  --panel-radius: 18px;
  --card-radius: 14px;
  --gutter: clamp(14px, 3.5vw, 40px);
  --font-rounded: "Nunito", ui-rounded, "SF Pro Rounded", "Quicksand", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--mist);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.zh { display: none; }
body.lang-zh .en { display: none; }
body.lang-zh .zh { display: inline; }
body.lang-en .zh { display: none; }
body.lang-en .en { display: inline; }

/* ---- top bar ---- */
.survey-top {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(5, 10, 75, 0.25);
}
.survey-top-inner {
  max-width: 980px; margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--yellow); color: var(--navy);
  font-family: var(--font-rounded); font-weight: 800;
  display: grid; place-items: center; font-size: 15px;
}
.brand-text { font-family: var(--font-rounded); font-weight: 700; letter-spacing: -0.01em; }
.lang-toggle { display: inline-flex; background: rgba(255,255,255,0.12); border-radius: 999px; padding: 3px; }
.lang-btn {
  border: 0; background: transparent; color: rgba(255,255,255,0.8);
  font-family: var(--font-rounded); font-weight: 700; font-size: 13px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: 150ms;
}
.lang-btn.active { background: #fff; color: var(--navy); }

/* ---- layout ---- */
.survey-wrap { max-width: 980px; margin: 0 auto; padding: 24px var(--gutter) 48px; }
.intro-card {
  background: var(--white); border-radius: var(--panel-radius);
  padding: 28px clamp(20px, 4vw, 36px);
  box-shadow: var(--shadow-soft); margin-bottom: 22px;
  border: 1px solid var(--line);
}
.intro-card h1 { font-family: var(--font-rounded); font-size: clamp(22px, 3.4vw, 30px); margin: 0 0 12px; color: var(--navy); }
.intro-card p { margin: 0 0 10px; color: #2a3766; }
.intro-note { background: var(--hero-blue-soft); border-radius: 12px; padding: 12px 14px; color: var(--navy-2) !important; font-size: 14px; }

/* ---- participant info ---- */
.field-block {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--card-radius); padding: 18px 20px; margin-bottom: 22px;
  box-shadow: var(--shadow-soft);
}
.field-row { display: flex; flex-wrap: wrap; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 180px; }
.field-label { font-family: var(--font-rounded); font-weight: 700; font-size: 13px; color: var(--navy-2); }
.field input {
  height: 44px; border: 2px solid var(--line-strong); border-radius: 10px;
  padding: 0 12px; font-size: 15px; color: var(--ink); background: var(--mist);
}
.field input:focus { outline: none; border-color: var(--hero-blue); box-shadow: 0 0 0 4px rgba(11,115,246,0.18); }

/* ---- sections ---- */
.section { margin-bottom: 22px; }
.section-bar {
  background: var(--navy); color: #fff; border-radius: 12px;
  padding: 12px 18px; font-family: var(--font-rounded); font-weight: 800;
  font-size: 16px; letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 10px;
}
.section-bar .sec-num { color: var(--yellow); }
.section-sub {
  background: var(--navy-3); color: #fff; border-radius: 9px;
  padding: 8px 14px; font-family: var(--font-rounded); font-weight: 700; font-size: 14px;
  margin: 14px 0 10px;
}
.q-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--card-radius); padding: 16px 18px; margin-bottom: 12px;
  box-shadow: var(--shadow-soft);
}
.q-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.q-num {
  flex: 0 0 auto; min-width: 26px; height: 26px; border-radius: 8px;
  background: var(--mist-2); color: var(--navy-2);
  font-family: var(--font-rounded); font-weight: 800; font-size: 13px;
  display: grid; place-items: center; border: 1px solid var(--line);
}
.q-text { font-size: 15px; color: #1c274d; }
.q-text .en { display: block; }
.q-text .zh { display: none; color: #34406b; }
body.lang-zh .q-text .en { display: none; }
body.lang-zh .q-text .zh { display: block; }
.q-note {
  margin-top: 6px; font-size: 12.5px; color: var(--danger);
  background: var(--danger-soft); border-radius: 8px; padding: 6px 10px;
}

/* ---- consent ---- */
.consent-box { display: flex; gap: 12px; align-items: flex-start; }
.consent-box input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--hero-blue); flex: 0 0 auto; }
.consent-box label { font-size: 15px; color: #1c274d; cursor: pointer; }

/* ---- yes/no ---- */
.yn-row { display: flex; gap: 12px; }
.yn-opt {
  flex: 0 1 120px; display: flex; align-items: center; gap: 8px;
  border: 2px solid var(--line-strong); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; font-family: var(--font-rounded); font-weight: 700;
  color: var(--navy-2); transition: 150ms; user-select: none;
}
.yn-opt:hover { border-color: var(--hero-blue); }
.yn-opt input { accent-color: var(--hero-blue); width: 18px; height: 18px; }
.yn-opt.checked { background: var(--hero-blue-soft); border-color: var(--hero-blue); }

/* ---- likert grid ---- */
.likert {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 4px;
}
.likert-opt {
  border: 2px solid var(--line-strong); border-radius: 10px;
  padding: 10px 4px 8px; text-align: center; cursor: pointer;
  font-family: var(--font-rounded); transition: 150ms; user-select: none;
  background: var(--white);
}
.likert-opt:hover { border-color: var(--hero-blue); background: var(--hero-blue-soft); }
.likert-opt .num { font-weight: 800; font-size: 16px; color: var(--navy); display: block; }
.likert-opt .lab { font-size: 10.5px; line-height: 1.25; color: var(--muted); margin-top: 2px; display: block; }
.likert-opt.checked { background: var(--navy); border-color: var(--navy); }
.likert-opt.checked .num, .likert-opt.checked .lab { color: #fff; }
.likert-scale {
  display: flex; justify-content: space-between; font-size: 11px; color: var(--muted);
  margin-top: 8px; padding: 0 2px; font-family: var(--font-rounded);
}

/* ---- open / lines ---- */
.open-box textarea {
  width: 100%; min-height: 120px; border: 2px solid var(--line-strong);
  border-radius: 10px; padding: 12px; font-size: 14.5px; font-family: var(--font-body);
  color: var(--ink); background: var(--mist); resize: vertical; line-height: 1.6;
}
.open-box textarea:focus { outline: none; border-color: var(--hero-blue); box-shadow: 0 0 0 4px rgba(11,115,246,0.18); }
.lines-box textarea { min-height: 110px; }
.ruled {
  background-image: repeating-linear-gradient(var(--mist) 0, var(--mist) 33px, var(--line) 33px, var(--line) 34px);
  line-height: 34px !important; padding-top: 0 !important;
}

/* ---- static blocks ---- */
.static-block {
  background: var(--mist-2); border: 1px dashed var(--line-strong);
  border-radius: var(--card-radius); padding: 18px 20px; margin: 18px 0;
}
.static-block h3 { font-family: var(--font-rounded); color: var(--navy); margin: 0 0 8px; font-size: 16px; }
.static-block p { margin: 0 0 6px; color: #2a3766; }

/* ---- submit ---- */
.submit-area { margin-top: 26px; text-align: center; }
.submit-hint { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.submit-btn {
  border: 0; background: var(--hero-blue); color: #fff;
  font-family: var(--font-rounded); font-weight: 800; font-size: 16px;
  padding: 14px 34px; border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 0 var(--navy-3), 0 12px 24px rgba(11,115,246,0.3);
  transition: 150ms;
}
.submit-btn .zh { display: none; }
body.lang-zh .submit-btn .en { display: none; }
body.lang-zh .submit-btn .zh { display: inline; }
.submit-btn:hover:not(:disabled) { transform: translateY(-1px); }
.submit-btn:disabled { background: #9db6d4; box-shadow: 0 6px 0 #7f97b8; cursor: not-allowed; }
.submit-status { margin-top: 14px; font-size: 14px; font-weight: 600; min-height: 20px; }
.submit-status.ok { color: var(--green); }
.submit-status.err { color: var(--danger); }

.survey-foot {
  text-align: center; color: var(--muted); font-size: 12.5px;
  padding: 22px var(--gutter) 40px;
}

/* ---- responsive ---- */
@media (max-width: 640px) {
  .likert { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
  .likert-opt { padding: 7px 2px 6px; }
  .likert-opt .lab { font-size: 8.5px; }
  .likert-opt .num { font-size: 13px; }
  .field-row { flex-direction: column; }
}

/* Link from the questionnaire back to the companion tool (Round 37 wiring). */
.task-link {
  display: inline-block;
  margin-top: 14px;
  padding: 12px 18px;
  background: var(--hero-blue);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}
.task-link:hover { background: var(--hero-blue-dark); }

/* ---- stage routing (Round 43) ---- */
.stage-bar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, var(--hero-blue) 0%, var(--hero-blue-dark) 100%);
  color: #fff; border-radius: 12px; padding: 12px 18px; margin-bottom: 20px;
  font-family: var(--font-rounded); font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-soft);
}
.stage-tag {
  background: var(--yellow); color: var(--navy); border-radius: 999px;
  padding: 3px 12px; font-size: 12px; letter-spacing: 0.02em; white-space: nowrap;
}
.restore-note {
  border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 14px;
  border: 1px solid var(--line-strong);
}
.restore-note.ok { background: var(--green-soft); color: var(--green); border-color: #b7e3cc; }
.restore-note.warn { background: var(--danger-soft); color: var(--danger); border-color: #f0c9b8; }
.restore-note a { color: inherit; font-weight: 700; }
.stage-continue { margin-bottom: 4px; }

/* ---- in-page stage switcher (Round 49): reach any part from anywhere ---- */
.stage-switcher {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--card-soft, #f4f7ff);
  border: 1px solid var(--line-strong, #dce3f2);
  border-radius: 12px; padding: 10px 14px; margin: -8px 0 22px;
  font-size: 14px;
}
.ss-label { color: var(--muted, #5b6b88); font-weight: 600; white-space: nowrap; }
.ss-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.ss-tab {
  text-decoration: none; color: var(--hero-blue, #2f6bff);
  background: #fff; border: 1px solid var(--hero-blue, #2f6bff);
  border-radius: 999px; padding: 5px 14px; font-weight: 700; font-size: 13.5px;
  transition: background .15s ease, color .15s ease;
}
.ss-tab:hover { background: #eaf1ff; }
.ss-tab.active {
  background: var(--hero-blue, #2f6bff); color: #fff; cursor: default;
}

/* ---- action row: export PDF + skip (选做) ---- */
.survey-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.ghost-btn {
  font: inherit; font-size: 14px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer;
}
.ghost-btn:hover { background: #f3f6ff; }
.ghost-btn.skip { color: var(--muted); }
/* Enlarged return-to-homepage button in the survey footer (user request). */
.survey-foot-actions { text-align: center; }
.survey-foot-actions .ghost-btn {
  display: inline-block;
  font-family: var(--font-rounded); font-weight: 700; font-size: 16px;
  padding: 14px 30px; border-radius: 12px;
  border-color: var(--navy); box-shadow: var(--shadow-soft);
}
.survey-foot-actions .ghost-btn:hover { background: #eef2ff; }

/* ---- print: clean single-language PDF of questions + answers ---- */
@media print {
  .lang-toggle, .survey-actions, .survey-foot, .intro-note { display: none !important; }
  body { background: #fff; }
  .survey-top { box-shadow: none; border: none; }
  .survey-wrap { max-width: none; padding: 0; }
  .q-card, .section-bar, .subgroup-bar, .intro-card, .field-block { break-inside: avoid; }
  input, textarea { border: 1px solid #aaa; background: #fff; color: #000; }
  .submit-btn { display: none !important; }
}
