/* =====================================================================
   Switch Cost Test — demo-specific styles.
   Inherits tokens + base from ../styles.css.

   Desktop-first: almost everyone runs this on a laptop, so the default
   layout is a centred square grid at comfortable eye distance with the
   F / J keys as the primary response affordance. The buttons stay
   clickable, but they read as keyboard legends rather than tap slabs.
   The max-width: 620px block at the bottom converts them back into
   thumb targets for the minority opening it on a phone.
   ===================================================================== */

.demo-body { min-height: 100vh; }

.test {
  --test-pad: clamp(1.5rem, 3vw, 3rem);
  max-width: 48rem;
  margin-inline: auto;
  padding: var(--test-pad);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.screen { width: 100%; }

/* Reading screens stay narrower than the shell so the measure holds. */
.screen--intro,
.screen--break { max-width: 40rem; margin-inline: auto; }
.screen--result { max-width: 44rem; margin-inline: auto; }

/* ---- Intro / break / result share these ---- */
.test__title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.5rem, 1rem + 4vw, 3.75rem);
  line-height: 1;
  margin: 0 0 1.25rem;
}
.test__title--sm { font-size: clamp(2rem, 1rem + 2.5vw, 2.75rem); }
.test__lede { font-size: 1.2rem; line-height: 1.5; color: var(--parchment); margin: 0 0 1.75rem; }
.test__fine { font-size: 0.95rem; color: var(--parchment-dim); line-height: 1.55; margin: 1.5rem 0 0; max-width: 56ch; }

.btn--big { font-size: 1.2rem; padding: 1rem 2rem; min-width: 17rem; }
.backlink {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--parchment-dim);
  text-decoration: none;
  font-size: 0.95rem;
}
.backlink:hover { color: var(--gild); }

/* ---- Rule board on the intro ---- */
.ruleboard {
  background: var(--velvet-raised);
  border: 1px solid var(--velvet-edge);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 0 0 1.75rem;
  display: grid;
  gap: 1rem;
}
.ruleboard__row { display: flex; align-items: baseline; gap: 1rem; }
.ruleboard__where {
  flex: 0 0 6.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gild);
}
.ruleboard strong { color: var(--parchment); }
.ruleboard__keys {
  display: flex;
  gap: 2.5rem;
  border-top: 1px solid var(--velvet-edge);
  padding-top: 1rem;
  font-size: 0.98rem;
  color: var(--parchment-dim);
}
.keycap {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--velvet-deep);
  background: var(--parchment-dim);
  border-radius: 4px;
  padding: 0.15em 0.55em;
  margin-right: 0.45em;
}

/* =====================================================================
   The task screen — a centred square board, sized off viewport height
   so the whole trial sits inside one screen with no scrolling.
   ===================================================================== */
/* No min-height here: .test is already a full-height centring shell, and
   adding 100vh on top of its padding is what makes a task screen scroll.
   The board is capped in vh so head + hint + responses still fit on a
   short laptop viewport. */
.screen--task {
  --board: min(54vh, 32rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.task__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  width: var(--board);
}
.task__phase {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--parchment-dim);
  white-space: nowrap;
}
.task__progress { flex: 1; height: 4px; background: var(--velvet-edge); border-radius: 2px; overflow: hidden; }
.task__progress span { display: block; height: 100%; width: 0%; background: var(--gild); transition: width 200ms; }

.task__rulehint {
  text-align: center;
  min-height: 1.5em;
  margin: 1.1rem 0 0.6rem;
  color: var(--gild);
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

/* 2×2 grid with the stimulus painted into the active quadrant */
.quadgrid {
  position: relative;
  width: var(--board);
  height: var(--board);
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
}
.qcell {
  position: relative;
  border: 1px solid var(--velvet-edge);
  border-radius: 10px;
  background: var(--velvet-raised);
}
.qcell.is-active { border-color: var(--gild); background: #33202b; }
.qedge {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--parchment-fant);
}
.qedge--top { top: 0.6rem; }
.qedge--bottom { bottom: 0.6rem; }

.stimulus {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--board) * 0.17);
  font-weight: 600;
  color: var(--parchment);
  width: 50%;
  height: 50%;
  pointer-events: none;
  opacity: 0;
}
.stimulus.is-on { opacity: 1; }
/* quadrant positions: 0=TL 1=TR 2=BR 3=BL */
.stimulus[data-pos="0"] { left: 0; top: 0; }
.stimulus[data-pos="1"] { left: 50%; top: 0; }
.stimulus[data-pos="2"] { left: 50%; top: 50%; }
.stimulus[data-pos="3"] { left: 0; top: 50%; }

