/* An illustration toy inside the portfolio's plum-and-pink world. */
body.is-puzzle-open { overflow: hidden; }
.sliding-puzzle {
  --puzzle-ink: #e6a5ff;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #28002b url('assets/textures/paper-grain.png');
  color: var(--puzzle-ink);
  font-family: "Avenir Next", "Gill Sans", "Helvetica Neue", sans-serif;
  overscroll-behavior: contain;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #8c6094 #28002b;
  cursor: auto;
}
.sliding-puzzle::backdrop { background: #28002b; }
.sliding-puzzle[open] { animation: puzzle-enter 180ms ease-out; }
.puzzle-shell {
  --puzzle-top: max(64px, calc(env(safe-area-inset-top) + 44px));
  --puzzle-bottom: max(16px, env(safe-area-inset-bottom));
  --puzzle-width: min(100vw, 740px, max(240px, calc((100svh - var(--puzzle-top) - var(--puzzle-bottom) - 52px) * var(--puzzle-ratio, 1))));
  box-sizing: border-box;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.puzzle-header { position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); z-index: 5; }
.sliding-puzzle button { font-family: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sliding-puzzle button:focus-visible,
.puzzle-board:focus-visible { outline: 1px solid var(--puzzle-ink); outline-offset: 4px; }
.puzzle-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.puzzle-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; }
.sliding-puzzle .puzzle-close:focus-visible { outline: none; }
.puzzle-close:focus-visible svg { stroke-width: 1.8; }
.puzzle-main { display: grid; place-content: center; justify-items: center; gap: 0; width: 100%; padding: var(--puzzle-top) 0 var(--puzzle-bottom); box-sizing: border-box; }
.puzzle-board {
  position: relative;
  width: var(--puzzle-width);
  aspect-ratio: var(--puzzle-ratio, 1);
  background: #1d0020;
  border: 0;
  box-sizing: border-box;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.puzzle-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; pointer-events: none; transition: opacity 180ms ease; }
.puzzle-pieces { position: absolute; inset: 0; transition: opacity 160ms ease; }
.puzzle-piece {
  appearance: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  height: 25%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  transition: transform 160ms cubic-bezier(.22, 1, .36, 1);
}
.puzzle-piece[aria-disabled="true"] { cursor: default; }
.puzzle-piece.is-dragging { transition: none; z-index: 1; }
.puzzle-piece-window { position: relative; display: block; width: 100%; height: 100%; overflow: hidden; }
.puzzle-piece-window::after { content: ''; position: absolute; inset: 0; border: 1.5px solid #28002b; box-sizing: border-box; pointer-events: none; }
.puzzle-piece-art { position: absolute; top: 0; left: 0; width: 400%; height: 400%; background-size: 100% 100%; background-repeat: no-repeat; pointer-events: none; }
.puzzle-board.is-loading .puzzle-pieces { opacity: 0; }
.puzzle-board.is-loading .puzzle-piece { transition: none; }
.puzzle-board.is-peeking .puzzle-preview,
.puzzle-board.is-solved .puzzle-preview { opacity: 1; }
.puzzle-board.is-peeking .puzzle-pieces,
.puzzle-board.is-solved .puzzle-pieces { opacity: 0; pointer-events: none; }
.puzzle-controls { width: var(--puzzle-width); display: flex; align-items: center; justify-content: space-between; gap: 24px; box-sizing: border-box; padding: 8px 12px 0; }
.puzzle-peek, .puzzle-another { min-height: 44px; padding: 6px 12px; border: 0; border-radius: 0; background: transparent; font-size: 14px; line-height: 1.5; text-decoration: none; }
.puzzle-peek[aria-pressed="true"] { opacity: .7; }
.puzzle-peek:disabled, .puzzle-another:disabled { opacity: .5; cursor: wait; }
.puzzle-help, .puzzle-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@keyframes puzzle-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .sliding-puzzle[open] { animation: none; }
  .puzzle-piece, .puzzle-preview, .puzzle-pieces { transition: none; }
}
