/* ==========================================================
   Pretest UI — continuous, 16Personalities-inspired rhythm
   Equal-size response circles retained for research neutrality.
   ========================================================== */

:root {
  --text: #2f3b4e;
  --text-soft: #667085;
  --text-muted: #87909d;
  --line: #e8eaee;
  --line-strong: #d8dde5;
  --green: #25a56a;
  --green-dark: #168653;
  --green-soft: #eaf8f1;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --shadow: 0 8px 28px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: auto;
  background: var(--surface);
}

html.modal-open,
html.modal-open body {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: "Red Hat Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

.jspsych-display-element,
#jspsych-content {
  font-family: "Red Hat Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.jspsych-display-element {
  font-size: 17px;
}

#jspsych-content {
  width: min(1460px, calc(100% - 40px));
  max-width: none;
  margin: 16px auto 72px;
  text-align: left;
}

/* ===== jsPsych main button ===== */
.jspsych-btn,
.start-evaluation-btn {
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  min-height: 48px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(37, 165, 106, .18);
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}

.jspsych-btn:hover:not(:disabled),
.start-evaluation-btn:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.jspsych-btn:focus-visible,
.start-evaluation-btn:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(37, 165, 106, .25);
  outline-offset: 3px;
}

.jspsych-btn.is-disabled,
.jspsych-btn:disabled {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

/* ===== Overall progress ===== */
#jspsych-progressbar-container {
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  padding: 0;
}

#jspsych-progressbar-outer {
  height: 5px;
  border: 0;
  border-radius: 0;
  background: #eef1f4;
  overflow: hidden;
}

#jspsych-progressbar-inner {
  height: 100%;
  background: var(--green);
}

#jspsych-progressbar-container span,
#jspsych-progressbar-container > div:first-child:not(#jspsych-progressbar-outer) {
  display: none;
}

/* ===== Welcome / final cards ===== */
.survey-card {
  max-width: 820px;
  margin: 36px auto;
  padding: 44px 48px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .055);
  background: #fff;
}

.eyebrow,
.intro-meta {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .055em;
  text-transform: uppercase;
}

.welcome-card h1,
.stimulus-intro h1 {
  margin: 7px 0 16px;
  color: var(--text);
  font-size: clamp(30px, 3.1vw, 42px);
  line-height: 1.16;
  font-weight: 700;
}

.welcome-card p,
.stimulus-intro p {
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1.62;
}

.save-card {
  margin-top: 70px;
}

/* ===== First exposure to each stimulus ===== */
.stimulus-intro {
  max-width: 920px;
  margin: 26px auto 54px;
  text-align: center;
}

.stimulus-intro .intro-meta {
  text-align: center;
}

.stimulus-intro h1 {
  font-size: clamp(25px, 2.25vw, 32px);
}

.stimulus-intro p {
  max-width: 720px;
  margin: 0 auto 22px;
  font-size: 16px;
}

.intro-image-button,
.desktop-stimulus-button,
.mobile-stimulus-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: zoom-in;
}

.intro-image-button {
  display: block;
  margin: 0 auto 22px;
  border-radius: 14px;
}

.intro-stimulus-image {
  display: block;
  max-width: min(620px, 92vw);
  max-height: min(68vh, 700px);
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
  filter: drop-shadow(0 8px 22px rgba(16, 24, 40, .10));
}

.start-evaluation-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 2px auto 0;
}

/* ===== Evaluation layout ===== */
.evaluation-shell[hidden],
.stimulus-intro[hidden],
.stimulus-modal[hidden] {
  display: none !important;
}

.evaluation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(330px, .9fr);
  gap: clamp(34px, 4.2vw, 72px);
  align-items: stretch;
  max-width: 1420px;
  overflow: visible;
  margin: 0 auto;
}

.question-column {
  min-width: 0;
}

.evaluation-status {
  position: sticky;
  top: 7px;
  z-index: 12;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  margin: 0 0 14px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  box-shadow: none;
  color: var(--text-soft);
  font-size: 13px;
}

.evaluation-status > span:first-child {
  font-weight: 700;
  color: var(--text);
}

.evaluation-status strong {
  font-weight: 500;
  color: var(--text-soft);
}

.mobile-stimulus-bar {
  display: none;
}

.stimulus-column {
  min-width: 0;
  align-self: stretch;
  position: relative;
  overflow: visible;
}

