/* The daily puzzle (/puzzle/, /fr/probleme-du-jour/) and its widget for other sites
   (/embed/puzzle/, body.pz-embed), on top of styles.css. The puzzle is a panel of the app's sand:
   the board (site/position.js), what to do, the plays to pick from as tiles on the ivory of a card,
   then the verdict, Pip's explanation and the app. puzzle.js fills it in.
   After changing this file run tools/site/stamp-assets.sh. */
:root {
  --pz-field: #fffdf8;
  --pz-edge: rgba(28, 21, 14, 0.18);
  --pz-good: #2f5b3e;
  --pz-bad: #9d4334;
}

.pz {
  margin: 2rem calc(-1 * var(--inset)) 0;
  padding: clamp(0.9rem, 3vw, 1.5rem);
  border-radius: 24px;
  background: var(--sheet);
}
.pz [hidden] { display: none !important; }
.pz p { margin: 0; }

/* Until the puzzle is here: the script's words (loading, no connection), or the page's own if
   the script never runs. */
.pz .pz-status { padding: 0.9rem 1rem; border-radius: 14px; background: var(--pz-field); color: var(--ink-2); font-size: 0.9375rem; }
.pz-status .link-btn { min-height: 0; margin-left: 0.25rem; }

.pz .pz-kicker { margin-bottom: 0.7rem; color: var(--amber-text); font: 600 0.875rem/1.3 var(--round); }
.pz-board { position: relative; }
.pz-board svg { display: block; width: 100%; height: auto; }
/* The tap targets over the board (puzzle.js): invisible, a pointer over the player's checkers
   and the dice, the amber ring of focus from the keyboard. */
