/* The Principle of Least Surprise — predict-the-output game.
   Read a Ruby expression, guess the result. Ruby keeps matching your intuition;
   the running score is the point. Vanilla JS, no deps, no build. Dark theme. */

#least-surprise-demo {
  --ls-accent: #30d158;                  /* matched / the win — calm green, shared with sibling widgets */
  --ls-muted: rgba(255,255,255,0.42);    /* a miss — neutral, never red */
  font-family: var(--font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
  background: var(--color-bg-elevated, #111111);
  border: 1px solid var(--color-border, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  padding: clamp(16px, 3vw, 26px);
  margin: 2.5rem 0;
  color: var(--color-text-primary, #ffffff);
}

.ls-title { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
.ls-explain {
  font-size: 0.9rem; line-height: 1.55; margin: 8px 0 18px;
  color: var(--color-text-secondary, rgba(255, 255, 255, 0.7));
}

/* the question card */
.ls-card {
  background: var(--color-bg-surface, #1a1a1a);
  border: 1px solid var(--color-border-subtle, rgba(255,255,255,0.08));
  border-radius: 12px; padding: 20px; transition: border-color 0.25s;
}
.ls-card.is-correct { border-color: var(--ls-accent); }
/* a miss is not an error — keep the card neutral, just reveal the answer below */
.ls-prompt {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--color-text-tertiary, rgba(255,255,255,0.42)); margin-bottom: 12px;
}
.ls-expr {
  font-family: var(--font-mono, "SF Mono", Monaco, monospace);
  font-size: 1.35rem; color: #fff; background: #0c0c0f;
  border: 1px solid var(--color-border-subtle, rgba(255,255,255,0.09));
  border-radius: 10px; padding: 22px 18px; overflow-x: auto; white-space: pre;
  text-align: center; letter-spacing: 0.2px;
}
.ls-expr .cmt { color: rgba(255,255,255,0.34); }

/* options */
.ls-options { display: grid; gap: 8px; margin-top: 14px; }
@media (min-width: 520px) { .ls-options { grid-template-columns: 1fr 1fr; } }
.ls-opt {
  position: relative; appearance: none; text-align: left;
  border: 1px solid var(--color-border, rgba(255,255,255,0.14));
  background: rgba(255,255,255,0.02); color: var(--color-text-primary, #fff);
  font: inherit; font-family: var(--font-mono, monospace); font-size: 0.95rem;
  padding: 13px 40px 13px 15px; border-radius: 9px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, opacity 0.15s, transform 0.1s;
}
.ls-opt:hover:not(:disabled) { border-color: rgba(255,255,255,0.42); background: rgba(255,255,255,0.06); }
.ls-opt:active:not(:disabled) { transform: scale(0.99); }
.ls-opt:disabled { cursor: default; }
.ls-opt.is-correct { border-color: var(--ls-accent); background: rgba(48,209,88,0.18); color: #fff; font-weight: 600; }
.ls-opt.is-correct::after {
  content: "\2713"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ls-accent); font-weight: 700; font-size: 1rem;
}
/* the miss you picked: neutral, dimmed, marked — no red, no alarm */
.ls-opt.is-wrong { border-color: var(--color-border, rgba(255,255,255,0.14)); opacity: 0.55; }
.ls-opt.is-wrong::after {
  content: "\2715"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ls-muted); font-weight: 600; font-size: 0.9rem;
}
.ls-opt.is-dim { opacity: 0.32; }

/* revealed note */
.ls-note {
  margin-top: 16px; padding-top: 14px; font-size: 0.9rem; line-height: 1.6;
  border-top: 1px solid var(--color-border-subtle, rgba(255,255,255,0.07));
  color: var(--color-text-secondary, rgba(255,255,255,0.78)); display: none;
}
.ls-card.answered .ls-note { display: block; }
.ls-note b { color: #fff; }
.ls-note .tag-correct { color: var(--ls-accent); font-weight: 700; }
.ls-note .tag-wrong { color: var(--color-text-primary, #fff); font-weight: 700; }

/* footer: progress + next */
.ls-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.ls-progress { font-size: 0.84rem; color: var(--color-text-secondary, rgba(255,255,255,0.55)); display: inline-flex; align-items: center; gap: 6px; }
.ls-progress b { color: #fff; font-variant-numeric: tabular-nums; }
.ls-progress .ls-score {
  display: inline-block; background: rgba(48,209,88,0.16); color: var(--ls-accent);
  font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 9px; border-radius: 999px;
}
/* primary action — white fill + dark text, matching the sibling widgets' primary button */
.ls-next {
  margin-left: auto; appearance: none;
  border: 1px solid var(--color-accent, #fff); background: var(--color-accent, #fff); color: #0b0b0b;
  font: inherit; font-size: 0.9rem; font-weight: 650; padding: 9px 18px; border-radius: 9px;
  cursor: pointer; transition: opacity 0.15s; display: none;
}
.ls-next.show { display: inline-block; }
.ls-next:hover { opacity: 0.9; }
@media (max-width: 520px) { .ls-next { margin-left: 0; } }

/* summary */
.ls-summary {
  background: var(--color-bg-surface, #1a1a1a);
  border: 1px solid var(--color-border-subtle, rgba(255,255,255,0.12)); border-radius: 12px; padding: 20px;
  display: none;
}
.ls-summary.show.is-win { border-color: var(--ls-accent); }
.ls-summary.show { display: block; }
.ls-score-big { font-size: 2.2rem; font-weight: 700; color: #fff; font-family: var(--font-mono, monospace); line-height: 1; letter-spacing: -0.01em; }
.ls-summary p { font-size: 0.92rem; line-height: 1.6; color: var(--color-text-secondary, rgba(255,255,255,0.78)); margin: 10px 0 0; }
.ls-replay {
  margin-top: 14px; appearance: none;
  border: 1px solid var(--color-border, rgba(255,255,255,0.15)); background: transparent;
  color: var(--color-text-primary, #fff); font: inherit; font-size: 0.85rem;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
}
.ls-replay:hover { border-color: rgba(255,255,255,0.35); }
.ls-noscript { font-size: 0.9rem; color: var(--color-text-secondary, rgba(255,255,255,0.65)); line-height: 1.6; }
