/* static/how_to_play.css
 * How to Play (templates/_help_modal.html, static/js/how_to_play.js): the
 * first visit's welcome and the ? card, one card.
 *
 * The demo round is the game in miniature, built from its own pieces (the
 * board's pills, the guess list's entries), so it borrows their styles from
 * styles.css and only scales them down here. Its motion is stop-motion:
 * every move is three or four held frames (steps()), never a glide, at the
 * same pace as the script's FRAME. The look of the game doesn't change; only
 * how the demo gets there. The chef's stamp (ksStamp) is the game's own,
 * from styles.css, shared with the coachmark's 🟨.
 */

/* Narrower than the other popups: the demo is a phone screen in miniature */
#helpModal .modal-dialog { max-width: 420px; }

/* --- Which card, and whether the round is playing ---
   .is-intro   the first visit (the script sets it), otherwise the ? card
   .is-playing the round plays, captions under it; otherwise it's shown
               finished, with the legend */
.htp:not(.is-intro) .htp-for-intro { display: none; }
.htp.is-intro .htp-for-guide { display: none; }
.htp:not(.is-playing) .htp-caption,
.htp.is-playing .htp-replay { display: none; }
.htp.is-playing .htp-legend {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- The stage: a guess box, the board, the notes ---
   A fixed height, so the card never changes size as the round plays: the
   notes take whatever the board leaves, latest at the top, and run out of
   sight under a fade. */
.htp-stage {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 14.5rem;
  margin-top: 0.85rem;
  padding: 8px;
  overflow: hidden;
  text-align: left;
  background: var(--color-bg-body);
  border: 1px solid var(--color-border-medium);
  border-radius: 12px;
}

/* The guess box and Sniff, as the welcome screen draws them */
.htp-guess { display: flex; flex: 0 0 auto; height: 30px; }
.htp-field {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  padding: 0 0.6rem;
  overflow: hidden;
  font-size: 0.8rem;
  white-space: nowrap;
  color: var(--color-text-default);
  background: var(--color-bg-white);
  border: 1px solid var(--color-border-medium);
  border-right: 0;
  border-radius: 8px 0 0 8px;
}
.htp-field.is-empty::after { content: attr(data-placeholder); color: var(--color-text-subtle); }
.htp-caret {
  flex: 0 0 auto;
  width: 1px;
  height: 1em;
  margin: 0 1px;
  background: var(--color-text-default);
  animation: htpBlink 1s step-end infinite;
}
.htp-sniff {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-on-dark);
  background: var(--color-text-default);
  border-radius: 0 8px 8px 0;
}
.htp-sniff.is-pressed {
  background: var(--color-text-on-brand-secondary-hover);
  transform: translateY(1px);
}
/* The tap: a ring that opens out from Sniff in four frames */
.htp-tap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid var(--color-brand-primary);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.htp-sniff.is-tapped .htp-tap { animation: htpTap 360ms steps(4, jump-none) both; }

/* The board: three boxes side by side, whatever the card's width */
.htp .htp-board {
  flex: 0 0 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.htp-board .feedback-category { padding: 4px 5px; border-radius: 7px; }
.htp-board .feedback-category h6 { margin-bottom: 4px; font-size: 0.56rem; }
.htp-board .feedback-items-container { grid-template-columns: minmax(0, 1fr); gap: 3px; }
.htp-board .feedback-item {
  padding: 1px 4px;
  overflow: hidden;
  font-size: 0.64rem;
  line-height: 1.35;
  text-overflow: ellipsis;
}
.htp-board .feedback-subcategory { margin-top: 5px; padding-top: 5px; }

/* The notes: the guess list, as the game marks it */
.htp-notes {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 0.4rem;
  overflow: hidden;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border-primary);
  border-radius: 8px;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 16px), transparent);
}
.htp-notes .guess-entry { padding: 0.35rem 0.2rem; animation: none; }
.htp-notes .guess-entry:not(.is-in) { display: none; }
.htp-notes .guess-header { margin-bottom: 0.15rem; }
.htp-notes .guess-num { font-size: 0.68rem; }
.htp-notes .guess-name { font-size: 0.8rem; }
.htp-notes .guess-feedback-pills .pill { font-size: 0.64rem; }
.htp-notes .guess-mark { display: inline-block; }

/* A guess waits unmarked, in plain ink, until the chef's pen reaches each
   value: then the real marks (styles.css, "The guess list") */
.htp-notes .pill:not(.is-marked) .guess-mark { visibility: hidden; }
.htp-notes .pill:not(.is-marked) .guess-value {
  font-weight: 600;
  color: var(--color-text-default);
  text-decoration: none;
}
.htp-notes .pill:not(.is-marked) .subtype-pill { color: inherit; text-decoration: none; }

/* --- The frames ---
   Each move is held frames, not a glide: steps(n, jump-none) shows the
   first and last keyframes as frames of their own. */
.htp-notes .guess-entry.is-in,
.htp-board .feedback-subcategory.is-in { animation: htpDrop 270ms steps(3, jump-none) both; }
.htp-notes .pill.is-marked .guess-mark { animation: ksStamp 270ms steps(3, jump-none) both; }
.htp-board .feedback-item.is-popping { animation: htpPop 270ms steps(3, jump-none); }
.htp-board .feedback-item.is-going { opacity: 0.45; transform: scale(0.82); }
.htp-board .feedback-item.is-gone { display: none; }

/* Between rounds: a cut, the stage blank for a few frames */
.htp-stage.is-cut > * { visibility: hidden; }

/* The finished round on the ? card: no motion, no caret */
.htp-stage.is-still *,
.htp-stage.is-still *::after { animation: none !important; }
.htp-stage.is-still .htp-caret { visibility: hidden; }

@keyframes htpBlink {
  0% { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes htpTap {
  0% { opacity: 0.9; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.6); }
}
@keyframes htpDrop {
  0% { opacity: 0; transform: translateY(-8px); }
  50% { opacity: 0.6; transform: translateY(-3px) rotate(-0.6deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes htpPop {
  0% { transform: none; }
  50% { transform: scale(1.14) rotate(-2deg); }
  100% { transform: none; }
}
@keyframes htpFlick {
  0% { opacity: 0; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* --- Words --- */
/* One caption at a time, under the round. Two lines held, so the card
   doesn't jump as they change. */
.htp-caption {
  min-height: 2.9em;
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
  color: var(--color-text-muted);
}
.htp-caption > span { display: none; }
.htp-caption > span.is-on { display: inline; animation: htpFlick 270ms steps(3, jump-none) both; }
.htp-caption strong { color: var(--color-text-default); }

/* The marks in words, in the guess list's colours */
.htp-mark { font-weight: 700; }
.htp-mark.is-tick { color: var(--color-state-success); }
.htp-mark.is-cross { color: var(--color-brand-primary); }

.htp-replay { margin: 0.6rem 0 0; text-align: center; }
.htp-watch {
  padding: 0;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-brand-primary);
  background: none;
  border: 0;
}
.htp-watch:hover { text-decoration: underline; }

.htp-legend { margin-top: 0.85rem; }

.htp-hint {
  margin: 0.8rem 0 0;
  font-size: 0.74rem;
  text-align: center;
  color: var(--color-text-subtle);
}

@media (prefers-reduced-motion: reduce) {
  .htp-replay { display: none; }
  .htp-stage *,
  .htp-stage *::after,
  .htp-caption > span.is-on { animation: none !important; }
}