.pz-board .pz-hit { position: absolute; inset: 0; height: 100%; -webkit-tap-highlight-color: transparent; }
.pz-hit rect { fill: transparent; outline: none; }
.pz-hit rect.on { cursor: pointer; }
.pz-hit rect:focus-visible { stroke: var(--amber); stroke-width: 4; }
@media (hover: hover) { .pz-hit rect.on:hover { fill: rgba(255, 251, 243, 0.07); } }
.pz-desc { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pz .pz-pips { margin-top: 0.45rem; color: var(--ink-3); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }

/* What to do, then the verdict in the same place. */
.pz-ask { margin-top: 1rem; }
.pz .pz-task { color: var(--ink); font: 700 1.25rem/1.25 var(--round); letter-spacing: -0.01em; }
.pz-task:focus { outline: none; }
.pz .pz-sub { margin-top: 0.25rem; color: var(--ink-2); font-size: 0.9375rem; line-height: 1.45; }
.pz-verdict { display: flex; align-items: center; gap: 0.55rem; }
.pz-verdict::before {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  color: #fff;
  font: 700 0.875rem/1 var(--text);
}
.pz-verdict.ok::before { content: "✓"; background: var(--pz-good); }
.pz-verdict.no::before { content: "✕"; background: var(--pz-bad); }

/* The plays (or the two cube answers) as tiles: notation on top, after the answer what each was worth. */
.pz-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.9rem; }
.pz-tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.15rem;
  min-width: 0;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pz-edge);
  border-radius: 12px;
  background: var(--pz-field);
  color: var(--ink);
  font: 600 1rem/1.2 var(--round);
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}
.pz-cube .pz-tile { align-items: center; text-align: center; }
.pz-label { overflow-wrap: anywhere; }
.pz-tile[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.pz-tile:focus-visible { outline: 2px solid var(--amber-edge); outline-offset: 2px; }
.pz-tile:disabled { cursor: default; }
.pz-tile:disabled:not(.pz-yours) { opacity: 0.75; }
@media (hover: hover) { .pz-tile:not(:disabled):hover { border-color: rgba(28, 21, 14, 0.42); } }
.pz-tag { color: var(--ink-3); font: 500 0.8125rem/1.25 var(--text); }
.v-best .pz-tag, .v-good .pz-tag { color: var(--pz-good); font-weight: 600; }
.v-inaccuracy .pz-tag, .v-blunder .pz-tag { color: var(--pz-bad); }
.pz-yours { background: #fff; }

.pz .pz-hint { margin-top: 0.75rem; padding: 0.65rem 0.85rem; border-radius: 12px; background: var(--pz-field); color: var(--ink-2); font-size: 0.9375rem; line-height: 1.45; }
.pz-actions { display: flex; align-items: center; gap: 1rem; margin-top: 0.9rem; }
.pz-actions .btn { margin-left: auto; border: 0; cursor: pointer; }
.pz-actions .btn:disabled { opacity: 0.45; cursor: default; }
.pz .link-btn {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--amber-text);
  font: 500 0.9375rem/1.3 var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  cursor: pointer;
}
.pz .link-btn:disabled { color: var(--ink-3); text-decoration: none; opacity: 0.6; cursor: default; }
@media (hover: hover) { .pz .link-btn:not(:disabled):hover { color: var(--ink); } }

/* After the answer. */
.pz-result { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.pz .pz-chances { color: var(--ink-2); font-size: 0.9375rem; }
.pz-chances:empty { display: none; }
.pz-why { display: flex; align-items: flex-start; gap: 0.75rem; margin-top: 0.75rem; }
.pz-chances:empty + .pz-why { margin-top: 0; }
.pz-why img { flex: none; width: 44px; height: 44px; margin-top: -0.2rem; }
.pz .pz-why p { color: var(--ink); font-size: 1rem; line-height: 1.5; }
.pz-play { font-weight: 600; white-space: nowrap; }
.pz-app { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-top: 1rem; padding: 0.75rem 0.9rem; border-radius: 14px; background: var(--pz-field); }
.pz .pz-app p { color: var(--ink); font: 600 0.9375rem/1.35 var(--round); }
.pz .pz-next { margin-top: 0.6rem; color: var(--ink-3); font-size: 0.8125rem; }

/* The page's snippet for clubs. */
.embed-code { position: relative; margin: 1rem 0 0; }
.embed-code pre {
  margin: 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: var(--sheet);
  color: var(--ink);
  font: 0.8125rem/1.55 ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.embed-code button { margin-top: 0.6rem; border: 0; cursor: pointer; }

/* ---------- the widget: the whole frame is the panel, a little tighter. */
html:has(body.pz-embed) { background: var(--sheet); }
body.pz-embed { min-height: 0; background: var(--sheet); font-size: 15px; line-height: 1.45; }
/* At most 360 pixels wide, centred: a wider frame needs no more height than the snippet's 680. */
.pz-embed .pz { width: 100%; max-width: 360px; margin: 0 auto; padding: 12px 12px 0; border-radius: 0; }
.pz-embed .pz .pz-kicker { margin-bottom: 0.5rem; font-size: 0.8125rem; }
.pz-embed .pz .pz-pips { display: none; }
.pz-embed .pz-ask { margin-top: 0.7rem; }
.pz-embed .pz .pz-task { font-size: 1.0625rem; }
.pz-embed .pz .pz-sub, .pz-embed .pz .pz-chances, .pz-embed .pz .pz-hint { font-size: 0.875rem; }
.pz-embed .pz-tiles { margin-top: 0.6rem; gap: 0.4rem; }
.pz-embed .pz-tile { min-height: 44px; padding: 0.4rem 0.65rem; font-size: 0.9375rem; }
.pz-embed .pz-tag { font-size: 0.75rem; }
.pz-embed .pz-actions { margin-top: 0.5rem; }
.pz-embed .pz-actions .btn { min-height: 40px; padding: 0.5rem 1.1rem; font-size: 0.9375rem; }
.pz-embed .pz-result { margin-top: 0.6rem; padding-top: 0.6rem; }
.pz-embed .pz-why { gap: 0.6rem; margin-top: 0.55rem; }
.pz-embed .pz-why img { width: 36px; height: 36px; }
.pz-embed .pz .pz-why p { font-size: 0.875rem; line-height: 1.45; }
.pz-embed .pz-app { flex-wrap: nowrap; margin-top: 0.6rem; padding: 0.5rem 0.5rem 0.5rem 0.75rem; }
.pz-embed .pz .pz-app p { font-size: 0.8125rem; line-height: 1.3; }
.pz-embed .pz-app .btn { flex: none; min-height: 36px; padding: 0.4rem 0.8rem; font-size: 0.8125rem; }
/* Answered, the widget keeps what fits its frame: the player's play and the best as tiles (the
   best's tag says it, so no line above them for a checker play), no countdown. */
.pz-embed .pz-done .pz-other { display: none; }
.pz-embed .pz-done.pz-one { grid-template-columns: minmax(0, 1fr); }
.pz-embed .pz-ask:has(+ .pz-done:not(.pz-cube)) .pz-sub { display: none; }
.pz-embed .pz-done .pz-tag { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz-embed .pz-done .pz-tag-v { display: none; }
.pz-embed .pz .pz-next { display: none; }
.pz-foot { padding: 0.5rem 12px 10px; text-align: center; }
.pz-foot a { color: var(--ink-3); font-size: 0.75rem; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
@media (hover: hover) { .pz-foot a:hover { color: var(--ink); } }
