/* ============================================================================
   Inner Voice Questionnaire — visual theme
   A calm, professional, readable look layered on top of the default jsPsych CSS.
   ========================================================================== */

:root {
  --ink:        #1f2530;
  --ink-soft:   #51596b;
  --bg:         #f4f6fb;
  --card:       #ffffff;
  --accent:     #4f6df5;
  --accent-dk:  #3c55cc;
  --accent-sft: #eaeefe;
  --border:     #dfe3ec;
  --radius:     14px;
  --maxw:       760px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

/* jsPsych mounts everything inside this element */
.jspsych-display-element {
  display: block;          /* let content flow from the top and scroll normally */
  min-height: 100vh;
  padding: 40px 20px 64px;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Override jsPsych's default vertical-centering, which clips tall pages at the
   top so you can't scroll up to them. */
.jspsych-content-wrapper {
  display: block !important;
  height: auto !important;
  width: 100%;
}

.jspsych-content {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(31, 37, 48, 0.06);
  padding: 44px 48px;
  text-align: left;
}

/* Typography ---------------------------------------------------------------- */
.jspsych-content h1 { font-size: 1.7rem; font-weight: 700; margin: 0 0 .4em; letter-spacing: -.01em; }
.jspsych-content h2 { font-size: 1.3rem; font-weight: 600; margin: 0 0 .5em; }
.jspsych-content h3 { font-size: 1.1rem; font-weight: 600; color: var(--ink-soft); }
.jspsych-content p  { margin: 0 0 1em; color: var(--ink); }
.jspsych-content a  { color: var(--accent); }
.muted  { color: var(--ink-soft); font-size: .95rem; }
.kbd {
  display: inline-block; padding: 2px 9px; border-radius: 6px;
  background: #eef0f6; border: 1px solid var(--border);
  font-family: ui-monospace, Menlo, monospace; font-size: .9em;
}

/* A reusable "reading card" for presenting stimulus passages */
.stim-passage {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 22px 26px;
  margin: 18px 0 26px;
  font-size: 1.12rem;
  line-height: 1.75;
  white-space: pre-wrap;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .08em; font-size: .72rem;
  font-weight: 700; color: var(--accent); margin-bottom: 6px;
}

/* Buttons ------------------------------------------------------------------- */
.jspsych-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 26px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
  margin: 6px;
}
.jspsych-btn:hover { background: var(--accent-dk); }
.jspsych-btn:active { transform: translateY(1px); }
/* consent screen: green = consent, red = decline */
.jspsych-btn.btn-consent { background: #1e9e5a; border-color: #1e9e5a; color: #fff; }
.jspsych-btn.btn-consent:hover { background: #18854c; border-color: #18854c; }
.jspsych-btn.btn-decline { background: #e5392b; border-color: #e5392b; color: #fff; }
.jspsych-btn.btn-decline:hover { background: #c72f23; border-color: #c72f23; }
.jspsych-btn:focus-visible { outline: 3px solid var(--accent-sft); outline-offset: 2px; }

/* Secondary / "decline" style for opt-out buttons */
.btn-secondary .jspsych-btn,
.jspsych-btn.secondary {
  background: #fff; color: var(--ink-soft); border: 1px solid var(--border);
}

/* Form controls (survey-html-form, survey-likert, etc.) --------------------- */
.jspsych-survey-html-form label,
.jspsych-survey-multi-choice-text,
.jspsych-survey-multi-select-text { font-size: 1rem; }

input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font); font-size: 1rem; color: var(--ink);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 10px 12px; background: #fff; width: 100%; box-sizing: border-box;
}
textarea { min-height: 90px; resize: vertical; }
select { width: auto; min-width: 220px; }
input[type="text"]:focus, input[type="number"]:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-sft);
}

/* Range sliders (reading-habits inventory) */
.slider-row { display: grid; grid-template-columns: 1fr 220px 64px; gap: 14px; align-items: center; margin: 10px 0; }
.slider-row label { font-weight: 500; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider-val { font-weight: 600; color: var(--accent-dk); text-align: right; font-variant-numeric: tabular-nums; }

/* Likert tables */
.jspsych-survey-likert-opts { font-size: .95rem; }
table.jspsych-survey-likert-statement,
.jspsych-survey-likert-statement { line-height: 1.4; }
/* Colour the scale radio buttons (instead of default grey) and enlarge them */
.jspsych-survey-likert-opts input[type="radio"] {
  accent-color: var(--accent);
  width: 20px; height: 20px; cursor: pointer;
}
.jspsych-survey-likert-opts label { color: var(--ink); }
/* Tint the whole option column on hover for clearer targeting */
.jspsych-survey-likert-opts label:hover { color: var(--accent-dk); }

/* Progress bar -------------------------------------------------------------- */
#jspsych-progressbar-container {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 12px 0; color: var(--ink-soft); font-size: .85rem;
}
#jspsych-progressbar-inner { background: var(--accent); }

/* Self-paced reading canvas centring */
.jspsych-content canvas { max-width: 100%; }

/* PsyToolkit-style questions (pt.js) --------------------------------------- */
fieldset.pt-q {
  border: none; margin: 0 0 28px; padding: 0;
}
.pt-prompt { font-weight: 500; margin-bottom: 12px; line-height: 1.5; }
.pt-options { display: grid; gap: 9px; }
.pt-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color .12s ease, background .12s ease;
  font-weight: 400;
}
.pt-opt:hover { border-color: var(--accent); background: var(--accent-sft); }
.pt-opt input[type="radio"], .pt-opt input[type="checkbox"] {
  margin-top: 3px; accent-color: var(--accent); flex: 0 0 auto;
}
.pt-opt span { flex: 1; }

