:root {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-muted: #555555;
  --color-accent: #2563eb;
  --color-border: #d4d4d4;
  --font-size-base: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: var(--font-size-base);
  line-height: 1.5;
}

#placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 2rem;
}

#jspsych-target {
  max-width: 900px;
  margin: 0 auto;
}

button {
  font-size: 1rem;
  font-family: inherit;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-accent);
  color: #ffffff;
  cursor: pointer;
}

button:disabled {
  background: var(--color-border);
  color: var(--color-muted);
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

p {
  max-width: 640px;
  margin: 0 auto 1rem auto;
}

/* IAT trial layout: category labels pinned to top corners, stimulus centered. */
.iat-trial {
  position: relative;
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iat-label {
  position: fixed;
  top: 1.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  line-height: 1.3;
  color: var(--color-text);
}

.iat-label-left {
  left: 1.5rem;
  text-align: left;
}

.iat-label-right {
  right: 1.5rem;
  text-align: right;
}

.iat-key {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-accent);
  margin-bottom: 0.2rem;
}

/* Two category families, colour-coded so language vs valence stay distinct in the stacked
   combined-block labels. Colour is never the only signal: the active family is also brighter
   (the inactive one is dimmed per trial) and the text itself names the category. */
.iat-family-target {
  color: #0f766e;
}
.iat-family-attribute {
  color: #b45309;
}

/* The family NOT being judged on this trial (audio trial dims valence, word trial dims
   language), so the participant sees at a glance which rule is live. */
.iat-label-dim {
  opacity: 0.28;
}

/* Separator between the two stacked categories on one key, so they do not read as one label. */
.iat-label-sep {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-muted);
  margin: 0.1rem 0;
}

.iat-center {
  text-align: center;
}

/* Per-trial rule reminder under the word stimulus (audio trials carry their own listen/respond
   cue instead). */
.iat-rule-hint {
  margin-top: 0.75rem;
  font-size: 1.1rem;
  color: var(--color-muted);
}

/* Block counter at the top of each IAT instruction screen. */
.iat-progress {
  font-weight: 700;
  color: var(--color-muted);
  margin-bottom: 0.5rem;
}

.iat-stimulus-word {
  font-size: 2.5rem;
  font-weight: 600;
}

/* Audio-trial center cue: "listening" while the clip plays, "respond" once it ends. The pulse
   makes clear the screen is active (not frozen) while early key presses are being rejected. */
.iat-audio-listening {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--color-muted);
  animation: iat-pulse 1.2s ease-in-out infinite;
}

.iat-audio-respond {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--color-text);
}

/* Early key press (before the clip ends): emphasise the wait cue in amber so the ignored press
   is visibly acknowledged. */
.iat-audio-wait {
  color: #b45309;
  animation: iat-wait-flash 0.3s ease-in-out 2;
}

@keyframes iat-wait-flash {
  50% {
    transform: scale(1.08);
  }
}

@keyframes iat-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.iat-error-x {
  margin-top: 1rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: #dc2626;
}

.iat-instructions {
  max-width: 640px;
  margin: 0 auto;
  padding-top: 3rem;
}

.iat-instructions p {
  text-align: left;
}

/* Visual E/I category map on instruction screens: two sides, each showing the key badge and the
   categories on that key this block, colour-coded by family. */
.iat-instr-map {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.iat-instr-side {
  flex: 1;
  max-width: 260px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1.4;
}

.iat-instr-key {
  margin-bottom: 0.5rem;
  color: var(--color-muted);
  font-size: 0.95rem;
}

.iat-instr-key .iat-key {
  display: inline;
  font-size: 1.5rem;
}

.iat-continue-prompt {
  font-weight: 700;
  margin-top: 1.5rem;
  text-align: center;
}

/* Generic vanilla screens: consent, eligibility, gates, demographics, behavioral choice,
   completion, dead ends. */
.screen {
  max-width: 720px;
  margin: 3.5rem auto 2.5rem auto;
  padding: 0 1.5rem;
}

.screen-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

button.secondary {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.completion-code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem auto;
  padding: 1.5rem;
  max-width: 480px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #f6f8fc;
}

.completion-code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', Menlo, monospace;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--color-accent);
  word-break: break-all;
  user-select: all;
}

.consent-checkbox {
  display: block;
  margin: 1.5rem auto;
  max-width: 640px;
  text-align: left;
}

.consent-checkbox input {
  margin-right: 0.5rem;
}

.app-form {
  max-width: 640px;
  margin: 0 auto;
  text-align: left;
}

.form-field {
  margin-bottom: 1.25rem;
}

.form-field label,
.form-field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-field select,
.form-field input[type='number'] {
  font-size: 1rem;
  font-family: inherit;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 320px;
}

.radio-option {
  display: inline-block;
  font-weight: 400;
  margin-right: 1.5rem;
}

.radio-option input {
  margin-right: 0.4rem;
}

.screen-keytest-prompt {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
}

.sd-error-text {
  color: #dc2626;
  font-weight: 600;
}

/* SD-II video + rating page. */
.sd-progress {
  font-weight: 700;
  color: var(--color-muted);
  margin: 0 auto 0.75rem auto;
  max-width: 640px;
}

/* Live "X of 15 filled" count by the Lanjut button, so a disabled button never looks frozen. */
.sd-rating-count {
  align-self: center;
  color: var(--color-muted);
  font-size: 0.95rem;
}
.sd-rating-count-done {
  color: #15803d;
  font-weight: 600;
}

.sd-video-wrap {
  max-width: 640px;
  margin: 0 auto 1rem auto;
}

.sd-video {
  width: 100%;
  height: auto;
  background: #000;
  border-radius: 8px;
}

.sd-rating-form {
  max-width: 720px;
  margin: 1.5rem auto 0 auto;
  text-align: left;
}

.sd-rating-hidden {
  display: none;
}

.sd-rating-table {
  margin-top: 1rem;
}

.sd-rating-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.5rem;
}

.sd-rating-row:nth-child(odd) {
  background: #f5f5f5;
}

.sd-endpoint-label {
  font-weight: 600;
  font-size: 0.95rem;
}

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

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

.sd-scale {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.sd-scale-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: #ffffff;
}

.sd-scale-btn.selected {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

/* Blocking busy overlay during API waits (assign, checkpoint, complete). */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.busy-box {
  text-align: center;
}

.busy-spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 1rem auto;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: busy-spin 0.9s linear infinite;
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}