.desktop-stimulus-card {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.desktop-stimulus-meta {
  width: min(100%, 520px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 9px;
  color: var(--text-soft);
  font-size: 13px;
}

.desktop-stimulus-meta span {
  font-weight: 700;
  color: var(--text);
}

.desktop-stimulus-meta button {
  border: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
}

.desktop-stimulus-button {
  display: block;
  width: 100%;
}

.desktop-stimulus-button img {
  display: block;
  width: auto;
  max-width: min(100%, 520px);
  max-height: calc(100vh - 112px);
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  filter: drop-shadow(0 7px 20px rgba(16, 24, 40, .09));
}

/* ===== Section headings ===== */
.question-section {
  margin: 0;
}

.section-intro {
  padding: 18px 12px 22px;
}

.section-intro h2,
.final-section h2 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.36;
  font-weight: 700;
}

.section-intro p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.45;
}

.semantic-section {
  margin-top: 12px;
}

.semantic-intro {
  margin-top: 0;
  padding-top: 26px;
}

/* ===== Continuous question rows ===== */
.scale-stack {
  border-top: 1px solid var(--line);
}

.scale-question {
  min-height: 205px;
  padding: 26px 12px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  scroll-margin-top: 74px;
  transition: color .22s ease, opacity .22s ease;
}

.statement-text {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.36;
  font-weight: 600;
  letter-spacing: -.006em;
  transition: color .22s ease;
}

/* Muted rows stay fully readable but visually recede. */
.scale-question.is-muted .statement-text,
.scale-question.is-answered .statement-text {
  color: #778291;
}

.scale-question.is-active:not(.is-answered) .statement-text {
  color: #263346;
}

/* Semantic differential uses the same vertical rhythm as all other questions.
   Only the horizontal layout differs to give long Czech anchors enough room. */
.semantic-question .scale-control {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  column-gap: 28px;
  width: 100%;
}

.semantic-question .scale-options {
  width: auto;
  display: grid;
  grid-template-columns: repeat(7, 62px);
  gap: 16px;
  justify-content: center;
  align-items: center;
}

.semantic-question .scale-choice {
  width: 62px;
  height: 62px;
  flex: none;
}

.semantic-question .endpoint-left {
  justify-self: end;
  text-align: right;
}

.semantic-question .endpoint-right {
  justify-self: start;
  text-align: left;
}

.semantic-question .endpoint-label {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
  font-size: 13px;
}

/* ===== Equal-size 1–7 controls ===== */
.scale-control {
  display: grid;
  grid-template-columns: minmax(92px, 116px) minmax(320px, 1fr) minmax(92px, 116px);
  gap: 12px;
  align-items: center;
  width: 100%;
}

.endpoint-label {
  color: #737d8b;
  font-size: 13.5px;
  line-height: 1.22;
  font-weight: 400;
  transition: color .16s ease;
}

.endpoint-left { text-align: right; }
.endpoint-right { text-align: left; }

.scale-question.is-active:not(.is-answered) .endpoint-label {
  color: #4f5b6c;
}

.scale-options {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  align-items: center;
  justify-items: center;
  gap: clamp(4px, .75vw, 11px);
}

.scale-choice {
  position: relative;
  display: inline-flex;
  width: 62px;
  height: 62px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}

.scale-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-circle {
  width: 52px;
  height: 52px;
  display: block;
  border: 2px solid #9da6b2;
  border-radius: 50%;
  background: #fff;
  transition:
    transform .12s ease,
    background .14s ease,
    border-color .14s ease,
    box-shadow .14s ease;
}

.choice-number {
  position: absolute;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
  color: #687384;
  pointer-events: none;
  transition: color .14s ease;
}

/* Active row = strong focus, but all seven choices remain visually neutral. */
.scale-question.is-active:not(.is-answered) .scale-choice input:not(:checked) + .choice-circle {
  border-color: var(--green);
}

.scale-question.is-active:not(.is-answered) .scale-choice input:not(:checked) ~ .choice-number {
  color: var(--green-dark);
}

.scale-question:not(.is-answered) .scale-choice:hover input:not(:checked) + .choice-circle {
  transform: scale(1.045);
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 3px rgba(37, 165, 106, .08);
}

.scale-question:not(.is-answered) .scale-choice:hover input:not(:checked) ~ .choice-number {
  color: var(--green-dark);
}

/* Answered rows stay grey when revisited/hovered; only the checked value changes. */
.scale-question.is-answered .scale-choice:hover input:not(:checked) + .choice-circle {
  transform: none;
  border-color: #9da6b2;
  background: #fff;
  box-shadow: none;
}

.scale-question.is-answered .scale-choice:hover input:not(:checked) ~ .choice-number {
  color: #687384;
}

.scale-question.needs-answer {
  background: rgba(37, 165, 106, .035);
}

/* Once selected, an answer stays grey — active or inactive, desktop or mobile. */
.scale-choice input:checked + .choice-circle {
  background: #98a2b3;
  border-color: #98a2b3;
  box-shadow: none;
}

