/*
 * 猜心 — the page's own rules.
 *
 * The shell comes from app.css (the column, topbar, brand mark, buttons, status
 * line, the panel and its head/foot), which this page links even though it runs
 * none of the scatter engine — the family's shell in one place, and the rules
 * that match nothing here simply match nothing. What is left for this file is
 * the shape none of the other tools has: a stack of question cards whose answer
 * chips are marked up *after* they have been answered.
 *
 * [Why the checkmark marks are classes on the option, not a separate list] The
 * reveal belongs where the question is. A person who has just been told 「猜中 5
 * 题」 wants to look at the three they got wrong, and a second list of eight rows
 * would be the same eight facts in a place they have to scroll to. So the panel
 * below carries the misses in words, and the cards carry the marks in place.
 *
 * Three rules here are copies of rules in other tools' sheets — `.paste`, the
 * link textarea, and `.verdict` — because those sheets are per-tool by
 * construction and there is no sheet they could have come from. The shell is the
 * thing this family shares; a per-tool sheet borrowing another per-tool sheet
 * would be the coupling app.css exists to remove.
 */

/* ------------------------------------------------------------------ hero */

.lede {
  margin: 0 0 var(--s6);
  color: var(--text-dim);
}

/* ------------------------------------------------------------------ name */

.name-row {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-bottom: var(--s7);
}

.name-label {
  font-size: var(--t2);
  color: var(--text-dim);
}

.name-row input {
  width: 100%;
  padding: var(--s4) var(--s5);
  font: inherit;
  /* 16px, not for looks: iOS zooms a page when a control under 16px takes focus. */
  font-size: var(--t5);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: border-color var(--dur-fast) var(--ease);
}

.name-row input::placeholder {
  color: var(--text-faint);
}

.name-row input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ----------------------------------------------------------- the questions */

.qlist {
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

/*
 * A fieldset, not a div, because the four chips are one mutually exclusive
 * choice — that is what a radio group is, and the browser brings its keyboard
 * behaviour and its announcement for free. Everything a fieldset draws by
 * default has to be turned off for it to read as a plain card.
 */
.qcard {
  min-width: 0;
  margin: 0;
  padding: var(--s5);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.qtext {
  padding: 0;
  font-size: var(--t4);
  font-weight: 600;
  line-height: 1.5;
}

.opts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s2);
  margin-top: var(--s4);
}

/*
 * The real input is 1px and transparent, and the chip beside it is what a person
 * sees and taps. Keeping the control rather than replacing it with a styled
 * button is what keeps the arrow-key behaviour and the checked state native;
 * `+` in the selectors below is what makes tapping the chip reach it.
 */
.opt {
  position: relative;
  display: block;
  cursor: pointer;
}

