/* Legpuzzel: home tile, menu (sizes and pictures), the board and the loose pieces. The menu is built
   from the shell's components (css/style.css). */

/* ---------- home tile ---------- */
#tile-legpuzzel .tile-art { display: flex; align-items: center; justify-content: center; }
#tile-legpuzzel .tile-art > svg { width: 100%; height: 100%; display: block; }

/* ---------- menu: the sizes as level cells, the pictures as picture cards (css/style.css) ---------- */
.puzzel-keep { display: flex; justify-content: center; margin: 4px 0 6px; }
.puzzel-pictures { padding-bottom: var(--bz-space-5); }
.puzzel-pic .option-art > svg { aspect-ratio: 4 / 3; box-shadow: 0 0 0 2px rgba(43, 35, 112, 0.15); }
.puzzel-pic .check { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 3px; border-radius: 50%; background: #2f7d4f; color: #fff; }
.puzzel-pic.done { border-color: #8fd3a8; }

/* ---------- the puzzle ---------- */
.puzzel-hud .btn.icon svg { width: 30px; height: 30px; }
#legpuzzel-ghost[aria-pressed="false"] { opacity: 0.55; }
#legpuzzel-zoom[hidden] { display: none; }
#legpuzzel-zoom[aria-pressed="true"] { background: var(--gold); color: var(--primary-dark); }
#legpuzzel-zoom[aria-pressed="true"] .loupe-plus { display: none; } /* a minus: tap to see it all again */
.puzzel-wrap { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; padding: 4px 12px 8px; }
.puzzel-stage { position: relative; flex: 1; min-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; }
/* the board and the pieces in one layer: the magnifier scales and moves it as a whole */
.puzzel-world { position: absolute; inset: 0; transform-origin: 0 0; }
.puzzel-world.glide { transition: transform 0.25s ease-out; }
.puzzel-stage.zoomed { overflow: hidden; border-radius: 14px; box-shadow: inset 0 0 0 3px rgba(201, 193, 255, 0.9); }
.puzzel-board {
  position: absolute;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 0 4px #fff, 0 0 0 7px #c9c1ff, 0 10px 24px rgba(59, 47, 168, 0.18);
}
.puzzel-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.28; border-radius: 6px; transition: opacity 0.2s; }
.puzzel-board.ghost-off canvas { opacity: 0; }
.puzzel-board.done { animation: puzzel-glow 1.2s ease 2; }
.ppiece {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 3px 2px rgba(43, 35, 112, 0.3));
  -webkit-tap-highlight-color: transparent;
}
.ppiece.lift { cursor: grabbing; filter: drop-shadow(0 10px 8px rgba(43, 35, 112, 0.35)); scale: 1.06; }
.ppiece.placed { z-index: 1; filter: none; cursor: default; }
.ppiece.snap { transition: transform 0.15s ease-out; animation: puzzel-snap 0.35s ease-out; }
.puzzel-status { flex: none; margin: 6px 0 0; min-height: 1.4em; font-weight: 800; color: var(--primary-dark); text-align: center; }
.puzzel-ov svg { width: 180px; height: 135px; display: block; border-radius: 14px; box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--gold); }

/* short sideways phones: the HUD a column on the left */
@media (orientation: landscape) and (max-height: 520px) {
  #screen-legpuzzel { flex-direction: row; }
  .puzzel-hud { flex-direction: column; justify-content: space-between; padding: 10px 6px 10px 12px; width: 100px; flex: none; }
  .puzzel-hud .hud-mid { flex: 0; max-width: 92px; text-align: center; }
  .puzzel-hud .dogu-title { white-space: normal; font-size: 0.95rem; }
  .puzzel-hud .btn.icon { width: 54px; height: 54px; }
  .puzzel-wrap { padding: 8px 10px 4px 4px; }
  .puzzel-status { font-size: 0.85rem; margin-top: 2px; }
  /* the end card's picture made it too tall, cutting off Menu (the finished
     puzzle is visible behind the card anyway) */
  .puzzel-ov svg { display: none; }
}
@media (max-height: 600px) {
  .puzzel-ov svg { width: 120px; height: 90px; }
}

@keyframes puzzel-snap { 0% { scale: 1.08; } 60% { scale: 0.97; } 100% { scale: 1; } }
@keyframes puzzel-glow { 0%, 100% { box-shadow: 0 0 0 4px #fff, 0 0 0 7px #c9c1ff, 0 10px 24px rgba(59, 47, 168, 0.18); } 50% { box-shadow: 0 0 0 4px #fff, 0 0 0 9px var(--gold), 0 0 30px rgba(255, 197, 49, 0.6); } }

@media (prefers-reduced-motion: reduce) {
  .ppiece.snap, .puzzel-board.done { animation: none !important; transition: none; }
  .puzzel-world.glide { transition: none; }
}

/* three icon buttons in the bar (back, magnifier, example) never shrink (they used to squeeze down
   next to the title); on a narrow phone they are 52 px and the title may take two lines */
.puzzel-hud .hud-mid { min-width: 0; }
@media (max-width: 400px) {
  .puzzel-hud { gap: 8px; }
  .puzzel-hud .btn.icon { width: 52px; height: 52px; }
  .puzzel-hud .dogu-title { font-size: 1.05rem; line-height: 1.15; white-space: normal; }
}
