/* =========================================================================
   실험 화면 스타일
   원칙 : 조건 간 시각적 차이를 최소화한다.
          설명 제시군과 미제시군의 레이아웃·서체·여백이 달라 보이면
          그 자체가 조작 신호로 읽혀 요구특성을 만든다.
   ========================================================================= */

:root {
  --ink:        #1b1d21;
  --ink-soft:   #4a4f57;
  --ink-faint:  #767c86;
  --line:       #dfe2e7;
  --bg:         #f4f5f7;
  --card:       #ffffff;
  --accent:     #2f5d9e;
  --accent-bg:  #eef3fb;
  --warn:       #9a6410;
  --warn-bg:    #fdf4e3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo",
               "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- 뼈대 */

.topbar {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.topbar-meta  { font-size: 12.5px; color: var(--ink-faint); }

#jspsych-target {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px 128px;   /* 고정 푸터(세 줄)에 가리지 않게 */
}

.footbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--card);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-faint);
}
.footbar a { color: var(--accent); }

/* ------------------------------------------------------ jsPsych 기본 재정의 */

.jspsych-display-element { font-size: 16px; }
.jspsych-content { max-width: 100%; margin: 0; text-align: left; }
.jspsych-content-wrapper { justify-content: flex-start; }

.jspsych-btn {
  display: inline-block;
  padding: 11px 22px;
  margin: 0 8px 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.jspsych-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.jspsych-btn:disabled, .jspsych-btn:disabled:hover {
  border-color: var(--line); background: #eef0f3; color: #a3a8b0; cursor: not-allowed; }

#jspsych-html-button-response-btngroup,
#jspsych-survey-multi-choice-form { margin-top: 8px; }

/* ------------------------------------------------------------ 자극 카드 */

.stim {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 22px 18px;
  margin-bottom: 22px;
}

.stim-block { padding: 16px 0; border-bottom: 1px dashed var(--line); }
.stim-block:last-child { border-bottom: none; }
.stim-block p { margin: 8px 0 0; }

.stim-block.q p { font-weight: 600; }
.stim-block.a p { font-size: 17px; }
.stim-block.e p { color: var(--ink-soft); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tag.ai   { background: var(--accent-bg); color: var(--accent); }
.tag.exp  { background: var(--accent-bg); color: var(--accent); }
.tag.warn { background: var(--warn-bg);   color: var(--warn); }

.q-prompt {
  margin: 0 0 12px;
  font-weight: 600;
  font-size: 16.5px;
}
.q-prompt .anchor {
  display: block;
  margin-top: 2px;
  font-weight: 400;
  font-size: 13.5px;
  color: var(--ink-faint);
}

/* --------------------------------------------------------------- 문서 화면 */

.doc { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; }
.doc h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -0.01em; }
.doc-sub { margin: 0 0 18px; color: var(--ink-faint); font-size: 14px; }
.doc dl { margin: 0; }
.doc dt { margin-top: 16px; font-weight: 700; font-size: 14px; color: var(--accent); }
.doc dd { margin: 4px 0 0; }
.doc dd p { margin: 0 0 8px; }
.doc dd p:last-child { margin-bottom: 0; }
.doc-lead { margin: 0 0 6px; }
.doc-ver { margin: 18px 0 0; color: var(--ink-faint); font-size: 13px; }

/* 동의서 문항(약관식). 항목마다 확인란을 두고 맨 위에 「모두 동의」를 둔다. */
.consent-clauses { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.consent-clauses h3 { margin: 0 0 4px; font-size: 17px; }
.consent-guide { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }
.consent-all { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  font-weight: 700; background: var(--accent-bg); border: 1px solid var(--line); border-radius: 8px; }
.consent-list { list-style: none; margin: 8px 0 0; padding: 0; }
.consent-list li { border-bottom: 1px solid var(--line); }
.consent-list li:last-child { border-bottom: 0; }
.consent-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; cursor: pointer; font-size: 15px; }
.consent-all input, .consent-item input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.consent-item input { margin-top: 4px; }
.consent-item .req { color: var(--accent); font-weight: 700; font-size: 13px; }
.consent-hint { margin: 10px 0 0; color: var(--warn); font-size: 13.5px; }
.consent-hint[hidden] { display: none; }
.consent-list-text { margin: 8px 0 0; padding-left: 22px; }
.consent-list-text li { margin-bottom: 6px; }

/* 동의 화면의 설명문 사본 도구. 선택 버튼(.jspsych-btn)과 구별되도록 작은 글자 버튼으로 둔다. */
.doc-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 8px; margin: 10px 0 4px; font-size: 13.5px; color: var(--ink-faint); }
.doc-tools-note { margin-right: auto; }
.doc-tool-btn { font: inherit; font-size: 13.5px; padding: 5px 12px; cursor: pointer;
  color: var(--accent); background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.doc-tool-btn:hover, .doc-tool-btn:focus-visible { border-color: var(--accent); background: var(--accent-bg); }
.bullets { margin: 12px 0 0; padding-left: 20px; }
.bullets li { margin-bottom: 6px; }

.callout {
  margin-top: 20px; padding: 14px 18px;
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.callout p { margin: 0 0 6px; }
.callout p:last-child { margin-bottom: 0; }

.lead { font-size: 18px; font-weight: 600; }
.code { margin-top: 10px !important; padding: 10px 14px; background: #fff;
  border: 1px dashed var(--accent); border-radius: 8px; font-size: 17px; letter-spacing: 0.03em; }
.endmsg { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px 28px; }

/* ------------------------------------------------------------- 문항 진행 표시 */

.item-counter {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- 슬라이더 */

.conf-wrap { display: flex; align-items: center; gap: 12px; margin: 4px 0 -6px; }

.conf-readout {
  display: inline-block;
  min-width: 3.4em;
  padding: 3px 12px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 21px;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
}
.conf-readout.on { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.conf-hint { font-size: 13px; color: var(--ink-faint); }
/* 점수가 표시되면 안내 문구는 감춘다 */
.conf-readout.on + .conf-hint { visibility: hidden; }

.jspsych-html-slider-response-container { max-width: 100% !important; margin: 14px 0 8px; }
.jspsych-html-slider-response-container span { font-size: 13px; color: var(--ink-faint); }

/* 손잡이를 직접 그린다. 기본 렌더링에서는 손잡이를 숨길 수 없기 때문이다.
   ([06] 측정문항전문의 "초기값 미지정" 요건 구현) */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; background: var(--line);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px; margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .28);
  transition: opacity .12s;
}
input[type="range"]::-moz-range-track {
  height: 6px; border-radius: 999px; background: var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .28);
  transition: opacity .12s;
}
.slider-untouched input[type="range"]::-webkit-slider-thumb { opacity: 0; }
.slider-untouched input[type="range"]::-moz-range-thumb { opacity: 0; }

/* 키보드 접근성 */
input[type="range"]:focus-visible,
.jspsych-btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* 경고형 콜아웃 */
.callout.warn { background: var(--warn-bg); border-left-color: var(--warn); }

/* ------------------------------------------------------------ 인구통계 문항 */

.jspsych-survey-multi-choice-question {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 12px;
}
.jspsych-survey-multi-choice-text { font-weight: 600; }
.jspsych-survey-multi-choice-option { margin: 6px 0; }

/* ------------------------------------------------------------------ 반응형 */

@media (max-width: 560px) {
  body { font-size: 15px; }
  #jspsych-target { padding: 18px 14px 104px; }
  .stim { padding: 4px 16px 14px; }
  .doc  { padding: 20px 18px; }
  .jspsych-btn { display: block; width: 100%; margin: 0 0 8px; }
  /* 손가락으로 끌 수 있도록 손잡이를 키운다 */
  input[type="range"]::-webkit-slider-thumb { width: 32px; height: 32px; margin-top: -13px; }
  input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; }
  .conf-wrap { flex-wrap: wrap; gap: 8px; }
}

/* 캡처용 미리보기에서는 고정 푸터를 숨긴다. */
body.preview-mode .footbar { display: none; }

/* 인쇄 : 동의 화면의 「설명문 인쇄」는 설명문 블록만 남긴다(머리·꼬리 띠, 사본 도구, 동의 버튼 제외). */
@media print {
  body { background: #fff; }
  .topbar, .footbar, .doc-tools,
  #jspsych-html-button-response-btngroup { display: none !important; }
  #jspsych-target { max-width: none; padding: 0; }
  .doc { border: 0; border-radius: 0; padding: 0; }
  /* 동의서 문항은 확인 상태 없이 문안만 인쇄한다. */
  .consent-all, .consent-guide, .consent-hint, .consent-item input, .consent-item .req { display: none !important; }
  .consent-item { padding: 4px 0; }
}