.scale-choice input:checked ~ .choice-number {
  color: #fff;
}

.scale-choice input:focus-visible + .choice-circle {
  outline: 3px solid rgba(37, 165, 106, .27);
  outline-offset: 3px;
}


/* ===== Stimulus zoom modal ===== */
.stimulus-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
}

.stimulus-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 28, 38, .82);
  backdrop-filter: blur(4px);
}

.stimulus-modal-content {
  position: relative;
  z-index: 2;
  max-width: min(92vw, 720px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 12px;
  overscroll-behavior: contain;
}

.stimulus-modal-content img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: auto;
  border-radius: 8px;
}

.stimulus-modal-close {
  position: fixed;
  z-index: 3;
  top: 18px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .96);
  color: #263346;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* ===== Final questions ===== */
.final-card {
  max-width: 900px;
}

.final-section > h2 {
  font-size: 25px;
  margin-bottom: 8px;
}

.final-question {
  padding: 28px 0;
  border-top: 1px solid var(--line);
}

.final-question:first-of-type {
  margin-top: 20px;
}

.final-question-title {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.choice-line {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-soft);
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}

.choice-line:hover {
  border-color: #9fcfb8;
  background: #fbfefc;
}

.choice-line input {
  accent-color: var(--green);
}

.choice-line:has(input:checked) {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--text);
}

.final-validity-question .statement-text {
  margin-bottom: 20px;
  text-align: left;
}

.final-validity-question .scale-control {
  max-width: 760px;
}

.launch-error {
  max-width: 720px;
  margin: 70px auto;
  padding: 0 24px;
  font-family: "Red Hat Display", Arial, sans-serif;
  line-height: 1.55;
}

/* ===== Tablet / mobile ===== */
@media (max-width: 1020px) {
  .evaluation-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(300px, .82fr);
    gap: 28px;
  }

  .scale-control {
    grid-template-columns: minmax(82px, 100px) minmax(300px, 1fr) minmax(82px, 100px);
    gap: 8px;
  }

  .semantic-question .scale-control {
    grid-template-columns: minmax(145px, 1fr) auto minmax(145px, 1fr);
    column-gap: 20px;
  }

  .semantic-question .scale-options {
    grid-template-columns: repeat(7, 54px);
    gap: 10px;
  }

  .semantic-question .scale-choice {
    width: 54px;
    height: 54px;
  }

  .semantic-question .choice-circle {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 820px) {
  #jspsych-content {
    width: 100%;
    margin: 0 auto 52px;
  }

  .evaluation-shell {
    width: 100%;
  }

  .evaluation-grid {
    display: block;
    max-width: 100%;
  }

  .stimulus-column,
  .evaluation-status {
    display: none;
  }

  /* The actual photo stays visible at the top throughout answering. */
  .mobile-stimulus-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: block;
    width: 100%;
    background: rgba(255, 255, 255, .965);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 3px 14px rgba(16, 24, 40, .055);
    backdrop-filter: blur(10px);
  }

  .mobile-stimulus-button {
    width: 100%;
    min-height: 98px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 7px 18px 7px 16px;
    text-align: left;
    cursor: zoom-in;
  }

  .mobile-stimulus-button img {
    flex: 0 0 auto;
    width: 49px;
    height: 86px;
    object-fit: contain;
    border-radius: 4px;
    filter: drop-shadow(0 3px 6px rgba(16, 24, 40, .08));
  }

  .mobile-stimulus-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-soft);
    line-height: 1.25;
  }

  .mobile-stimulus-copy strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
  }

  .mobile-stimulus-copy > span {
    font-size: 13px;
    font-weight: 400;
  }

  .mobile-stimulus-copy small {
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 500;
  }

  .question-column {
    width: min(100%, 760px);
    margin: 0 auto;
  }

  .section-intro {
    padding: 21px 22px 19px;
  }

  .section-intro h2 {
    font-size: 18px;
    line-height: 1.34;
  }

  .section-intro p {
    font-size: 13px;
  }

  .scale-question {
    min-height: 198px;
    padding: 22px 22px 21px;
    scroll-margin-top: 112px;
  }

  .statement-text {
    margin-bottom: 17px;
    font-size: 17px;
    line-height: 1.34;
    font-weight: 600;
  }

  /* 16P-like mobile arrangement: circles on one row, endpoint labels below. */
  .scale-control,
  .semantic-question .scale-control {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "options options"
      "left right";
    gap: 8px 12px;
  }

  .scale-options,
  .semantic-question .scale-options {
    grid-area: options;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
  }

  .semantic-question .scale-choice {
    flex: none;
  }

  .endpoint-left {
    grid-area: left;
    text-align: left;
  }

  .endpoint-right {
    grid-area: right;
    text-align: right;
  }

  .endpoint-label {
    font-size: 13px;
    line-height: 1.18;
    font-weight: 400;
  }

  .scale-choice {
    width: 54px;
    height: 54px;
  }

  .choice-circle {
    width: 48px;
    height: 48px;
  }

  .choice-number {
    font-size: 13.5px;
  }


  .completion-note {
    margin-left: 22px;
    margin-right: 22px;
  }

  form > .jspsych-btn,
  form > input.jspsych-btn {
    margin-left: 22px;
    margin-top: 24px;
  }

  .stimulus-intro {
    padding: 26px 20px 24px;
    margin: 0 auto;
  }

  .stimulus-intro h1 {
    font-size: 24px;
    line-height: 1.22;
  }

  .stimulus-intro p {
    font-size: 16px;
    line-height: 1.52;
  }

  .intro-stimulus-image {
    max-width: min(500px, 94vw);
    max-height: 61vh;
  }

  .survey-card {
    max-width: calc(100% - 28px);
    margin: 28px auto;
    padding: 30px 24px;
    border-radius: 14px;
  }

  .welcome-card h1 {
    font-size: 31px;
  }

  .welcome-card p {
    font-size: 16px;
  }

  .choice-list {
    grid-template-columns: 1fr;
  }

  .final-validity-question .scale-control {
    max-width: none;
  }
}