.opt input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.otext {
  display: block;
  padding: var(--s3) var(--s4);
  font-size: var(--t3);
  line-height: 1.4;
  text-align: center;
  color: var(--text);
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  transition:
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.opt:hover .otext {
  border-color: var(--border);
}

.opt input:focus-visible + .otext {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.opt input:checked + .otext {
  color: var(--primary-ink);
  background: var(--primary-soft);
  border-color: var(--primary);
}

/*
 * After the reveal there is nothing left to choose — the inputs are disabled in
 * guess.js — so the chips stop offering. The disabled input's own dimming never
 * reaches the chip, which is deliberate: what a person is reading here is the
 * answer, and an answer rendered at 60% is an answer that is hard to read.
 */
.qcard.is-revealed .opt {
  cursor: default;
}

/* -------------------------------------------------------- the reveal marks */

/*
 * 其实 / 你猜的 / 猜对了.
 *
 * The answer is the primary-soft pair the rest of the site uses for "this is
 * the one that counts" (see readings.js's manual picker); a guess is dashed,
 * because dashed already means "provisional" everywhere else; and when the two
 * are the same chip, one solid mark says so rather than two tags saying it
 * twice.
 */
.opt.is-answer .otext,
.opt.is-hit .otext {
  color: var(--primary-ink);
  background: var(--primary-soft);
  border-color: var(--primary);
}

.opt.is-hit .otext {
  font-weight: 650;
}

.opt.is-guess .otext {
  border-style: dashed;
  border-color: var(--border);
}

.tag {
  display: inline-block;
  margin-left: var(--s2);
  padding: 0 var(--s1);
  font-size: var(--t1);
  font-weight: 500;
  line-height: 1.6;
  border-radius: var(--radius);
}

.opt.is-answer .tag,
.opt.is-hit .tag {
  color: var(--primary-ink);
  background: var(--primary);
}

.opt.is-guess .tag {
  color: var(--text-dim);
  background: var(--bg-hover);
  border: 1px solid var(--border-soft);
}

/* ------------------------------------------------------- progress and count */

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  margin-top: var(--s5);
}

.count {
  font-size: var(--t2);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------- the link */

/*
 * Shown the moment the eighth answer lands, and hidden again if one is changed
 * away — the block has no state of its own, it is a projection of "how many are
 * answered", which is why there is no open/closed bookkeeping here to get wrong.
 */
.sharing {
  margin-top: var(--s7);
  padding: var(--s6);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.sharing h2 {
  margin: 0 0 var(--s2);
  font-size: var(--t5);
  font-weight: 650;
}

.sharing-hint {
  margin: 0 0 var(--s5);
  font-size: var(--t3);
  color: var(--text-dim);
}

/*
 * A textarea, not a link with a copy button beside it: the payload is not
 * something to read, it is something to take, and a selectable box is the one
 * control where "select all, copy" is a single gesture on every platform.
 */
.sharing-box {
  width: 100%;
  padding: var(--s4) var(--s5);
  font: inherit;
  font-size: var(--t2);
  color: var(--text-dim);
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  resize: none;
  overflow-wrap: anywhere;
}

.sharing-foot {
  display: flex;
  margin-top: var(--s3);
}

.sharing-code {
  margin-top: var(--s5);
  font-size: var(--t2);
  color: var(--text-dim);
}

.sharing-code summary {
  padding: var(--s2) 0;
  cursor: pointer;
  border-radius: var(--radius);
}

.sharing-code summary:hover {
  color: var(--text);
}

.sharing-code .btn {
  margin-top: var(--s3);
}

/* -------------------------------------------------------------- the paste */

/*
 * A disclosure rather than a visible box, same argument as 评理's: opening a link
 * imports the game by itself, so this exists for the link that did not survive
 * the trip — a minority of visits, and a paste box under the questions on every
 * visit would read as "there is something else you were supposed to do".
 */
.paste {
  margin-top: var(--s7);
  font-size: var(--t3);
  color: var(--text-dim);
}

.paste summary {
  padding: var(--s2) 0;
  cursor: pointer;
  border-radius: var(--radius);
}

.paste summary:hover {
  color: var(--text);
}

.paste form {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding-top: var(--s3);
}

.paste textarea {
  width: 100%;
  padding: var(--s4) var(--s5);
  font: inherit;
  font-size: var(--t4);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  /* A 口令 is one long unbroken run of characters, and `anywhere` is the only
     value that will break inside it. */
  overflow-wrap: anywhere;
}

.paste .btn {
  align-self: flex-start;
}

/* -------------------------------------------------------------- the panel */

#panel:not([hidden]) {
  margin-top: var(--s6);
}

.verdict {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: 0 var(--s3) var(--s5);
}

.sum {
  margin: 0;
  font-size: var(--t5);
  font-weight: 650;
}

.sub {
  margin: 0;
  font-size: var(--t3);
  color: var(--text-dim);
}

.misses {
  padding: 0 var(--s3);
}

.misses-head {
  margin: 0 0 var(--s3);
  font-size: var(--t2);
  font-weight: 600;
  color: var(--text-dim);
}

.misses-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/*
 * One missed question: what was asked, then the two options side by side. The
 * guess comes first on purpose — reading 「我猜 X，其实 Y」 is the order the
 * person lived it in, and the other order reads as a correction handed out.
 */
.miss {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding-left: var(--s4);
  border-left: 2px solid var(--border-soft);
}

.mtext {
  font-size: var(--t3);
  color: var(--text);
}

.mpair {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  font-size: var(--t2);
  color: var(--text-dim);
}

.mguess {
  color: var(--text-faint);
}

.all-hit {
  margin: 0;
  padding: 0 var(--s3);
  font-size: var(--t3);
  color: var(--text-dim);
}

.hint {
  margin: var(--s5) 0 0;
  padding: 0 var(--s3);
  font-size: var(--t1);
  color: var(--text-faint);
}

/* -------------------------------------------------------------- narrow */

/*
 * One column of chips, not two. Four options of five to seven characters do fit
 * two-across on a phone, but a question whose options are uneven lengths ends up
 * with a ragged grid, and the row of chips is the thing being read here.
 */
@media (max-width: 560px) {
  .opts {
    grid-template-columns: minmax(0, 1fr);
  }

  .otext {
    text-align: left;
  }

  .progress-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s3);
  }

  .progress-row .btn {
    width: 100%;
  }
}
