/* Puzzle en ligne : styles propres à l'outil. Le plateau est dessiné dans un canvas, couleurs tirées des variables du site. */
.o-puzzle {
  min-width: 0;
  --o-puzzle-tapis: color-mix(in srgb, var(--marque) 9%, var(--surface-2));
  --o-puzzle-cadre: rgb(255 255 255 / 55%);
  --o-puzzle-trait: rgb(60 70 90 / 55%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .o-puzzle { --o-puzzle-cadre: rgb(0 0 0 / 28%); --o-puzzle-trait: rgb(200 210 230 / 45%); }
}
:root[data-theme="dark"] .o-puzzle { --o-puzzle-cadre: rgb(0 0 0 / 28%); --o-puzzle-trait: rgb(200 210 230 / 45%); }
.o-puzzle [hidden] { display: none !important; }
.o-puzzle .btn:focus-visible, .o-puzzle input:focus-visible, .o-puzzle-vignette:focus-visible, .o-puzzle-plateau:focus-visible { outline: 3px solid var(--marque); outline-offset: 2px; }
.atelier .o-puzzle .btn[aria-pressed="true"], .atelier .o-puzzle .o-puzzle-fichier.actif { background: var(--marque); border-color: var(--marque); color: var(--sur-marque); }

.o-puzzle-images { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.o-puzzle-images > strong { font-size: .9rem; color: var(--texte-2); font-weight: 600; }
.o-puzzle-vignettes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.o-puzzle-vignette {
  padding: 2px; margin: 0; border: 2px solid var(--bord); border-radius: var(--rayon-petit); background: var(--surface); cursor: pointer; line-height: 0;
}
.o-puzzle-vignette canvas { display: block; border-radius: 4px; }
.o-puzzle-vignette:hover { border-color: var(--texte-2); }
.o-puzzle-vignette[aria-pressed="true"] { border-color: var(--marque); box-shadow: 0 0 0 2px var(--marque); }
.o-puzzle-fichier { position: relative; display: inline-flex; align-items: center; cursor: pointer; min-height: 44px; }
.o-puzzle-fichier input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.o-puzzle-fichier:focus-within { outline: 3px solid var(--marque); outline-offset: 2px; }
.o-puzzle-aide { font-size: .88rem; color: var(--texte-2); margin: 8px 0; line-height: 1.5; }

.o-puzzle .o-puzzle-comptes { padding: 10px 0 8px; }
.o-puzzle-comptes .btn { min-width: 52px; font-variant-numeric: tabular-nums; }
.o-puzzle-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-bottom: 10px; }
.o-puzzle-options label.case { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--texte); min-height: 40px; }
.o-puzzle-options input { width: 20px; height: 20px; accent-color: var(--marque); }
.o-puzzle-options .btn { margin-left: auto; min-height: 42px; }

.o-puzzle-barre { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 22px; margin: 4px 0 10px; }
.o-puzzle-barre p { margin: 0; display: inline-flex; align-items: baseline; gap: 6px; color: var(--texte-2); font-size: .9rem; }
.o-puzzle-barre strong { color: var(--texte); font: 700 1.15rem/1 var(--mono); font-variant-numeric: tabular-nums; }

.o-puzzle-cadre {
  position: relative; height: min(70vh, 640px); min-height: 320px; border-radius: var(--rayon); overflow: hidden;
  background: var(--o-puzzle-tapis); border: 1px solid var(--bord);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.o-puzzle-plateau { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; -webkit-tap-highlight-color: transparent; }
.o-puzzle-plateau.tient { cursor: grabbing; }
.o-puzzle-apercu {
  position: absolute; top: 8px; right: 8px; max-width: 40%; height: auto; border-radius: var(--rayon-petit);
  border: 2px solid var(--surface); box-shadow: 0 4px 14px rgb(0 0 0 / 30%); pointer-events: none;
}
.o-puzzle-depot {
  position: absolute; inset: 8px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px;
  border: 3px dashed var(--marque); border-radius: var(--rayon); background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--texte); font-weight: 700; font-size: 1.1rem; pointer-events: none;
}
.o-puzzle-cadre.bravo { animation: o-puzzle-bravo .9s ease-in-out 2; }
@keyframes o-puzzle-bravo { 50% { box-shadow: 0 0 0 4px var(--marque); } }
@media (prefers-reduced-motion: reduce) { .o-puzzle-cadre.bravo { animation: none; } }

.o-puzzle-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 10px; }
.atelier .o-puzzle-actions .btn { min-height: 42px; }
.o-puzzle-zoom { display: inline-flex; gap: 6px; }
.atelier .o-puzzle-zoom .btn[data-zoom="1"], .atelier .o-puzzle-zoom .btn[data-zoom="-1"] { min-width: 44px; font-size: 1.2rem; line-height: 1; padding: 4px 10px; }

.o-puzzle-message { display: block; min-height: 1.5em; margin: 10px 0 4px; text-align: center; font-weight: 600; color: var(--texte); }

.o-puzzle-bloc { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--bord); }
.o-puzzle-bloc h2 { font-size: 1.05rem; margin: 0 0 10px; }
.o-puzzle-rejouer { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.o-puzzle-rejouer label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--texte-2); }
.o-puzzle-rejouer input { width: 11em; max-width: 100%; }
.o-puzzle-records { border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; max-width: 440px; }
.o-puzzle-records th, .o-puzzle-records td { padding: 6px 10px; border-bottom: 1px solid var(--bord); text-align: right; }
.o-puzzle-records th[scope="row"], .o-puzzle-records thead th:first-child { text-align: left; }
.o-puzzle-records thead th { font-size: .85rem; color: var(--texte-2); font-weight: 600; }

@media (max-width: 520px) {
  .o-puzzle-cadre { height: 66vh; margin: 0 -6px; }
  .o-puzzle-barre { gap: 4px 14px; }
  .o-puzzle-barre p { font-size: .82rem; }
  .o-puzzle-options .btn { margin-left: 0; }
  .atelier .o-puzzle-actions .btn { padding-left: 10px; padding-right: 10px; }
}
