/* Widget 57: the challenge game ({{CHALLENGE:id}}, inc/challenge.php, assets/js/challenge.js).
   Without JavaScript the reader sees every chat with its answer in a toggle; while playing, the
   static list hides and one phone-style chat shows at a time. "Me" bubbles use the deep brand pink
   (#c91c42) so white text stays readable in both themes. */

.hc-ch {
  --ch-me-bg: #c91c42;
  --ch-me-fg: #ffffff;
  --ch-them-bg: #ece9e6;
  --ch-them-fg: #12151a;
  --ch-screen: #faf8f6;
  --ch-right: #2e8b57;
  --ch-wrong: #c91c42;
}

:root[data-theme="dark"] .hc-ch {
  --ch-them-bg: #2c3038;
  --ch-them-fg: #eef0f4;
  --ch-screen: #1b1e24;
  --ch-right: #3dbe8b;
  --ch-wrong: #fe6e7c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hc-ch {
    --ch-them-bg: #2c3038;
    --ch-them-fg: #eef0f4;
    --ch-screen: #1b1e24;
    --ch-right: #3dbe8b;
    --ch-wrong: #fe6e7c;
  }
}

.hc-prose .hc-ch .hc-ch__intro {
  margin: 0 0 16px;
  color: var(--hc-muted);
  font-size: 16px;
}

/* static, readable version (no JavaScript, crawlers) */
.hc-ch .hc-ch__rounds {
  margin: 0;
  padding: 0;
  list-style: none;
}
.hc-ch .hc-ch__round {
  margin: 0 0 20px;
}
.hc-ch .hc-ch__who {
  margin: 0 0 6px;
  font-weight: 600;
}
.hc-ch .hc-ch__answer {
  margin-top: 8px;
  font-size: 15px;
  color: var(--hc-muted);
}
.hc-ch .hc-ch__answer summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--hc-text);
}
.hc-ch .hc-ch__composite {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--hc-muted);
}

/* while playing */
.hc-ch.is-playing .hc-ch__rounds,
.hc-ch.is-playing .hc-ch__end {
  display: none;
}

.hc-ch .hc-ch__progress {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--hc-muted);
}

.hc-ch .hc-ch__screen {
  max-width: 420px;
  margin: 0 auto;
  border: 1px solid var(--hc-line);
  border-radius: 22px;
  background: var(--ch-screen);
  overflow: hidden;
}

.hc-ch .hc-ch__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hc-line);
  font-weight: 600;
}

.hc-ch .hc-ch__avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ch-them-bg);
  color: var(--ch-them-fg);
  font-size: 14px;
}

.hc-ch .hc-ch__chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 14px;
  list-style: none;
}

.hc-ch .hc-ch__msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.45;
  transition: box-shadow 0.2s ease;
}

.hc-ch .hc-ch__msg--them {
  align-self: flex-start;
  background: var(--ch-them-bg);
  color: var(--ch-them-fg);
  border-bottom-left-radius: 6px;
}
.hc-ch .hc-ch__msg--me {
  align-self: flex-end;
  background: var(--ch-me-bg);
  color: var(--ch-me-fg);
  border-bottom-right-radius: 6px;
}

/* in the readable version the giveaway is marked only inside the answer; while playing, after the pick */
.hc-ch .hc-ch__round .is-tell {
  box-shadow: none;
}
.hc-ch .hc-ch__stage .hc-ch__msg.is-tell {
  box-shadow: 0 0 0 3px var(--hc-brand);
}

.hc-ch .hc-ch__choices {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  max-width: 420px;
  margin: 14px auto 0;
}

.hc-ch .hc-ch__btn {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--hc-line-strong, var(--hc-line));
  border-radius: 12px;
  background: var(--hc-card);
  color: var(--hc-text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.hc-ch .hc-ch__btn:hover:not(:disabled) {
  border-color: var(--hc-brand);
}
.hc-ch .hc-ch__btn:focus-visible {
  outline: 2px solid var(--hc-focus, var(--hc-brand));
  outline-offset: 2px;
}
.hc-ch .hc-ch__btn:disabled {
  cursor: default;
  opacity: 0.55;
}
.hc-ch .hc-ch__btn.is-answer {
  opacity: 1;
  border-color: var(--ch-right);
  box-shadow: inset 0 0 0 1px var(--ch-right);
}
.hc-ch .hc-ch__btn.is-wrong {
  opacity: 1;
  border-color: var(--ch-wrong);
  box-shadow: inset 0 0 0 1px var(--ch-wrong);
}

.hc-ch .hc-ch__reveal {
  max-width: 420px;
  margin: 12px auto 0;
  font-size: 15px;
  line-height: 1.55;
}
.hc-ch .hc-ch__reveal p {
  margin: 0 0 8px;
}
.hc-ch .hc-ch__verdict {
  font-weight: 700;
}
.hc-ch .hc-ch__verdict.is-right {
  color: var(--ch-right);
}
.hc-ch .hc-ch__verdict.is-wrong {
  color: var(--ch-wrong);
}
.hc-ch .hc-ch__hint,
.hc-ch .hc-ch__others {
  color: var(--hc-muted);
  font-size: 14px;
}
.hc-ch .hc-ch__btn--next,
.hc-ch .hc-ch__btn--ghost {
  width: 100%;
  margin-top: 6px;
  background: var(--hc-btn-bg);
  color: var(--hc-btn-fg);
  border-color: transparent;
}

.hc-ch .hc-ch__final {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
}
.hc-ch .hc-ch__end-line {
  margin: 14px 0;
  color: var(--hc-text);
}
.hc-ch .hc-ch__note {
  color: var(--hc-muted);
  font-size: 14px;
}

/* the spread of everyone's scores, the reader's bar marked */
.hc-ch .hc-ch__spread-title {
  margin: 0 0 8px;
  font-weight: 600;
}
.hc-ch .hc-ch__few {
  margin: 0;
  color: var(--hc-muted);
}

.hc-ch .hc-ch__bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hc-ch .hc-ch__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}

.hc-ch .hc-ch__fill {
  width: 100%;
  height: var(--hc-h, 0%);
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: var(--hc-line-strong, #c9c6c2);
}

.hc-ch .hc-ch__col.is-mine .hc-ch__fill {
  background: var(--hc-brand);
}
.hc-ch .hc-ch__you {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--hc-brand);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.hc-ch .hc-ch__results {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--hc-wash, var(--hc-card));
  font-size: 15px;
}
.hc-ch .hc-ch__pct {
  font-size: 12px;
  color: var(--hc-muted);
}
.hc-ch .hc-ch__score {
  font-size: 13px;
  font-weight: 600;
}
.hc-ch .hc-ch__col.is-mine .hc-ch__score {
  color: var(--hc-accent);
}
.hc-ch .hc-ch__better {
  margin: 10px 0 0;
  font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .hc-ch .hc-ch__bars .hc-ch__fill {
    transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .hc-ch .hc-ch__bars:not(.is-in) .hc-ch__fill {
    height: 2px;
  }
  .hc-ch .hc-ch__stage .hc-ch__msg {
    animation: hc-ch-in 0.25s ease both;
    animation-delay: calc(var(--hc-i, 0) * 0.12s);
  }
  @keyframes hc-ch-in {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

@media (max-width: 480px) {
  .hc-ch .hc-ch__choices {
    grid-auto-flow: row;
  }
}