@media (max-width: 430px) {
  .mobile-stimulus-button {
    min-height: 92px;
    padding-left: 13px;
    padding-right: 13px;
  }

  .mobile-stimulus-button img {
    width: 45px;
    height: 80px;
  }

  .scale-question {
    min-height: 194px;
    padding-left: 16px;
    padding-right: 16px;
  }

  .section-intro {
    padding-left: 16px;
    padding-right: 16px;
  }

  .statement-text {
    font-size: 16.5px;
  }

  .scale-choice {
    width: 50px;
    height: 50px;
  }

  .choice-circle {
    width: 44px;
    height: 44px;
  }

  .choice-number {
    font-size: 12px;
  }

  .endpoint-label {
    font-size: 12.5px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
  }
}

/* Final ecological-validity selection uses the same grey selected state. */
.final-validity-question .scale-choice input:checked + .choice-circle {
  background: #98a2b3;
  border-color: #98a2b3;
  box-shadow: none;
}

.final-validity-question .scale-choice input:checked ~ .choice-number {
  color: #fff;
}

#jspsych-html-button-response-btngroup {
  text-align: center;
  margin-top: 12px;
}

form > .jspsych-btn,
form > input.jspsych-btn {
  margin: 24px 12px 10px;
}


/* ==========================================================
   Semantic differential alignment patch
   Keep the exact same 1–7 geometry as the trait questions.
   Only the endpoint words differ.
   ========================================================== */
@media (min-width: 1021px) {
  .semantic-question .scale-control {
    grid-template-columns: minmax(92px, 116px) minmax(320px, 1fr) minmax(92px, 116px);
    gap: 12px;
  }

  .semantic-question .scale-options {
    width: 100%;
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: clamp(4px, .75vw, 11px);
    justify-items: center;
  }

  .semantic-question .scale-choice {
    width: 62px;
    height: 62px;
  }

  .semantic-question .choice-circle {
    width: 52px;
    height: 52px;
  }

  .semantic-question .endpoint-label {
    width: max-content;
    white-space: nowrap;
    font-size: 13.5px;
  }

  .semantic-question .endpoint-left {
    justify-self: end;
    text-align: right;
  }

  .semantic-question .endpoint-right {
    justify-self: start;
    text-align: left;
  }
}

@media (min-width: 821px) and (max-width: 1020px) {
  .semantic-question .scale-control {
    grid-template-columns: minmax(82px, 100px) minmax(300px, 1fr) minmax(82px, 100px);
    gap: 8px;
  }

  .semantic-question .scale-options {
    width: 100%;
    grid-template-columns: repeat(7, minmax(42px, 1fr));
    gap: clamp(4px, .75vw, 11px);
    justify-items: center;
  }

  .semantic-question .scale-choice {
    width: 62px;
    height: 62px;
  }

  .semantic-question .choice-circle {
    width: 52px;
    height: 52px;
  }

  .semantic-question .endpoint-label {
    width: max-content;
    white-space: nowrap;
    font-size: 13.5px;
  }

  .semantic-question .endpoint-left {
    justify-self: end;
    text-align: right;
  }

  .semantic-question .endpoint-right {
    justify-self: start;
    text-align: left;
  }
}