/* "Other (please specify)" — text field drops below the option label */
.pt-opt-other { flex-direction: column; align-items: stretch; }
.pt-opt-head { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.pt-opt-head span { flex: 1; }
.pt-other-text { margin: 10px 0 0 28px; width: calc(100% - 28px); box-sizing: border-box; }
.pt-other-text:disabled { background: #f3f4f8; color: #aab; }

.pt-slider { margin: 16px 0; }
.pt-slider-label { font-weight: 500; margin-bottom: 4px; }
.slider-row { grid-template-columns: minmax(0,1fr) 2.6fr minmax(0,1fr) 56px; }
.pt-anchor { font-size: .8rem; color: var(--ink-soft); }

.pt-video { display: flex; justify-content: center; margin: 18px 0; }
.pt-video iframe, .pt-video video { max-width: 100%; width: 640px; border-radius: 10px; background: #000; }

.pt-media { display: flex; justify-content: center; margin: 16px 0 20px; }
.pt-media img {
  max-width: 100%; max-height: 460px; border-radius: 10px;
  border: 1px solid var(--border);
}
.pt-media audio { width: 100%; max-width: 460px; }

.pt-info { font-size: 1.05rem; line-height: 1.6; }
.pt-info:first-line { font-weight: 600; }

/* Validation message ("please answer") */
.pt-error {
  color: #c0392b; font-size: .9rem; font-weight: 600; margin-top: 8px;
}

/* SurveyJS (jsPsych survey plugin) — match the project theme ---------------- */
.sd-root-modern {
  --sjs-primary-backcolor: var(--accent);
  --sjs-primary-backcolor-dark: var(--accent-dk);
  --sjs-primary-backcolor-light: var(--accent-sft);
  --sjs-primary-forecolor: #ffffff;
  --sjs-general-backcolor: #ffffff;
  --sjs-general-backcolor-dim: #ffffff;
  --sjs-general-backcolor-dim-light: #ffffff;
  --sjs-corner-radius: 10px;
  --sjs-font-family: var(--font);
  background: transparent !important;
}
.sd-container-modern { background: transparent; }
.sd-body { padding: 0 !important; }
.sd-body.sd-body--responsive,
.sd-body.sd-body--static { max-width: none; }
.sd-page { padding: 0 !important; }
.sd-title.sd-container-modern__title { box-shadow: none; background: transparent; padding: 0; }
.sd-question__title { font-family: var(--font); font-size: 1.05rem; color: var(--ink); }
.sd-element__title { font-weight: 600; }
/* navigation buttons (Previous / Next / Continue) */
.sd-navigation__prev-btn,
.sd-navigation__next-btn,
.sd-navigation__complete-btn {
  font-family: var(--font); font-weight: 600; border-radius: 10px;
  padding: 12px 26px; cursor: pointer;
}
/* Next / Continue = primary blue so navigation is obvious */
.sd-navigation__next-btn,
.sd-navigation__complete-btn {
  background: var(--accent) !important; color: #fff !important;
  border: none !important; box-shadow: none !important;
}
.sd-navigation__next-btn:hover,
.sd-navigation__complete-btn:hover { background: var(--accent-dk) !important; }
/* Previous = secondary outline */
.sd-navigation__prev-btn {
  background: #fff !important; color: var(--ink-soft) !important;
  border: 1px solid var(--border) !important; box-shadow: none !important;
}
/* keep the navigation bar visible with a little breathing room */
.sd-action-bar.sd-footer { padding-top: 8px; justify-content: flex-start; gap: 10px; }
/* the HTML prompt blocks we inject keep their pt-prompt / pt-info styling */
.sd-html .pt-prompt { margin-bottom: 0; }

/* multi-select (tagbox) chips → accent blue */
.sv-tagbox__item { background-color: var(--accent) !important; }
.sv-tagbox__item-text { color: #fff !important; }
.sd-tagbox-item_clean-button-svg { fill: #fff !important; }

/* slider (reading-habit hours) → accent blue fill + thumb */
.sd-slider__range-track { background-color: var(--accent) !important; }
.sd-slider__thumb-dot { background-color: var(--accent) !important; border-color: var(--accent) !important; }
/* keep room so the end labels (e.g. "30+", "100") aren't clipped at the edges */
/* Inset the slider with MARGIN (not padding): padding shrinks only the rail
   while the labels keep full width, so the rail (10–90) and labels (0–100) drift
   apart. Margin shrinks rail + labels together (kept aligned) and leaves room
   for the end labels ("0", "100", "30+") to extend past the rail without clipping. */
.sd-slider-container { margin: 0 26px; box-sizing: border-box; }
.sd-slider__label-text { white-space: nowrap; overflow: visible; }
.sd-slider-labels-container { overflow: visible; }
/* keep slider end-labels ("30+", "100") from being clipped by the card / cell edge */
.sd-slider-container, .sd-slider-container__slider,
.sd-slider, .sd-question--slider .sd-question__content { overflow: visible !important; }

/* keep the 0–10 proficiency scale on one line: min label · buttons · max label */
.sd-rating { display: flex !important; flex-wrap: nowrap !important; align-items: center !important; gap: 4px; }
.sd-rating__min-text, .sd-rating__max-text {
  position: static !important; white-space: nowrap; flex: 0 0 auto; margin: 0 8px !important;
  font-size: .8rem; color: var(--ink-soft);
}
.sd-rating__item, .sd-rating__item--fixed-size {
  flex: 0 0 auto; min-width: 34px !important; width: 34px !important; height: 34px !important;
}

/* selected rating button → accent blue (modern theme defaults to dark) */
.sd-rating__item--selected,
.sd-rating__item--selected .sd-rating__item-text {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}
/* kill the square focus outline on rating buttons (the round selected fill is
   the indicator); the number lives in the span text, so suppress the duplicate
   ::after that overlaps it on the selected button */
.sd-rating__item:focus, .sd-rating__item:focus-within,
.sd-rating__item input:focus, .sd-rating__item input:focus-visible,
.sd-rating__item-text:focus { outline: none !important; box-shadow: none !important; }
.sd-rating__item-text::after { content: none !important; }

/* Matrix (Likert grid) — grey header, gridlines, compact rows (Part 3 & 5) */
.sd-matrix__table { border-collapse: collapse !important; width: 100%; }
.sd-matrix__table .sd-table__cell {
  border: 1px solid var(--border) !important;
  padding: 7px 6px !important;
  text-align: center; vertical-align: middle; overflow-wrap: break-word;
}
.sd-matrix__table .sd-table__cell--header {
  background: var(--accent-sft); font-weight: 600; font-size: .8rem; line-height: 1.25;
}
.sd-matrix__table .sd-table__cell--header,
.sd-matrix__table .sd-table__cell--header .sv-string-viewer { color: var(--ink) !important; }
/* first column = item text: left-aligned, wider so it wraps less */
.sd-matrix__table .sd-table__row > .sd-table__cell:first-child { text-align: left; font-weight: 500; font-size: .92rem; }
.sd-matrix__table .sd-table__cell--header:first-child { text-align: left; }
/* English ease-of-use matrices: wide sentence column, narrow 1–5 columns.
   The "width:1%" trick shrinks the number columns to their content so the
   first (sentence) column absorbs all remaining width. */
.ease-matrix .sd-matrix__table thead th,
.ease-matrix .sd-matrix__table tbody td:not(:first-child) { width: 1% !important; min-width: 46px !important; white-space: nowrap; }
/* Likert grids (IRQ / VISQ-R): same idea, but let the multi-word labels wrap so
   the answer columns shrink to the label width and the statement column widens. */
.likert-matrix .sd-matrix__table thead th,
.likert-matrix .sd-matrix__table tbody td:not(:first-child) { width: 1% !important; min-width: 60px !important; }
/* (sticky header removed: the only way to keep it visible is an inner scroll
   box, which clipped the last column and hid the Next/Previous buttons.) */

/* SurveyJS question titles (used directly in Part 1) → match pt-prompt look */
.sd-question__title {
  font-family: var(--font) !important;
  font-weight: 500 !important;
  font-size: 1rem !important;
  color: var(--ink) !important;
  line-height: 1.5;
}
/* the jsPsych survey plugin sets an inline min-width: min(100vw, 800px) on its
   container, which forces the survey wider than the card (so the dynamic-panel
   border + Add/Remove buttons overflow). Let it shrink to the card width. */
.jspsych-survey-container { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }

/* SurveyJS gives the panels container a -40px full-bleed margin (+40 padding)
   that overshoots our flattened layout and pushes the Add/Remove buttons past
   the card edges — neutralise it so panels fit inside the card. */
.sd-paneldynamic__panels-container {
  margin-left: 0 !important; margin-right: 0 !important;
  padding-left: 0 !important; padding-right: 0 !important;
}
/* flex/grid children default to min-width:auto (min-content), which lets the
   dynamic-panel push the whole survey wider than the card. Force them to shrink. */
.sd-root-modern, .sd-container-modern, .sd-body, .sd-page, .sd-row,
.sd-element, .sd-question, .sd-paneldynamic, .sd-paneldynamic__panel,
.sd-paneldynamic__panels-container, .sd-paneldynamic__panel-wrapper {
  min-width: 0 !important; max-width: 100% !important; box-sizing: border-box;
}
.sd-paneldynamic__panel-wrapper {
  border: 1px solid var(--border); border-radius: 12px; padding: 18px 18px 16px; margin-bottom: 16px;
}
/* give the dynamic-panel add/remove controls room (don't clip them) */
.sd-paneldynamic__add-btn, .sd-paneldynamic__remove-btn { margin-top: 8px; }
/* the panel footer ("Remove …") has a negative right margin for full-bleed,
   which overshoots once we flatten the panel padding — keep it inside */
.sd-paneldynamic__panel-footer { margin-right: 0 !important; }
.sd-paneldynamic__add-btn { margin-left: 0 !important; }
/* wide matrix tables scroll instead of clipping the last column —
   scoped to questions that actually contain a table, so it never clips
   paneldynamic buttons or other content vertically */
.sd-question__content:has(table) { overflow-x: auto; }

/* required-field error messages: SurveyJS gives them a negative margin to span
   full width, which clipped on the left once we removed the question padding.
   Reset to normal padded boxes. */
.sd-question__erbox, .sd-error, .sd-question__erbox--outside-question {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 8px 14px !important;
  border-radius: 8px;
  box-sizing: border-box;
}

/* Flatten SurveyJS's per-question cards so they blend into our page card
   (otherwise each question shows a nested bordered box that looks "cut off"). */
.sd-element--with-frame {
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
}
.sd-question__content { padding: 0 !important; }
.sd-question__header { padding: 0 !important; }
.sd-html { padding: 0 !important; }
/* spacing between stacked questions on a multi-question page */
.sd-row { margin-top: 4px !important; }
.sd-page__row + .sd-page__row { margin-top: 18px !important; }
/* keep text inputs / dropdowns looking like the rest of the form */
.sd-input {
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  border-radius: 9px !important;
}
.sd-input:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-sft) !important; }

/* Don't clip the focus/selection ring on radio & checkbox options */
.sd-question, .sd-question__content, .sd-selectbase, .sd-selectbase__item,
.sd-item, .sd-row, .sd-page, .sd-page__row, .sd-body, .sd-container-modern {
  overflow: visible !important;
}
/* give options a touch of left room so the ring is never flush to an edge */
.sd-selectbase__item { padding-left: 3px; }

/* Selected radio / checkbox in the accent colour (modern theme defaults to dark) */
.sd-radio--checked .sd-radio__decorator {
  background: #fff !important;
  border: 2px solid var(--accent) !important;
  box-shadow: none !important;
}
.sd-radio--checked .sd-radio__decorator::after { background-color: var(--accent) !important; }
.sd-checkbox--checked .sd-checkbox__decorator {
  background-color: var(--accent) !important; border-color: var(--accent) !important;
  box-shadow: none !important;
}
.sd-checkbox--checked .sd-checkbox__svg { fill: #fff !important; }
/* focus ring (kept soft and un-clipped) */
.sd-item__control:focus + .sd-item__decorator {
  box-shadow: 0 0 0 3px var(--accent-sft) !important;
}

/* Small screens */
@media (max-width: 640px) {
  .jspsych-content { padding: 28px 20px; }
  .slider-row { grid-template-columns: 1fr; }
}

/* ============================================================================
   "Journey through the brain" engagement layer
   ========================================================================== */
.journey { text-align: center; max-width: 34em; margin-left: auto; margin-right: auto; }
.journey h1 { font-size: 1.7rem; line-height: 1.2; margin: 6px 0 10px; }
.journey-lead { color: var(--ink-soft); max-width: 32em; margin: 8px auto; font-size: 1.02rem; }
.journey-hook { color: var(--ink-soft); max-width: 30em; margin: 6px auto 2px; font-size: 1.05rem; }
.journey-info { color: var(--ink); max-width: 32em; margin: 12px auto 2px; font-size: .96rem; }
/* parts overview list */
.overview-list { list-style: none; padding: 0; margin: 18px auto 0; max-width: 34em; text-align: left; }
.overview-list li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--border); color: var(--ink-soft); font-size: .96rem; }
.overview-list li:first-child { border-top: 0; }
.overview-num { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; color: var(--ink); font-weight: 700; font-size: .82rem; display: inline-flex; align-items: center; justify-content: center; }
.overview-text { flex: 1; }
.overview-name { font-weight: 700; color: var(--ink); white-space: nowrap; }
.journey-step { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--accent-dk); }
.journey-title { font-size: 1.5rem; }

/* the brain illustration */
.brain-svg { display: block; margin: 0 auto 14px; height: auto; max-width: 86%; }
.brain-lobe { transition: fill .8s cubic-bezier(.2,.8,.2,1); }

/* progress pips */
.journey-pips { display: flex; gap: 8px; justify-content: center; margin: 10px 0 4px; }
.journey-pips .pip { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.journey-pips .pip.done { background: var(--accent); }
.journey-pips .pip.now { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-sft); }

/* region name pill */
.region-name { padding: 1px 10px; border-radius: 999px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.region-frontal { background: #b4d8ec; } .region-occipital { background: #f7a6b6; }
.region-temporal { background: #b6cf9d; } .region-parietal { background: #fcfb98; }
.region-cerebellum { background: #f3b66a; }

/* profile card */
.profile-disclaimer { font-size: .85rem; margin: 2px auto 14px; max-width: 30em; }
.profile-rows { text-align: left; max-width: 30em; margin: 0 auto; }
.profile-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.profile-row:first-child { border-top: 0; }
.profile-icon { font-size: 1.4rem; line-height: 1.4; flex: 0 0 auto; }
.profile-label { font-weight: 700; color: var(--accent-dk); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.profile-text { font-size: 1rem; color: var(--ink); }

/* verbal/visual spectrum */
.spectrum { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.spectrum-end { font-size: .78rem; color: var(--ink-soft); white-space: nowrap; }
.spectrum-bar { position: relative; flex: 1; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, #1E9E5A, #2E6FC9); }
.spectrum-dot { position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--accent-dk);
  box-shadow: 0 1px 4px rgba(0,0,0,.25); }
