/*
 * Brightness Perception Experiment styles.
 *
 * During the study the page is a uniform grey (--bg-grey, set from config)
 * and instruction screens deliberately have no cards or coloured surfaces, so
 * the participant's light adaptation stays constant. Colour is only used on
 * the results screen, after all brightness judgements are finished.
 */

:root {
  --bg-grey: rgb(145, 145, 145);
  --ink: #111;
  --ink-soft: #2b2b2b;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --word-size: 28px;
}

html,
body {
  margin: 0;
  background: var(--bg-grey);
  color: var(--ink);
  font-family: var(--font);
}

.jspsych-display-element {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
}

.jspsych-content {
  max-width: 760px;
  padding: 0 16px;
}

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

.panel h1 {
  font-size: 32px;
  line-height: 1.2;
  margin: 0.3em 0;
}

.panel h2 {
  font-size: 24px;
  margin: 0 0 0.5em;
}

.panel p,
.panel li {
  color: var(--ink-soft);
}

.lede {
  font-size: 20px;
}

.muted {
  color: var(--ink-soft);
  opacity: 0.85;
}

.badge {
  font-size: 14px;
  font-style: italic;
}

.facts {
  display: flex;
  gap: 32px;
  padding: 0;
  margin: 1.2em 0;
  list-style: none;
}

.facts li {
  display: flex;
  flex-direction: column;
}

.facts strong {
  font-size: 22px;
  color: var(--ink);
}

.facts span {
  font-size: 14px;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 8px;
  font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  color: var(--ink);
  /* Transparent so key hints never add a bright patch next to the probe. */
  background: transparent;
  border: 1.5px solid var(--ink);
  border-bottom-width: 3px;
  border-radius: 6px;
}

.key-legend {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 16px 0 0;
  font-size: 16px;
}

.key-legend.subtle {
  margin-top: 6px;
  opacity: 0.8;
  font-size: 14px;
}

.swatch {
  width: var(--size, 200px);
  height: var(--size, 200px);
  margin: 16px auto;
}

.sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 24px 0;
}

.sequence .frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  border: 1.5px dashed rgba(0, 0, 0, 0.45);
  border-radius: 8px;
}

.sequence .frame .swatch {
  margin: 4px auto;
}

.sequence small {
  font-size: 12px;
  margin-top: 4px;
}

.sequence .fx {
  font-size: 32px;
}

.sequence .w {
  font-size: 18px;
}

.jspsych-btn {
  font-family: var(--font);
  font-size: 16px;
  padding: 10px 20px;
  margin: 16px 6px 0;
  border-radius: 8px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
}

.jspsych-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.jspsych-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

#jspsych-progressbar-container {
  background: transparent;
  border-bottom: none;
}

#jspsych-progressbar-outer {
  background: rgba(0, 0, 0, 0.12);
  border: none;
  height: 6px;
  border-radius: 3px;
}

#jspsych-progressbar-inner {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  transition: width 300ms ease;
}

/* ---------- trial (word-probe plugin) ---------- */

.wp-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Fixed-size slot so nothing shifts between fixation, word and probe. */
.wp-slot {
  display: grid;
  place-items: center;
  width: var(--probe-size);
  height: var(--probe-size);
}

.wp-slot > * {
  grid-area: 1 / 1;
}

.wp-fixation {
  font-size: 48px;
  line-height: 1;
}

.wp-word,
.valence-word {
  font-size: var(--word-size);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.valence-word {
  margin: 80px 0 40px;
}

.wp-probe {
  width: 100%;
  height: 100%;
}

.wp-feedback {
  font-size: 26px;
  font-weight: 700;
}

.wp-feedback.is-correct {
  color: #0b3d0b;
}

.wp-feedback.is-incorrect {
  color: #5a0c0c;
}

.wp-prompt {
  min-height: 60px;
}

/* ---------- results screen ----------
   Laid out like a short paper, matching the project page. */

body.results-mode {
  color-scheme: light;
  --paper: #fffff8;
  --ink: #111;
  --ink-2: #444;
  --rule: #ccc;
  --faint: #e8e6dc;
  --link: #1a4b8c;
  --red: #a4161a;
  background: var(--paper);
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.results-mode {
    color-scheme: dark;
    --paper: #151515; --ink: #ddd; --ink-2: #aaa; --rule: #444; --faint: #262626; --link: #8fb4e8; --red: #e5675b;
  }
}
:root[data-theme="dark"] body.results-mode {
  color-scheme: dark;
  --paper: #151515; --ink: #ddd; --ink-2: #aaa; --rule: #444; --faint: #262626; --link: #8fb4e8; --red: #e5675b;
}

body.results-mode .jspsych-content-wrapper,
body.results-mode .jspsych-content {
  display: block;
  max-width: none;
  padding: 0;
  margin: 0;
  height: auto;
}

.results {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 16px 64px;
  text-align: left;
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
}
.results .note { font-style: italic; color: var(--ink-2); font-size: 0.85em; margin: 0 0 1.5em; }
.results h1 { font-size: 2em; font-weight: 400; line-height: 1.15; margin: 0 0 0.6em; }
.results h2 { font-size: 1.2em; font-weight: 400; font-style: italic; margin: 2em 0 0.5em; }
.results p { margin: 0 0 1em; }
.results a { color: var(--link); }
.results .code { font-family: "Source Code Pro", Menlo, Consolas, monospace; font-size: 0.8em; }

.results figure { margin: 1.6em 0; }
.results figcaption { font-size: 0.8em; line-height: 1.45; color: var(--ink-2); margin-top: 0.7em; }
.results figcaption b { color: var(--ink); font-weight: 600; }

.reveal { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; padding: 28px 16px; background: var(--bg-grey); color: #111; font-family: Arial, Helvetica, sans-serif; }
.reveal div { display: grid; justify-items: center; gap: 8px; font-size: 18px; }
.reveal .swatch { --size: 88px; }

.chart { width: 100%; height: auto; display: block; }
.chart text { font: 12px "Source Serif 4", Georgia, serif; fill: var(--ink-2); font-variant-numeric: lining-nums; }
.chart .base { stroke: var(--ink); }
.chart .ref { stroke: var(--red); stroke-dasharray: 3 3; }
.chart .bar { fill: var(--ink-2); }
.chart .value { fill: var(--ink); }

.results table { width: 100%; border-collapse: collapse; font-size: 0.8em; font-variant-numeric: lining-nums tabular-nums; }
.results thead th { border-top: 1.5px solid var(--ink); border-bottom: 1px solid var(--ink); font-weight: 600; padding: 5px 8px; text-align: right; }
.results td, .results tbody th { padding: 4px 8px; text-align: right; font-weight: 400; }
.results th:first-child { text-align: left; }
.results tbody tr:last-child > * { border-bottom: 1.5px solid var(--ink); }
.results td.diag { font-weight: 600; }

.results .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 2em; }
.results .btn {
  font: 0.85em "Source Serif 4", Georgia, serif; color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink-2); padding: 5px 14px; text-decoration: none; cursor: pointer; border-radius: 0;
}
.results .btn:hover { background: var(--faint); }
.results .btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