/* Response controls — on a laptop these are keyboard legends that
   happen to be clickable, so they stay low and wide under the board. */
.responses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: var(--board);
  margin-top: 1.25rem;
}
.response {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 4.25rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--velvet-edge);
  background: var(--velvet-raised);
  transition: transform 80ms, background 120ms, border-color 120ms;
}
.response:active { transform: scale(0.98); }
.response--left { border-bottom: 4px solid var(--gild); }
.response--right { border-bottom: 4px solid var(--evidence); }
.response.is-hit { background: #33202b; }
.response.is-error { background: #4a1f22; border-color: #d8623f; }
.response__key {
  flex: 0 0 auto;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--parchment);
  border: 1px solid var(--velvet-edge);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 0.2em 0.65em;
  background: var(--velvet-deep);
}
/* Both of a key's meanings sit on one line on desktop, stacked on mobile. */
.response__label { display: flex; align-items: baseline; font-weight: 600; line-height: 1.2; }
.response__opt + .response__opt::before {
  content: "·";
  color: var(--parchment-fant);
  margin: 0 0.45em;
  font-weight: 400;
}

/* =====================================================================
   Result
   ===================================================================== */
.resultcard {
  background: var(--velvet-deep);
  border: 1px solid var(--velvet-edge);
  border-radius: 16px;
  padding: clamp(1.5rem, 3vw, 2.25rem);
}
.resultcard .eyebrow { margin-bottom: 0.5rem; }
.resultcard__big {
  font-size: clamp(4rem, 1rem + 9vw, 6.5rem);
  font-weight: 600;
  line-height: 0.95;
  color: var(--evidence);
  margin: 0;
}
.resultcard__unit { font-size: 0.28em; color: var(--parchment-dim); margin-left: 0.2em; }
.resultcard__read { color: var(--parchment); margin: 0.75rem 0 1.5rem; font-size: 1.08rem; line-height: 1.45; max-width: 58ch; }

.resultgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--velvet-raised);
  border: 1px solid var(--velvet-edge);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stat--cold { border-color: rgba(87,201,221,0.4); }
.stat__label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--parchment-dim); }
.stat__val { font-size: 2.1rem; font-weight: 600; }
.stat--cold .stat__val { color: var(--evidence); }
.stat__sub { font-size: 0.8rem; color: var(--parchment-dim); }

.resultcard__legend { font-size: 0.8rem; color: var(--parchment-dim); margin: 0.75rem 0 0.5rem; }
.resultcard__lapse { font-size: 0.8rem; color: var(--parchment-fant); margin: 0 0 0.5rem; }
.resultcard__brand { font-size: 0.75rem; color: var(--parchment-fant); letter-spacing: 0.1em; text-align: right; margin: 0.5rem 0 0; }

.result__actions { display: flex; gap: 0.75rem; margin: 1.5rem 0 0; }
.result__actions .btn { text-align: center; text-decoration: none; }

/* =====================================================================
   Phones — restore the thumb-height tap targets.
   ===================================================================== */
@media (max-width: 620px) {
  .demo-body { min-height: 100svh; }
  .test {
    --test-pad: clamp(1.25rem, 5vw, 2rem);
    max-width: none;
    min-height: 100svh;
  }
  .test__title { font-size: clamp(2.25rem, 1rem + 7vw, 3rem); }
  .test__lede { font-size: 1.1rem; }
  .btn--big { width: 100%; min-width: 0; }

  .ruleboard__row { flex-direction: column; gap: 0.25rem; }
  .ruleboard__where { flex: none; }
  .ruleboard__keys { flex-direction: column; gap: 0.5rem; }

  /* Here the screen does claim the full height, minus the shell padding,
     so the response row can sit at thumb height against the bottom. */
  .screen--task {
    --board: min(92vw, 46vh);
    min-height: calc(100svh - var(--test-pad) * 2);
    justify-content: flex-start;
  }
  .task__head { width: 100%; }
  .quadgrid { margin-top: auto; }

  /* Big, stacked, thumb height, hard against the bottom edge. */
  .responses {
    width: 100%;
    margin-top: auto;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .response {
    flex-direction: column;
    gap: 0.35rem;
    min-height: clamp(90px, 16vh, 130px);
    border-radius: 14px;
  }
  .response__key {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--parchment-dim);
    border-bottom-width: 1px;
    background: none;
  }
  .response__label { flex-direction: column; align-items: center; }
  .response__opt + .response__opt::before { content: none; }

  .resultgrid { gap: 0.75rem; }
  .stat__val { font-size: 1.9rem; }
  .result__actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .task__progress span, .response, .stimulus { transition: none; }
}
